Makefile.inc1 revision 96829
1#
2# $FreeBSD: head/Makefile.inc1 96829 2002-05-18 00:20:01Z obrien $
3#
4# Make command line options:
5#	-DMAKE_KERBEROS4 to build KerberosIV
6#	-DMAKE_KERBEROS5 to build Kerberos5
7#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8#	-DNOCLEAN do not clean at all
9#	-DNOCRYPT will prevent building of crypt versions
10#	-DNOPROFILE do not build profiled libraries
11#	-DNOSECURE do not go into secure subdir
12#	-DNOGAMES do not go into games subdir
13#	-DNOSHARE do not go into share subdir
14#	-DNOINFO do not make or install info files
15#	-DNOLIBC_R do not build libc_r.
16#	-DNO_FORTRAN do not build g77 and related libraries.
17#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
18#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
19#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
20#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
21#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
22#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
23#	TARGET_ARCH="arch" to crossbuild world to a different arch
24
25#
26# The intended user-driven targets are:
27# buildworld  - rebuild *everything*, including glue to help do upgrades
28# installworld- install everything built by "buildworld"
29# update      - convenient way to update your source tree (eg: sup/cvs)
30# most        - build user commands, no libraries or include files
31# installmost - install user commands, no libraries or include files
32#
33# Standard targets (not defined here) are documented in the makefiles in
34# /usr/share/mk.  These include:
35#		obj depend all install clean cleandepend cleanobj
36
37# Put initial settings here.
38SUBDIR=
39
40# We must do share/info early so that installation of info `dir'
41# entries works correctly.  Do it first since it is less likely to
42# grow dependencies on include and lib than vice versa.
43.if exists(${.CURDIR}/share/info)
44SUBDIR+= share/info
45.endif
46
47.if exists(${.CURDIR}/include)
48SUBDIR+= include
49.endif
50.if exists(${.CURDIR}/lib)
51SUBDIR+= lib
52.endif
53
54.if exists(${.CURDIR}/bin)
55SUBDIR+= bin
56.endif
57.if exists(${.CURDIR}/games) && !defined(NOGAMES)
58SUBDIR+= games
59.endif
60.if exists(${.CURDIR}/gnu)
61SUBDIR+= gnu
62.endif
63.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
64    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
65SUBDIR+= kerberosIV
66.endif
67.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
68    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
69SUBDIR+= kerberos5
70.endif
71.if exists(${.CURDIR}/libexec)
72SUBDIR+= libexec
73.endif
74.if exists(${.CURDIR}/sbin)
75SUBDIR+= sbin
76.endif
77.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
78SUBDIR+= secure
79.endif
80.if exists(${.CURDIR}/share) && !defined(NOSHARE)
81SUBDIR+= share
82.endif
83.if exists(${.CURDIR}/sys)
84SUBDIR+= sys
85.endif
86.if exists(${.CURDIR}/usr.bin)
87SUBDIR+= usr.bin
88.endif
89.if exists(${.CURDIR}/usr.sbin)
90SUBDIR+= usr.sbin
91.endif
92
93# etc must be last for "distribute" to work
94.if exists(${.CURDIR}/etc)
95SUBDIR+= etc
96.endif
97
98# These are last, since it is nice to at least get the base system
99# rebuilt before you do them.
100.if defined(LOCAL_DIRS)
101.for _DIR in ${LOCAL_DIRS}
102.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
103SUBDIR+= ${_DIR}
104.endif
105.endfor
106.endif
107
108.if defined(SUBDIR_OVERRIDE)
109SUBDIR=		${SUBDIR_OVERRIDE}
110.endif
111
112.if defined(NOCLEANDIR)
113CLEANDIR=	clean cleandepend
114.else
115CLEANDIR=	cleandir
116.endif
117
118CVS?=		cvs
119SUP?=		/usr/local/bin/cvsup
120SUPFLAGS?=	-g -L 2 -P -
121.if defined(SUPHOST)
122SUPFLAGS+=	-h ${SUPHOST}
123.endif
124
125MAKEOBJDIRPREFIX?=	/usr/obj
126TARGET_ARCH?=	${MACHINE_ARCH}
127.if ${TARGET_ARCH} == ${MACHINE_ARCH}
128TARGET?=	${MACHINE}
129.else
130TARGET?=	${TARGET_ARCH}
131.endif
132.if make(buildworld)
133BUILD_ARCH!=	sysctl -n hw.machine_arch
134.if ${MACHINE_ARCH} != ${BUILD_ARCH}
135.error To cross-build, set TARGET_ARCH.
136.endif
137.endif
138.if ${MACHINE} == ${TARGET}
139OBJTREE=	${MAKEOBJDIRPREFIX}
140.else
141OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
142.endif
143WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
144# /usr/games added for fortune which depend on strfile
145STRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
146TMPPATH=	${STRICTTMPPATH}:${PATH}
147OBJFORMAT_PATH?=	/usr/libexec
148
149INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
150
151#
152# Building a world goes through the following stages
153#
154# 1. bootstrap-tool stage [BMAKE]
155#	This stage is responsible for creating programs that
156#	are needed for backward compatibility reasons. They
157#	are not built as cross-tools.
158# 2. build-tool stage [TMAKE]
159#	This stage is responsible for creating the object
160#	tree and building any tools that are needed during
161#	the build process.
162# 3. cross-tool stage [XMAKE]
163#	This stage is responsible for creating any tools that
164#	are needed for cross-builds. A cross-compiler is one
165#	of them.
166# 4. world stage [WMAKE]
167#	This stage actually builds the world.
168# 5. install stage (optional) [IMAKE]
169#	This stage installs a previously built world.
170#
171
172# Common environment for world related stages
173CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
174		MACHINE_ARCH=${TARGET_ARCH} \
175		MACHINE=${TARGET} \
176		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
177		GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
178		GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
179		GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
180
181# bootstrap-tool stage
182BMAKEENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
183		DESTDIR= \
184		INSTALL="sh ${.CURDIR}/tools/install.sh"
185BMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
186		-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
187		-DNO_WERROR
188
189# build-tool stage
190TMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
191		DESTDIR= \
192		INSTALL="sh ${.CURDIR}/tools/install.sh"
193TMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING
194
195# cross-tool stage
196XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
197
198# world stage
199WMAKEENV=	${CROSSENV} \
200		DESTDIR=${WORLDTMP} \
201		INSTALL="sh ${.CURDIR}/tools/install.sh" \
202		PATH=${TMPPATH}
203WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
204
205# install stage
206IMAKEENV=	${CROSSENV} \
207		PATH=${STRICTTMPPATH}:${INSTALLTMP}
208IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
209
210# kernel stage
211KMAKEENV=	${WMAKEENV} \
212		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
213
214USRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
215		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc \
216		usr/share/dict \
217		usr/share/groff_font/devX100 \
218		usr/share/groff_font/devX100-12 \
219		usr/share/groff_font/devX75 \
220		usr/share/groff_font/devX75-12 \
221		usr/share/groff_font/devascii \
222		usr/share/groff_font/devcp1047 \
223		usr/share/groff_font/devdvi \
224		usr/share/groff_font/devhtml \
225		usr/share/groff_font/devkoi8-r \
226		usr/share/groff_font/devlatin1 \
227		usr/share/groff_font/devlbp \
228		usr/share/groff_font/devlj4 \
229		usr/share/groff_font/devps \
230		usr/share/groff_font/devutf8 \
231		usr/share/tmac/mdoc usr/share/tmac/mm
232
233INCDIRS=	arpa dev fs g++/std isc isofs libmilter objc openssl \
234		protocols readline rpc rpcsvc security ufs
235
236#
237# buildworld
238#
239# Attempt to rebuild the entire system, with reasonable chance of
240# success, regardless of how old your existing system is.
241#
242_worldtmp:
243	@echo
244	@echo "--------------------------------------------------------------"
245	@echo ">>> Rebuilding the temporary build tree"
246	@echo "--------------------------------------------------------------"
247.if !defined(NOCLEAN)
248	rm -rf ${WORLDTMP}
249.else
250	# XXX - These two can depend on any header file.
251	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
252	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
253.endif
254.for _dir in ${USRDIRS}
255	mkdir -p ${WORLDTMP}/${_dir}
256.endfor
257.for _dir in ${INCDIRS}
258	mkdir -p ${WORLDTMP}/usr/include/${_dir}
259.endfor
260	ln -sf ${.CURDIR}/sys ${WORLDTMP}
261_bootstrap-tools:
262	@echo
263	@echo "--------------------------------------------------------------"
264	@echo ">>> stage 1: bootstrap tools"
265	@echo "--------------------------------------------------------------"
266	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
267_cleanobj:
268.if !defined(NOCLEAN)
269	@echo
270	@echo "--------------------------------------------------------------"
271	@echo ">>> stage 2: cleaning up the object tree"
272	@echo "--------------------------------------------------------------"
273	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
274.endif
275_obj:
276	@echo
277	@echo "--------------------------------------------------------------"
278	@echo ">>> stage 2: rebuilding the object tree"
279	@echo "--------------------------------------------------------------"
280	cd ${.CURDIR}; ${WMAKE} par-obj
281_build-tools:
282	@echo
283	@echo "--------------------------------------------------------------"
284	@echo ">>> stage 2: build tools"
285	@echo "--------------------------------------------------------------"
286	cd ${.CURDIR}; ${TMAKE} build-tools
287_cross-tools:
288	@echo
289	@echo "--------------------------------------------------------------"
290	@echo ">>> stage 3: cross tools"
291	@echo "--------------------------------------------------------------"
292	cd ${.CURDIR}; ${XMAKE} cross-tools
293_includes:
294	@echo
295	@echo "--------------------------------------------------------------"
296	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
297	@echo "--------------------------------------------------------------"
298	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
299_libraries:
300	@echo
301	@echo "--------------------------------------------------------------"
302	@echo ">>> stage 4: building libraries"
303	@echo "--------------------------------------------------------------"
304	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
305_depend:
306	@echo
307	@echo "--------------------------------------------------------------"
308	@echo ">>> stage 4: make dependencies"
309	@echo "--------------------------------------------------------------"
310	cd ${.CURDIR}; ${WMAKE} par-depend
311everything:
312	@echo
313	@echo "--------------------------------------------------------------"
314	@echo ">>> stage 4: building everything.."
315	@echo "--------------------------------------------------------------"
316	cd ${.CURDIR}; ${WMAKE} all
317
318
319WMAKE_TGTS=
320.if !defined(SUBDIR_OVERRIDE) && !defined(X_QUICK)
321WMAKE_TGTS+=	_worldtmp _bootstrap-tools
322.endif
323.if !defined(X_QUICK)
324WMAKE_TGTS+=	_cleanobj _obj _build-tools
325.endif
326.if !defined(SUBDIR_OVERRIDE) && !defined(X_QUICK)
327WMAKE_TGTS+=	_cross-tools
328.endif
329WMAKE_TGTS+=	_includes _libraries _depend everything
330
331.for __target in ${WMAKE_TGTS}
332.if defined(NO${__target})
333WMAKE_TGTS:=	${WMAKE_TGTS:N${__target}}
334.endif
335.endfor
336
337buildworld: ${WMAKE_TGTS}
338.ORDER: ${WMAKE_TGTS}
339
340#
341# installcheck
342#
343# Checks to be sure system is ready for installworld
344#
345installcheck:
346.if !defined(NO_SENDMAIL)
347	@if ! `grep -q '^smmsp:' /etc/passwd`; then \
348		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
349		false; \
350	fi
351	@if ! `grep -q '^smmsp:' /etc/group`; then \
352		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
353		false; \
354	fi
355.endif
356
357#
358# distributeworld
359#
360# Distributes everything compiled by a `buildworld'.
361#
362# installworld
363#
364# Installs everything compiled by a 'buildworld'.
365#
366distributeworld installworld: installcheck
367	mkdir -p ${INSTALLTMP}
368	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
369	    ln make makewhatis mkdir mtree mv pwd_mkdb rm sed sh sysctl \
370	    test true uname wc zic; do \
371		cp `which $$prog` ${INSTALLTMP}; \
372	done
373	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
374	rm -rf ${INSTALLTMP}
375
376#
377# reinstall
378#
379# If you have a build server, you can NFS mount the source and obj directories
380# and do a 'make reinstall' on the *client* to install new binaries from the
381# most recent server build.
382#
383reinstall:
384	@echo "--------------------------------------------------------------"
385	@echo ">>> Making hierarchy"
386	@echo "--------------------------------------------------------------"
387	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
388	@echo
389	@echo "--------------------------------------------------------------"
390	@echo ">>> Installing everything.."
391	@echo "--------------------------------------------------------------"
392	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
393.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
394	@echo
395	@echo "--------------------------------------------------------------"
396	@echo ">>> Rebuilding man page indices"
397	@echo "--------------------------------------------------------------"
398	cd ${.CURDIR}/share/man; ${MAKE} makedb
399.endif
400
401redistribute:
402	@echo "--------------------------------------------------------------"
403	@echo ">>> Distributing everything.."
404	@echo "--------------------------------------------------------------"
405	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
406
407#
408# buildkernel and installkernel
409#
410# Which kernels to build and/or install is specified by setting
411# KERNCONF. If not defined a GENERIC kernel is built/installed.
412# Only the existing (depending TARGET) config files are used
413# for building kernels and only the first of these is designated
414# as the one being installed.
415#
416# Note that we have to use TARGET instead of TARGET_ARCH when
417# we're in kernel-land. Since only TARGET_ARCH is (expected) to
418# be set to cross-build, we have to make sure TARGET is set
419# properly.
420
421.if !defined(KERNCONF) && defined(KERNEL)
422KERNCONF=	${KERNEL}
423KERNWARN=	yes
424.else
425KERNCONF?=	GENERIC
426.endif
427INSTKERNNAME?=	kernel
428
429KRNLSRCDIR=	${.CURDIR}/sys
430KRNLCONFDIR=	${KRNLSRCDIR}/${TARGET}/conf
431KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
432KERNCONFDIR?=	${KRNLCONFDIR}
433
434BUILDKERNELS=
435INSTALLKERNEL=
436.for _kernel in ${KERNCONF}
437.if exists(${KERNCONFDIR}/${_kernel})
438BUILDKERNELS+=	${_kernel}
439.if empty(INSTALLKERNEL)
440INSTALLKERNEL= ${_kernel}
441.endif
442.endif
443.endfor
444
445#
446# buildkernel
447#
448# Builds all kernels defined by BUILDKERNELS.
449#
450buildkernel:
451.if empty(BUILDKERNELS)
452	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
453	@false
454.endif
455.if defined(KERNWARN)
456	@echo "--------------------------------------------------------------"
457	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
458	@echo "--------------------------------------------------------------"
459	@sleep 3
460.endif
461	@echo
462.for _kernel in ${BUILDKERNELS}
463	@echo "--------------------------------------------------------------"
464	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
465	@echo "--------------------------------------------------------------"
466	@echo "===> ${_kernel}"
467	mkdir -p ${KRNLOBJDIR}
468.if !defined(NO_KERNELCONFIG)
469	cd ${KRNLCONFDIR}; \
470		PATH=${TMPPATH} \
471		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
472			${KERNCONFDIR}/${_kernel}
473.endif
474.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
475	cd ${KRNLOBJDIR}/${_kernel}; \
476	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
477.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
478	cd ${KRNLOBJDIR}/${_kernel}; \
479	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
480.endif
481.endif
482	cd ${KRNLOBJDIR}/${_kernel}; \
483		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
484		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
485.if !defined(NO_KERNELDEPEND)
486	cd ${KRNLOBJDIR}/${_kernel}; \
487	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
488.endif
489	cd ${KRNLOBJDIR}/${_kernel}; \
490	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
491	@echo "--------------------------------------------------------------"
492	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
493	@echo "--------------------------------------------------------------"
494.endfor
495
496#
497# installkernel
498#
499# Install the kernel defined by INSTALLKERNEL
500#
501installkernel reinstallkernel:
502	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
503	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
504
505#
506# update
507#
508# Update the source tree, by running sup and/or running cvs to update to the
509# latest copy.
510#
511update:
512.if defined(SUP_UPDATE)
513	@echo "--------------------------------------------------------------"
514	@echo ">>> Running ${SUP}"
515	@echo "--------------------------------------------------------------"
516.if defined(SUPFILE)
517	@${SUP} ${SUPFLAGS} ${SUPFILE}
518.endif
519.if defined(SUPFILE1)
520	@${SUP} ${SUPFLAGS} ${SUPFILE1}
521.endif
522.if defined(SUPFILE2)
523	@${SUP} ${SUPFLAGS} ${SUPFILE2}
524.endif
525.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
526	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
527.endif
528.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
529	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
530.endif
531.endif
532.if defined(CVS_UPDATE)
533	@echo "--------------------------------------------------------------"
534	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
535	@echo "--------------------------------------------------------------"
536	cd ${.CURDIR}; ${CVS} -q update -A -P -d
537.endif
538
539#
540# most
541#
542# Build most of the user binaries on the existing system libs and includes.
543#
544most:
545	@echo "--------------------------------------------------------------"
546	@echo ">>> Building programs only"
547	@echo "--------------------------------------------------------------"
548.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
549	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ all
550.endfor
551
552#
553# installmost
554#
555# Install the binaries built by the 'most' target.  This does not include
556# libraries or include files.
557#
558installmost:
559	@echo "--------------------------------------------------------------"
560	@echo ">>> Installing programs only"
561	@echo "--------------------------------------------------------------"
562.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
563	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ install
564.endfor
565
566#
567# ------------------------------------------------------------------------
568#
569# From here onwards are utility targets used by the 'make world' and
570# related targets.  If your 'world' breaks, you may like to try to fix
571# the problem and manually run the following targets to attempt to
572# complete the build.  Beware, this is *not* guaranteed to work, you
573# need to have a pretty good grip on the current state of the system
574# to attempt to manually finish it.  If in doubt, 'make world' again.
575#
576
577#
578# bootstrap-tools: Build tools needed for compatibility
579#
580.if exists(${.CURDIR}/games) && !defined(NOGAMES)
581_strfile=	games/fortune/strfile
582.endif
583.if ${CXX:T} != "c++"
584_cxx_consumers=	gnu/usr.bin/groff
585.endif
586
587bootstrap-tools:
588.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
589    usr.bin/rpcgen usr.bin/xargs usr.bin/xinstall \
590    usr.sbin/config usr.sbin/kbdcontrol \
591    ${_cxx_consumers} gnu/usr.bin/texinfo
592	cd ${.CURDIR}/${_tool}; \
593		${MAKE} DIRPRFX=${_tool}/ obj; \
594		${MAKE} DIRPRFX=${_tool}/ depend; \
595		${MAKE} DIRPRFX=${_tool}/ all; \
596		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
597.endfor
598
599#
600# build-tools: Build special purpose build tools
601#
602.if exists(${.CURDIR}/games) && !defined(NOGAMES)
603_games=	games/adventure games/hack games/phantasia
604.endif
605
606.if exists(${.CURDIR}/share) && !defined(NOSHARE)
607_share=	share/syscons/scrnmaps
608.endif
609
610.if !defined(NO_FORTRAN)
611_fortran= gnu/usr.bin/cc/f771
612.endif
613
614.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
615    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
616_libroken4= kerberosIV/lib/libroken
617.endif
618
619.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
620    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
621_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
622    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
623.endif
624
625build-tools:
626.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
627    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
628    usr.bin/awk usr.bin/file usr.sbin/sysinstall
629	cd ${.CURDIR}/${_tool}; ${MAKE} DIRPRFX=${_tool}/ build-tools
630.endfor
631
632#
633# cross-tools: Build cross-building tools
634#
635.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
636_elf2exe=	usr.sbin/elf2exe
637.endif
638
639.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
640_btxld=	usr.sbin/btxld
641.endif
642
643_xlint=	usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
644
645cross-tools:
646.for _tool in ${_btxld} ${_elf2exe} \
647    gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
648    gnu/usr.bin/cc ${_xlint}
649	cd ${.CURDIR}/${_tool}; \
650		${MAKE} DIRPRFX=${_tool}/ obj; \
651		${MAKE} DIRPRFX=${_tool}/ depend; \
652		${MAKE} DIRPRFX=${_tool}/ all; \
653		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
654.endfor
655
656#
657# hierarchy - ensure that all the needed directories are present
658#
659hierarchy:
660	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
661
662#
663# libraries - build all libraries, and install them under ${DESTDIR}.
664#
665# The list of libraries with dependents (${_prebuild_libs}) and their
666# interdependencies (__L) are built automatically by the
667# ${.CURDIR}/tools/make_libdeps.sh script.
668#
669libraries:
670	cd ${.CURDIR}; \
671	    ${MAKE} -f Makefile.inc1 _startup_libs; \
672	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
673	    ${MAKE} -f Makefile.inc1 _generic_libs;
674
675# These dependencies are not automatically generated:
676#
677# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
678# shared libraries for ELF.
679#
680_startup_libs=	gnu/lib/csu gnu/lib/libgcc
681.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
682_startup_libs+=	lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
683.else
684_startup_libs+=	lib/csu/${MACHINE_ARCH}
685.endif
686
687_prebuild_libs=
688
689_generic_libs=	gnu/lib
690
691.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
692_prebuild_libs+=	kerberos5/lib/libasn1
693_prebuild_libs+=	kerberos5/lib/libgssapi
694_prebuild_libs+=	kerberos5/lib/libkrb5
695_prebuild_libs+=	kerberos5/lib/libroken
696_generic_libs+=	kerberos5/lib
697.endif
698
699.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
700_prebuild_libs+=	kerberosIV/lib/libkrb
701kerberosIV/lib/libkrb__L: lib/libcrypt__L
702_generic_libs+=	kerberosIV/lib
703.endif
704
705_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libkvm lib/libmd \
706		lib/libncurses lib/libopie lib/libradius lib/librpcsvc \
707		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
708		lib/libz lib/msun
709
710lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
711lib/libypclnt__L: lib/librpcsvc__L
712
713_generic_libs+=	lib
714
715.if !defined(NOCRYPT) && !defined(NOSECURE)
716_prebuild_libs+=	secure/lib/libcrypto
717.if !defined(NO_OPENSSH)
718_prebuild_libs+=	secure/lib/libssh
719secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
720.endif
721_generic_libs+=	secure/lib
722.endif
723
724_generic_libs+=	usr.bin/lex/lib
725
726.if ${MACHINE_ARCH} == "i386"
727_generic_libs+=	usr.sbin/pcvt/keycap
728.endif
729
730.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
731${_lib}__L: .PHONY
732.if exists(${.CURDIR}/${_lib})
733	cd ${.CURDIR}/${_lib}; \
734		${MAKE} DIRPRFX=${_lib}/ depend; \
735		${MAKE} DIRPRFX=${_lib}/ all; \
736		${MAKE} DIRPRFX=${_lib}/ install
737.endif
738.endfor
739
740_startup_libs: ${_startup_libs:S/$/__L/}
741_prebuild_libs: ${_prebuild_libs:S/$/__L/}
742_generic_libs: ${_generic_libs:S/$/__L/}
743
744.for __target in clean cleandepend cleandir depend includes obj
745.for entry in ${SUBDIR}
746${entry}.${__target}__D: .PHONY
747	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
748		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
749		edir=${entry}.${MACHINE_ARCH}; \
750		cd ${.CURDIR}/$${edir}; \
751	else \
752		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
753		edir=${entry}; \
754		cd ${.CURDIR}/$${edir}; \
755	fi; \
756	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
757.endfor
758par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
759.endfor
760
761.include <bsd.subdir.mk>
762