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