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