# ========== compile everything ===========
#for i in *.c
#do
#    echo $i
#    cc -c -LIB $i
#done


# ========== build library ==============
#
# Build libc.a using all of the .s files in the current directory.
# New files are placed at the beginning of the library followed by
# modules which are already in the old library (/usr/lib/libc.a).
# Old modules are placed in the new library in the same order in which
# they appear in the old library.
#
# Art Zemon, July 17, 1987
#
echo Reading old library
ar t /usr/lib/libc.a > list
split -8 list
cat /dev/null > orig.order
echo Creating orig.order
for f in x??
do
    echo ar a libc.a `cat $f` >> orig.order
    rm $f
done

#
# Figure out which files are not in the existing library.
# Base this decision on the .c files because there are a couple of .s
# files here which don't belong in the library.
#
echo Checking .c files
cat /dev/null > new.files
for c in *.c
do
    f=`basename $c .c`
    f=$f".s"
    echo $f
    if grep -s $f list > /dev/null 2>&1 ; then cat /dev/null ; else echo ar av libc.a $f >> new.files ; fi
done

#
# Figure out which modules are in the library but not here and extract them
# from the library.
#
echo determining which modules must be extracted from old library
rm -f libc.a
sh orig.order > /dev/null 2> missing
ar xv /usr/lib/libc.a `grep 'Cannot find ' missing | gres 'Cannot find ' ''`
rm missing libc.a list

#
# Construct the library
#
echo constructing new library with new modules
sh new.files
echo appending original modules to new library
sh orig.order
echo done
#--
#	-- Art Zemon
#	   FileNet Corporation
#	   Costa Mesa, California
#	   ...!hplabs!felix!zemon


