Makefile.inc1 revision 74840
131921Sbrian#
231921Sbrian# $FreeBSD: head/Makefile.inc1 74840 2001-03-27 05:45:52Z ken $
331921Sbrian#
431921Sbrian# Make command line options:
531921Sbrian#	-DMAKE_KERBEROS4 to build KerberosIV
631921Sbrian#	-DMAKE_KERBEROS5 to build Kerberos5
731921Sbrian#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
831921Sbrian#	-DNOCLEAN do not clean at all
931921Sbrian#	-DNOCRYPT will prevent building of crypt versions
1031921Sbrian#	-DNOPROFILE do not build profiled libraries
1131921Sbrian#	-DNOSECURE do not go into secure subdir
1231921Sbrian#	-DNOGAMES do not go into games subdir
1331921Sbrian#	-DNOSHARE do not go into share subdir
1431921Sbrian#	-DNOINFO do not make or install info files
1531921Sbrian#	-DNOLIBC_R do not build libc_r.
1631921Sbrian#	-DNO_FORTRAN do not build g77 and related libraries.
1731921Sbrian#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1831921Sbrian#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
1931921Sbrian#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2031921Sbrian#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2131921Sbrian#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2231921Sbrian#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2331921Sbrian#	MACHINE_ARCH="machine arch" to crossbuild world to a different arch
2431921Sbrian
2531921Sbrian#
2631921Sbrian# The intended user-driven targets are:
2799109Sobrien# buildworld  - rebuild *everything*, including glue to help do upgrades
2899109Sobrien# installworld- install everything built by "buildworld"
2935773Scharnier# update      - convenient way to update your source tree (eg: sup/cvs)
3069457Sbrian# most        - build user commands, no libraries or include files
3127874Sbrian# installmost - install user commands, no libraries or include files
3227874Sbrian#
3327874Sbrian# Standard targets (not defined here) are documented in the makefiles in
3427874Sbrian# /usr/share/mk.  These include:
3527874Sbrian#		obj depend all install clean cleandepend cleanobj
3627874Sbrian
3727874Sbrian# Put initial settings here.
3891079SmarkmSUBDIR=
3927874Sbrian
4027874Sbrian# We must do share/info early so that installation of info `dir'
4127874Sbrian# entries works correctly.  Do it first since it is less likely to
4227874Sbrian# grow dependencies on include and lib than vice versa.
4357326Salfred.if exists(${.CURDIR}/share/info)
4457326SalfredSUBDIR+= share/info
4527874Sbrian.endif
4627874Sbrian
4727874Sbrian# We must do include and lib early so that the perl *.ph generation
4827874Sbrian# works correctly as it uses the header files installed by this.
4927874Sbrian.if exists(${.CURDIR}/include)
5027874SbrianSUBDIR+= include
5127874Sbrian.endif
5227874Sbrian.if exists(${.CURDIR}/lib)
5327874SbrianSUBDIR+= lib
5427874Sbrian.endif
5559175Sbrian
5627874Sbrian.if exists(${.CURDIR}/bin)
5727874SbrianSUBDIR+= bin
5859022Sbrian.endif
5959022Sbrian.if exists(${.CURDIR}/games) && !defined(NOGAMES)
6059175SbrianSUBDIR+= games
6159022Sbrian.endif
6259175Sbrian.if exists(${.CURDIR}/gnu)
6359175SbrianSUBDIR+= gnu
6459175Sbrian.endif
6559022Sbrian.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
6659022Sbrian    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
6759022SbrianSUBDIR+= kerberosIV
6859022Sbrian.endif
6959022Sbrian.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
7027874Sbrian    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
7127874SbrianSUBDIR+= kerberos5
7227874Sbrian.endif
7327874Sbrian.if exists(${.CURDIR}/libexec)
7427874SbrianSUBDIR+= libexec
7528025Sbrian.endif
7628025Sbrian.if exists(${.CURDIR}/sbin)
7727874SbrianSUBDIR+= sbin
7827874Sbrian.endif
7927874Sbrian.if exists(${.CURDIR}/share) && !defined(NOSHARE)
8027874SbrianSUBDIR+= share
8127874Sbrian.endif
8227874Sbrian.if exists(${.CURDIR}/sys)
8328025SbrianSUBDIR+= sys
8427874Sbrian.endif
8527874Sbrian.if exists(${.CURDIR}/usr.bin)
8627874SbrianSUBDIR+= usr.bin
8727874Sbrian.endif
8827874Sbrian.if exists(${.CURDIR}/usr.sbin)
8927874SbrianSUBDIR+= usr.sbin
9027874Sbrian.endif
9127874Sbrian.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
9227874SbrianSUBDIR+= secure
9327874Sbrian.endif
9427874Sbrian
9569457Sbrian# etc must be last for "distribute" to work
9669457Sbrian.if exists(${.CURDIR}/etc)
9727874SbrianSUBDIR+= etc
9827874Sbrian.endif
9927874Sbrian
10027874Sbrian# These are last, since it is nice to at least get the base system
10127874Sbrian# rebuilt before you do them.
10227874Sbrian.if defined(LOCAL_DIRS)
10327874Sbrian.for _DIR in ${LOCAL_DIRS}
10427874Sbrian.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
10527874SbrianSUBDIR+= ${_DIR}
10627874Sbrian.endif
10727874Sbrian.endfor
10827874Sbrian.endif
10927874Sbrian
11027874Sbrian.if defined(NOCLEANDIR)
11127874SbrianCLEANDIR=	clean cleandepend
11227874Sbrian.else
11327874SbrianCLEANDIR=	cleandir
11427874Sbrian.endif
11527874Sbrian
11627874SbrianSUP?=		cvsup
11727874SbrianSUPFLAGS?=	-g -L 2 -P -
11827874Sbrian.if defined(SUPHOST)
11927874SbrianSUPFLAGS+=	-h ${SUPHOST}
12027874Sbrian.endif
12127874Sbrian
12227874SbrianMAKEOBJDIRPREFIX?=	/usr/obj
12327874SbrianTARGET_ARCH?=	${MACHINE_ARCH}
12427874SbrianBUILD_ARCH!=	sysctl -n hw.machine_arch
12527874Sbrian.if ${BUILD_ARCH} == ${MACHINE_ARCH}
12627874SbrianOBJTREE=	${MAKEOBJDIRPREFIX}
12727874Sbrian.else
12859175SbrianOBJTREE=	${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
12927874Sbrian.endif
13027874SbrianWORLDTMP=	${OBJTREE}${.CURDIR}/${BUILD_ARCH}
13127874Sbrian# /usr/games added for fortune which depend on strfile
13227874SbrianSTRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
13327874SbrianTMPPATH=	${STRICTTMPPATH}:${PATH}
13427874SbrianOBJFORMAT_PATH?=	/usr/libexec
13527874Sbrian
13627874SbrianTMPDIR?=	/tmp
13727874SbrianTMPPID!=	echo $$$$
13827874SbrianINSTALLTMP=	${TMPDIR}/install.${TMPPID}
13927874Sbrian
14027874Sbrian#
14127874Sbrian# Building a world goes through the following stages
14227874Sbrian#
14327874Sbrian# 1. bootstrap-tool stage [BMAKE]
14427874Sbrian#	This stage is responsible for creating programs that
14559175Sbrian#	are needed for backward compatibility reasons. They
14627874Sbrian#	are not built as cross-tools.
14727874Sbrian# 2. build-tool stage [TMAKE]
14827874Sbrian#	This stage is responsible for creating the object
14959175Sbrian#	tree and building any tools that are needed during
15027874Sbrian#	the build process.
151133381Syar# 3. cross-tool stage [XMAKE]
152133381Syar#	This stage is responsible for creating any tools that
15327874Sbrian#	are needed for cross-builds. A cross-compiler is one
15427874Sbrian#	of them.
15527874Sbrian# 4. world stage [WMAKE]
15627874Sbrian#	This stage actually builds the world.
15727874Sbrian# 5. install stage (optional) [IMAKE]
15846073Simp#	This stage installs a previously built world.
15927874Sbrian#
16027874Sbrian
16127874Sbrian# Common environment for bootstrap related stages
16227874SbrianBOOTSTRAPENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
16346073Simp		DESTDIR=${WORLDTMP} \
16459022Sbrian		INSTALL="sh ${.CURDIR}/tools/install.sh" \
16559175Sbrian		MACHINE_ARCH=${BUILD_ARCH} \
16659022Sbrian		TOOLS_PREFIX=${WORLDTMP} \
16759022Sbrian		PATH=${TMPPATH}
16859022Sbrian
16959022Sbrian# Common environment for world related stages
17059022SbrianCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
17159022Sbrian		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
17227874Sbrian		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
17327874Sbrian		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
17427874Sbrian		PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0
17546073Simp
17627874Sbrian# bootstrap-tool stage
17727874SbrianBMAKEENV=	${BOOTSTRAPENV}
17827874SbrianBMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOHTML -DNOINFO \
17927874Sbrian			-DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
18046073Simp
18159022Sbrian# build-tool stage
18259175SbrianTMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
18327874Sbrian		INSTALL="sh ${.CURDIR}/tools/install.sh" \
18459022Sbrian		PATH=${TMPPATH}
18559022SbrianTMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1
18659175Sbrian
18759022Sbrian# cross-tool stage
18859022SbrianXMAKEENV=	${BOOTSTRAPENV} \
18959022Sbrian		TARGET_ARCH=${MACHINE_ARCH}
19059022SbrianXMAKE=		${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
19127874Sbrian			-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \
19227874Sbrian			-DNOSHARED
19327874Sbrian
19427874Sbrian# world stage
19527874SbrianWMAKEENV=	${CROSSENV} \
19627874Sbrian		DESTDIR=${WORLDTMP} \
19727874Sbrian		INSTALL="sh ${.CURDIR}/tools/install.sh" \
19827874Sbrian		PATH=${TMPPATH}
19927874SbrianWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
200133381Syar
201133381Syar# install stage
202133381SyarIMAKEENV=	${CROSSENV} \
203133381Syar		PATH=${STRICTTMPPATH}:${INSTALLTMP}
204133381SyarIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
20559175Sbrian
20627874Sbrian# kernel stage
20727874SbrianKMAKEENV=	${WMAKEENV} \
20827874Sbrian		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
20959175Sbrian
21027874SbrianUSRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
21191079Smarkm		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc
21259022Sbrian
21327874SbrianINCDIRS=	arpa g++/std objc protocols readline rpc rpcsvc openssl \
21427874Sbrian		security ss
21527874Sbrian
21691079Smarkm#
21791079Smarkm# buildworld
21891079Smarkm#
21927874Sbrian# Attempt to rebuild the entire system, with reasonable chance of
22059175Sbrian# success, regardless of how old your existing system is.
22127874Sbrian#
22227874Sbrianbuildworld:
22327874Sbrian	@echo
22427874Sbrian	@echo "--------------------------------------------------------------"
22527874Sbrian	@echo ">>> Rebuilding the temporary build tree"
22627874Sbrian	@echo "--------------------------------------------------------------"
22727874Sbrian.if !defined(NOCLEAN)
22827874Sbrian	rm -rf ${WORLDTMP}
22927874Sbrian.else
23027874Sbrian	for dir in bin games include lib sbin; do \
23127874Sbrian		rm -rf ${WORLDTMP}/usr/$$dir; \
23227874Sbrian	done
23359175Sbrian	# XXX - Work-around for broken cc/cc_tools/Makefile.
23427874Sbrian	# This is beyond dirty...
23527874Sbrian	rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
23627874Sbrian.endif
23727874Sbrian.for _dir in ${USRDIRS}
23827874Sbrian	mkdir -p ${WORLDTMP}/${_dir}
23927874Sbrian.endfor
24027874Sbrian.for _dir in ${INCDIRS}
24127874Sbrian	mkdir -p ${WORLDTMP}/usr/include/${_dir}
24227874Sbrian.endfor
24327874Sbrian	ln -sf ${.CURDIR}/sys ${WORLDTMP}
24427874Sbrian	@echo
24527874Sbrian	@echo "--------------------------------------------------------------"
24627874Sbrian	@echo ">>> stage 1: bootstrap tools"
24727874Sbrian	@echo "--------------------------------------------------------------"
24827874Sbrian	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
24959175Sbrian.if !defined(NOCLEAN)
25027874Sbrian	@echo
25127874Sbrian	@echo "--------------------------------------------------------------"
25227874Sbrian	@echo ">>> stage 2: cleaning up the object tree"
25359175Sbrian	@echo "--------------------------------------------------------------"
25427874Sbrian	cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
25527874Sbrian.endif
25627874Sbrian	@echo
25727874Sbrian	@echo "--------------------------------------------------------------"
25828025Sbrian	@echo ">>> stage 2: rebuilding the object tree"
25927874Sbrian	@echo "--------------------------------------------------------------"
26027874Sbrian	cd ${.CURDIR}; ${TMAKE} par-obj
26127874Sbrian	@echo
26227874Sbrian	@echo "--------------------------------------------------------------"
26327874Sbrian	@echo ">>> stage 2: build tools"
26427874Sbrian	@echo "--------------------------------------------------------------"
26527874Sbrian	cd ${.CURDIR}; ${TMAKE} build-tools
26659022Sbrian	@echo
26760836Sbrian	@echo "--------------------------------------------------------------"
26827874Sbrian	@echo ">>> stage 3: cross tools"
26959022Sbrian	@echo "--------------------------------------------------------------"
27027874Sbrian	cd ${.CURDIR}; ${XMAKE} cross-tools
27127874Sbrian	@echo
27227874Sbrian	@echo "--------------------------------------------------------------"
27327874Sbrian	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
27459022Sbrian	@echo "--------------------------------------------------------------"
27559022Sbrian	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
27660836Sbrian	@echo
27727874Sbrian	@echo "--------------------------------------------------------------"
27827874Sbrian	@echo ">>> stage 4: building libraries"
27960836Sbrian	@echo "--------------------------------------------------------------"
28027874Sbrian	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
28127874Sbrian	@echo
28227874Sbrian	@echo "--------------------------------------------------------------"
28360836Sbrian	@echo ">>> stage 4: make dependencies"
28427874Sbrian	@echo "--------------------------------------------------------------"
28527874Sbrian	cd ${.CURDIR}; ${WMAKE} par-depend
28627874Sbrian	@echo
28727874Sbrian	@echo "--------------------------------------------------------------"
28827874Sbrian	@echo ">>> stage 4: building everything.."
28959175Sbrian	@echo "--------------------------------------------------------------"
29027874Sbrian	cd ${.CURDIR}; ${WMAKE} all
29128025Sbrian
29228025Sbrianeverything:
29328025Sbrian	@echo "--------------------------------------------------------------"
29428025Sbrian	@echo ">>> Building everything.."
29527874Sbrian	@echo "--------------------------------------------------------------"
29659022Sbrian	cd ${.CURDIR}; ${WMAKE} all
29759022Sbrian
29859022Sbrian#
29959022Sbrian# installworld
30059022Sbrian#
30159022Sbrian# Installs everything compiled by a 'buildworld'.
30259022Sbrian#
30359175Sbrianinstallworld:
30459022Sbrian	mkdir -p ${INSTALLTMP}
30559022Sbrian	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
30628025Sbrian	    install ln make makewhatis mtree mv perl rm sed sh sysctl \
30728025Sbrian	    test true uname wc zic; do \
30827874Sbrian		cp `which $$prog` ${INSTALLTMP}; \
30959022Sbrian	done
31059022Sbrian	cd ${.CURDIR}; ${IMAKE} reinstall
31159022Sbrian	rm -rf ${INSTALLTMP}
31259022Sbrian
31359022Sbrian#
31459022Sbrian# reinstall
31559022Sbrian#
31659022Sbrian# If you have a build server, you can NFS mount the source and obj directories
31759022Sbrian# and do a 'make reinstall' on the *client* to install new binaries from the
31859022Sbrian# most recent server build.
31959175Sbrian#
32028025Sbrianreinstall:
32128025Sbrian	@echo "--------------------------------------------------------------"
32228025Sbrian	@echo ">>> Making hierarchy"
32328025Sbrian	@echo "--------------------------------------------------------------"
32427874Sbrian	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
32528025Sbrian	@echo
32628025Sbrian	@echo "--------------------------------------------------------------"
32728025Sbrian	@echo ">>> Installing everything.."
32827874Sbrian	@echo "--------------------------------------------------------------"
32928025Sbrian	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
33059175Sbrian.if !defined(NOMAN)
33127874Sbrian	@echo
33227874Sbrian	@echo "--------------------------------------------------------------"
33328025Sbrian	@echo ">>> Rebuilding man page indices"
33459175Sbrian	@echo "--------------------------------------------------------------"
33528025Sbrian	cd ${.CURDIR}/share/man; ${MAKE} makedb
33628025Sbrian.endif
33728025Sbrian
33828025Sbrian#
33928025Sbrian# distribworld
34028025Sbrian#
34159022Sbrian# Front-end to distribute to make sure the search path contains
34259175Sbrian# the object directory. Needed for miniperl.
34359022Sbrian#
34459022Sbriandistribworld:
34559022Sbrian	cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
34659022Sbrian
34759022Sbrian#
34859022Sbrian# buildkernel and installkernel
34928025Sbrian#
35028025Sbrian# Which kernels to build and/or install is specified by setting
35128025Sbrian# KERNCONF. If not defined a GENERIC kernel is built/installed.
35259022Sbrian# Only the existing (depending MACHINE) config files are used
35359175Sbrian# for building kernels and only the first of these is designated
35428025Sbrian# as the one being installed.
35559022Sbrian#
35659022Sbrian# Note that we have to use MACHINE instead of MACHINE_ARCH when
35759175Sbrian# we're in kernel-land. Since only MACHINE_ARCH is (expected) to
35859022Sbrian# be set to cross-build, we have to make sure MACHINE is set
35959022Sbrian# properly.
36059022Sbrian
36159022Sbrian.if !defined(KERNCONF) && defined(KERNEL)
36228025SbrianKERNCONF=	${KERNEL}
36328025SbrianKERNWARN=	yes
36428025Sbrian.else
36528025SbrianKERNCONF?=	GENERIC
36628025Sbrian.endif
36728025SbrianINSTKERNNAME?=	kernel
36828025Sbrian
36928025Sbrian# The only exotic MACHINE_ARCH/MACHINE combination valid at this
37028025Sbrian# time is i386/pc98. In all other cases set MACHINE equal to
37159175Sbrian# MACHINE_ARCH.
37228025Sbrian.if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
37328025SbrianMACHINE=	${MACHINE_ARCH}
37444598Sbrian.endif
37559175Sbrian
37644598SbrianKRNLSRCDIR=	${.CURDIR}/sys
37744598SbrianKRNLCONFDIR=	${KRNLSRCDIR}/${MACHINE}/conf
37844598SbrianKRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
37944598Sbrian
38044598SbrianBUILDKERNELS=
38144598SbrianINSTALLKERNEL=
38259022Sbrian.for _kernel in ${KERNCONF}
38359175Sbrian.if exists(${KRNLCONFDIR}/${_kernel})
38459022SbrianBUILDKERNELS+=	${_kernel}
38559022Sbrian.if empty(INSTALLKERNEL)
38659022SbrianINSTALLKERNEL= ${_kernel}
38759022Sbrian.endif
38859022Sbrian.endif
38959022Sbrian.endfor
39044598Sbrian
39144598Sbrian#
39244598Sbrian# buildkernel
39359022Sbrian#
39459175Sbrian# Builds all kernels defined by BUILDKERNELS.
39544598Sbrian#
39659022Sbrianbuildkernel:
39759022Sbrian.if empty(BUILDKERNELS)
39859175Sbrian	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
39959022Sbrian	@false
40059022Sbrian.endif
40159022Sbrian.if defined(KERNWARN)
40259022Sbrian	@echo "--------------------------------------------------------------"
40344598Sbrian	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
40444598Sbrian	@echo "--------------------------------------------------------------"
40544598Sbrian	@sleep 3
40644598Sbrian.endif
40744598Sbrian	@echo
40844598Sbrian.for _kernel in ${BUILDKERNELS}
40944598Sbrian	@echo "--------------------------------------------------------------"
41044598Sbrian	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
41144598Sbrian	@echo "--------------------------------------------------------------"
41259175Sbrian	@echo "===> ${_kernel}"
41344598Sbrian	mkdir -p ${KRNLOBJDIR}
41444598Sbrian.if !defined(NO_KERNELCONFIG)
41527874Sbrian	cd ${KRNLCONFDIR}; \
41627874Sbrian		PATH=${TMPPATH} \
41727874Sbrian		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
41828025Sbrian.endif
41928025Sbrian.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
42028025Sbrian	cd ${KRNLOBJDIR}/${_kernel}; \
42191079Smarkm	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
42228025Sbrian.endif
42328025Sbrian	cd ${KRNLOBJDIR}/${_kernel}; \
42427874Sbrian		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
42528025Sbrian		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
42628025Sbrian.if !defined(NO_KERNELDEPEND)
42728025Sbrian	cd ${KRNLOBJDIR}/${_kernel}; \
42828025Sbrian	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
42928025Sbrian.endif
43028025Sbrian	cd ${KRNLOBJDIR}/${_kernel}; \
43128025Sbrian	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
43228025Sbrian	@echo "--------------------------------------------------------------"
43328025Sbrian	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
43428025Sbrian	@echo "--------------------------------------------------------------"
43559175Sbrian.endfor
43659175Sbrian
43759175Sbrian#
43828025Sbrian# installkernel
43928025Sbrian#
44028025Sbrian# Install the kernel defined by INSTALLKERNEL
44159175Sbrian#
44228025Sbrianinstallkernel:
44328025Sbrian	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
44428025Sbrian	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
44528025Sbrianreinstallkernel:
44659175Sbrian	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
44728025Sbrian	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
44828025Sbrian
44927874Sbrian#
45028025Sbrian# kernel
45128025Sbrian#
45228025Sbrian# Short hand for `make buildkernel installkernel'
45328025Sbrian#
45428025Sbriankernel: buildkernel installkernel
45528025Sbrian
45644598Sbrian#
45759175Sbrian# update
45844598Sbrian#
45944598Sbrian# Update the source tree, by running sup and/or running cvs to update to the
46028025Sbrian# latest copy.
46159175Sbrian#
46228025Sbrianupdate:
46328025Sbrian.if defined(SUP_UPDATE)
46428025Sbrian	@echo "--------------------------------------------------------------"
46559175Sbrian	@echo ">>> Running ${SUP}"
46628025Sbrian	@echo "--------------------------------------------------------------"
46728025Sbrian.if defined(SUPFILE)
46828025Sbrian	@${SUP} ${SUPFLAGS} ${SUPFILE}
46959175Sbrian.endif
47059175Sbrian.if defined(SUPFILE1)
47128025Sbrian	@${SUP} ${SUPFLAGS} ${SUPFILE1}
47228025Sbrian.endif
47328025Sbrian.if defined(SUPFILE2)
47459175Sbrian	@${SUP} ${SUPFLAGS} ${SUPFILE2}
47559175Sbrian.endif
47628025Sbrian.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
47728025Sbrian	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
47828025Sbrian.endif
47959175Sbrian.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
48059175Sbrian	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
48128025Sbrian.endif
48228025Sbrian.endif
48328025Sbrian.if defined(CVS_UPDATE)
48459175Sbrian	@echo "--------------------------------------------------------------"
48559175Sbrian	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
48628025Sbrian	@echo "--------------------------------------------------------------"
48728025Sbrian	cd ${.CURDIR}; cvs -q update -A -P -d
48828025Sbrian.endif
48927874Sbrian
49028025Sbrian#
49127874Sbrian# most
49227874Sbrian#
49327874Sbrian# Build most of the user binaries on the existing system libs and includes.
49427874Sbrian#
49527874Sbrianmost:
49627874Sbrian	@echo "--------------------------------------------------------------"
49727874Sbrian	@echo ">>> Building programs only"
49827874Sbrian	@echo "--------------------------------------------------------------"
49927874Sbrian	cd ${.CURDIR}/bin;		${MAKE} all
50027874Sbrian	cd ${.CURDIR}/sbin;		${MAKE} all
50127874Sbrian	cd ${.CURDIR}/libexec;		${MAKE} all
50227874Sbrian	cd ${.CURDIR}/usr.bin;		${MAKE} all
50327874Sbrian	cd ${.CURDIR}/usr.sbin;		${MAKE} all
50427874Sbrian	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
50527874Sbrian	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
50627874Sbrian	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
507
508#
509# installmost
510#
511# Install the binaries built by the 'most' target.  This does not include
512# libraries or include files.
513#
514installmost:
515	@echo "--------------------------------------------------------------"
516	@echo ">>> Installing programs only"
517	@echo "--------------------------------------------------------------"
518	cd ${.CURDIR}/bin;		${MAKE} install
519	cd ${.CURDIR}/sbin;		${MAKE} install
520	cd ${.CURDIR}/libexec;		${MAKE} install
521	cd ${.CURDIR}/usr.bin;		${MAKE} install
522	cd ${.CURDIR}/usr.sbin;		${MAKE} install
523	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
524	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
525	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
526
527#
528# ------------------------------------------------------------------------
529#
530# From here onwards are utility targets used by the 'make world' and
531# related targets.  If your 'world' breaks, you may like to try to fix
532# the problem and manually run the following targets to attempt to
533# complete the build.  Beware, this is *not* guaranteed to work, you
534# need to have a pretty good grip on the current state of the system
535# to attempt to manually finish it.  If in doubt, 'make world' again.
536#
537
538#
539# bootstrap-tools: Build tools needed for compatibility
540#
541.if exists(${.CURDIR}/games) && !defined(NOGAMES)
542_strfile=	games/fortune/strfile
543.endif
544
545bootstrap-tools:
546.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.sbin/config \
547    gnu/usr.bin/gperf gnu/usr.bin/texinfo
548	cd ${.CURDIR}/${_tool}; \
549		${MAKE} obj; \
550		${MAKE} depend; \
551		${MAKE} all; \
552		${MAKE} install
553.endfor
554
555#
556# build-tools: Build special purpose build tools
557#
558.if exists(${.CURDIR}/games) && !defined(NOGAMES)
559_games=	games/adventure games/hack games/phantasia
560.endif
561
562.if exists(${.CURDIR}/share) && !defined(NOSHARE)
563_share=	share/syscons/scrnmaps
564.endif
565
566.if !defined(NO_FORTRAN)
567_fortran= gnu/usr.bin/cc/f771
568.endif
569
570.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
571    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
572_libroken4= kerberosIV/lib/libroken
573.endif
574
575.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
576    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
577_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
578.endif
579
580build-tools:
581.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
582    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.sbin/sysinstall
583	cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
584.endfor
585
586#
587# cross-tools: Build cross-building tools
588#
589# WARNING: Because the bootstrap tools are expected to run on the
590# build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
591# target is being made. TARGET_ARCH is *always* set to reflect the
592# target-machine (which you can set by specifying MACHINE_ARCH on
593# make's command-line, get it?).
594# The reason is simple: we build these tools not to be run on the
595# architecture we're cross-building, but on the architecture we're
596# currently building on (ie the host-machine) and we expect these
597# tools to produce output for the architecture we're trying to
598# cross-build.
599#
600.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
601_elf2exe=	usr.sbin/elf2exe
602.endif
603
604.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
605_btxld=	usr.sbin/btxld
606.endif
607
608.if !defined(NOPERL)
609_perl=	gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl
610.endif
611
612cross-tools:
613.for _tool in ${_btxld} ${_elf2exe} ${_perl} \
614    usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
615	cd ${.CURDIR}/${_tool}; \
616		${MAKE} obj; \
617		${MAKE} depend; \
618		${MAKE} all; \
619		${MAKE} install
620.endfor
621
622#
623# hierarchy - ensure that all the needed directories are present
624#
625hierarchy:
626	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
627
628#
629# includes - possibly generate and install the include files.
630#
631includes:
632	cd ${.CURDIR}/include;			${MAKE} -B all install
633	cd ${.CURDIR}/gnu/include;		${MAKE} install
634	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
635	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
636	cd ${.CURDIR}/gnu/lib/libreadline/readline;	${MAKE} beforeinstall
637	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
638	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
639	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
640	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
641	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
642.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
643.if exists(${.CURDIR}/secure/lib/libcrypto)
644	cd ${.CURDIR}/secure/lib/libcrypto;	${MAKE} beforeinstall
645.endif
646.if exists(${.CURDIR}/secure/lib/libssl)
647	cd ${.CURDIR}/secure/lib/libssl;	${MAKE} beforeinstall
648.endif
649.endif
650.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
651    defined(MAKE_KERBEROS4)
652	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
653	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
654	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
655	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
656	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
657	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
658.else
659	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
660.endif
661.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
662    defined(MAKE_KERBEROS5)
663	cd ${.CURDIR}/kerberos5/lib/libasn1;		${MAKE} beforeinstall
664	cd ${.CURDIR}/kerberos5/lib/libhdb;		${MAKE} beforeinstall
665	cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;	${MAKE} beforeinstall
666	cd ${.CURDIR}/kerberos5/lib/libkadm5srv;	${MAKE} beforeinstall
667	cd ${.CURDIR}/kerberos5/lib/libkafs5;		${MAKE} beforeinstall
668	cd ${.CURDIR}/kerberos5/lib/libkrb5;		${MAKE} beforeinstall
669	cd ${.CURDIR}/kerberos5/lib/libsl;		${MAKE} beforeinstall
670.endif
671.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
672	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
673.endif
674	cd ${.CURDIR}/gnu/lib/csu;		${MAKE} beforeinstall
675	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
676	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
677	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
678	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
679	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
680	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
681	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
682	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
683	cd ${.CURDIR}/lib/libfetch;		${MAKE} beforeinstall
684	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
685	cd ${.CURDIR}/lib/libkvm;		${MAKE} beforeinstall
686	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
687.if !defined(WANT_CSRG_LIBM)
688	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
689.endif
690	cd ${.CURDIR}/lib/libncp;		${MAKE} beforeinstall
691	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
692	cd ${.CURDIR}/lib/libnetgraph;		${MAKE} beforeinstall
693	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
694	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
695	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
696	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
697	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
698	cd ${.CURDIR}/lib/libsbuf;		${MAKE} beforeinstall
699	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
700	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
701	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
702	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
703	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
704	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
705	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
706	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
707	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
708	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
709
710#
711# libraries - build all libraries, and install them under ${DESTDIR}.
712#
713# The following dependencies exist between the libraries:
714#
715# lib*: csu libgcc_pic
716# libatm: libmd
717# libcam: libsbuf
718# libcrypt: libmd
719# libdialog: libncurses
720# libedit: libncurses
721# libg++: libm
722# libkrb: libcrypt
723# libopie: libmd
724# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
725#	  libskey libtacplus libutil libz libssh
726# libradius: libmd
727# libreadline: libncurses
728# libskey: libcrypt libmd
729# libss: libcom_err
730# libstc++: libm
731# libtacplus: libmd
732#
733# Across directories this comes down to (rougly):
734#
735# gnu/lib: lib/libm lib/libncurses
736# kerberosIV/lib kerberos5/lib: lib/libcrypt
737# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
738#             secure/lib/libssh lib/libz
739# secure/lib: lib/libmd
740#
741.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
742_csu=	lib/csu/${MACHINE_ARCH}.pcc
743.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
744_csu=	lib/csu/i386-elf
745.else
746_csu=	lib/csu/${MACHINE_ARCH}
747.endif
748
749.if !defined(NOSECURE) && !defined(NOCRYPT)
750_secure_lib=	secure/lib
751.endif
752
753.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
754_kerberosIV_lib=	kerberosIV/lib
755.endif
756
757.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
758_kerberos5_lib=	kerberos5/lib
759.endif
760
761.if defined(WANT_CSRG_LIBM)
762_libm=	lib/libm
763.else
764_libm=	lib/msun
765.endif
766
767.if ${MACHINE_ARCH} == "i386"
768_libkeycap=	usr.sbin/pcvt/keycap
769.endif
770
771.if !defined(NOPERL)
772_libperl=	gnu/usr.bin/perl/libperl
773.endif
774
775libraries:
776.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
777    ${_secure_lib} ${_kerberosIV_lib} \
778    ${_kerberos5_lib} lib/libcom_err ${_libm} lib/libncurses \
779    lib/libopie lib/libradius lib/libsbuf lib/libskey lib/libtacplus \
780    lib/libutil lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
781.if exists(${.CURDIR}/${_lib})
782	cd ${.CURDIR}/${_lib}; \
783		${MAKE} depend; \
784		${MAKE} all; \
785		${MAKE} install
786.endif
787.endfor
788
789.for __target in clean cleandepend cleandir depend obj
790.for entry in ${SUBDIR}
791${entry}.${__target}__D: .PHONY
792	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
793		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
794		edir=${entry}.${MACHINE_ARCH}; \
795		cd ${.CURDIR}/$${edir}; \
796	else \
797		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
798		edir=${entry}; \
799		cd ${.CURDIR}/$${edir}; \
800	fi; \
801	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
802.endfor
803par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
804.endfor
805
806.include <bsd.subdir.mk>
807