#! /bin/sh
#
#   Build script for iMatix SFL Package, for generic UNIX.
#   Requires the 'c' shell script.
#
#   Generated by Otto v2.11 from buildsfl.txt on 98/02/07, 11:46:37
#   For more info see Otto documentation at http://www.imatix.com.
#   Bug reports & questions to <ph@imatix.com>
#   ---------------------------------------------------------------
#
test -f c && chmod +x c
echo Building Standard Function Library version 1.6
echo Press any key to continue, or Ctrl-C to abort.
read pause
echo Checking for required files...

#-  require prelude.h
if test ! -f prelude.h; then
    echo prelude.h missing - aborting
    exit
fi

#-  require sflbits.h  sflbits.c
if test ! -f sflbits.h; then
    echo sflbits.h missing - aborting
    exit
fi
if test ! -f sflbits.c; then
    echo sflbits.c missing - aborting
    exit
fi

#-  require sflhttp.h  sflhttp.c
if test ! -f sflhttp.h; then
    echo sflhttp.h missing - aborting
    exit
fi
if test ! -f sflhttp.c; then
    echo sflhttp.c missing - aborting
    exit
fi

#-  require sflcomp.h  sflcomp.c
if test ! -f sflcomp.h; then
    echo sflcomp.h missing - aborting
    exit
fi
if test ! -f sflcomp.c; then
    echo sflcomp.c missing - aborting
    exit
fi

#-  require sflcons.h  sflcons.c
if test ! -f sflcons.h; then
    echo sflcons.h missing - aborting
    exit
fi
if test ! -f sflcons.c; then
    echo sflcons.c missing - aborting
    exit
fi

#-  require sflconv.h  sflcvbs.c  sflcvdp.c  sflcvds.c  sflcvns.c
if test ! -f sflconv.h; then
    echo sflconv.h missing - aborting
    exit
fi
if test ! -f sflcvbs.c; then
    echo sflcvbs.c missing - aborting
    exit
fi
if test ! -f sflcvdp.c; then
    echo sflcvdp.c missing - aborting
    exit
fi
if test ! -f sflcvds.c; then
    echo sflcvds.c missing - aborting
    exit
fi
if test ! -f sflcvns.c; then
    echo sflcvns.c missing - aborting
    exit
fi

#-  require            sflcvsb.c  sflcvsd.c  sflcvsn.c  sflcvst.c
if test ! -f sflcvsb.c; then
    echo sflcvsb.c missing - aborting
    exit
fi
if test ! -f sflcvsd.c; then
    echo sflcvsd.c missing - aborting
    exit
fi
if test ! -f sflcvsn.c; then
    echo sflcvsn.c missing - aborting
    exit
fi
if test ! -f sflcvst.c; then
    echo sflcvst.c missing - aborting
    exit
fi

#-  require            sflcvtp.c  sflcvts.c  sflconv.c
if test ! -f sflcvtp.c; then
    echo sflcvtp.c missing - aborting
    exit
fi
if test ! -f sflcvts.c; then
    echo sflcvts.c missing - aborting
    exit
fi
if test ! -f sflconv.c; then
    echo sflconv.c missing - aborting
    exit
fi

#-  require sflcryp.h  sflcryp.c
if test ! -f sflcryp.h; then
    echo sflcryp.h missing - aborting
    exit
fi
if test ! -f sflcryp.c; then
    echo sflcryp.c missing - aborting
    exit
fi

#-  require sfldate.h  sfldate.c
if test ! -f sfldate.h; then
    echo sfldate.h missing - aborting
    exit
fi
if test ! -f sfldate.c; then
    echo sfldate.c missing - aborting
    exit
fi

#-  require sfldir.h   sfldir.c
if test ! -f sfldir.h; then
    echo sfldir.h missing - aborting
    exit
fi
if test ! -f sfldir.c; then
    echo sfldir.c missing - aborting
    exit
fi

#-  require sflenv.h   sflenv.c
if test ! -f sflenv.h; then
    echo sflenv.h missing - aborting
    exit
fi
if test ! -f sflenv.c; then
    echo sflenv.c missing - aborting
    exit
fi

#-  require sflexdr.h  sflexdr.c
if test ! -f sflexdr.h; then
    echo sflexdr.h missing - aborting
    exit
fi
if test ! -f sflexdr.c; then
    echo sflexdr.c missing - aborting
    exit
fi

