summaryrefslogtreecommitdiff
path: root/src/cmd/INIT/cc.next.i386
blob: 16df7093a827f52e7aa73f7b66a4b70949292257 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
: next.i386 cc wrapper for unix message and exit code semantics : 1995-05-09 :

HOSTTYPE=next.i386

case " $* " in
*" -dumpmachine "*) echo $HOSTTYPE; exit ;;
esac

# 1995-05-09	-lposix termios.o waitpid.o setpgid.o *do* work
# 1994-11-04	-posix has old redirection hole bug
#		-D_POSIX_SOURCE requires <sys/dirent.h> manual fixes
#		libexpr/exeval.c bombs -O, no -O ok

command=cc
cc="/bin/cc -D_POSIX_SOURCE"
nooptimize="exeval"

# first check $INSTALLROOT/botch

case $INSTALLROOT in
"")	echo "$command: INSTALLROOT: must be defined and exported" >&2; exit 1 ;;
esac
if	test ! -d $INSTALLROOT/botch -a -dryrun != "$1"
then	if	mkdir $INSTALLROOT/botch
	then	: ok to initialize
	else	echo "$command: $INSTALLROOT/botch must be initialized by the owner of $INSTALLROOT" 2>&1
		exit 1
	fi
	(
		cd $INSTALLROOT/botch
		dir=.
		for i in lib . include sys
		do	case $i in
			.)	dir=.
				;;
			*)	case $i in
				/*)	dir=$i ;;
				*)	dir=$dir/$i ;;
				esac
				test -d $dir || mkdir $dir
				;;
			esac
		done
		if	test ! -f include/sys/dirent.h
		then	echo "#include <dirent.h>" > tmp.c
			header=`$cc -E tmp.c | sed -e '/^#[ 	]*1[ 	].*\/sys\/dirent\.h"/!d' -e 's/.*"\(.*\)".*/\1/'`
			sed -e 's/[ 	]off_t[ 	][ 	]*d_off[ 	]*;//' $header > include/sys/dirent.h
		fi
		if	test ! -f lib/libbotch.a
		then	lipo /usr/lib/libposix.a -thin i386 -output tmp.a
			ar x tmp.a termios.o waitpid.o setpgid.o
			ar cr lib/libbotch.a *.o
			ranlib lib/libbotch.a
		fi
		rm -f *.[aco]
	)
fi

# now slip in our args

case $nooptimize in
"")	nooptimize=.
	;;
*)	optimize=
	for arg in $nooptimize
	do	case $optimize in
		?*)	optimize="$optimize|" ;;
		esac
		optimize="$optimize$arg.[ci]|*/$arg.[ci]"
	done
	nooptimize=$optimize
	;;
esac
set . "$@" .
noexec=
library=
local=
optimize=
verbose=
while	:
do	shift
	arg=$1
	shift
	case $arg in
	.)	break
		;;
	-[cES])	library=1
		;;
	-O)	optimize=1
		;;
	-v)	verbose=1
		;;
	-dryrun)noexec=1
		verbose=1
		;;
	-I-)	case $local in
		"")	local=1
			set . "$@" -I$INSTALLROOT/botch/include -I- -I$INSTALLROOT/botch/include
			;;
		*)	set . "$@" -I- -I$INSTALLROOT/botch/include
			;;
		esac
		continue
		;;
	-I*|*.[cChHiI]|*.[cChHiI][pPxX][pPxX])
		case $optimize in
		1)	eval	"
				case \$arg in
				$nooptimize)
					optimize=0
					;;
				esac
			"
			;;
		esac
		case $local in
		"")	local=1
			set . "$@" -I$INSTALLROOT/botch/include "$arg"
			continue
			;;
		esac
		;;
	-last|*/libast.a)
		case $library in
		"")	library=1
			set . "$@" $INSTALLROOT/botch/lib/libbotch.a "$arg" $INSTALLROOT/botch/lib/libbotch.a
			continue
			;;
		esac
		;;
	esac
	set . "$@" "$arg"
done
case $library in
"")	set . "$@" $INSTALLROOT/botch/lib/libbotch.a
	shift
	;;
esac
case $optimize in
0)	set . "$@" .
	while	:
	do	shift
		arg=$1
		shift
		case $arg in
		.)	break ;;
		-O)	set . "$@" ;;
		*)	set . "$@" "$arg" ;;
		esac
	done
	;;
esac
case $verbose in
?*)	echo $cc "$@" ;;
esac
case $noexec in
"")	$cc "$@" ;;
esac