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