Makefile revision 30132
1#
2#	$Id: Makefile,v 1.150 1997/10/05 15:39:47 markm Exp $
3#
4# Make command line options:
5#	-DCLOBBER will remove /usr/include
6#	-DMAKE_EBONES to build eBones (KerberosIV)
7#	-DALLLANG to build documentation for all languages
8#	  (where available -- see share/doc/Makefile)
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#	-DNOSHARE do not go into share subdir
19#	-DNOINFO do not make or install info files
20#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
21
22#
23# The intended user-driven targets are:
24# buildworld  - rebuild *everything*, including glue to help do upgrades
25# installworld- install everything built by "buildworld"
26# world       - buildworld + installworld
27# update      - convenient way to update your source tree (eg: sup/cvs)
28# most        - build user commands, no libraries or include files
29# installmost - install user commands, no libraries or include files
30#
31# Standard targets (not defined here) are documented in the makefiles in
32# /usr/share/mk.  These include:
33#		obj depend all install clean cleandepend cleanobj
34
35.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
36.MAKEFLAGS:=	${.MAKEFLAGS} -m ${.CURDIR}/share/mk
37.endif
38
39# Put initial settings here.
40SUBDIR=
41
42# We must do include and lib first so that the perl *.ph generation
43# works correctly as it uses the header files installed by this.
44.if exists(include)
45SUBDIR+= include
46.endif
47.if exists(lib)
48SUBDIR+= lib
49.endif
50
51.if exists(bin)
52SUBDIR+= bin
53.endif
54.if exists(games) && !defined(NOGAMES)
55SUBDIR+= games
56.endif
57.if exists(gnu)
58SUBDIR+= gnu
59.endif
60.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
61SUBDIR+= eBones
62.endif
63.if exists(libexec)
64SUBDIR+= libexec
65.endif
66.if exists(sbin)
67SUBDIR+= sbin
68.endif
69.if exists(share) && !defined(NOSHARE)
70SUBDIR+= share
71.endif
72.if exists(sys)
73SUBDIR+= sys
74.endif
75.if exists(usr.bin)
76SUBDIR+= usr.bin
77.endif
78.if exists(usr.sbin)
79SUBDIR+= usr.sbin
80.endif
81.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
82SUBDIR+= secure
83.endif
84.if exists(lkm) && !defined(NOLKM)
85SUBDIR+= lkm
86.endif
87
88# etc must be last for "distribute" to work
89.if exists(etc) && make(distribute)
90SUBDIR+= etc
91.endif
92
93# These are last, since it is nice to at least get the base system
94# rebuilt before you do them.
95.if defined(LOCAL_DIRS)
96.for _DIR in ${LOCAL_DIRS}
97.if exists(${_DIR}) & exists(${_DIR}/Makefile)
98SUBDIR+= ${_DIR}
99.endif
100.endfor
101.endif
102
103# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
104.if defined(NOOBJDIR)
105OBJDIR=
106.else
107OBJDIR=		obj
108.endif
109
110.if defined(NOCLEAN)
111CLEANDIR=
112.else
113.if defined(NOCLEANDIR)
114CLEANDIR=	clean
115.else
116CLEANDIR=	cleandir
117.endif
118.endif
119
120SUP?=		sup
121SUPFLAGS?=	-v
122
123#
124# While building tools for bootstrapping, we dont need to waste time on
125# profiled libraries or man pages.  This speeds things up somewhat.
126#
127MK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE
128
129#
130# world
131#
132# Attempt to rebuild and reinstall *everything*, with reasonable chance of
133# success, regardless of how old your existing system is.
134#
135# >> Beware, it overwrites the local build environment! <<
136#
137world:
138	@echo "--------------------------------------------------------------"
139	@echo "make world started on `LC_TIME=C date`"
140	@echo "--------------------------------------------------------------"
141.if target(pre-world)
142	@echo
143	@echo "--------------------------------------------------------------"
144	@echo " Making 'pre-world' target"
145	@echo "--------------------------------------------------------------"
146	cd ${.CURDIR} && ${MAKE} pre-world
147.endif
148	cd ${.CURDIR} && ${MAKE} buildworld
149	cd ${.CURDIR} && ${MAKE} -B installworld
150.if target(post-world)
151	@echo
152	@echo "--------------------------------------------------------------"
153	@echo " Making 'post-world' target"
154	@echo "--------------------------------------------------------------"
155	cd ${.CURDIR} && ${MAKE} post-world
156.endif
157	@echo
158	@echo "--------------------------------------------------------------"
159	@echo "make world completed on `LC_TIME=C date`"
160	@echo "--------------------------------------------------------------"
161
162.if defined(MAKEOBJDIRPREFIX)
163WORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
164.else
165WORLDTMP=	/usr/obj${.CURDIR}/tmp
166.endif
167STRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
168TMPPATH=	${STRICTTMPPATH}:${PATH}
169
170# XXX COMPILER_PATH is needed for finding cc1, ld and as
171# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
172#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
173#	wouldn't link *crt.o or libgcc if it were used.
174# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
175#	want that - all compile-time library paths should be resolved by gcc.
176#	It fails for set[ug]id executables (are any used?).
177COMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
178		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
179		GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \
180		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
181		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
182
183BMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
184XMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
185		CC='cc -nostdinc'	# XXX -nostdlib
186
187# used to compile and install 'make' in temporary build tree
188IBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
189# bootstrap make
190BMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
191# cross make used for compilation
192XMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
193# cross make used for final installation
194IXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
195
196#
197# buildworld
198#
199# Attempt to rebuild the entire system, with reasonable chance of
200# success, regardless of how old your existing system is.
201#
202buildworld:
203.if !defined(NOCLEAN)
204	@echo
205	@echo "--------------------------------------------------------------"
206	@echo " Cleaning up the temporary build tree"
207	@echo "--------------------------------------------------------------"
208	mkdir -p ${WORLDTMP}
209	chflags -R noschg ${WORLDTMP}/
210	rm -rf ${WORLDTMP}
211.endif
212	@echo
213	@echo "--------------------------------------------------------------"
214	@echo " Making make"
215	@echo "--------------------------------------------------------------"
216	mkdir -p ${WORLDTMP}/usr/bin
217	cd ${.CURDIR}/usr.bin/make && \
218		${IBMAKE} -I${.CURDIR}/share/mk -B ${CLEANDIR} ${OBJDIR} depend && \
219		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
220		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} \
221			-B install clean cleandepend
222	@echo
223	@echo "--------------------------------------------------------------"
224	@echo " Making hierarchy"
225	@echo "--------------------------------------------------------------"
226	cd ${.CURDIR} && ${BMAKE} hierarchy
227.if !defined(NOCLEAN)
228	@echo
229	@echo "--------------------------------------------------------------"
230	@echo " Cleaning up the obj tree"
231	@echo "--------------------------------------------------------------"
232	cd ${.CURDIR} && ${BMAKE} par-${CLEANDIR}
233.endif
234.if !defined(NOOBJDIR)
235	@echo
236	@echo "--------------------------------------------------------------"
237	@echo " Rebuilding the obj tree"
238	@echo "--------------------------------------------------------------"
239	cd ${.CURDIR} && ${BMAKE} par-obj
240.endif
241	@echo
242	@echo "--------------------------------------------------------------"
243	@echo " Rebuilding bootstrap tools"
244	@echo "--------------------------------------------------------------"
245	cd ${.CURDIR} && ${BMAKE} bootstrap
246	@echo
247	@echo "--------------------------------------------------------------"
248	@echo " Rebuilding tools necessary to build the include files"
249	@echo "--------------------------------------------------------------"
250	cd ${.CURDIR} && ${BMAKE} include-tools
251	@echo
252	@echo "--------------------------------------------------------------"
253	@echo " Rebuilding /usr/include"
254	@echo "--------------------------------------------------------------"
255	cd ${.CURDIR} && SHARED=symlinks ${BMAKE} includes
256	@echo
257	@echo "--------------------------------------------------------------"
258	@echo " Rebuilding tools needed to build the libraries"
259	@echo "--------------------------------------------------------------"
260	cd ${.CURDIR} && ${BMAKE} lib-tools
261	@echo
262	@echo "--------------------------------------------------------------"
263	@echo " Rebuilding /usr/lib"
264	@echo "--------------------------------------------------------------"
265	cd ${.CURDIR} && ${BMAKE} libraries
266	@echo
267	@echo "--------------------------------------------------------------"
268	@echo " Rebuilding all other tools needed to build the world"
269	@echo "--------------------------------------------------------------"
270	cd ${.CURDIR} && ${BMAKE} build-tools
271	@echo
272	@echo "--------------------------------------------------------------"
273	@echo " Rebuilding dependencies"
274	@echo "--------------------------------------------------------------"
275	cd ${.CURDIR} && ${XMAKE} ${.MAKEFLAGS} par-depend
276	@echo
277	@echo "--------------------------------------------------------------"
278	@echo " Building everything.."
279	@echo "--------------------------------------------------------------"
280	cd ${.CURDIR} && ${XMAKE} all
281
282#
283# installworld
284#
285# Installs everything compiled by a 'buildworld'.
286#
287installworld:
288	cd ${.CURDIR} && ${IXMAKE} reinstall
289
290#
291# reinstall
292#
293# If you have a build server, you can NFS mount the source and obj directories
294# and do a 'make reinstall' on the *client* to install new binaries from the
295# most recent server build.
296#
297reinstall:
298	@echo "--------------------------------------------------------------"
299	@echo " Making hierarchy"
300	@echo "--------------------------------------------------------------"
301	cd ${.CURDIR} && ${MAKE} hierarchy
302	@echo
303	@echo "--------------------------------------------------------------"
304	@echo " Installing everything.."
305	@echo "--------------------------------------------------------------"
306	cd ${.CURDIR} && ${MAKE} install
307	@echo
308	@echo "--------------------------------------------------------------"
309	@echo " Rebuilding man page indexes"
310	@echo "--------------------------------------------------------------"
311	cd ${.CURDIR}/share/man && ${MAKE} makedb
312
313#
314# update
315#
316# Update the source tree, by running sup and/or running cvs to update to the
317# latest copy.
318#
319update:
320.if defined(SUP_UPDATE)
321	@echo "--------------------------------------------------------------"
322	@echo "Running sup"
323	@echo "--------------------------------------------------------------"
324	@${SUP} ${SUPFLAGS} ${SUPFILE}
325.if defined(SUPFILE1)
326	@${SUP} ${SUPFLAGS} ${SUPFILE1}
327.endif
328.if defined(SUPFILE2)
329	@${SUP} ${SUPFLAGS} ${SUPFILE2}
330.endif
331.endif
332.if defined(CVS_UPDATE)
333	@echo "--------------------------------------------------------------"
334	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
335	@echo "--------------------------------------------------------------"
336	cd ${.CURDIR} && cvs -q update -P -d
337.endif
338
339#
340# most
341#
342# Build most of the user binaries on the existing system libs and includes.
343#
344most:
345	@echo "--------------------------------------------------------------"
346	@echo " Building programs only"
347	@echo "--------------------------------------------------------------"
348	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
349	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
350	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
351	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
352	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
353	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
354	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
355	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
356#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
357#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
358#.endif
359#.if !defined(NOSECURE) && !defined(NOCRYPT)
360#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
361#.endif
362
363#
364# installmost
365#
366# Install the binaries built by the 'most' target.  This does not include
367# libraries or include files.
368#
369installmost:
370	@echo "--------------------------------------------------------------"
371	@echo " Installing programs only"
372	@echo "--------------------------------------------------------------"
373	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
374	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
375	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
376	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
377	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
378	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
379	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
380	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
381#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
382#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
383#.endif
384#.if !defined(NOSECURE) && !defined(NOCRYPT)
385#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
386#.endif
387
388#
389# ------------------------------------------------------------------------
390#
391# From here onwards are utility targets used by the 'make world' and
392# related targets.  If your 'world' breaks, you may like to try to fix
393# the problem and manually run the following targets to attempt to
394# complete the build.  Beware, this is *not* guaranteed to work, you
395# need to have a pretty good grip on the current state of the system
396# to attempt to manually finish it.  If in doubt, 'make world' again.
397#
398
399#
400# heirarchy - ensure that all the needed directories are present
401#
402hierarchy:
403	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
404
405#
406# bootstrap - [re]build tools needed to run the actual build, this includes
407# tools needed by 'make depend', as some tools are needed to generate source
408# for the dependency information to be gathered from.
409#
410bootstrap:
411.if defined(DESTDIR)
412	rm -f ${DESTDIR}/usr/src/sys
413	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
414	cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
415	cd ${.CURDIR}/include && make symlinks
416.endif
417	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
418		${MAKE} ${MK_FLAGS} all && \
419		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
420	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
421		${MAKE} ${MK_FLAGS} all && \
422		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
423	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
424		${MAKE} ${MK_FLAGS} -DNOLIB && \
425		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
426.if !defined(NOOBJDIR)
427	cd ${.CURDIR}/usr.bin/lex && ${MAKE} obj
428.endif
429
430#
431# include-tools - generally the same as 'bootstrap', except that it's for
432# things that are specifically needed to generate include files.
433#
434# XXX should be merged with bootstrap, it's not worth keeeping them separate.
435# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
436# on cleaned away headers in ${WORLDTMP}.
437#
438include-tools:
439	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} -B cleandepend depend && \
440		${MAKE} ${MK_FLAGS} all && \
441		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
442
443#
444# includes - possibly generate and install the include files.
445#
446includes:
447.if defined(CLOBBER)
448	rm -rf ${DESTDIR}/usr/include/*
449	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
450		-p ${DESTDIR}/usr/include
451.endif
452	cd ${.CURDIR}/include &&		${MAKE} -B all install
453	cd ${.CURDIR}/gnu/include &&		${MAKE} install
454	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
455	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
456	cd ${.CURDIR}/gnu/lib/libstdc++ &&	${MAKE} beforeinstall
457	cd ${.CURDIR}/gnu/lib/libg++ &&		${MAKE} beforeinstall
458	cd ${.CURDIR}/gnu/lib/libdialog &&	${MAKE} beforeinstall
459.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
460	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
461	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
462	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
463.endif
464	cd ${.CURDIR}/lib/csu/i386 &&		${MAKE} beforeinstall
465	cd ${.CURDIR}/lib/libalias &&		${MAKE} beforeinstall
466	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
467	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
468	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
469	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
470	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
471	cd ${.CURDIR}/lib/libmytinfo &&		${MAKE} beforeinstall
472	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
473.if !defined(WANT_CSRG_LIBM)
474	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
475.endif
476	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
477	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
478	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
479	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
480	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
481	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
482	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
483	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
484	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
485
486#
487# lib-tools - build tools to compile and install the libraries.
488#
489# XXX gperf is required for cc
490# XXX a new ld and tsort is required for cc
491lib-tools:
492.for d in				\
493		gnu/usr.bin/gperf	\
494		gnu/usr.bin/ld		\
495		usr.bin/tsort		\
496		gnu/usr.bin/as		\
497		gnu/usr.bin/bison	\
498		gnu/usr.bin/cc		\
499		usr.bin/ar		\
500		usr.bin/compile_et	\
501		usr.bin/lex/lib		\
502		usr.bin/mk_cmds		\
503		usr.bin/nm		\
504		usr.bin/ranlib		\
505		usr.bin/uudecode
506	cd ${.CURDIR}/$d && ${MAKE} depend && \
507		${MAKE} ${MK_FLAGS} all && \
508		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
509.endfor
510
511#
512# libraries - build and install the libraries
513#
514libraries:
515.if exists(lib/csu/i386)
516	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
517		${MAKE} ${MK_FLAGS} all && \
518		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
519.endif
520.if exists(lib/libcompat)
521	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
522		${MAKE} ${MK_FLAGS} all && \
523		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
524.endif
525.if exists(lib/libncurses)
526	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
527		${MAKE} ${MK_FLAGS} all && \
528		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
529.endif
530.if exists(lib/libtermcap)
531	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
532		${MAKE} ${MK_FLAGS} all && \
533		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
534.endif
535.if exists(gnu)
536	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
537		${MAKE} ${MK_FLAGS} all && \
538		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
539.endif
540.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
541	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
542		${MAKE} ${MK_FLAGS} all && \
543		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
544.endif
545.if exists(lib)
546	cd ${.CURDIR}/lib && ${MAKE} depend && \
547		${MAKE} ${MK_FLAGS} all && \
548		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
549.endif
550.if exists(usr.bin/lex/lib)
551	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
552		${MAKE} ${MK_FLAGS} all && \
553		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
554.endif
555.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
556	cd ${.CURDIR}/kerberosIV/lib && ${MAKE} depend && \
557		${MAKE} ${MK_FLAGS} all && \
558		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
559.endif
560.if exists(usr.sbin/pcvt/keycap)
561	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
562		${MAKE} ${MK_FLAGS} all && \
563		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
564.endif
565
566#
567# build-tools - build and install any other tools needed to complete the
568# compile and install.
569# ifdef stale
570# bc and cpp are required to build groff.  Otherwise, the order here is
571# mostly historical, i.e., bogus.
572# chmod is used to build gcc's tmpmultilib[2] at obscure times.
573# endif stale
574# XXX uname is a bug - the target should not depend on the host.
575#
576build-tools:
577.for d in				\
578		bin/cat 		\
579		bin/chmod		\
580		bin/cp 			\
581		bin/date		\
582		bin/dd			\
583		bin/echo		\
584		bin/expr		\
585		bin/hostname		\
586		bin/ln			\
587		bin/ls			\
588		bin/mkdir		\
589		bin/mv			\
590		bin/rm			\
591		bin/sh			\
592		bin/test		\
593		gnu/usr.bin/awk		\
594		gnu/usr.bin/bc		\
595		gnu/usr.bin/grep	\
596		gnu/usr.bin/groff	\
597		gnu/usr.bin/gzip	\
598		gnu/usr.bin/man/makewhatis	\
599		gnu/usr.bin/sort	\
600		gnu/usr.bin/texinfo     \
601		share/info		\
602		usr.bin/basename	\
603		usr.bin/cap_mkdb	\
604		usr.bin/chflags		\
605		usr.bin/cmp		\
606		usr.bin/col		\
607		usr.bin/cpp		\
608		usr.bin/expand		\
609		usr.bin/file2c		\
610		usr.bin/find		\
611		usr.bin/gencat		\
612		usr.bin/lorder		\
613		usr.bin/m4		\
614		usr.bin/mkdep		\
615		usr.bin/paste		\
616		usr.bin/sed		\
617		usr.bin/size		\
618		usr.bin/soelim		\
619		usr.bin/strip		\
620		usr.bin/symorder	\
621		usr.bin/touch		\
622		usr.bin/tr		\
623		usr.bin/true		\
624		usr.bin/uname		\
625		usr.bin/uuencode	\
626		usr.bin/vgrind		\
627		usr.bin/vi		\
628		usr.bin/wc		\
629		usr.bin/yacc		\
630		usr.sbin/chown		\
631		usr.sbin/mtree		\
632		usr.sbin/zic
633	cd ${.CURDIR}/$d && ${MAKE} depend && \
634		${MAKE} ${MK_FLAGS} all && \
635		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
636.endfor
637
638.for __target in clean cleandir obj depend
639.for entry in ${SUBDIR}
640${entry}.${__target}__D: .PHONY
641	if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
642		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
643		edir=${entry}.${MACHINE}; \
644		cd ${.CURDIR}/$${edir}; \
645	else \
646		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
647		edir=${entry}; \
648		cd ${.CURDIR}/$${edir}; \
649	fi; \
650	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
651.endfor
652par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
653.endfor
654
655.include <bsd.subdir.mk>
656