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