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