1# To incorporate the 7300/3b1 shared library, run this script in place
2# of 'CC'.
3# You can skip this is you have the shcc program installed as cc in
4# your path.
5# First: Run 'Configure' through to the end and run 'make depend'.
6# Second: Edit 'makefile' ( not Makefile ) and set CC = 3b1cc.
7# Third: Edit 'x2p/makefile' and set CC = 3b1cc.
8#
9# Do not use '3b1cc' as the default compiler.  The call to the default
10# compiler is used by 'perl' and will not be available when running
11# 'perl'.
12#
13# Note: This script omits libraries which are redundant in the shared
14# library.  It is an excerpt from a grander version available upon
15# request from "zebra!vern" or "vern@zebra.alphacdc.com".
16
17CC="cc"
18LIBS=
19INCL=
20
21LD="ld"
22SHAREDLIB="/lib/crt0s.o /lib/shlib.ifile"
23
24# Local variables
25COBJS=
26LOBJS=
27TARG=
28FLAGS=
29CMD=
30
31# These are libraries which are incorporated in the shared library
32OMIT="-lmalloc"
33
34# These routines are in libc.a but not in the shared library
35if [ ! -f vsprintf.o -o ! -f doprnt.o ]
36then
37	echo "Extracting vsprintf.o from libc.a"
38	ar -x /lib/libc.a vsprintf.o doprnt.o
39fi
40
41CMD="$CC"
42while [ $# -gt 0 ]
43do
44	case $1 in
45	-c)	CFLAG=$1;;
46	-o)	CFLAG=$1
47		shift
48		TARG="$1";;
49	-l*)	match=false
50		for i in $OMIT
51		do
52			[ "$i" = "$1" ] && match=true
53		done
54		[ "$match" != false ] || LIBS="$LIBS $1";;
55	-*)	FLAGS="$FLAGS $1";;
56	*.c)	COBJS="$COBJS $1";;
57	*.o)	LOBJS="$LOBJS $1";;
58	*)	TARG="$1";;
59	esac
60	shift
61done
62
63if [ -n "$COBJS" ]
64then
65	CMD="$CMD $FLAGS $INCL $LPATHS $LIBS $COBJS $CFLAG $TARG"
66elif [ -n "$LOBJS" ]
67then
68	LOBJS="$LOBJS vsprintf.o doprnt.o"
69	CMD="$LD -r $LOBJS $LPATHS $LIBS -o temp.o"
70	echo "\t$CMD"
71	$CMD
72	CMD="$LD -s temp.o $SHAREDLIB -o $TARG"
73	echo "\t$CMD"
74	$CMD
75	ccrslt=$?
76	if [ $ccrslt -ne 0 ]
77	then
78		exit $ccrslt
79	fi
80	CMD="rm -f temp.o"
81else
82	exit 1
83fi
84echo "\t$CMD"
85$CMD
86ccrslt=$?
87rm -f $$.c
88exit $ccrslt
89