#-  require sflfile.h  sflfile.c
if test ! -f sflfile.h; then
    echo sflfile.h missing - aborting
    exit
fi
if test ! -f sflfile.c; then
    echo sflfile.c missing - aborting
    exit
fi

#-  require sflfind.h  sflfind.c
if test ! -f sflfind.h; then
    echo sflfind.h missing - aborting
    exit
fi
if test ! -f sflfind.c; then
    echo sflfind.c missing - aborting
    exit
fi

#-  require sflini.h   sflini.c
if test ! -f sflini.h; then
    echo sflini.h missing - aborting
    exit
fi
if test ! -f sflini.c; then
    echo sflini.c missing - aborting
    exit
fi

#-  require sfllang.h  sfllang.c
if test ! -f sfllang.h; then
    echo sfllang.h missing - aborting
    exit
fi
if test ! -f sfllang.c; then
    echo sfllang.c missing - aborting
    exit
fi

#-  require sfllbuf.h  sfllbuf.c
if test ! -f sfllbuf.h; then
    echo sfllbuf.h missing - aborting
    exit
fi
if test ! -f sfllbuf.c; then
    echo sfllbuf.c missing - aborting
    exit
fi

#-  require sfllist.h  sfllist.c
if test ! -f sfllist.h; then
    echo sfllist.h missing - aborting
    exit
fi
if test ! -f sfllist.c; then
    echo sfllist.c missing - aborting
    exit
fi

#-  require sflmath.h  sflmath.c
if test ! -f sflmath.h; then
    echo sflmath.h missing - aborting
    exit
fi
if test ! -f sflmath.c; then
    echo sflmath.c missing - aborting
    exit
fi

#-  require sflmem.h   sflmem.c
if test ! -f sflmem.h; then
    echo sflmem.h missing - aborting
    exit
fi
if test ! -f sflmem.c; then
    echo sflmem.c missing - aborting
    exit
fi

#-  require sflmesg.h  sflmesg.c
if test ! -f sflmesg.h; then
    echo sflmesg.h missing - aborting
    exit
fi
if test ! -f sflmesg.c; then
    echo sflmesg.c missing - aborting
    exit
fi

#-  require sflmime.h  sflmime.c
if test ! -f sflmime.h; then
    echo sflmime.h missing - aborting
    exit
fi
if test ! -f sflmime.c; then
    echo sflmime.c missing - aborting
    exit
fi

#-  require sflnode.h  sflnode.c
if test ! -f sflnode.h; then
    echo sflnode.h missing - aborting
    exit
fi
if test ! -f sflnode.c; then
    echo sflnode.c missing - aborting
    exit
fi

#-  require sflproc.h  sflproc.c
if test ! -f sflproc.h; then
    echo sflproc.h missing - aborting
    exit
fi
if test ! -f sflproc.c; then
    echo sflproc.c missing - aborting
    exit
fi

#-  require sflslot.h  sflslot.c
if test ! -f sflslot.h; then
    echo sflslot.h missing - aborting
    exit
fi
if test ! -f sflslot.c; then
    echo sflslot.c missing - aborting
    exit
fi

#-  require sflsock.h  sflsock.c
if test ! -f sflsock.h; then
    echo sflsock.h missing - aborting
    exit
fi
if test ! -f sflsock.c; then
    echo sflsock.c missing - aborting
    exit
fi

#-  require sflstr.h   sflstr.c
if test ! -f sflstr.h; then
    echo sflstr.h missing - aborting
    exit
fi
if test ! -f sflstr.c; then
    echo sflstr.c missing - aborting
    exit
fi

#-  require sflsymb.h  sflsymb.c
if test ! -f sflsymb.h; then
    echo sflsymb.h missing - aborting
    exit
fi
if test ! -f sflsymb.c; then
    echo sflsymb.c missing - aborting
    exit
fi

#-  require sflsyst.h  sflsyst.c
if test ! -f sflsyst.h; then
    echo sflsyst.h missing - aborting
    exit
fi
if test ! -f sflsyst.c; then
    echo sflsyst.c missing - aborting
    exit
fi

#-  require sfltok.h   sfltok.c
if test ! -f sfltok.h; then
    echo sfltok.h missing - aborting
    exit
fi
if test ! -f sfltok.c; then
    echo sfltok.c missing - aborting
    exit
fi

#-  require sfltree.h  sfltree.c
if test ! -f sfltree.h; then
    echo sfltree.h missing - aborting
    exit
