lmjm@doc.ic.ac.uk (Lee McLoughlin) (02/05/89)
All this is aimed at people with hard disc's. Heaven knows how you rebuild libc.a on floppies. I just faced the problem of rebuilding libc for 1.4. Since make can't handle a setup that large I decided to write a shell script to do it. It needs a couple of auxillary programs. One to check if one file is newer than another (you can do it with find - but its a pain). The other just splits up tsort output. I've used various hints from postings on the net but blame me for any problems. To make things more manageable I've split minix/lib into subdirectories and moved things around. All the compiler support is in CC_I8088/, ibm specific stuff in IBM_PC/, the rest of the library source in src/. The bins/ directory is where .s files end up either as src/ files get compiled or by being copied from compiler support or ibm specific. The 'run' shell script fakes being a makefile and compiles any src/ files that are newer than the .s file in bins/ and moves the new .s file into bins/. It then creates a temp libc.a so that it can be lordered and tsorted. The resultant list is then split up and used to create a new archive. In the below shar file. 'du' is the the output of du on lib/ showing how I've I've split up the sources (ignore the SVC directories). 'newer.c' and 'sptonl.c' are the sources for the two auxillary programs - since the programs are not generally useful I leave the executables in the lib/ directory. 'run' is the new generation script. You need to compile newer.c and sptonl.c, move the source around change run (if necessary) and then type 'run'. If you know that currently nothing needs to be rebuilt then cd to the bins directory and do 'ar x' on your libc.a. Since the extracted files will all be newer than the sources 'run' will believe that everything is up to date. 'run' has a lot of variables at the start. I know others have already split up their lib/ directory so I've tried to allow for that. 'run' is a bit space expensive as it requires all the sources, the .s files in bins/, a temporary copy of libc.a and the generated libc.a Please let me know of any problems. Lee. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # du # newer.c # run # sptonl.c # This archive created: Sun Feb 5 14:53:53 1989 export PATH; PATH=/bin:$PATH if test -f 'du' then echo shar: will not over-write existing file "'du'" else cat << \SHAR_EOF > 'du' 1 ./READ_ME 1 ./IBM_PC/brksize.s 1 ./IBM_PC/catchsig.s 1 ./IBM_PC/crtso.s 1 ./IBM_PC/end.s 2 ./IBM_PC/getutil.s 1 ./IBM_PC/head.s 1 ./IBM_PC/sendrec.s 1 ./IBM_PC/setjmp.s 2 ./IBM_PC/portio.s 11 ./IBM_PC 1 ./src/abort.c 1 ./src/abs.c 1 ./src/access.c 1 ./src/alarm.c 3 ./src/amoeba.c 2 ./src/atoi.c 1 ./src/atol.c 1 ./src/bcmp.c 1 ./src/bcopy.c 1 ./src/brk.c 1 ./src/brk2.c 1 ./src/bsearch.c 1 ./src/bzero.c 3 ./src/call.c 1 ./src/chdir.c 1 ./src/chmod.c 1 ./src/chown.c 1 ./src/chroot.c 1 ./src/cleanup.c 1 ./src/close.c 1 ./src/creat.c 1 ./src/crypt.c 1 ./src/ctermid.c 2 ./src/ctime.c 1 ./src/ctype.c 1 ./src/cuserid.c 5 ./src/doprintf.c 1 ./src/dup.c 1 ./src/dup2.c 3 ./src/exec.c 2 ./src/execlp.c 1 ./src/exit.c 1 ./src/fclose.c 1 ./src/fdopen.c 1 ./src/fflush.c 1 ./src/ffs.c 1 ./src/fgetc.c 1 ./src/fgets.c 1 ./src/fopen.c 1 ./src/fork.c 1 ./src/fprintf.c 1 ./src/fputc.c 1 ./src/fputs.c 1 ./src/fread.c 1 ./src/freopen.c 1 ./src/fseek.c 1 ./src/fstat.c 1 ./src/ftell.c 1 ./src/fwrite.c 3 ./src/getcwd.c 1 ./src/getegid.c 1 ./src/getenv.c 1 ./src/geteuid.c 1 ./src/getgid.c 3 ./src/getgrent.c 1 ./src/getlogin.c 1 ./src/getpass.c 1 ./src/getpid.c 2 ./src/getpwent.c 1 ./src/gets.c 1 ./src/getuid.c 1 ./src/gtty.c 1 ./src/index.c 2 ./src/ioctl.c 1 ./src/isatty.c 1 ./src/itoa.c 1 ./src/kill.c 1 ./src/link.c 1 ./src/lsearch.c 1 ./src/lseek.c 5 ./src/malloc.c 1 ./src/memccpy.c 1 ./src/memchr.c 1 ./src/memcmp.c 1 ./src/memcpy.c 1 ./src/memset.c 1 ./src/message.c 1 ./src/mknod.c 1 ./src/mktemp.c 1 ./src/mount.c 1 ./src/open.c 1 ./src/pause.c 2 ./src/perror.c 1 ./src/pipe.c 2 ./src/popen.c 1 ./src/printdat.c 4 ./src/printk.c 2 ./src/prints.c 1 ./src/puts.c 3 ./src/qsort.c 1 ./src/rand.c 1 ./src/read.c 28 ./src/regexp.c 3 ./src/regsub.c 1 ./src/rindex.c 6 ./src/scanf.c 1 ./src/setbuf.c 1 ./src/setgid.c 1 ./src/setuid.c 2 ./src/signal.c 2 ./src/sleep.c 1 ./src/sprintf.c 1 ./src/stat.c 1 ./src/stb.c 1 ./src/stderr.c 1 ./src/stime.c 1 ./src/strcat.c 1 ./src/strchr.c 1 ./src/strcmp.c 1 ./src/strcpy.c 1 ./src/strcspn.c 1 ./src/strlen.c 1 ./src/strncat.c 1 ./src/strncmp.c 1 ./src/strncpy.c 1 ./src/strpbrk.c 1 ./src/strrchr.c 1 ./src/strspn.c 1 ./src/strstr.c 2 ./src/strtok.c 1 ./src/stty.c 1 ./src/swab.c 1 ./src/sync.c 5 ./src/syslib.c 1 ./src/system.c 6 ./src/termcap.c 1 ./src/time.c 1 ./src/times.c 2 ./src/ttyname.c 1 ./src/umask.c 1 ./src/umount.c 1 ./src/ungetc.c 1 ./src/uniqport.c 1 ./src/unlink.c 1 ./src/utime.c 1 ./src/wait.c 1 ./src/write.c 1 ./src/lib.h 1 ./src/closedir.c 2 ./src/run.hmmm 1 ./src/makefile.bak 1 ./src/makefile 2 ./src/.t 1 ./src/ctype.note 1 ./src/.makerule 4 ./src/curses.c 5 ./src/fortune.dat 1 ./src/run.bak 8 ./src/getdents.c 5 ./src/getopt.c 1 ./src/help.more 1 ./src/lock.c 2 ./src/lrand.c 2 ./src/opendir.c 1 ./src/utime.c.bak 1 ./src/readdir.c 1 ./src/rename.c 1 ./src/rewinddir.c 3 ./src/seekdir.c 1 ./src/strerror.c 1 ./src/telldir.c 1 ./src/vsprintf.c 1 ./src/SVC/bcmp.c,S 1 ./src/SVC/bcopy.c,S 1 ./src/SVC/bzero.c,S 1 ./src/SVC/ctype.c,S 1 ./src/SVC/fdopen.c,S 1 ./src/SVC/index.c,S 1 ./src/SVC/memccpy.c,S 1 ./src/SVC/memchr.c,S 1 ./src/SVC/memcmp.c,S 1 ./src/SVC/memcpy.c,S 1 ./src/SVC/memset.c,S 2 ./src/SVC/popen.c,S 1 ./src/SVC/rand.c,S 1 ./src/SVC/rindex.c,S 1 ./src/SVC/signal.c,S 1 ./src/SVC/sleep.c,S 1 ./src/SVC/strcat.c,S 1 ./src/SVC/strchr.c,S 1 ./src/SVC/strcmp.c,S 1 ./src/SVC/strcpy.c,S 1 ./src/SVC/strcspn.c,S 1 ./src/SVC/strlen.c,S 1 ./src/SVC/strncat.c,S 1 ./src/SVC/strncmp.c,S 1 ./src/SVC/strncpy.c,S 1 ./src/SVC/strpbrk.c,S 1 ./src/SVC/strrchr.c,S 1 ./src/SVC/strspn.c,S 1 ./src/SVC/strstr.c,S 2 ./src/SVC/strtok.c,S 1 ./src/SVC/system.c,S 6 ./src/SVC/termcap.c,S 1 ./src/SVC/utime.c,S 40 ./src/SVC 305 ./src 1 ./bins/abort.s 1 ./bins/abs.s 1 ./bins/access.s 1 ./bins/alarm.s 1 ./bins/atoi.s 1 ./bins/atol.s 1 ./bins/bcmp.s 1 ./bins/bcopy.s 1 ./bins/brk.s 1 ./bins/brk2.s 1 ./bins/bsearch.s 1 ./bins/bzero.s 1 ./bins/call.s 1 ./bins/chdir.s 1 ./bins/chmod.s 1 ./bins/chown.s 1 ./bins/chroot.s 1 ./bins/cleanup.s 1 ./bins/close.s 1 ./bins/creat.s 2 ./bins/crypt.s 1 ./bins/ctermid.s 2 ./bins/ctime.s 1 ./bins/ctype.s 1 ./bins/cuserid.s 3 ./bins/doprintf.s 1 ./bins/dup.s 1 ./bins/dup2.s 2 ./bins/exec.s 1 ./bins/execlp.s 1 ./bins/exit.s 1 ./bins/fclose.s 1 ./bins/fdopen.s 1 ./bins/fflush.s 1 ./bins/ffs.s 1 ./bins/fgets.s 1 ./bins/fopen.s 1 ./bins/fork.s 1 ./bins/fprintf.s 1 ./bins/fputc.s 1 ./bins/fputs.s 1 ./bins/fread.s 1 ./bins/freopen.s 1 ./bins/fseek.s 1 ./bins/fstat.s 1 ./bins/ftell.s 1 ./bins/fwrite.s 2 ./bins/getcwd.s 1 ./bins/getegid.s 1 ./bins/getenv.s 1 ./bins/geteuid.s 1 ./bins/getgid.s 2 ./bins/getgrent.s 1 ./bins/getlogin.s 1 ./bins/getpass.s 1 ./bins/getpid.s 2 ./bins/getpwent.s 1 ./bins/gets.s 1 ./bins/getuid.s 1 ./bins/gtty.s 1 ./bins/index.s 2 ./bins/ioctl.s 1 ./bins/isatty.s 1 ./bins/itoa.s 1 ./bins/kill.s 1 ./bins/link.s 1 ./bins/lsearch.s 1 ./bins/lseek.s 2 ./bins/malloc.s 1 ./bins/memccpy.s 1 ./bins/memchr.s 1 ./bins/memcmp.s 1 ./bins/memcpy.s 1 ./bins/memset.s 1 ./bins/message.s 1 ./bins/mknod.s 1 ./bins/mktemp.s 1 ./bins/mount.s 1 ./bins/open.s 1 ./bins/pause.s 3 ./bins/perror.s 1 ./bins/pipe.s 2 ./bins/popen.s 1 ./bins/printdat.s 3 ./bins/printk.s 1 ./bins/prints.s 1 ./bins/puts.s 2 ./bins/qsort.s 1 ./bins/rand.s 1 ./bins/read.s 12 ./bins/regexp.s 2 ./bins/regsub.s 1 ./bins/rindex.s 4 ./bins/scanf.s 1 ./bins/setbuf.s 1 ./bins/setgid.s 1 ./bins/setuid.s 1 ./bins/signal.s 1 ./bins/sleep.s 1 ./bins/sprintf.s 1 ./bins/stat.s 1 ./bins/stb.s 1 ./bins/stderr.s 1 ./bins/stime.s 1 ./bins/strcat.s 1 ./bins/strchr.s 1 ./bins/strcmp.s 1 ./bins/strcpy.s 1 ./bins/strcspn.s 1 ./bins/strlen.s 1 ./bins/strncat.s 1 ./bins/strncmp.s 1 ./bins/strncpy.s 1 ./bins/strpbrk.s 1 ./bins/strrchr.s 1 ./bins/strspn.s 1 ./bins/strstr.s 1 ./bins/strtok.s 1 ./bins/stty.s 1 ./bins/swab.s 1 ./bins/sync.s 2 ./bins/syslib.s 1 ./bins/system.s 4 ./bins/termcap.s 1 ./bins/time.s 1 ./bins/times.s 1 ./bins/ttyname.s 1 ./bins/umask.s 1 ./bins/umount.s 1 ./bins/ungetc.s 1 ./bins/unlink.s 1 ./bins/utime.s 1 ./bins/wait.s 1 ./bins/write.s 1 ./bins/closedir.s 4 ./bins/curses.s 1 ./bins/fgetc.s 2 ./bins/getdents.s 2 ./bins/getopt.s 1 ./bins/lock.s 1 ./bins/lrand.s 1 ./bins/opendir.s 1 ./bins/readdir.s 1 ./bins/rename.s 1 ./bins/rewinddir.s 1 ./bins/seekdir.s 1 ./bins/strerror.s 1 ./bins/telldir.s 1 ./bins/vsprintf.s 1 ./bins/brksize.s 1 ./bins/catchsig.s 1 ./bins/crtso.s 1 ./bins/end.s 2 ./bins/getutil.s 1 ./bins/head.s 2 ./bins/portio.s 1 ./bins/sendrec.s 1 ./bins/setjmp.s 1 ./bins/_dup.s 1 ./bins/adi.s 1 ./bins/and.s 1 ./bins/blm.s 1 ./bins/cii.s 1 ./bins/cmi4.s 1 ./bins/cms.s 1 ./bins/cmu4.s 1 ./bins/com.s 1 ./bins/csa2.s 1 ./bins/csb2.s 1 ./bins/cuu.s 1 ./bins/dvi4.s 1 ./bins/dvu4.s 1 ./bins/error.s 1 ./bins/exg.s 1 ./bins/fakfp.s 1 ./bins/fat.s 1 ./bins/gto.s 1 ./bins/iaar.s 1 ./bins/ilar.s 1 ./bins/inn.s 1 ./bins/ior.s 1 ./bins/isar.s 1 ./bins/lar2.s 1 ./bins/lfr6.s 1 ./bins/lfr8.s 1 ./bins/loi.s 1 ./bins/mli4.s 1 ./bins/mon.s 1 ./bins/nop.s 1 ./bins/rck.s 1 ./bins/ret6.s 1 ./bins/ret8.s 1 ./bins/retarea.s 1 ./bins/return.s 1 ./bins/rmi4.s 1 ./bins/rmu4.s 1 ./bins/sar2.s 1 ./bins/sbi.s 1 ./bins/set.s 1 ./bins/sti.s 1 ./bins/stop.s 1 ./bins/strhp.s 2 ./bins/trp.s 1 ./bins/unknown.s 1 ./bins/vars.s 1 ./bins/xor.s 249 ./bins 1 ./newer.c 3 ./newer 2 ./run.orig 95 ./libc.a 1 ./sptonl.c 2 ./sptonl 1 ./CC_I8088/_dup.s 1 ./CC_I8088/adi.s 1 ./CC_I8088/and.s 1 ./CC_I8088/blm.s 1 ./CC_I8088/cii.s 1 ./CC_I8088/cmi4.s 1 ./CC_I8088/cms.s 1 ./CC_I8088/cmu4.s 1 ./CC_I8088/com.s 1 ./CC_I8088/csa2.s 1 ./CC_I8088/csb2.s 1 ./CC_I8088/cuu.s 1 ./CC_I8088/dvi4.s 1 ./CC_I8088/dvu4.s 1 ./CC_I8088/error.s 1 ./CC_I8088/exg.s 1 ./CC_I8088/fakfp.s 1 ./CC_I8088/fat.s 1 ./CC_I8088/gto.s 1 ./CC_I8088/iaar.s 1 ./CC_I8088/ilar.s 1 ./CC_I8088/inn.s 1 ./CC_I8088/ior.s 1 ./CC_I8088/isar.s 1 ./CC_I8088/lar2.s 1 ./CC_I8088/lfr6.s 1 ./CC_I8088/lfr8.s 1 ./CC_I8088/loi.s 1 ./CC_I8088/mli4.s 1 ./CC_I8088/mon.s 1 ./CC_I8088/nop.s 1 ./CC_I8088/rck.s 1 ./CC_I8088/ret6.s 1 ./CC_I8088/ret8.s 1 ./CC_I8088/retarea.s 1 ./CC_I8088/return.s 1 ./CC_I8088/rmi4.s 1 ./CC_I8088/rmu4.s 1 ./CC_I8088/sar2.s 1 ./CC_I8088/sbi.s 1 ./CC_I8088/set.s 1 ./CC_I8088/sti.s 1 ./CC_I8088/stop.s 1 ./CC_I8088/strhp.s 2 ./CC_I8088/trp.s 1 ./CC_I8088/unknown.s 1 ./CC_I8088/vars.s 1 ./CC_I8088/xor.s 49 ./CC_I8088 1 ./run2 730 . SHAR_EOF fi # end of overwriting check if test -f 'newer.c' then echo shar: will not over-write existing file "'newer.c'" else cat << \SHAR_EOF > 'newer.c' /* newer file1 file2 * return status of true if file2 newer than file1 or if file1 doesn't exist */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> main( argc, argv ) char **argv; { struct stat f1, f2; if( argc != 3 ){ fprintf( stderr, "Usage: %s file1 file2\n", argv[ 0 ] ); exit( 1 ); } if( stat( argv[ 1 ], &f1 ) < 0 ) exit( 0 ); if( stat( argv[ 2 ], &f2 ) < 0 ){ fprintf( stderr, "cannot stat file %s\n", argv[ 2 ] ); exit( 1 ); } exit( f2.st_mtime > f1.st_mtime ? 0 : 1 ); } SHAR_EOF fi # end of overwriting check if test -f 'run' then echo shar: will not over-write existing file "'run'" else cat << \SHAR_EOF > 'run' # Create a new libc.a # Lee McLoughlin, Department of Computing, Imperial College. Feb 1988 # # This script cd's around a lot so try and keep any filenames as full # pathnames (not relative) # Run this script in the minix/lib directory LIB=`pwd` # NEWER is a program that returns a true exit status if the # second filename passed to it is newer than the first (or if the second # file doesn't exist) NEWER=$LIB/newer # SPTONL is a program that converts spaces on standard input into newlines SPTONL=$LIB/sptonl # Needed flags CFLAGS='-Di8088 -DCONST= -DSIZET=int -DVOIDSTAR=char\ * -LIB' CC=cc # Suffix for binary files. S=s # Where the .$S files end up (not the current dir, in order to avoid # overloading ls) BIN=$LIB/bins # Directories where sources that should be compiled into $BIN SRCDIRS="src" # Directories where objects are # The object files in them are copied to $BIN OBJDIRS="IBM_PC CC_I8088" # Final library name LIBC=$LIB/libc.a # temporary copy of archive needed to lorder/tsort (probably too big # for the /tmp area on most systems) LIBTMP=$LIB/libc.a.tmp # Temporary file listing the contents of an individual directory. LIBLIST=/tmp/.liblist # Temp files storing the ouput of lorder and tsort LIBLORD=/tmp/.liblist.lord LIBTSORT=/tmp/.liblist.tsrt # Loop around all the src directories and compile anything which # has changed. Mv the generated .$S file into $BIN echo "Compiling all" for i in $SRCDIRS do echo "Compiling in $i" cd $i # Create the list of all the generated files (without suffix) echo "Creating file list" ls | sed -n 's/\.c$//p' > $LIBLIST echo "Finding what needs to be compiled" while read srcname do if $NEWER $BIN/$srcname.$S $srcname.c then echo compiling $srcname.c $CC -c $CFLAGS $srcname.c mv $srcname.$S $BIN/$srcname.$S fi done < $LIBLIST rm -f $LIBLIST cd $LIB done echo "Compiling done" echo "Copying other object files" for dir in $OBJDIRS do echo "Copying from $dir" cd $dir # Do it in sections to avoid limit on argv under minix cp [_-m]*.$S $BIN cp [n-z]*.$S $BIN cd $LIB done echo "Creating tmp library" rm -f $LIBTMP cd $BIN # Do it in sections to avoid limit on argv under minix ar rv $LIBTMP [_-m]*.$S ar rv $LIBTMP [n-z]*.$S cd $LIB echo "Lordering" lorder $LIBTMP > $LIBLORD rm -f $LIBTMP echo "Tsorting" tsort < $LIBLORD > $LIBTSORT rm -f $LIBLORD echo "Creating new archive" rm -f $LIBC cd $BIN # List is too big to give to ar. It is also all one line. # Chop it up into manageable chunks. rm -f xa? $SPTONL < $LIBTSORT | split -50 rm -f $LIBTSORT for s in xa? do ar crv $LIBC `cat $s` done rm -f xa? cd $LIB echo All done ls -l $LIBC SHAR_EOF chmod +x 'run' fi # end of overwriting check if test -f 'sptonl.c' then echo shar: will not over-write existing file "'sptonl.c'" else cat << \SHAR_EOF > 'sptonl.c' /* convert all spaces on standard input into newlines. * Meant as a postprocessor of tsort output */ #include <stdio.h> main() { int c = getchar(); while( (c = getchar()) != EOF ){ if( c == ' ' ) c = '\n'; putchar( c ); } putchar( '\n' ); }/ SHAR_EOF fi # end of overwriting check # End of shell archive exit 0