Makefile revision 17469
1#
2#	$Id: Makefile,v 1.95 1996/08/07 13:25:54 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	@echo
151.if !defined(NOOBJDIR)
152	@echo "--------------------------------------------------------------"
153	@echo " Rebuilding the obj tree"
154	@echo "--------------------------------------------------------------"
155	cd ${.CURDIR} && ${MAKE} obj
156	@echo
157.endif
158	@echo "--------------------------------------------------------------"
159	@echo " Rebuilding bootstrap tools"
160	@echo "--------------------------------------------------------------"
161	cd ${.CURDIR} && ${MAKE} bootstrap
162	@echo
163	@echo "--------------------------------------------------------------"
164	@echo " Rebuilding tools necessary to build the include files"
165	@echo "--------------------------------------------------------------"
166	cd ${.CURDIR} && ${MAKE} include-tools
167	@echo
168	@echo "--------------------------------------------------------------"
169	@echo " Rebuilding /usr/include"
170	@echo "--------------------------------------------------------------"
171	cd ${.CURDIR} && ${MAKE} includes
172	@echo
173	@echo "--------------------------------------------------------------"
174	@echo " Rebuilding tools needed to build the libraries"
175	@echo "--------------------------------------------------------------"
176	cd ${.CURDIR} && ${MAKE} lib-tools
177	@echo
178	@echo "--------------------------------------------------------------"
179	@echo " Rebuilding /usr/lib"
180	@echo "--------------------------------------------------------------"
181	cd ${.CURDIR} && ${MAKE} libraries
182	@echo
183	@echo "--------------------------------------------------------------"
184	@echo " Rebuilding C compiler, make, symorder, sgmlfmt and zic(8)"
185	@echo "--------------------------------------------------------------"
186	cd ${.CURDIR} && ${MAKE} build-tools
187	@echo
188	@echo "--------------------------------------------------------------"
189	@echo " Rebuilding.. The whole thing"
190	@echo "--------------------------------------------------------------"
191	cd ${.CURDIR} && ${MAKE} depend && ${MAKE} all install
192	cd ${.CURDIR}/share/man && ${MAKE} makedb
193.if target(post-world)
194	@echo
195	@echo "--------------------------------------------------------------"
196	@echo " Making 'post-world' target"
197	@echo "--------------------------------------------------------------"
198	cd ${.CURDIR} && ${MAKE} post-world
199.endif
200	@echo
201	@echo "--------------------------------------------------------------"
202	@echo "make world completed on `date`"
203
204#
205# reinstall
206#
207# If you have a build server, you can NFS mount the source and obj directories
208# and do a 'make reinstall' on the *client* to install new binaries from the
209# most recent server build.
210#
211reinstall:
212	@echo "--------------------------------------------------------------"
213	@echo " Making hierarchy"
214	@echo "--------------------------------------------------------------"
215	cd ${.CURDIR} && ${MAKE} hierarchy
216	@echo
217	@echo "--------------------------------------------------------------"
218	@echo " Rebuilding /usr/share/mk"
219	@echo "--------------------------------------------------------------"
220	cd ${.CURDIR} && ${MAKE} mk
221	@echo
222	@echo "--------------------------------------------------------------"
223	@echo " Rebuilding /usr/include"
224	@echo "--------------------------------------------------------------"
225	cd ${.CURDIR} && ${MAKE} includes
226	@echo
227	@echo "--------------------------------------------------------------"
228	@echo " Reinstalling..  The whole thing"
229	@echo "--------------------------------------------------------------"
230	@echo
231	cd ${.CURDIR} && ${MAKE} install
232	cd ${.CURDIR}/share/man && ${MAKE} makedb
233
234
235#
236# update
237#
238# Update the source tree, by running sup and/or running cvs to update to the
239# latest copy.
240#
241update:
242.if defined(SUP_UPDATE)
243	@echo "--------------------------------------------------------------"
244	@echo "Running sup"
245	@echo "--------------------------------------------------------------"
246	@sup -v ${SUPFILE}
247.if defined(SUPFILE1)
248	@sup -v ${SUPFILE1}
249.endif
250.if defined(SUPFILE2)
251	@sup -v ${SUPFILE2}
252.endif
253.endif
254.if defined(CVS_UPDATE)
255	@echo "--------------------------------------------------------------"
256	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
257	@echo "--------------------------------------------------------------"
258	cd ${.CURDIR} &&  cvs -q update -P -d
259.endif
260
261
262#
263# most
264#
265# Build most of the user binaries on the existing system libs and includes.
266#
267most:
268	@echo "--------------------------------------------------------------"
269	@echo " Building programs only"
270	@echo "--------------------------------------------------------------"
271	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
272	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
273	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
274	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
275	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
276	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
277	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
278	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
279#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
280#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
281#.endif
282#.if !defined(NOSECURE) && !defined(NOCRYPT)
283#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
284#.endif
285
286#
287# installmost
288#
289# Install the binaries built by the 'most' target.  This does not include
290# libraries or include files.
291#
292installmost:
293	@echo "--------------------------------------------------------------"
294	@echo " Installing programs only"
295	@echo "--------------------------------------------------------------"
296	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
297	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
298	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
299	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
300	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
301	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
302	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
303	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
304#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
305#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
306#.endif
307#.if !defined(NOSECURE) && !defined(NOCRYPT)
308#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
309#.endif
310
311#
312# ------------------------------------------------------------------------
313#
314# From here onwards are utility targets used by the 'make world' and
315# related targets.  If your 'world' breaks, you may like to try to fix
316# the problem and manually run the following targets to attempt to
317# complete the build.  Beware, this is *not* guaranteed to work, you
318# need to have a pretty good grip on the current state of the system
319# to attempt to manually finish it.  If in doubt, 'make world' again.
320#
321
322#
323# heirarchy - ensure that all the needed directories are present
324#
325hierarchy:
326	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
327
328#
329# mk - update the /usr/share/mk makefiles.
330#
331mk:
332	cd ${.CURDIR}/share/mk &&	${MAKE} install
333
334#
335# bootstrap - [re]build tools needed to run the actual build, this includes
336# tools needed by 'make depend', as some tools are needed to generate source
337# for the dependency information to be gathered from.
338#
339bootstrap:
340	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
341		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
342	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
343		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
344	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
345		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
346
347#
348# include-tools - generally the same as 'bootstrap', except that it's for
349# things that are specifically needed to generate include files.
350#
351# XXX should be merged with bootstrap, it's not worth keeeping them seperate
352#
353include-tools:
354	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \
355		${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR}
356
357#
358# includes - possibly generate and install the include files.
359#
360includes:
361.if defined(CLOBBER)
362	rm -rf ${DESTDIR}/usr/include/*
363	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
364		-p ${DESTDIR}/usr/include
365.endif
366	cd ${.CURDIR}/include &&		${MAKE} install
367	cd ${.CURDIR}/gnu/include &&		${MAKE} install
368	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
369	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
370	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
371	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
372.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
373	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
374	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
375	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
376.endif
377	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
378	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
379	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
380	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
381	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
382	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
383	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
384.if !defined(WANT_CSRG_LIBM)
385	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
386.endif
387	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
388	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
389	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
390	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
391	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
392	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
393	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
394	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
395	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
396
397#
398# lib-tools - build tools to compile and install the libraries.
399#
400lib-tools:
401	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
402		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
403	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
404		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
405	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
406		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
407	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
408		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
409	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
410		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
411	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
412		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
413	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
414		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
415		rm -f /usr/sbin/compile_et
416	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
417		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
418
419#
420# libraries - build and install the libraries
421#
422libraries:
423.if exists(lib/libcompat)
424	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
425		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
426.endif
427.if exists(lib/libncurses)
428	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
429		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
430.endif
431.if exists(lib/libtermcap)
432	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
433		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
434.endif
435.if exists(lib)
436	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
437		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
438.endif
439.if exists(gnu)
440	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
441		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
442	cd ${.CURDIR}/gnu/usr.bin/cc/libgcc && ${MAKE} depend && \
443		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
444.endif
445.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
446	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
447		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
448.endif
449.if exists(lib)
450	cd ${.CURDIR}/lib && ${MAKE} depend && \
451		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
452.endif
453.if exists(usr.bin/lex/lib)
454	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
455		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
456.endif
457.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
458	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
459		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
460.endif
461.if exists(usr.sbin/pcvt/keycap)
462	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
463		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
464.endif
465
466#
467# build-tools - build and install any other tools needed to complete the
468# compile and install.
469#
470build-tools:
471	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
472		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
473	cd ${.CURDIR}/usr.bin/symorder && ${MAKE} depend && \
474		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
475	cd ${.CURDIR}/usr.bin/sgmlfmt && ${MAKE} depend && \
476		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} 
477	cd ${.CURDIR}/share/sgml && ${MAKE} depend && \
478		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} 
479	cd ${.CURDIR}/usr.sbin/zic && ${MAKE} depend && \
480		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
481
482.include <bsd.subdir.mk>
483