-
Notifications
You must be signed in to change notification settings - Fork 7
/
:mk.i386
338 lines (296 loc) · 10.2 KB
/
:mk.i386
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
echo ""
echo ""
echo " Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T"
echo " All Rights Reserved"
echo ""
echo " THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T"
echo " The copyright notice above does not evidence any actual or"
echo " intended publication of such source code."
echo ""
echo ""
echo ""
#ident "@(#)mk::mk.i386 1.1.2.1"
#
# Shell script for rebuilding the Complete UNIX System V/386 Release 4.0
#
if [ "$ROOT" = "" ]
then echo "$0: You must specify a \$ROOT directory, other than '/', \
as the root of the source and output tree."
exit 1
fi
if [ "$ROOT" = "/" ]
then echo "$0: You must specify a \$ROOT directory, other than '/', \
as the root of the source and output tree."
exit 1
fi
if [ ! -d ${ROOT} ]
then echo "$0: You must specify a \$ROOT directory, other than '/', \
as the root of the source and output tree."
exit 1
fi
OLDPATH=$PATH; export OLDPATH
PATH=$ROOT/xenv:$ROOT/i386/usr/ccs/bin:/bin:/etc:/usr/bin; export PATH
#
PATH=$PATH:$OLDPATH; export PATH
MCS=${MCS:-mcs}; export MCS
#
# changed to allow the following to be setable
#
LOAD=${LOAD:-STC}; export LOAD
RELEASE=${RELEASE:-4.0}; export RELEASE
TARGET=${TARGET:-i386}; export TARGET
PRODUCT=${PRODUCT:-386unix}; export PRODUCT
echo $0 started at `date`
trap "exit 1" 1 2 3 15
SHELL="/bin/sh"
export SHELL
CH=`id | sed '/uid=0[^0-9].*/!s|.*|#|;/#/!d'`
export CH
CCSTYPE=COFF; export CCSTYPE
SYMLINK=: export SYMLINK
XSGS=$ROOT/i386
export XSGS
if [ "$ROOT" = "" ]
then
PATH=/bin:/etc:/usr/bin; export PATH
else
# Cross-makes may not have all the directories needed
for dir in /bin /lib /usr/include /usr/include/sys /shlib /tmp /xenv
do if [ ! -d $ROOT/$dir ]
then rm -f $ROOT/$dir
mkdir $ROOT/$dir
chmod 755 $ROOT/$dir
fi
done
fi
echo "uname -a = \c"; uname -a
echo "Building Cross C Compiler ...."
#chmod 644 $ROOT/xenv/lint
rm -f $ROOT/xenv/i386cc $ROOT/xenv/cc $ROOT/xenv/make $ROOT/xenv/i386 $ROOT/xenv/vax $ROOT/xenv/cpset
rm -f $ROOT/xenv/ar $ROOT/xenv/i386as $ROOT/xenv/i386ld $ROOT/xenv/tic $ROOT/xenv/lint1
cp /bin/true ${ROOT}/xenv/i386
chmod 755 ${ROOT}/xenv/i386
for i in `ls -i /bin | grep "\`ls -i /bin/true | cut -c1-6\`" | grep -v true | cut -c7-`
do
if [ ${i} = "i386" ]
then continue
fi
cp /bin/false ${ROOT}/xenv/${i}
done
echo 'MAKEOPTS="MAKE=make AS=as CC=cc LD=ld ROOT=$ROOT INC=$ROOT/usr/include CCSLIB=$ROOT/i386/usr/ccs/lib"
export MAKEOPTS
/bin/make ${MAKEOPTS} "$@"
' > $ROOT/xenv/make
chmod +x ${ROOT}/xenv/make
echo '/bin/cc -D_STYPES -U__STDC__ "$@" -I$ROOT/usr/include' > $ROOT/xenv/cc
chmod +x ${ROOT}/xenv/cc
cd $ROOT/usr/src
while [ $# -ge 1 ]
do
case "$1" in
at386|AT386|at|AT) BUS=AT386; ARCH=AT386;;
vpix|VPIX) VPIX=VPIX;;
novpix|NOVPIX) VPIX=NOVPIX;;
merge386|MERGE386) MERGE386=MERGE386;;
nomerge386|NOMERGE386) MERGE386=" ";;
mca|MCA) BUS=MCA; ARCH=MCA;;
mb1|MB1|mbus1|MBUS1) BUS=MB1; ARCH=MBUS;;
mb2|MB2|mbus2|MBUS2) BUS=MB2; ARCH=MBUS;;
eisa|EISA) BUS=EISA; ARCH=AT386;;
ev\-at|EV\-AT) BUS=EV-AT; ARCH=EV-AT;;
i860|I860|860) ;;
mbus|MBUS) ;;
*) BUS="$1"; ARCH="$1";;
esac
shift
done
BUS=${BUS:-AT386}; export BUS
ARCH=${ARCH:-AT386}; export ARCH
MERGE386=${MERGE386:-MERGE386}; export MERGE386
VPIX=${VPIX:-VPIX}; export VPIX
# install /usr/include and /usr/include/sys header files
sh ./:mkhead
sh ./:mksyshead
sh ./:mkucbhead
rm -f $ROOT/xenv/i386 $ROOT/xenv/vax
cd cmd/sgs/xenv/i386
sh pathedit << !
n
y
y
!
if [ ! -f makefile.1 ]
then mv makefile makefile.1
fi
grep -v unix_conv makefile.1 > makefile
cd ../../../..
# Build the C Compilation tools, fltused changes
rm -f $ROOT/usr/bin/tic_native $ROOT/usr/ccs/bin/tic $ROOT/usr/bin/tic_cross
rm -f $ROOT/etc/conf/bin/idconfig_native $ROOT/etc/conf/bin/idconfig $ROOT/etc/conf/bin/idconfig_cross
rm -f $ROOT/etc/conf/bin/idmkunix_native $ROOT/etc/conf/bin/idmkunix $ROOT/etc/conf/bin/idmkunix_native
sh ./:mkcmd BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 sgs
sh ./:mkcmd BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 cpset
mv $ROOT/usr/bin/cpset $ROOT/xenv/cpset
echo '${XSGS}/usr/ccs/bin/i386cc -G -Y 0,${XSGS}/usr/ccs/lib -Y 2,${XSGS}/usr/ccs/lib -Y a,${XSGS}/usr/ccs/bin -Y l,${XSGS}/usr/ccs/bin "$@" -Y I,${ROOT}/usr/include' > $ROOT/xenv/i386cc
cd cmd/sgs/xenv/i386
mv makefile.1 makefile
sh pathedit << !
y
y
y
!
cd ../../../..
rm -f ${ROOT}/xenv/cc
chmod +x ${ROOT}/xenv/i386cc
cp ${XSGS}/usr/ccs/bin/i386ar ${ROOT}/xenv/i386ar
cp ${XSGS}/usr/ccs/bin/i386as ${ROOT}/xenv/i386as
cp ${XSGS}/usr/ccs/bin/i386ld ${ROOT}/xenv/i386ld
CCSTYPE=ELF; export CCSTYPE
SHELL=/bin/sh; export SHELL
INC=$ROOT/usr/include; export INC
INCSYS=$ROOT/usr/include; export INCSYS
# Build the C library
sh ./:mklib BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 xlibcurses
cp ${ROOT}/usr/ccs/bin/tic ${ROOT}/xenv/tic
rm -f ${ROOT}/xenv/make
sh ./:mklib BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 libc
echo '${XSGS}/usr/ccs/bin/i386cc -G -Y 0,${XSGS}/usr/ccs/lib -Y 2,${XSGS}/usr/ccs/lib -Y a,${XSGS}/usr/ccs/bin -Y l,${XSGS}/usr/ccs/bin -Y S,${ROOT}/usr/ccs/lib -Y L,${ROOT}/usr/lib -Y U,${ROOT}/usr/ccs/lib "$@" -Y I,${ROOT}/usr/include' > $ROOT/xenv/i386cc
cp $ROOT/usr/ccs/lib/crt0.o $ROOT/usr/ccs/lib/i386crt0.o
cp $ROOT/usr/ccs/lib/crt1.o $ROOT/usr/ccs/lib/i386crt1.o
cp $ROOT/usr/ccs/lib/crti.o $ROOT/usr/ccs/lib/i386crti.o
cp $ROOT/usr/ccs/lib/crtn.o $ROOT/usr/ccs/lib/i386crtn.o
cp $ROOT/usr/ccs/lib/mcrt0.o $ROOT/usr/ccs/lib/i386mcrt0.o
cp $ROOT/usr/ccs/lib/mcrt1.o $ROOT/usr/ccs/lib/i386mcrt1.o
cp $ROOT/usr/ccs/lib/pcrt1.o $ROOT/usr/ccs/lib/i386pcrt1.o
cp $ROOT/usr/ccs/lib/values-Xa.o $ROOT/usr/ccs/lib/i386values-Xa.o
cp $ROOT/usr/ccs/lib/values-Xc.o $ROOT/usr/ccs/lib/i386values-Xc.o
cp $ROOT/usr/ccs/lib/values-Xt.o $ROOT/usr/ccs/lib/i386values-Xt.o
# Build the Libraries
sh ./:mklib BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 libcrypt libdl libgen libl libm libmalloc liby rtld xlibcurses zlibeti zlibetitam
rm -f $ROOT/i386/usr/ccs/lib/libcurses.a $ROOT/usr/ccs/lib/libtermcap.a $ROOT/usr/ccs/lib/libtermlib.a
ln ${ROOT}/usr/ccs/lib/libcurses.a ${ROOT}/usr/ccs/lib/libtermlib.a
ln ${ROOT}/usr/ccs/lib/libcurses.a ${ROOT}/usr/ccs/lib/libtermcap.a
ln ${ROOT}/usr/ccs/lib/libcurses.a ${ROOT}/usr/lib/libtermcap.a
# Build all the non CSDS libraries
(
cd lib
ls -a | sed \
-e "/^.lib.mk$/d" \
-e "/^.libmk.temp$/d" \
-e "/^libc$/d" \
-e "/^libcrypt$/d" \
-e "/^libdl$/d" \
-e "/^libgen$/d" \
-e "/^libl$/d" \
-e "/^libm$/d" \
-e "/^libmalloc$/d" \
-e "/^liby$/d" \
-e "/^rtld$/d" \
-e "/^xlibcurses$/d" \
-e "/^zlibeti$/d" \
-e "/^zlibetitam$/d" |
sort -u | sed -n '3,$p' > /tmp/$$.doit
)
if [ -s /tmp/$$.doit ]
then sh ./:mklib $VPIX $MERGE386 `cat -s /tmp/$$.doit`
fi
rm -f /tmp/$$.doit
(
cd ${ROOT}/usr/src/xcplib
ls -a |
sort -u |
sed -n '3,$p' > /tmp/$$.xit
)
sh ./:mkxcplib `cat -s /tmp/$$.xit`
rm -f /tmp/$$.xit
(
cd ${ROOT}/usr/src/ucblib
ls -a |
sort -u |
sed -n '3,$p' > /tmp/$$.ucbit
)
sh ./:mkucblib `cat -s /tmp/$$.ucbit`
rm -f /tmp/$$.ucbit
sh ./:mklib BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 libc
echo '${XSGS}/usr/ccs/bin/i386cc -Y 0,${XSGS}/usr/ccs/lib -Y 2,${XSGS}/usr/ccs/lib -Y a,${XSGS}/usr/ccs/bin -Y l,${XSGS}/usr/ccs/bin -Y S,${ROOT}/usr/ccs/lib -Y L,${ROOT}/usr/lib -Y U,${ROOT}/usr/ccs/lib "$@" -Y I,${ROOT}/usr/include' > $ROOT/xenv/i386cc
chmod +x ${ROOT}/xenv/i386cc
# build all the commands
# Build the sgs now so that libld.a is installed for other cmds.
sh ./:mkcmd BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 sgs
mkdir $ROOT/i386/usr/ccs/lib $ROOT/i386/usr/ccs/lib/lex > /dev/null 2>&1
cp $ROOT/usr/ccs/lib/lex/ncform $ROOT/i386/usr/ccs/lib/lex/ncform
(
cd ${ROOT}/usr/src/cmd
ls -a |
sed -e "s/\.mk$//" -e "s/\.sh$//" -e "s/\.c$//" \
-e "/^include$/d" |
sort -u |
egrep -v "sgs" |
sed -n '3,$p' > /tmp/$$.doit
)
sh ./:mkcmd BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 `cat -s /tmp/$$.doit`
rm -f /tmp/$$.doit
cp $ROOT/usr/ccs/lib/llib-lcrypt $ROOT/usr/lib/llib-lcrypt
cp $ROOT/usr/ccs/lib/llib-lcrypt.ln $ROOT/usr/lib/llib-lcrypt.ln
(
cd ${ROOT}/usr/src/ucbcmd
ls -a |
sed -e "s/\.mk$//" -e "s/\.sh$//" -e "s/\.c$//" |
sort -u |
sed -n '3,$p' > /tmp/$$.ucbit
)
sh ./:mkucbcmd `cat -s /tmp/$$.ucbit`
rm -f /tmp/$$.ucbit
# Remove these five files which are links to other files
rm -f ${ROOT}/usr/bin/view ${ROOT}/usr/bin/vedit ${ROOT}/usr/bin/edit ${ROOT}/usr/bin/ex ${ROOT}/usr/bin/pcat
rm ${ROOT}/usr/ccs/lib/libtermcap.a ${ROOT}/usr/ccs/lib/libtermlib.a
ln ${ROOT}/usr/ccs/lib/libcurses.a ${ROOT}/usr/ccs/lib/libtermcap.a
ln ${ROOT}/usr/ccs/lib/libtermcap.a ${ROOT}/usr/ccs/lib/libtermlib.a
# build the OS itself
ln ${XSGS}/usr/ccs/bin/i386as ${ROOT}/usr/bin/idas
ln ${XSGS}/usr/ccs/bin/i386ld ${ROOT}/usr/bin/idld
ln ${XSGS}/usr/ccs/bin/i386cc ${ROOT}/usr/bin/idcc
ln ${XSGS}/usr/ccs/lib/i386cpp ${ROOT}/usr/lib/idcpp
ln ${XSGS}/usr/ccs/lib/i386acomp ${ROOT}/usr/lib/idacomp
ln $ROOT/usr/bin/idas $ROOT/bin/idas
ln $ROOT/usr/bin/idcc $ROOT/bin/idcc
ln $ROOT/usr/bin/idld $ROOT/bin/idld
ln $ROOT/usr/lib/idcpp $ROOT/lib/idcpp
ln $ROOT/usr/lib/idacomp $ROOT/lib/idacomp
CCSROOT=$ROOT/i386 PFX=i386 sh ./:mkuts ${BUS} ${ARCH} $VPIX $MERGE386
# Build the add-ons
# build all the add-ons that are present.
pkglist=""
for i in `cd add-on; ls`
do
# skip ones which are interactive
[ $i = source ] && continue
pkglist="$pkglist $i"
done
sh ./:mk.addon BUS=${BUS} ARCH=${ARCH} $VPIX $MERGE386 $pkglist
for i in `cd pkg; ls`
do
pkglist="$pkglist $i"
done
sh ./:mkoam BUS=${BUS} ARCH=${ARCH} $pkglist
# Put 'native' guys in
mv $ROOT/xenv/tic $ROOT/usr/bin/tic_cross
ln $ROOT/usr/ccs/bin/tic_native $ROOT/usr/bin/tic
mv $ROOT/etc/conf/bin/idconfig $ROOT/etc/conf/bin/idconfig_cross
ln $ROOT/etc/conf/bin/idconfig_native $ROOT/etc/conf/bin/idconfig
mv $ROOT/etc/conf/bin/idmkunix $ROOT/etc/conf/bin/idmkunix_cross
ln $ROOT/etc/conf/bin/idmkunix_native $ROOT/etc/conf/bin/idmkunix
ln ${ROOT}/usr/ccs/bin/as ${ROOT}/usr/bin/idas
ln ${ROOT}/usr/ccs/bin/ld ${ROOT}/usr/bin/idld
ln ${ROOT}/usr/ccs/bin/cc ${ROOT}/usr/bin/idcc
ln ${ROOT}/usr/ccs/lib/cpp ${ROOT}/usr/lib/idcpp
ln ${ROOT}/usr/ccs/lib/acomp ${ROOT}/usr/lib/idacomp
cp ${ROOT}/usr/ccs/bin/ar ${ROOT}/usr/bin/ar
cp ${ROOT}/usr/ccs/bin/captoinfo ${ROOT}/usr/bin/captoinfo
cp ${ROOT}/usr/ccs/bin/infocmp ${ROOT}/usr/bin/infocmp
cp ${ROOT}/usr/ccs/bin/mcs ${ROOT}/usr/bin/mcs
cp ${ROOT}/usr/ccs/bin/tic ${ROOT}/usr/bin/tic
cp ${ROOT}/usr/ccs/bin/tput ${ROOT}/usr/bin/tput
cp ${ROOT}/usr/ccs/bin/what ${ROOT}/usr/bin/what
echo $0 done at `date`
exit 0