This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
383 lines (337 loc) · 10.4 KB
/
Makefile
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#
# @(#)Makefile 1.1 94/10/31 SMI
#
DESTDIR = /proto
SH = /bin/sh
ECHO = /bin/echo
RM = /bin/rm
DATE = /bin/date
CPP = /lib/cpp
CHOWN = /etc/chown
GREP = /usr/bin/grep
LS = /bin/ls
PSTAT = /usr/etc/pstat
# kludges...
RELEASE_SRC= ./release
INSTALL_SRC= ./usr.bin
MAKE_SRC= ./bin/make
SCCS_SRC= ./sccs
CONFIG_SRC= ./usr.etc/config
MAKEINSTALL= /usr/release/bin/makeinstall
WINSTALL= /usr/release/bin/winstall
UNMOUNT = /usr/release/bin/unmount
INCDIR = /usr/tmp
CRYPT = sundist/exclude.lists/crypt.kit
.DEFAULT:
sccs get $@
#
# Programs that live in subdirectories, and have makefiles of their own.
# Order here is critical for make install.
#
# suninstall *must* come last
# the libraries *must* come first
#
LAST= usr.etc/suninstall
SUBDIR= etc bin usr.etc usr.bin ucb 5bin \
xpginclude xpglib xpgbin posixlib adm files man pub sccs \
diagnostics sys demo games old ${LAST}
#LIBDIR= include lib usr.lib 5include 5lib
LIBDIR= lib usr.lib ucblib
INCLDIR= include ucbinclude
CRYPTDIR= lib 5lib include include/rpcsvc bin etc ucb share \
share/man share/man/man1 share/man/man3
#
# Directories that must exist before make install
#
DIRS= etc tmp var var/adm var/crash var/log var/preserve var/spool var/tmp \
dev mnt usr sbin home
USRDIRS= bin ucb etc include 5bin 5lib 5include lib share hosts \
boot local old kvm xpg2include xpg2lib xpg2bin
#
# The default target populates the /usr/src tree, installs the new header
# files, builds, tests, and installs the new language tools, and finally
# compiles all of /usr/src.
#
all: INCBOOT LANGBOOT lang LIBRARIES ${SUBDIR}
@${ECHO} "Build done on" `${DATE}` > BUILT
@cat BUILT
BUILT:
${MAKE} DESTDIR=${DESTDIR} CHOWN=${CHOWN} all
#########################
#
# HOW TO DO IT:
#
# At this writing, the recommended sequence of commands to produce
# an entire release starting in a bare directory is:
#
# mkdir SCCS_DIRECTORIES
# mount `pwd`/SCCS_DIRECTORIES
# ln -s SCCS_DIRECTORIES/SCCS
# make POPULATED
# su -c "make makeinstall"
# make all
# su -c "make proto"
#########################
#
# STEP 0: RESOURCES
#
# Before going any further, check to ensure that we have the resources
# and environment we need to build the release.
#
.INIT: environment
environment:
@k=`df ${INCDIR} |sed 1d|awk ' { print $$4 }'`;\
if [ $$k -lt 4000 ] ; then \
echo ${INCDIR} "does not have enough space in it!"; \
echo "Make at least 4M available and try again."; \
false;\
elif [ `csh -c limit|grep stacksize|awk '{print $$2}'` -lt 24000 ]; \
then \
echo "Stacksize limit too low!"; \
echo "Increase stack limit to at least 24M and try again."; \
false; \
fi
#########################
#
# STEP 1: POPULATE
#
# Assume a parallel hierarchy of SCCS files rooted at ./SCCS_DIRECTORIES.
# The POPULATE pass at least creates all the subdirectories and sets up
# the SCCS links. If a file named RELEASE exists in the current directory,
# and contains a string naming an SID-list file found in ./SIDlist,
# then all the source files needed to build that release will be checked out.
#
POPULATED: populate
${MAKE} clobber
${SH} populate
${MAKE} links
${ECHO} "Source Tree populated on" `${DATE}` > $@
clobber: unpopulate
if [ -f RELEASE ]; then ${SH} unpopulate; fi
${RM} -f POPULATED
links: rmlinks
${CPP} makelinks | ${SH} -x
rmlinks: makelinks
${CPP} -DCLEAN makelinks | ${SH} -x
#########################
#
# STEP 1.5 UTIL_BOOT
#
# This step makes and installs from source all those odd ball utilities
# which, in the past, have had new features added which a current build
# would depend on. Because the new version was not installed before the
# build started, the build would come to a halt at the point where the
# new feature was needed. It is expected that this list may grow.
#
# Note: there may at some time develop a "chicken/egg" loop if any of
# these utilities themselves are changed such that they need a new or
# changed header file installed before it could correctly build (the
# new header files are installed after this step in STEP number 2).
# If this rare case arises, you will have to manually install the
# header file(s) before this step.
# Another case to consider is that of config. This program depends
# on yacc, lex, and libln. As these programs are pretty stable,
# and, as any changes to them will probably not affect config,
# it probably will not be a problem. Still, they must be considered
# in the worst case.
UTIL_BOOT: POPULATED
@$(MAKE) unmount
cd ${INSTALL_SRC}; make installcmd; \
${WINSTALL} installcmd /usr/bin/install;
cd ${MAKE_SRC}; ${MAKEINSTALL} DESTDIR=
cd ${SCCS_SRC}; ${MAKEINSTALL} DESTDIR=
cd ${CONFIG_SRC}; ${MAKEINSTALL} DESTDIR=
@${ECHO} "Made UTIL_BOOT on" `${DATE}` > $@
#
# Since UTIL_BOOT is the first target after the populate pass, it's here
# that we do the rest of the environmental setup. (We couldn't do it
# sooner, or the populate pass would have clobbered anything we did.)
#
# We check to see if we're building an SID-based
# release. If so, then we need to unmount the SCCS directories
# before we actually start to build anything.
#
unmount: $(MAKEINSTALL)
@set -x; if [ -f RELEASE -a -d SCCS_DIRECTORIES/SCCS ]; then \
${UNMOUNT} `pwd`/SCCS_DIRECTORIES; \
fi
#
# Unfortunately, some parts of the build must be done as root.
# makeinstall and unmount are setuid-root scripts which are built
# and installed while running as root.
#
makeinstall: $(MAKEINSTALL)
$(MAKEINSTALL): POPULATED
@if [ ! -u $(MAKEINSTALL) ]; then \
${MAKE} rootid || (echo "You must, as root, do a \
'make makeinstall'. \
This will install /usr/release/bin with \
the appropriate programs which allow a lang boot \
to run" | fmt; false); \
cd ${RELEASE_SRC}; $(MAKE) install; \
else \
cd ${RELEASE_SRC}; $(MAKEINSTALL); \
fi
rootid:
@if [ "`whoami`x" != "root"x ] ; then \
false; \
fi
#########################
#
# STEP 2: INCBOOT
#
# The reason we do this is to make sure all the
# include files are populated correctly. Also, they really have
# to overlay our running system. Right now, this involves
# going into the include directory and doing an install as root
# of include.
#
incboot: INCBOOT
INCBOOT: UTIL_BOOT
@${MAKE} unmount
cd include; ${MAKEINSTALL} DESTDIR=
@${ECHO} "Made INCBOOT on" `${DATE}` > $@
#########################
#
# STEP 3: LANGBOOT
#
# This requires that the program /usr/release/bin/winstall
# exists. This program is suid root, because lang boot wipes the current
# system's libraries and compilers.
#
langboot: LANGBOOT
LANGBOOT: INCBOOT
@${MAKE} unmount
@set -x;CWD=`pwd`;case `mach` in \
mc68010|mc68020) \
cd lang/boot; ${MAKE} $(MFLAGS) CPU=m68k SRCROOT=$$CWD;;\
sparc) \
cd lang/boot; ${MAKE} $(MFLAGS) CPU=sparc SRCROOT=$$CWD;;\
esac
@${ECHO} "Langboot done on" `${DATE}` > $@
#########################
#
# STEP 4: BUILD
#
# Generic rules to actually build the subdirectories.
#
lang: POPULATED
@${MAKE} unmount
@set -x;CWD=`pwd`;case `mach` in \
mc68010|mc68020) cd lang; ${MAKE} $(MFLAGS) CPU=m68k SRCROOT=$$CWD;; \
sparc) cd lang; ${MAKE} $(MFLAGS) CPU=sparc SRCROOT=$$CWD;; \
esac
#
# This is a terrible, terrible hack, and I apologize for it. The right
# thing to do is to set the LD_LIBRARY_PATH up front to point to
# the libraries under development. As soon as that's tested, this
# will be fixed.
#
LIBRARIES: POPULATED
@$(MAKE) unmount
@set -x; for i in ${LIBDIR}; do \
(cd $$i; $(MAKE) $(MFLAGS)); \
(cd $$i; $(MAKEINSTALL) $(MFLAGS) DESTDIR= CHOWN=$(CHOWN)); \
done
@${ECHO} "Libraries done on" `${DATE}` > LIBRARIES
$(SUBDIR): POPULATED
@${MAKE} unmount
cd $@; $(MAKE) ${MFLAGS}
#########################
#
# STEP 5: INSTALL
#
# The "proto" target is provided as a convenience; it's important to
# carefully clean out the /proto partition before building the /proto
# file system.
#
install: BUILT install_dirs
@set -x; for i in ${INCLDIR} ${LIBDIR} ${SUBDIR}; do \
(cd $$i; \
$(MAKE) ${MFLAGS} DESTDIR=${DESTDIR} CHOWN=$(CHOWN) install); \
done
@set -x; case `mach` in \
mc680?0) cd lang; \
$(MAKE) $(MFLAGS) install DESTDIR=$(DESTDIR) CPU=m68k;;\
sparc) cd lang; \
$(MAKE) $(MFLAGS) install DESTDIR=$(DESTDIR) CPU=sparc;;\
esac
install_dirs:
@set -x; for i in ${DIRS}; do \
install -d -o bin -m 755 ${DESTDIR}/$$i; \
done
@set -x; for i in ${USRDIRS}; do \
install -d -o bin -m 755 ${DESTDIR}/usr/$$i; \
done
chmod 1777 ${DESTDIR}/tmp ${DESTDIR}/var/tmp
${RM} -f ${DESTDIR}/bin && ln -s usr/bin ${DESTDIR}/bin
${RM} -f ${DESTDIR}/lib && ln -s usr/lib ${DESTDIR}/lib
${RM} -f ${DESTDIR}/sys && ln -s usr/kvm/sys ${DESTDIR}/sys
${RM} -f ${DESTDIR}/usr/ucbinclude && ln -s include ${DESTDIR}/usr/ucbinclude
${RM} -f ${DESTDIR}/usr/ucblib && ln -s lib ${DESTDIR}/usr/ucblib
${RM} -f ${DESTDIR}/usr/src && ln -s share/src ${DESTDIR}/usr/src
userinstall: ${MAKEINSTALL}
${MAKEINSTALL} DESTDIR=${DESTDIR} CHOWN=${CHOWN}
proto: PROTO
PROTO: BUILT
@$(MAKE) rootid || (echo "You must make proto as root."; false)
@${MAKE} unmount
@RAW=`egrep /proto /etc/fstab | awk -F/ '{print "/dev/r"$$3}'`; \
if [ ! -n "$$RAW" ]; then \
echo "no device in fstab for /proto?"; \
exit 1; \
fi; \
echo using $$RAW; \
umount /proto; \
newfs $$RAW; \
mount /proto; \
chmod g+s /proto; \
chown root /proto; \
chgrp staff /proto; \
chmod g+s /proto/lost+found
$(MAKE) install DESTDIR=/proto
@echo "Prototype file system built on" `${DATE}` > $@
@echo running ranlib -t on library archives under ${DESTDIR}/usr...
@-for i in "`find ${DESTDIR}/usr -name '*lib*' -name '*\.*a*' \
-type f -print`"; do \
(file $$i | grep archive > /dev/null && ranlib -t $$i); \
done
@echo done
#########################
#
# STEP 6: TAPES
#
# This actually gets done in sundist, and is provided here as a convenience.
#
#
#tapes: PROTO
# @$(MAKE) rootid || (echo "You must make tapes as root."; false)
# @${MAKE} unmount
# @cd sundist; $(MAKE)
# @cd sundist; $(MAKE) quarter_hd_tapes
# @cd sundist; $(MAKE) half_tapes
#
#########################
#
# STEP 6: INTERNATIONALIZE
#
INTERNATIONAL: international
international:
#########################
#
# STEP 10: PREINSTALL
#
# This is only used for machines which will ship a preinstalled distribution.
#
preinstall:
@${MAKE} unmount
@cd sundist/pre; $(MAKE)
@echo "See sundist/pre/build-from-suni for build instructions."
clean: POPULATED makelinks
rm -f a.out core *.s *.o
-for i in ${SUBDIR}; do (cd $$i; $(MAKE) ${MFLAGS} clean); done
@set -x;case `mach` in \
mc68010|mc68020)cd lang; $(MAKE) $(MFLAGS) clean CPU=m68k;;\
sparc) cd lang; $(MAKE) $(MFLAGS) clean CPU=sparc;;\
esac
FRC: