[comp.sources.misc] cc command file for AT&T Unix/PC or 3B1

arnold@emory.UUCP (Arnold D. Robbins {EUCC}) (09/09/87)

The following shell script is useful to users of an AT&T Unix/PC or 3B1.
This machine has a nifty shared library, but the default 'cc' command does
not use it. Instead, one has to use unportable (although documented) features
of make. By renaming your original 'cc' to /bin/c-compiler and installing this
shell script as /bin/cc, nothing has to be changed. I have yet to come
across anything that this script breaks.

Arnold Robbins
Emory University Computing Center
------------- cut here, save your old cc, name this cc -------------------
#! /bin/sh

# cc -- cc replacement that uses the shared library
#	see cc(1) for details

PATH=/bin:/usr/bin
export PATH

OCC=${OCC-/bin/c-compiler}

startoff=/lib/crt0s.o		# use the shared library by default
libc=/lib/shlib.ifile
files=
ofiles=
ldargs=
ccargs=-c	# have to run real cc with this

load=1		# run ld
justprint=0	# just print what would do, -#
verbose=0	# be verbose, -v

while [ $# -gt 0 ]
do
	case "$1" in
	-#)		ccargs="$ccargs $1"
			justprint=1
			;;
	-v)		ccargs="$ccargs $1"
			verbose=1
			;;
	-680[012]0)	ccargs="$ccargs $1"
			;;
	-[OPW])		ccargs="$ccargs $1"
			;;
	-[ES])		ccargs="$ccargs $1"
			load=0
			;;
	-c)		load=0
			;;
	-g)		ccargs="$ccargs $1"
			ldargs="$ldargs -lg"
			startoff=/lib/crt0.o
			libc=/lib/libc.a
			;;
	-o)		ldargs="$ldargs $1 $2"
			shift
			;;
	-p)		ccargs="$ccargs $1"
			ldargs="$ldargs -L/lib/libp"
			startoff=/lib/mcrt0.o
			libc=/lib/libc.a
			;;
	-T)		ccargs="$ccargs $1"
			ldargs="$ldargs -G"
			;;
	-w)		ldargs="$ldargs $1"
			;;
	-[DI]*)		ccargs="$ccargs $1"
			;;
	-[nNzF])	;;			# let ifile set load type
	-ltam)		;;			# get this from shared lib
	-lc)		;;			# get this from shared lib
	-ltermlib)	;;			# get this from shared lib
	-ltermcap)	;;			# get this from shared lib
	-*)		ldargs="$ldargs $1"	# unknown go to loader
			;;
	*.[ao])		ofiles="$ofiles $1"
			;;
	*)		files="$files $1"
			ofiles="$ofiles `basename $1 .[cs]`.o"
			;;
	esac
	shift
done

$OCC $ccargs $files	# compile the source files

if [ "$load" -eq 1 ]
then
	run="/bin/ld $startoff $ofiles $ldargs $libc"
	if [ "$verbose" -eq 1 ]
	then
		echo Loading ...
	fi
	if [ "$justprint" -eq 1 ]
	then
		echo callsys $run
	else
		eval $run
	fi
fi
exit $?
-- 
Arnold Robbins
ARPA, CSNET:	arnold@emory.ARPA	BITNET: arnold@emory
UUCP:	{ decvax, gatech, sun!sunatl }!emory!arnold
ONE-OF-THESE-DAYS:	arnold@emory.math

Vs
aed (Sam