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