fi
if test ! -f sfltree.c; then
    echo sfltree.c missing - aborting
    exit
fi

#-  require sfltron.h  sfltron.c
if test ! -f sfltron.h; then
    echo sfltron.h missing - aborting
    exit
fi
if test ! -f sfltron.c; then
    echo sfltron.c missing - aborting
    exit
fi

#-  require sfluid.h   sfluid.c
if test ! -f sfluid.h; then
    echo sfluid.h missing - aborting
    exit
fi
if test ! -f sfluid.c; then
    echo sfluid.c missing - aborting
    exit
fi

#-  require testall.c
if test ! -f testall.c; then
    echo testall.c missing - aborting
    exit
fi

#-  require testbits.c
if test ! -f testbits.c; then
    echo testbits.c missing - aborting
    exit
fi

#-  require testcomp.c
if test ! -f testcomp.c; then
    echo testcomp.c missing - aborting
    exit
fi

#-  require testconv.c
if test ! -f testconv.c; then
    echo testconv.c missing - aborting
    exit
fi

#-  require testcryp.c
if test ! -f testcryp.c; then
    echo testcryp.c missing - aborting
    exit
fi

#-  require testdate.c
if test ! -f testdate.c; then
    echo testdate.c missing - aborting
    exit
fi

#-  require testdes.c
if test ! -f testdes.c; then
    echo testdes.c missing - aborting
    exit
fi

#-  require testdir.c
if test ! -f testdir.c; then
    echo testdir.c missing - aborting
    exit
fi

#-  require testexdr.c
if test ! -f testexdr.c; then
    echo testexdr.c missing - aborting
    exit
fi

#-  require testfind.c
if test ! -f testfind.c; then
    echo testfind.c missing - aborting
    exit
fi

#-  require testmem.c
if test ! -f testmem.c; then
    echo testmem.c missing - aborting
    exit
fi

#-  require testmime.c
if test ! -f testmime.c; then
    echo testmime.c missing - aborting
    exit
fi

#-  require teststr.c
if test ! -f teststr.c; then
    echo teststr.c missing - aborting
    exit
fi

#-  require testsym.c
if test ! -f testsym.c; then
    echo testsym.c missing - aborting
    exit
fi

#-  require testtree.c
if test ! -f testtree.c; then
    echo testtree.c missing - aborting
    exit
fi

#-  require testuid.c
if test ! -f testuid.c; then
    echo testuid.c missing - aborting
    exit
fi

#-  require testcgi.c
if test ! -f testcgi.c; then
    echo testcgi.c missing - aborting
    exit
fi

#-  delete $lib libsfl
rm -f libsfl.a

#-  library libsfl
CCLIBNAME=libsfl
export CCLIBNAME

#-  compile sflbits
./c sflbits
test $? -ne 0 && exit 1
rm sflbits.o

#-  compile sflhttp
./c sflhttp
test $? -ne 0 && exit 1
rm sflhttp.o

#-  compile sflcomp
./c sflcomp
test $? -ne 0 && exit 1
rm sflcomp.o

#-  compile sflcons
./c sflcons
test $? -ne 0 && exit 1
rm sflcons.o

#-  compile sflcryp
./c sflcryp
test $? -ne 0 && exit 1
rm sflcryp.o

#-  compile sflcvbs sflcvdp sflcvds sflcvns
./c sflcvbs
test $? -ne 0 && exit 1
rm sflcvbs.o
./c sflcvdp
test $? -ne 0 && exit 1
rm sflcvdp.o
./c sflcvds
test $? -ne 0 && exit 1
rm sflcvds.o
./c sflcvns
test $? -ne 0 && exit 1
rm sflcvns.o

#-  compile sflcvsb sflcvsd sflcvsn sflcvst
./c sflcvsb
test $? -ne 0 && exit 1
rm sflcvsb.o
./c sflcvsd
test $? -ne 0 && exit 1
rm sflcvsd.o
./c sflcvsn
test $? -ne 0 && exit 1
rm sflcvsn.o
./c sflcvst
test $? -ne 0 && exit 1
rm sflcvst.o

#-  compile sflcvtp sflcvts sflconv
./c sflcvtp
test $? -ne 0 && exit 1
rm sflcvtp.o
./c sflcvts
test $? -ne 0 && exit 1
rm sflcvts.o
./c sflconv
test $? -ne 0 && exit 1
rm sflconv.o

