Makefile.inc1 revision 77347
190792Sgshapiro#
290792Sgshapiro# $FreeBSD: head/Makefile.inc1 77347 2001-05-28 16:54:02Z ru $
390792Sgshapiro#
490792Sgshapiro# Make command line options:
590792Sgshapiro#	-DMAKE_KERBEROS4 to build KerberosIV
690792Sgshapiro#	-DMAKE_KERBEROS5 to build Kerberos5
790792Sgshapiro#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
890792Sgshapiro#	-DNOCLEAN do not clean at all
990792Sgshapiro#	-DNOCRYPT will prevent building of crypt versions
1090792Sgshapiro#	-DNOPROFILE do not build profiled libraries
11266711Sgshapiro#	-DNOSECURE do not go into secure subdir
1290792Sgshapiro#	-DNOGAMES do not go into games subdir
1390792Sgshapiro#	-DNOSHARE do not go into share subdir
1490792Sgshapiro#	-DNOINFO do not make or install info files
1590792Sgshapiro#	-DNOLIBC_R do not build libc_r.
1690792Sgshapiro#	-DNO_FORTRAN do not build g77 and related libraries.
1790792Sgshapiro#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1890792Sgshapiro#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
1990792Sgshapiro#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2090792Sgshapiro#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2190792Sgshapiro#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2290792Sgshapiro#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2390792Sgshapiro#	MACHINE_ARCH="machine arch" to crossbuild world to a different arch
2490792Sgshapiro
2590792Sgshapiro#
2690792Sgshapiro# The intended user-driven targets are:
2790792Sgshapiro# buildworld  - rebuild *everything*, including glue to help do upgrades
2890792Sgshapiro# installworld- install everything built by "buildworld"
2990792Sgshapiro# update      - convenient way to update your source tree (eg: sup/cvs)
3090792Sgshapiro# most        - build user commands, no libraries or include files
3190792Sgshapiro# installmost - install user commands, no libraries or include files
3290792Sgshapiro#
3390792Sgshapiro# Standard targets (not defined here) are documented in the makefiles in
3490792Sgshapiro# /usr/share/mk.  These include:
3590792Sgshapiro#		obj depend all install clean cleandepend cleanobj
3690792Sgshapiro
3790792Sgshapiro# Put initial settings here.
3890792SgshapiroSUBDIR=
3990792Sgshapiro
4090792Sgshapiro# We must do share/info early so that installation of info `dir'
4190792Sgshapiro# entries works correctly.  Do it first since it is less likely to
4290792Sgshapiro# grow dependencies on include and lib than vice versa.
4390792Sgshapiro.if exists(${.CURDIR}/share/info)
4490792SgshapiroSUBDIR+= share/info
4590792Sgshapiro.endif
4690792Sgshapiro
4790792Sgshapiro# We must do include and lib early so that the perl *.ph generation
4890792Sgshapiro# works correctly as it uses the header files installed by this.
4990792Sgshapiro.if exists(${.CURDIR}/include)
5090792SgshapiroSUBDIR+= include
5190792Sgshapiro.endif
5290792Sgshapiro.if exists(${.CURDIR}/lib)
5390792SgshapiroSUBDIR+= lib
5490792Sgshapiro.endif
5590792Sgshapiro
5690792Sgshapiro.if exists(${.CURDIR}/bin)
5790792SgshapiroSUBDIR+= bin
5890792Sgshapiro.endif
5990792Sgshapiro.if exists(${.CURDIR}/games) && !defined(NOGAMES)
6090792SgshapiroSUBDIR+= games
6190792Sgshapiro.endif
6290792Sgshapiro.if exists(${.CURDIR}/gnu)
6390792SgshapiroSUBDIR+= gnu
6490792Sgshapiro.endif
6590792Sgshapiro.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
6690792Sgshapiro    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
6790792SgshapiroSUBDIR+= kerberosIV
6890792Sgshapiro.endif
6990792Sgshapiro.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
7090792Sgshapiro    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
7190792SgshapiroSUBDIR+= kerberos5
7290792Sgshapiro.endif
7390792Sgshapiro.if exists(${.CURDIR}/libexec)
7490792SgshapiroSUBDIR+= libexec
7590792Sgshapiro.endif
7690792Sgshapiro.if exists(${.CURDIR}/sbin)
7790792SgshapiroSUBDIR+= sbin
7890792Sgshapiro.endif
7990792Sgshapiro.if exists(${.CURDIR}/share) && !defined(NOSHARE)
8090792SgshapiroSUBDIR+= share
8190792Sgshapiro.endif
8290792Sgshapiro.if exists(${.CURDIR}/sys)
8390792SgshapiroSUBDIR+= sys
8490792Sgshapiro.endif
8590792Sgshapiro.if exists(${.CURDIR}/usr.bin)
8690792SgshapiroSUBDIR+= usr.bin
8790792Sgshapiro.endif
8890792Sgshapiro.if exists(${.CURDIR}/usr.sbin)
8990792SgshapiroSUBDIR+= usr.sbin
9090792Sgshapiro.endif
9190792Sgshapiro.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
9290792SgshapiroSUBDIR+= secure
9390792Sgshapiro.endif
9490792Sgshapiro
9590792Sgshapiro# etc must be last for "distribute" to work
9690792Sgshapiro.if exists(${.CURDIR}/etc)
9790792SgshapiroSUBDIR+= etc
9890792Sgshapiro.endif
9990792Sgshapiro
10090792Sgshapiro# These are last, since it is nice to at least get the base system
10190792Sgshapiro# rebuilt before you do them.
10290792Sgshapiro.if defined(LOCAL_DIRS)
10390792Sgshapiro.for _DIR in ${LOCAL_DIRS}
10490792Sgshapiro.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
10590792SgshapiroSUBDIR+= ${_DIR}
10690792Sgshapiro.endif
10790792Sgshapiro.endfor
10890792Sgshapiro.endif
10990792Sgshapiro
11090792Sgshapiro.if defined(NOCLEANDIR)
11190792SgshapiroCLEANDIR=	clean cleandepend
11290792Sgshapiro.else
11390792SgshapiroCLEANDIR=	cleandir
11490792Sgshapiro.endif
11590792Sgshapiro
11690792SgshapiroSUP?=		cvsup
11790792SgshapiroSUPFLAGS?=	-g -L 2 -P -
11890792Sgshapiro.if defined(SUPHOST)
11990792SgshapiroSUPFLAGS+=	-h ${SUPHOST}
12090792Sgshapiro.endif
12190792Sgshapiro
12290792SgshapiroMAKEOBJDIRPREFIX?=	/usr/obj
12390792SgshapiroTARGET_ARCH?=	${MACHINE_ARCH}
12490792SgshapiroBUILD_ARCH!=	sysctl -n hw.machine_arch
12590792Sgshapiro.if ${BUILD_ARCH} == ${MACHINE_ARCH}
12690792SgshapiroOBJTREE=	${MAKEOBJDIRPREFIX}
12790792Sgshapiro.else
12890792SgshapiroOBJTREE=	${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
12990792Sgshapiro.endif
13090792SgshapiroWORLDTMP=	${OBJTREE}${.CURDIR}/${BUILD_ARCH}
13190792Sgshapiro# /usr/games added for fortune which depend on strfile
13290792SgshapiroSTRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
13390792SgshapiroTMPPATH=	${STRICTTMPPATH}:${PATH}
13490792SgshapiroOBJFORMAT_PATH?=	/usr/libexec
13590792Sgshapiro
13690792SgshapiroTMPDIR?=	/tmp
13790792SgshapiroTMPPID!=	echo $$$$
13890792SgshapiroINSTALLTMP=	${TMPDIR}/install.${TMPPID}
13990792Sgshapiro
14090792Sgshapiro#
14190792Sgshapiro# Building a world goes through the following stages
14290792Sgshapiro#
14390792Sgshapiro# 1. bootstrap-tool stage [BMAKE]
14490792Sgshapiro#	This stage is responsible for creating programs that
14590792Sgshapiro#	are needed for backward compatibility reasons. They
14690792Sgshapiro#	are not built as cross-tools.
14790792Sgshapiro# 2. build-tool stage [TMAKE]
14890792Sgshapiro#	This stage is responsible for creating the object
14990792Sgshapiro#	tree and building any tools that are needed during
15090792Sgshapiro#	the build process.
15190792Sgshapiro# 3. cross-tool stage [XMAKE]
15290792Sgshapiro#	This stage is responsible for creating any tools that
15390792Sgshapiro#	are needed for cross-builds. A cross-compiler is one
15490792Sgshapiro#	of them.
15590792Sgshapiro# 4. world stage [WMAKE]
15690792Sgshapiro#	This stage actually builds the world.
15790792Sgshapiro# 5. install stage (optional) [IMAKE]
15890792Sgshapiro#	This stage installs a previously built world.
15990792Sgshapiro#
16090792Sgshapiro
16190792Sgshapiro# Common environment for bootstrap related stages
16290792SgshapiroBOOTSTRAPENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
16390792Sgshapiro		DESTDIR=${WORLDTMP} \
16490792Sgshapiro		INSTALL="sh ${.CURDIR}/tools/install.sh" \
16590792Sgshapiro		MACHINE_ARCH=${BUILD_ARCH} \
16690792Sgshapiro		TOOLS_PREFIX=${WORLDTMP} \
16790792Sgshapiro		PATH=${TMPPATH}
16890792Sgshapiro
16990792Sgshapiro# Common environment for world related stages
17090792SgshapiroCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
17190792Sgshapiro		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
17290792Sgshapiro		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
17390792Sgshapiro		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
17490792Sgshapiro		PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0 \
17590792Sgshapiro		GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
17690792Sgshapiro		GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
17790792Sgshapiro		GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
17890792Sgshapiro
17990792Sgshapiro# bootstrap-tool stage
18090792SgshapiroBMAKEENV=	${BOOTSTRAPENV}
18190792SgshapiroBMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOHTML -DNOINFO \
18290792Sgshapiro			-DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
18390792Sgshapiro
18490792Sgshapiro# build-tool stage
18590792SgshapiroTMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
18690792Sgshapiro		INSTALL="sh ${.CURDIR}/tools/install.sh" \
18790792Sgshapiro		PATH=${TMPPATH}
18890792SgshapiroTMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1
18990792Sgshapiro
19090792Sgshapiro# cross-tool stage
19190792SgshapiroXMAKEENV=	${BOOTSTRAPENV} \
19290792Sgshapiro		TARGET_ARCH=${MACHINE_ARCH}
19390792SgshapiroXMAKE=		${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
19490792Sgshapiro			-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \
19590792Sgshapiro			-DNOSHARED
19690792Sgshapiro
19790792Sgshapiro# world stage
19890792SgshapiroWMAKEENV=	${CROSSENV} \
19990792Sgshapiro		DESTDIR=${WORLDTMP} \
20090792Sgshapiro		INSTALL="sh ${.CURDIR}/tools/install.sh" \
20190792Sgshapiro		PATH=${TMPPATH}
20290792SgshapiroWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
20390792Sgshapiro
20490792Sgshapiro# install stage
20590792SgshapiroIMAKEENV=	${CROSSENV} \
20690792Sgshapiro		PATH=${STRICTTMPPATH}:${INSTALLTMP}
20790792SgshapiroIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
20890792Sgshapiro
20990792Sgshapiro# kernel stage
21090792SgshapiroKMAKEENV=	${WMAKEENV} \
21190792Sgshapiro		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
21290792Sgshapiro
21390792SgshapiroUSRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
21490792Sgshapiro		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc \
21590792Sgshapiro		usr/share/dict \
21690792Sgshapiro		usr/share/groff_font/devX100 \
21790792Sgshapiro		usr/share/groff_font/devX100-12 \
21890792Sgshapiro		usr/share/groff_font/devX75 \
21990792Sgshapiro		usr/share/groff_font/devX75-12 \
22090792Sgshapiro		usr/share/groff_font/devascii \
22190792Sgshapiro		usr/share/groff_font/devcp1047 \
22290792Sgshapiro		usr/share/groff_font/devdvi \
22390792Sgshapiro		usr/share/groff_font/devhtml \
22490792Sgshapiro		usr/share/groff_font/devkoi8-r \
22590792Sgshapiro		usr/share/groff_font/devlatin1 \
22690792Sgshapiro		usr/share/groff_font/devlbp \
22790792Sgshapiro		usr/share/groff_font/devlj4 \
22890792Sgshapiro		usr/share/groff_font/devps \
22990792Sgshapiro		usr/share/groff_font/devutf8 \
23090792Sgshapiro		usr/share/tmac/mdoc usr/share/tmac/mm
23190792Sgshapiro
23290792SgshapiroINCDIRS=	arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
23390792Sgshapiro		security ss
23490792Sgshapiro
23590792Sgshapiro#
23690792Sgshapiro# buildworld
23790792Sgshapiro#
23890792Sgshapiro# Attempt to rebuild the entire system, with reasonable chance of
23990792Sgshapiro# success, regardless of how old your existing system is.
24090792Sgshapiro#
24190792Sgshapirobuildworld:
24290792Sgshapiro	@echo
24390792Sgshapiro	@echo "--------------------------------------------------------------"
24490792Sgshapiro	@echo ">>> Rebuilding the temporary build tree"
24590792Sgshapiro	@echo "--------------------------------------------------------------"
24690792Sgshapiro.if !defined(NOCLEAN)
24790792Sgshapiro	rm -rf ${WORLDTMP}
24890792Sgshapiro.else
24990792Sgshapiro	for dir in bin games include lib sbin share; do \
25090792Sgshapiro		rm -rf ${WORLDTMP}/usr/$$dir; \
25190792Sgshapiro	done
25290792Sgshapiro	# XXX - Work-around for broken cc/cc_tools/Makefile.
25390792Sgshapiro	# This is beyond dirty...
25490792Sgshapiro	rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
25590792Sgshapiro.endif
25690792Sgshapiro.for _dir in ${USRDIRS}
25790792Sgshapiro	mkdir -p ${WORLDTMP}/${_dir}
25890792Sgshapiro.endfor
25990792Sgshapiro.for _dir in ${INCDIRS}
26090792Sgshapiro	mkdir -p ${WORLDTMP}/usr/include/${_dir}
26190792Sgshapiro.endfor
26290792Sgshapiro	ln -sf ${.CURDIR}/sys ${WORLDTMP}
26390792Sgshapiro	@echo
26490792Sgshapiro	@echo "--------------------------------------------------------------"
26590792Sgshapiro	@echo ">>> stage 1: bootstrap tools"
26690792Sgshapiro	@echo "--------------------------------------------------------------"
26790792Sgshapiro	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
26890792Sgshapiro.if !defined(NOCLEAN)
26990792Sgshapiro	@echo
27090792Sgshapiro	@echo "--------------------------------------------------------------"
27190792Sgshapiro	@echo ">>> stage 2: cleaning up the object tree"
27290792Sgshapiro	@echo "--------------------------------------------------------------"
27390792Sgshapiro	cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
27490792Sgshapiro.endif
27590792Sgshapiro	@echo
27690792Sgshapiro	@echo "--------------------------------------------------------------"
27790792Sgshapiro	@echo ">>> stage 2: rebuilding the object tree"
27890792Sgshapiro	@echo "--------------------------------------------------------------"
27990792Sgshapiro	cd ${.CURDIR}; ${TMAKE} par-obj
28090792Sgshapiro	@echo
28190792Sgshapiro	@echo "--------------------------------------------------------------"
28290792Sgshapiro	@echo ">>> stage 2: build tools"
28390792Sgshapiro	@echo "--------------------------------------------------------------"
28490792Sgshapiro	cd ${.CURDIR}; ${TMAKE} build-tools
28590792Sgshapiro	@echo
28690792Sgshapiro	@echo "--------------------------------------------------------------"
28790792Sgshapiro	@echo ">>> stage 3: cross tools"
28890792Sgshapiro	@echo "--------------------------------------------------------------"
28990792Sgshapiro	cd ${.CURDIR}; ${XMAKE} cross-tools
29090792Sgshapiro	@echo
29190792Sgshapiro	@echo "--------------------------------------------------------------"
29290792Sgshapiro	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
29390792Sgshapiro	@echo "--------------------------------------------------------------"
29490792Sgshapiro	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
29590792Sgshapiro	@echo
29690792Sgshapiro	@echo "--------------------------------------------------------------"
29790792Sgshapiro	@echo ">>> stage 4: building libraries"
29890792Sgshapiro	@echo "--------------------------------------------------------------"
29990792Sgshapiro	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
30090792Sgshapiro	@echo
30190792Sgshapiro	@echo "--------------------------------------------------------------"
30290792Sgshapiro	@echo ">>> stage 4: make dependencies"
30390792Sgshapiro	@echo "--------------------------------------------------------------"
30490792Sgshapiro	cd ${.CURDIR}; ${WMAKE} par-depend
30590792Sgshapiro	@echo
30690792Sgshapiro	@echo "--------------------------------------------------------------"
30790792Sgshapiro	@echo ">>> stage 4: building everything.."
30890792Sgshapiro	@echo "--------------------------------------------------------------"
30990792Sgshapiro	cd ${.CURDIR}; ${WMAKE} all
31090792Sgshapiro
31190792Sgshapiroeverything:
31290792Sgshapiro	@echo "--------------------------------------------------------------"
31390792Sgshapiro	@echo ">>> Building everything.."
31490792Sgshapiro	@echo "--------------------------------------------------------------"
31590792Sgshapiro	cd ${.CURDIR}; ${WMAKE} all
31690792Sgshapiro
31790792Sgshapiro#
31890792Sgshapiro# installworld
31990792Sgshapiro#
32090792Sgshapiro# Installs everything compiled by a 'buildworld'.
32190792Sgshapiro#
32290792Sgshapiroinstallworld:
32390792Sgshapiro	mkdir -p ${INSTALLTMP}
32490792Sgshapiro	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
32590792Sgshapiro	    ln make makewhatis mtree mv perl rm sed sh sysctl \
32690792Sgshapiro	    test true uname wc zic; do \
32790792Sgshapiro		cp `which $$prog` ${INSTALLTMP}; \
32890792Sgshapiro	done
32990792Sgshapiro	cd ${.CURDIR}; ${IMAKE} reinstall
33090792Sgshapiro	rm -rf ${INSTALLTMP}
33190792Sgshapiro
33290792Sgshapiro#
33390792Sgshapiro# reinstall
33490792Sgshapiro#
33590792Sgshapiro# If you have a build server, you can NFS mount the source and obj directories
33690792Sgshapiro# and do a 'make reinstall' on the *client* to install new binaries from the
33790792Sgshapiro# most recent server build.
33890792Sgshapiro#
33990792Sgshapiroreinstall:
34090792Sgshapiro	@echo "--------------------------------------------------------------"
34190792Sgshapiro	@echo ">>> Making hierarchy"
34290792Sgshapiro	@echo "--------------------------------------------------------------"
34390792Sgshapiro	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
34490792Sgshapiro	@echo
34590792Sgshapiro	@echo "--------------------------------------------------------------"
34690792Sgshapiro	@echo ">>> Installing everything.."
34790792Sgshapiro	@echo "--------------------------------------------------------------"
34890792Sgshapiro	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
34990792Sgshapiro.if !defined(NOMAN)
35090792Sgshapiro	@echo
35190792Sgshapiro	@echo "--------------------------------------------------------------"
35290792Sgshapiro	@echo ">>> Rebuilding man page indices"
35390792Sgshapiro	@echo "--------------------------------------------------------------"
35490792Sgshapiro	cd ${.CURDIR}/share/man; ${MAKE} makedb
35590792Sgshapiro.endif
35690792Sgshapiro
35790792Sgshapiro#
35890792Sgshapiro# distribworld
35990792Sgshapiro#
360# Front-end to distribute to make sure the search path contains
361# the object directory. Needed for miniperl.
362#
363distribworld:
364	cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
365
366#
367# buildkernel and installkernel
368#
369# Which kernels to build and/or install is specified by setting
370# KERNCONF. If not defined a GENERIC kernel is built/installed.
371# Only the existing (depending MACHINE) config files are used
372# for building kernels and only the first of these is designated
373# as the one being installed.
374#
375# Note that we have to use MACHINE instead of MACHINE_ARCH when
376# we're in kernel-land. Since only MACHINE_ARCH is (expected) to
377# be set to cross-build, we have to make sure MACHINE is set
378# properly.
379
380.if !defined(KERNCONF) && defined(KERNEL)
381KERNCONF=	${KERNEL}
382KERNWARN=	yes
383.else
384KERNCONF?=	GENERIC
385.endif
386INSTKERNNAME?=	kernel
387
388# The only exotic MACHINE_ARCH/MACHINE combination valid at this
389# time is i386/pc98. In all other cases set MACHINE equal to
390# MACHINE_ARCH.
391.if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
392MACHINE=	${MACHINE_ARCH}
393.endif
394
395KRNLSRCDIR=	${.CURDIR}/sys
396KRNLCONFDIR=	${KRNLSRCDIR}/${MACHINE}/conf
397KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
398
399BUILDKERNELS=
400INSTALLKERNEL=
401.for _kernel in ${KERNCONF}
402.if exists(${KRNLCONFDIR}/${_kernel})
403BUILDKERNELS+=	${_kernel}
404.if empty(INSTALLKERNEL)
405INSTALLKERNEL= ${_kernel}
406.endif
407.endif
408.endfor
409
410#
411# buildkernel
412#
413# Builds all kernels defined by BUILDKERNELS.
414#
415buildkernel:
416.if empty(BUILDKERNELS)
417	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
418	@false
419.endif
420.if defined(KERNWARN)
421	@echo "--------------------------------------------------------------"
422	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
423	@echo "--------------------------------------------------------------"
424	@sleep 3
425.endif
426	@echo
427.for _kernel in ${BUILDKERNELS}
428	@echo "--------------------------------------------------------------"
429	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
430	@echo "--------------------------------------------------------------"
431	@echo "===> ${_kernel}"
432	mkdir -p ${KRNLOBJDIR}
433.if !defined(NO_KERNELCONFIG)
434	cd ${KRNLCONFDIR}; \
435		PATH=${TMPPATH} \
436		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
437.endif
438.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
439	cd ${KRNLOBJDIR}/${_kernel}; \
440	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
441.endif
442	cd ${KRNLOBJDIR}/${_kernel}; \
443		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
444		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
445.if !defined(NO_KERNELDEPEND)
446	cd ${KRNLOBJDIR}/${_kernel}; \
447	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
448.endif
449	cd ${KRNLOBJDIR}/${_kernel}; \
450	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
451	@echo "--------------------------------------------------------------"
452	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
453	@echo "--------------------------------------------------------------"
454.endfor
455
456#
457# installkernel
458#
459# Install the kernel defined by INSTALLKERNEL
460#
461installkernel:
462	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
463	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
464reinstallkernel:
465	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
466	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
467
468#
469# kernel
470#
471# Short hand for `make buildkernel installkernel'
472#
473kernel: buildkernel installkernel
474
475#
476# update
477#
478# Update the source tree, by running sup and/or running cvs to update to the
479# latest copy.
480#
481update:
482.if defined(SUP_UPDATE)
483	@echo "--------------------------------------------------------------"
484	@echo ">>> Running ${SUP}"
485	@echo "--------------------------------------------------------------"
486.if defined(SUPFILE)
487	@${SUP} ${SUPFLAGS} ${SUPFILE}
488.endif
489.if defined(SUPFILE1)
490	@${SUP} ${SUPFLAGS} ${SUPFILE1}
491.endif
492.if defined(SUPFILE2)
493	@${SUP} ${SUPFLAGS} ${SUPFILE2}
494.endif
495.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
496	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
497.endif
498.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
499	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
500.endif
501.endif
502.if defined(CVS_UPDATE)
503	@echo "--------------------------------------------------------------"
504	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
505	@echo "--------------------------------------------------------------"
506	cd ${.CURDIR}; cvs -q update -A -P -d
507.endif
508
509#
510# most
511#
512# Build most of the user binaries on the existing system libs and includes.
513#
514most:
515	@echo "--------------------------------------------------------------"
516	@echo ">>> Building programs only"
517	@echo "--------------------------------------------------------------"
518	cd ${.CURDIR}/bin;		${MAKE} all
519	cd ${.CURDIR}/sbin;		${MAKE} all
520	cd ${.CURDIR}/libexec;		${MAKE} all
521	cd ${.CURDIR}/usr.bin;		${MAKE} all
522	cd ${.CURDIR}/usr.sbin;		${MAKE} all
523	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
524	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
525	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
526
527#
528# installmost
529#
530# Install the binaries built by the 'most' target.  This does not include
531# libraries or include files.
532#
533installmost:
534	@echo "--------------------------------------------------------------"
535	@echo ">>> Installing programs only"
536	@echo "--------------------------------------------------------------"
537	cd ${.CURDIR}/bin;		${MAKE} install
538	cd ${.CURDIR}/sbin;		${MAKE} install
539	cd ${.CURDIR}/libexec;		${MAKE} install
540	cd ${.CURDIR}/usr.bin;		${MAKE} install
541	cd ${.CURDIR}/usr.sbin;		${MAKE} install
542	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
543	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
544	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
545
546#
547# ------------------------------------------------------------------------
548#
549# From here onwards are utility targets used by the 'make world' and
550# related targets.  If your 'world' breaks, you may like to try to fix
551# the problem and manually run the following targets to attempt to
552# complete the build.  Beware, this is *not* guaranteed to work, you
553# need to have a pretty good grip on the current state of the system
554# to attempt to manually finish it.  If in doubt, 'make world' again.
555#
556
557#
558# bootstrap-tools: Build tools needed for compatibility
559#
560.if exists(${.CURDIR}/games) && !defined(NOGAMES)
561_strfile=	games/fortune/strfile
562.endif
563
564bootstrap-tools:
565.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
566    usr.sbin/config usr.sbin/kbdcontrol \
567    gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
568	cd ${.CURDIR}/${_tool}; \
569		${MAKE} obj; \
570		${MAKE} depend; \
571		${MAKE} all; \
572		${MAKE} install
573.endfor
574
575#
576# build-tools: Build special purpose build tools
577#
578.if exists(${.CURDIR}/games) && !defined(NOGAMES)
579_games=	games/adventure games/hack games/phantasia
580.endif
581
582.if exists(${.CURDIR}/share) && !defined(NOSHARE)
583_share=	share/syscons/scrnmaps
584.endif
585
586.if !defined(NO_FORTRAN)
587_fortran= gnu/usr.bin/cc/f771
588.endif
589
590.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
591    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
592_libroken4= kerberosIV/lib/libroken
593.endif
594
595.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
596    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
597_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
598.endif
599
600build-tools:
601.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
602    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.sbin/sysinstall
603	cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
604.endfor
605
606#
607# cross-tools: Build cross-building tools
608#
609# WARNING: Because the bootstrap tools are expected to run on the
610# build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
611# target is being made. TARGET_ARCH is *always* set to reflect the
612# target-machine (which you can set by specifying MACHINE_ARCH on
613# make's command-line, get it?).
614# The reason is simple: we build these tools not to be run on the
615# architecture we're cross-building, but on the architecture we're
616# currently building on (ie the host-machine) and we expect these
617# tools to produce output for the architecture we're trying to
618# cross-build.
619#
620.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
621_elf2exe=	usr.sbin/elf2exe
622.endif
623
624.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
625_btxld=	usr.sbin/btxld
626.endif
627
628.if !defined(NOPERL)
629_perl=	gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl
630.endif
631
632cross-tools:
633.for _tool in ${_btxld} ${_elf2exe} ${_perl} \
634    usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
635	cd ${.CURDIR}/${_tool}; \
636		${MAKE} obj; \
637		${MAKE} depend; \
638		${MAKE} all; \
639		${MAKE} install
640.endfor
641
642#
643# hierarchy - ensure that all the needed directories are present
644#
645hierarchy:
646	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
647
648#
649# includes - possibly generate and install the include files.
650#
651includes:
652	cd ${.CURDIR}/include;			${MAKE} -B all install
653	cd ${.CURDIR}/gnu/include;		${MAKE} install
654	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
655	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
656	cd ${.CURDIR}/gnu/lib/libreadline/readline;	${MAKE} beforeinstall
657	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
658	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
659	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
660	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
661	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
662.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
663.if exists(${.CURDIR}/secure/lib/libcrypto)
664	cd ${.CURDIR}/secure/lib/libcrypto;	${MAKE} beforeinstall
665.endif
666.if exists(${.CURDIR}/secure/lib/libssl)
667	cd ${.CURDIR}/secure/lib/libssl;	${MAKE} beforeinstall
668.endif
669.endif
670.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
671    defined(MAKE_KERBEROS4)
672	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
673	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
674	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
675	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
676	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
677	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
678.else
679	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
680.endif
681.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
682    defined(MAKE_KERBEROS5)
683	cd ${.CURDIR}/kerberos5/lib/libasn1;		${MAKE} beforeinstall
684	cd ${.CURDIR}/kerberos5/lib/libhdb;		${MAKE} beforeinstall
685	cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;	${MAKE} beforeinstall
686	cd ${.CURDIR}/kerberos5/lib/libkadm5srv;	${MAKE} beforeinstall
687	cd ${.CURDIR}/kerberos5/lib/libkafs5;		${MAKE} beforeinstall
688	cd ${.CURDIR}/kerberos5/lib/libkrb5;		${MAKE} beforeinstall
689	cd ${.CURDIR}/kerberos5/lib/libsl;		${MAKE} beforeinstall
690.endif
691.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
692	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
693.endif
694	cd ${.CURDIR}/gnu/lib/csu;		${MAKE} beforeinstall
695	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
696	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
697	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
698	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
699	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
700	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
701	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
702	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
703	cd ${.CURDIR}/lib/libfetch;		${MAKE} beforeinstall
704	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
705	cd ${.CURDIR}/lib/libkvm;		${MAKE} beforeinstall
706	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
707.if !defined(WANT_CSRG_LIBM)
708	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
709.endif
710	cd ${.CURDIR}/lib/libncp;		${MAKE} beforeinstall
711	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
712	cd ${.CURDIR}/lib/libnetgraph;		${MAKE} beforeinstall
713	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
714	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
715	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
716	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
717	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
718	cd ${.CURDIR}/lib/libsbuf;		${MAKE} beforeinstall
719	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
720	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
721	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
722	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
723	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
724	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
725	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
726	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
727	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
728	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
729
730#
731# libraries - build all libraries, and install them under ${DESTDIR}.
732#
733# The following dependencies exist between the libraries:
734#
735# lib*: csu libgcc_pic
736# libatm: libmd
737# libcam: libsbuf
738# libcrypt: libmd
739# libdialog: libncurses
740# libedit: libncurses
741# libg++: libm
742# libkrb: libcrypt
743# libopie: libmd
744# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
745#	  libskey libtacplus libutil libz libssh
746# libradius: libmd
747# libreadline: libncurses
748# libskey: libcrypt libmd
749# libss: libcom_err
750# libstc++: libm
751# libtacplus: libmd
752#
753# Across directories this comes down to (rougly):
754#
755# gnu/lib: lib/libm lib/libncurses
756# kerberosIV/lib kerberos5/lib: lib/libcrypt
757# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
758#             secure/lib/libssh lib/libz
759# secure/lib: lib/libmd
760#
761.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
762_csu=	lib/csu/${MACHINE_ARCH}.pcc
763.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
764_csu=	lib/csu/i386-elf
765.else
766_csu=	lib/csu/${MACHINE_ARCH}
767.endif
768
769.if !defined(NOSECURE) && !defined(NOCRYPT)
770_secure_lib=	secure/lib
771.endif
772
773.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
774_kerberosIV_lib=	kerberosIV/lib
775.endif
776
777.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
778_kerberos5_lib=	kerberos5/lib
779.endif
780
781.if defined(WANT_CSRG_LIBM)
782_libm=	lib/libm
783.else
784_libm=	lib/msun
785.endif
786
787.if ${MACHINE_ARCH} == "i386"
788_libkeycap=	usr.sbin/pcvt/keycap
789.endif
790
791.if !defined(NOPERL)
792_libperl=	gnu/usr.bin/perl/libperl
793.endif
794
795libraries:
796.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
797    ${_secure_lib} ${_kerberosIV_lib} \
798    ${_kerberos5_lib} lib/libcom_err ${_libm} lib/libncurses \
799    lib/libopie lib/libradius lib/libsbuf lib/libskey lib/libtacplus \
800    lib/libutil lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
801.if exists(${.CURDIR}/${_lib})
802	cd ${.CURDIR}/${_lib}; \
803		${MAKE} depend; \
804		${MAKE} all; \
805		${MAKE} install
806.endif
807.endfor
808
809.for __target in clean cleandepend cleandir depend obj
810.for entry in ${SUBDIR}
811${entry}.${__target}__D: .PHONY
812	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
813		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
814		edir=${entry}.${MACHINE_ARCH}; \
815		cd ${.CURDIR}/$${edir}; \
816	else \
817		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
818		edir=${entry}; \
819		cd ${.CURDIR}/$${edir}; \
820	fi; \
821	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
822.endfor
823par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
824.endfor
825
826.include <bsd.subdir.mk>
827