Yet another Shared Library CC

Gene H. Olson gene at zeno.MN.ORG
Sun Jul 24 03:49:56 AEST 1988


Here is what I believe to be a better Shared Library C Compiler
shell script.   It works on everything I have tried, perhaps
50 programs, including news, rn, sc and lots of other stuff.

Try it, you'll like it.

Gene H. Olson
Smartware Consulting
Minneapolis, MN 55419

amdahl!bungia!zeno!gene

------------------------- Cut Here --------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Makefile README scc.sh
# Wrapped by gene at zeno on Sat Jul 23 12:43:42 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(938 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
XBIN = /usr/lbin
XLIB = /usr/llib
XUSER = bin
XGROUP = bin
X
XOBJ = setvbuf.o doprnt.o ctime.o lockf.o
X
XFILES = scc scc1.ifile scc2.ifile libscc.a
X
Xall : $(FILES)
X
X$(FILES) : Makefile
X
Xscc : scc.sh
X	sed -e 's|SCCLIBDIR|$(LIB)|' <scc.sh >scc
X	chmod a+x scc
X
Xscc1.ifile : /lib/shlib.ifile
X	sed -e '/^_.base/p' -e '/^[^ ]* =/d' </lib/shlib.ifile >scc1.ifile
X
Xscc2.ifile : /lib/shlib.ifile
X	sed -e '/^_.base/d' -e '/^[^ ]* =/!d' </lib/shlib.ifile | sort >scc2.ifile
X
Xlibscc.a : /lib/libc.a
X	rm -f libscc.a
X	ar x /lib/libc.a $(OBJ)
X	ar cr libscc.a $(OBJ)
X	rm -f $(OBJ)
X
Xinstall: $(FILES)
X	cp scc $(BIN)/scc
X	chmod 0555 $(BIN)/scc
X	chown $(USER) $(BIN)/scc
X	chgrp $(GROUP) $(BIN)/scc
X
X	cp scc1.ifile scc2.ifile libscc.a $(LIB)
X	chmod 0444 $(LIB)/scc1.ifile $(LIB)/scc2.ifile $(LIB)/libscc.a
X	chown $(USER) $(LIB)/scc1.ifile $(LIB)/scc2.ifile $(LIB)/libscc.a
X	chgrp $(GROUP) $(LIB)/scc1.ifile $(LIB)/scc2.ifile $(LIB)/libscc.a
X
Xclean:
X	rm -f $(FILES)
END_OF_Makefile
if test 938 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(2341 characters\)
sed "s/^X//" >README <<'END_OF_README'
XIncluded is a simple variation on the CC command.   The only
Xmajor difference is that it creates binaries using shared
Xlibraries.  This version is very versatile and will compile
Xand load almost anything with shared libraries.
X
XIt accomplishes this by creating a custom .ifile for each
Xset of input object files.   The custom .ifile contains only
Xthose entries from the shared library which are actually used
Xby the program.
X
XAbout the only time you will have a problem is when your program
Xdeclares bss global variables that are the same as the variable
Xnames in the shared library.  It is not clear what you meant
Xhere, so the loader gives you a message and uses the BSS variables
Xfrom the library.   If that isn't what was intended (it almost
Xalways is correct though) you will need to change the names
Xin your program.
X
XAn example of this is the COLS variable.  Lots of programs just
Xdeclare COLS as `int COLS',  which makes it global bss.  This
Xconflicts with the `COLS' variable in the shared library, so the
Xloader uses the library version (which is probably what you wanted)
Xand does not create a new COLS for you with the same name, but
Xa different address.
X
XThis command is fully compatible with -lcurses -lmalloc, and
Xhas been successfully used to compile rn, sc, and other large
Xprograms which extensively redefine standard library routines.
X
XWhen you type "make",  4 files are created:
X
Xscc             Version of "scc.sh" but with the LIB directory you
X                chose in the Makefile auto-hacked in.   This is
X                the only executable.
X
Xscc1.ifile      First library .ifile.   Created from /lib/shlib.ifile.
X                I couldn't just give you a hacked copy because that
X                would probably violate Copyright.
X
Xscc2.ifile      Second library .ifile.
X
Xlibscc.a        Library file created from /lib/libc.a, containing
X                stuff that is not in the shared library.  You may
X                wish to add stuff to this file yourself.
X
XWhen you type "make install":
X
Xscc             is copied to /usr/lbin or wherever you defined
X                $(BIN) to be.
X
Xthe other 3     are copied to /usr/llib or wherever you defined
X                $(LIB) to be.
X
XThere is no manual page.  Use the manual page from cc(1).
X
XGene H. Olson
XSmartware Consulting
XMinneapolis, MN, USA
Xgene at zeno.MN.ORG
END_OF_README
if test 2341 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f scc.sh -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"scc.sh\"
else
echo shar: Extracting \"scc.sh\" \(963 characters\)
sed "s/^X//" >scc.sh <<'END_OF_scc.sh'
X#	Break out the parameters
X
Xcf= co=-c cp= df= lf= lm= lp=
Xnoload=
X
Xfor i in $*
Xdo
X	case $i in
X		-[cEPS]) co=$i noload=1 ;;
X		-s) lp="$lp $i" ;;
X		-o) lp="$lp $i" lm='*' ;;
X		$lm) lp="$lp $i" lm= ;;
X		-[l]*) lf="$lf $i" ;;
X		-*) cp="$cp $i" ;;
X		*.c|*.s) cf="$cf $i"
X			o=`expr $i : '.*/\(.*\)\.' \| $i : '\(.*\)\.'`
X			lf="$lf $o.o" df="$df $o.o"
X			;;
X		*) lf="$lf $i" ;;
X	esac
Xdone
X
X#	Handle no load requested.
X
Xif [ -n "$noload" ]
Xthen
X	lf= df=
Xfi
X
X#	Do the compiles.
X
Xif [ -n "$cf" ]
Xthen
X	set -e
X	cc $co $cp $cf
Xfi
X
X#	Do the load.
X
Xif [ -n "$lf" ]
Xthen
X	set -e
X
X	trap "rm -f scc$$.o scc$$.ifile ; exit 1" 0 1 2 3 15
X
X	df="$df scc$$.o scc$$.ifile"
X
X	ld -r -o scc$$.o /lib/crt0s.o $lf SCCLIBDIR/libscc.a
X
X	(	cat SCCLIBDIR/scc1.ifile \
X	;	(	nm -uh scc$$.o \
X		|	sed -e 's/[ 	][ 	]*//' \
X		|	sort -u \
X		|	join - SCCLIBDIR/scc2.ifile \
X		) \
X	)	>scc$$.ifile
X
X	ld $lp scc$$.ifile scc$$.o
Xfi
X
X#	Delete files when done.
X
Xif [ -n "$df" ]
Xthen
X	rm -f $df
X
X	trap 0
Xfi
END_OF_scc.sh
if test 963 -ne `wc -c <scc.sh`; then
    echo shar: \"scc.sh\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0



More information about the Unix-pc.sources mailing list