#-  compile sfldate
./c sfldate
test $? -ne 0 && exit 1
rm sfldate.o

#-  compile sfldir
./c sfldir
test $? -ne 0 && exit 1
rm sfldir.o

#-  compile sflenv
./c sflenv
test $? -ne 0 && exit 1
rm sflenv.o

#-  compile sflexdr
./c sflexdr
test $? -ne 0 && exit 1
rm sflexdr.o

#-  compile sflfile
./c sflfile
test $? -ne 0 && exit 1
rm sflfile.o

#-  compile sflfind
./c sflfind
test $? -ne 0 && exit 1
rm sflfind.o

#-  compile sflini
./c sflini
test $? -ne 0 && exit 1
rm sflini.o

#-  compile sfllang
./c sfllang
test $? -ne 0 && exit 1
rm sfllang.o

#-  compile sfllbuf
./c sfllbuf
test $? -ne 0 && exit 1
rm sfllbuf.o

#-  compile sfllist
./c sfllist
test $? -ne 0 && exit 1
rm sfllist.o

#-  compile sflmath
./c sflmath
test $? -ne 0 && exit 1
rm sflmath.o

#-  compile sflmem
./c sflmem
test $? -ne 0 && exit 1
rm sflmem.o

#-  compile sflmesg
./c sflmesg
test $? -ne 0 && exit 1
rm sflmesg.o

#-  compile sflmime
./c sflmime
test $? -ne 0 && exit 1
rm sflmime.o

#-  compile sflnode
./c sflnode
test $? -ne 0 && exit 1
rm sflnode.o

#-  compile sflproc
./c sflproc
test $? -ne 0 && exit 1
rm sflproc.o

#-  compile sflslot
./c sflslot
test $? -ne 0 && exit 1
rm sflslot.o

#-  compile sflsock
./c sflsock
test $? -ne 0 && exit 1
rm sflsock.o

#-  compile sflstr
./c sflstr
test $? -ne 0 && exit 1
rm sflstr.o

#-  compile sflsymb
./c sflsymb
test $? -ne 0 && exit 1
rm sflsymb.o

#-  compile sflsyst
./c sflsyst
test $? -ne 0 && exit 1
rm sflsyst.o

#-  compile sfltok
./c sfltok
test $? -ne 0 && exit 1
rm sfltok.o

#-  compile sfltree
./c sfltree
test $? -ne 0 && exit 1
rm sfltree.o

#-  compile sfltron
./c sfltron
test $? -ne 0 && exit 1
rm sfltron.o

#-  compile sfluid
./c sfluid
test $? -ne 0 && exit 1
rm sfluid.o

#-  library

#-  compile testall  testbits testcomp testconv testcryp testdate testdes
./c testall
test $? -ne 0 && exit 1
./c testbits
test $? -ne 0 && exit 1
./c testcomp
test $? -ne 0 && exit 1
./c testconv
test $? -ne 0 && exit 1
./c testcryp
test $? -ne 0 && exit 1
./c testdate
test $? -ne 0 && exit 1
./c testdes
test $? -ne 0 && exit 1

#-  compile testexdr testfind testmem  testmime testsym  testtree testuid
./c testexdr
test $? -ne 0 && exit 1
./c testfind
test $? -ne 0 && exit 1
./c testmem
test $? -ne 0 && exit 1
./c testmime
test $? -ne 0 && exit 1
./c testsym
test $? -ne 0 && exit 1
./c testtree
test $? -ne 0 && exit 1
./c testuid
test $? -ne 0 && exit 1

#-  link    testall  testbits testcomp testconv testcryp testdate testdes
./c -L testall
./c -L testbits
./c -L testcomp
./c -L testconv
./c -L testcryp
./c -L testdate
./c -L testdes

#-  link    testexdr testfind testmem  testmime testsym  testtree testuid
./c -L testexdr
./c -L testfind
./c -L testmem
./c -L testmime
./c -L testsym
./c -L testtree
./c -L testuid

#-  compile testcgi  testdir  teststr
./c testcgi
test $? -ne 0 && exit 1
./c testdir
test $? -ne 0 && exit 1
./c teststr
test $? -ne 0 && exit 1

#-  link    testcgi  testdir  teststr
./c -L testcgi
./c -L testdir
./c -L teststr

#-  call buildh
test -f buildh && chmod +x buildh
./buildh 
echo SFL built successfully.

# -- end script without errors
exit 0
