#! /bin/sh
# mklib creates list of newer *.c files Updated.list, then executes this script.
# A library is maintained for each memory model.
# eo is a utility that executes something once, for each file in a list
# New .c functions will be automatically added to the libraries.
# Updated .c functions will be automatically updated in the libraries.
# Multiple functions may be contained in single .c files.

# Enter CC options in variable OPTIMIZE
OPTIMIZE="-c -w9 -Wc,-we -Wc,-e6 -ze -Oaeilrt"

# Enter root name of library in variable LIBROOT
# eg. mylib, not mylib3r.lib
LIBROOT=""

# SMALL MODEL
eo Updated.list "cc -2 -ms $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOTs.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# COMPACT MODEL
eo Updated.list "cc -2 -mc $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOTc.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# MEDIUM MODEL
eo Updated.list "cc -2 -mm $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOTm.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# LARGE MODEL
eo Updated.list "cc -2 -ml $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOTl.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# HUGE MODEL
eo Updated.list "cc -2 -mh $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOTh.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# FLAT MODEL
eo Updated.list "cc -5 -ms $OPTIMIZE @"
test $? -ne 0 && exit 1
wlib $LIBROOT3r.lib *.o
test $? -ne 0 && exit 1
rm -f *.o

# INSTALL THE NEW LIBRARIES
chmod 644 *.lib
cp -p *.lib /usr/lib
test $? -ne 0 && exit 1

exit 0
