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