Makefile revision 17467
1#
2#	$Id: Makefile,v 1.94 1996/08/07 13:21:43 peter Exp $
3#
4# Make command line options:
5#	-DCLOBBER will remove /usr/include
6#	-DMAKE_LOCAL to add ./local to the SUBDIR list
7#	-DMAKE_PORTS to add ./ports to the SUBDIR list
8#	-DMAKE_EBONES to build eBones (KerberosIV)
9#
10#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
11#	-DNOCLEAN do not clean at all
12#	-DNOCRYPT will prevent building of crypt versions
13#	-DNOLKM do not build loadable kernel modules
14#	-DNOOBJDIR do not run ``${MAKE} obj''
15#	-DNOPROFILE do not build profiled libraries
16#	-DNOSECURE do not go into secure subdir
17#	-DNOGAMES do not go into games subdir
18
19#
20# The intended user-driven targets are:
21# world       - rebuild *everything*, including glue to help do upgrades.
22# reinstall   - use an existing (eg: NFS mounted) build to do an update.
23# update      - convenient way to update your source tree (eg: sup/cvs)
24# most        - build user commands, no libraries or include files
25# installmost - install user commands, no libraries or include files
26# all         - run through SUBDIR and build everything.  This is an implicit
27#               rule, not particularly useful for everybody.  Use 'world'.
28
29
30# Put initial settings here.
31SUBDIR=
32
33# We must do include and lib first so that the perl *.ph generation
34# works correctly as it uses the header files installed by this.
35.if exists(include)
36SUBDIR+= include
37.endif
38.if exists(lib)
39SUBDIR+= lib
40.endif
41
42.if exists(bin)
43SUBDIR+= bin
44.endif
45.if exists(games) && !defined(NOGAMES)
46SUBDIR+= games
47.endif
48.if exists(gnu)
49SUBDIR+= gnu
50.endif
51.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
52SUBDIR+= eBones
53.endif
54.if exists(libexec)
55SUBDIR+= libexec
56.endif
57.if exists(sbin)
58SUBDIR+= sbin
59.endif
60.if exists(share)
61SUBDIR+= share
62.endif
63.if exists(sys)
64SUBDIR+= sys
65.endif
66.if exists(usr.bin)
67SUBDIR+= usr.bin
68.endif
69.if exists(usr.sbin)
70SUBDIR+= usr.sbin
71.endif
72.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
73SUBDIR+= secure
74.endif
75.if exists(lkm) && !defined(NOLKM)
76SUBDIR+= lkm
77.endif
78
79# etc must be last for "distribute" to work
80.if exists(etc) && make(distribute)
81SUBDIR+= etc
82.endif
83
84# These are last, since it is nice to at least get the base system
85# rebuilt before you do them.
86.if defined(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
87SUBDIR+= local
88.endif
89.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
90SUBDIR+= ports
91.endif
92
93# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
94.if defined(NOOBJDIR)
95OBJDIR=
96.else
97OBJDIR=		obj
98.endif
99
100.if defined(NOCLEAN)
101CLEANDIR=
102.else
103.if defined(NOCLEANDIR)
104CLEANDIR=	clean
105.else
106CLEANDIR=	cleandir
107.endif
108.endif
109
110#
111# While building tools for bootstrapping, we dont need to waste time on
112# profiled libraries or man pages.  This speeds things up somewhat.
113#
114MK_FLAGS=	-DNOMAN -DNOPROFILE
115
116#
117# world
118#
119# Attempt to rebuild and reinstall *everything*, with reasonable chance of
120# success, regardless of how old your existing system is.
121#
122# >> Beware, it overwrites the local build environment! <<
123#
124world:
125.if target(pre-world)
126	@echo "--------------------------------------------------------------"
127	@echo " Making 'pre-world' target"
128	@echo "--------------------------------------------------------------"
129	cd ${.CURDIR} && ${MAKE} pre-world
130	@echo
131.endif
132	@echo "--------------------------------------------------------------"
133	@echo " Making hierarchy"
134	@echo "--------------------------------------------------------------"
135	cd ${.CURDIR} && ${MAKE} hierarchy
136	@echo
137	@echo "--------------------------------------------------------------"
138	@echo " Rebuilding /usr/share/mk"
139	@echo "--------------------------------------------------------------"
140	cd ${.CURDIR} && ${MAKE} mk
141	@echo
142	@echo "--------------------------------------------------------------"
143	@echo " Cleaning up the source tree"
144	@echo "--------------------------------------------------------------"
145.if defined(NOCLEAN)
146	@echo "Not cleaning anything! I sure hope you know what you are doing!"
147.else
148	cd ${.CURDIR} && ${MAKE} ${CLEANDIR}
149.endif
150.endif
151	@echo
152.if !defined(NOOBJDIR)
153	@echo "--------------------------------------------------------------"
154	@echo " Rebuilding the obj tree"
155	@echo "--------------------------------------------------------------"
156	cd ${.CURDIR} && ${MAKE} obj
157	@echo
158.endif
159	@echo "--------------------------------------------------------------"
160	@echo " Rebuilding bootstrap tools"
161	@echo "--------------------------------------------------------------"
162	cd ${.CURDIR} && ${MAKE} bootstrap
163	@echo
164	@echo "--------------------------------------------------------------"
165	@echo " Rebuilding tools necessary to build the include files"
166	@echo "--------------------------------------------------------------"
167	cd ${.CURDIR} && ${MAKE} include-tools
168	@echo
169	@echo "--------------------------------------------------------------"
170	@echo " Rebuilding /usr/include"
171	@echo "--------------------------------------------------------------"
172	cd ${.CURDIR} && ${MAKE} includes
173	@echo
174	@echo "--------------------------------------------------------------"
175	@echo " Rebuilding tools needed to build the libraries"
176	@echo "--------------------------------------------------------------"
177	cd ${.CURDIR} && ${MAKE} lib-tools
178	@echo
179	@echo "--------------------------------------------------------------"
180	@echo " Rebuilding /usr/lib"
181	@echo "--------------------------------------------------------------"
182	cd ${.CURDIR} && ${MAKE} libraries
183	@echo
184	@echo "--------------------------------------------------------------"
185	@echo " Rebuilding C compiler, make, symorder, sgmlfmt and zic(8)"
186	@echo "--------------------------------------------------------------"
187	cd ${.CURDIR} && ${MAKE} build-tools
188	@echo
189	@echo "--------------------------------------------------------------"
190	@echo " Rebuilding.. The whole thing"
191	@echo "--------------------------------------------------------------"
192	cd ${.CURDIR} && ${MAKE} depend && ${MAKE} all install
193	cd ${.CURDIR}/share/man && ${MAKE} makedb
194.if target(post-world)
195	@echo
196	@echo "--------------------------------------------------------------"
197	@echo " Making 'post-world' target"
198	@echo "--------------------------------------------------------------"
199	cd ${.CURDIR} && ${MAKE} post-world
200.endif
201	@echo
202	@echo "--------------------------------------------------------------"
203	@echo "make world completed on `date`"
204
205#
206# reinstall
207#
208# If you have a build server, you can NFS mount the source and obj directories
209# and do a 'make reinstall' on the *client* to install new binaries from the
210# most recent server build.
211#
212reinstall:
213	@echo "--------------------------------------------------------------"
214	@echo " Making hierarchy"
215	@echo "--------------------------------------------------------------"
216	cd ${.CURDIR} && ${MAKE} hierarchy
217	@echo
218	@echo "--------------------------------------------------------------"
219	@echo " Rebuilding /usr/share/mk"
220	@echo "--------------------------------------------------------------"
221	cd ${.CURDIR} && ${MAKE} mk
222	@echo
223	@echo "--------------------------------------------------------------"
224	@echo " Rebuilding /usr/include"
225	@echo "--------------------------------------------------------------"
226	cd ${.CURDIR} && ${MAKE} includes
227	@echo
228	@echo "--------------------------------------------------------------"
229	@echo " Reinstalling..  The whole thing"
230	@echo "--------------------------------------------------------------"
231	@echo
232	cd ${.CURDIR} && ${MAKE} install
233	cd ${.CURDIR}/share/man && ${MAKE} makedb
234
235
236#
237# update
238#
239# Update the source tree, by running sup and/or running cvs to update to the
240# latest copy.
241#
242update:
243.if defined(SUP_UPDATE)
244	@echo "--------------------------------------------------------------"
245	@echo "Running sup"
246	@echo "--------------------------------------------------------------"
247	@sup -v ${SUPFILE}
248.if defined(SUPFILE1)
249	@sup -v ${SUPFILE1}
250.endif
251.if defined(SUPFILE2)
252	@sup -v ${SUPFILE2}
253.endif
254.endif
255.if defined(CVS_UPDATE)
256	@echo "--------------------------------------------------------------"
257	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
258	@echo "--------------------------------------------------------------"
259	cd ${.CURDIR} &&  cvs -q update -P -d
260.endif
261
262
263#
264# most
265#
266# Build most of the user binaries on the existing system libs and includes.
267#
268most:
269	@echo "--------------------------------------------------------------"
270	@echo " Building programs only"
271	@echo "--------------------------------------------------------------"
272	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
273	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
274	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
275	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
276	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
277	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
278	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
279	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
280#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
281#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
282#.endif
283#.if !defined(NOSECURE) && !defined(NOCRYPT)
284#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
285#.endif
286
287#
288# installmost
289#
290# Install the binaries built by the 'most' target.  This does not include
291# libraries or include files.
292#
293installmost:
294	@echo "--------------------------------------------------------------"
295	@echo " Installing programs only"
296	@echo "--------------------------------------------------------------"
297	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
298	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
299	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
300	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
301	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
302	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
303	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
304	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
305#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
306#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
307#.endif
308#.if !defined(NOSECURE) && !defined(NOCRYPT)
309#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
310#.endif
311
312#
313# ------------------------------------------------------------------------
314#
315# From here onwards are utility targets used by the 'make world' and
316# related targets.  If your 'world' breaks, you may like to try to fix
317# the problem and manually run the following targets to attempt to
318# complete the build.  Beware, this is *not* guaranteed to work, you
319# need to have a pretty good grip on the current state of the system
320# to attempt to manually finish it.  If in doubt, 'make world' again.
321#
322
323#
324# heirarchy - ensure that all the needed directories are present
325#
326hierarchy:
327	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
328
329#
330# mk - update the /usr/share/mk makefiles.
331#
332mk:
333	cd ${.CURDIR}/share/mk &&	${MAKE} install
334
335#
336# bootstrap - [re]build tools needed to run the actual build, this includes
337# tools needed by 'make depend', as some tools are needed to generate source
338# for the dependency information to be gathered from.
339#
340bootstrap:
341	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
342		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
343	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
344		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
345	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
346		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
347
348#
349# include-tools - generally the same as 'bootstrap', except that it's for
350# things that are specifically needed to generate include files.
351#
352# XXX should be merged with bootstrap, it's not worth keeeping them seperate
353#
354include-tools:
355	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \
356		${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR}
357
358#
359# includes - possibly generate and install the include files.
360#
361includes:
362.if defined(CLOBBER)
363	rm -rf ${DESTDIR}/usr/include/*
364	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
365		-p ${DESTDIR}/usr/include
366.endif
367	cd ${.CURDIR}/include &&		${MAKE} install
368	cd ${.CURDIR}/gnu/include &&		${MAKE} install
369	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
370	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
371	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
372	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
373.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
374	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
375	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
376	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
377.endif
378	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
379	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
380	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
381	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
382	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
383	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
384	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
385.if !defined(WANT_CSRG_LIBM)
386	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
387.endif
388	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
389	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
390	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
391	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
392	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
393	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
394	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
395	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
396	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
397
398#
399# lib-tools - build tools to compile and install the libraries.
400#
401lib-tools:
402	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
403		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
404	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
405		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
406	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
407		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
408	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
409		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
410	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
411		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
412	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
413		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
414	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
415		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
416		rm -f /usr/sbin/compile_et
417	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
418		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
419
420#
421# libraries - build and install the libraries
422#
423libraries:
424.if exists(lib/libcompat)
425	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
426		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
427.endif
428.if exists(lib/libncurses)
429	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
430		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
431.endif
432.if exists(lib/libtermcap)
433	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
434		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
435.endif
436.if exists(lib)
437	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
438		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
439.endif
440.if exists(gnu)
441	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
442		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
443	cd ${.CURDIR}/gnu/usr.bin/cc/libgcc && ${MAKE} depend && \
444		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
445.endif
446.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
447	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
448		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
449.endif
450.if exists(lib)
451	cd ${.CURDIR}/lib && ${MAKE} depend && \
452		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
453.endif
454.if exists(usr.bin/lex/lib)
455	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
456		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
457.endif
458.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
459	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
460		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
461.endif
462.if exists(usr.sbin/pcvt/keycap)
463	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
464		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
465.endif
466
467#
468# build-tools - build and install any other tools needed to complete the
469# compile and install.
470#
471build-tools:
472	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
473		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
474	cd ${.CURDIR}/usr.bin/symorder && ${MAKE} depend && \
475		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
476	cd ${.CURDIR}/usr.bin/sgmlfmt && ${MAKE} depend && \
477		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} 
478	cd ${.CURDIR}/share/sgml && ${MAKE} depend && \
479		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} 
480	cd ${.CURDIR}/usr.sbin/zic && ${MAKE} depend && \
481		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
482
483.include <bsd.subdir.mk>
484