[comp.os.minix] Rebuilding libc.a under Minix

zemon@felix.UUCP (Art Zemon) (07/23/87)

    The following two shell scripts will rebuild libc.a from
    source running on a Minix machine.  What you need to do is
    replace the "run" shell script with mine, run it, and then
    run my "build" shell script.  You must have an existing
    /usr/lib/libc.a on-line to run build.  The old library is
    used to determine the order in which the modules will be
    installed in the new library.  New modules are inserted in
    the new library in alphabetical order followed by modules
    which existed in the old library in the old order.

    I wrote and tested this under Minix v1.2 and know it works
    there.  I think it will work under v1.1 but have not tested
    it.

    Cheers,
	-- Art Z.


========== run ==================================================
for i in *.c
do
    echo $i
    cc -c -LIB $i
done


========== build ================================================
#
# 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`.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

zemon@felix.UUCP (Art Zemon) (07/24/87)

You also need to add

    #ifndef NIL
    #define NIL 0
    #endif

at an appropriate place near the top of lib/system.c
Other than this, the entire C library compiled without
problems under Minix v1.2.
--
	-- Art Zemon
	   FileNet Corporation
	   Costa Mesa, California
	   ...!hplabs!felix!zemon