Makefile.inc1 revision 270274
133965Sjdp#
278828Sobrien# $FreeBSD: stable/10/Makefile.inc1 270274 2014-08-21 14:56:57Z ian $
378828Sobrien#
433965Sjdp# Make command line options:
533965Sjdp#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
633965Sjdp#	-DNO_CLEAN do not clean at all
733965Sjdp#	-DDB_FROM_SRC use the user/group databases in src/etc instead of
833965Sjdp#	    the system database when installing.
933965Sjdp#	-DNO_SHARE do not go into share subdir
1033965Sjdp#	-DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
1133965Sjdp#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1233965Sjdp#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
1333965Sjdp#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
1433965Sjdp#	-DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
1533965Sjdp#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
1633965Sjdp#	-DNO_ROOT install without using root privilege
1733965Sjdp#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
1833965Sjdp#	-DNO_CTF do not run the DTrace CTF conversion tools on built objects
1933965Sjdp#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2033965Sjdp#	LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
2133965Sjdp#	LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
2233965Sjdp#	LOCAL_MTREE="list of mtree files" to process to allow local directories
2333965Sjdp#	    to be created before files are installed
2433965Sjdp#	LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
2533965Sjdp#	    list
2633965Sjdp#	METALOG="path to metadata log" to write permission and ownership
2733965Sjdp#	    when NO_ROOT is set.  (default: ${DESTDIR}/METALOG)
2833965Sjdp#	TARGET="machine" to crossbuild world for a different machine type
2933965Sjdp#	TARGET_ARCH= may be required when a TARGET supports multiple endians
3033965Sjdp#	BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
3133965Sjdp#	WORLD_FLAGS= additional flags to pass to make(1) during buildworld
3233965Sjdp#	KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
3333965Sjdp
3433965Sjdp#
3533965Sjdp# The intended user-driven targets are:
3633965Sjdp# buildworld  - rebuild *everything*, including glue to help do upgrades
3733965Sjdp# installworld- install everything built by "buildworld"
3833965Sjdp# doxygen     - build API documentation of the kernel
3933965Sjdp# update      - convenient way to update your source tree (eg: svn/svnup)
4033965Sjdp#
4133965Sjdp# Standard targets (not defined here) are documented in the makefiles in
4233965Sjdp# /usr/share/mk.  These include:
4333965Sjdp#		obj depend all install clean cleandepend cleanobj
4433965Sjdp
4533965Sjdp.if !defined(TARGET) || !defined(TARGET_ARCH)
4633965Sjdp.error "Both TARGET and TARGET_ARCH must be defined."
4733965Sjdp.endif
4833965Sjdp
4933965Sjdp.include <bsd.own.mk>
5033965Sjdp.include <bsd.arch.inc.mk>
5133965Sjdp.include <bsd.compiler.mk>
5233965Sjdp
5333965Sjdp# We must do share/info early so that installation of info `dir'
5433965Sjdp# entries works correctly.  Do it first since it is less likely to
5533965Sjdp# grow dependencies on include and lib than vice versa.
5633965Sjdp#
5733965Sjdp# We must do lib/ and libexec/ before bin/, because if installworld
5833965Sjdp# installs a new /bin/sh, the 'make' command will *immediately*
5933965Sjdp# use that new version.  And the new (dynamically-linked) /bin/sh
6033965Sjdp# will expect to find appropriate libraries in /lib and /libexec.
6133965Sjdp#
6233965SjdpSRCDIR?=	${.CURDIR}
6333965Sjdp.if defined(SUBDIR_OVERRIDE)
6433965SjdpSUBDIR=	${SUBDIR_OVERRIDE}
6533965Sjdp.else
6633965SjdpSUBDIR=	share/info lib libexec
6733965SjdpSUBDIR+=bin
6833965Sjdp.if ${MK_GAMES} != "no"
6989857SobrienSUBDIR+=games
7033965Sjdp.endif
7133965Sjdp.if ${MK_CDDL} != "no"
7233965SjdpSUBDIR+=cddl
7333965Sjdp.endif
7433965SjdpSUBDIR+=gnu include
7533965Sjdp.if ${MK_KERBEROS} != "no"
7633965SjdpSUBDIR+=kerberos5
7733965Sjdp.endif
7833965Sjdp.if ${MK_RESCUE} != "no"
7933965SjdpSUBDIR+=rescue
8033965Sjdp.endif
8133965SjdpSUBDIR+=sbin
8233965Sjdp.if ${MK_CRYPT} != "no"
8333965SjdpSUBDIR+=secure
8433965Sjdp.endif
8533965Sjdp.if !defined(NO_SHARE)
8633965SjdpSUBDIR+=share
8733965Sjdp.endif
8833965SjdpSUBDIR+=sys usr.bin usr.sbin
8933965Sjdp.if ${MK_TESTS} != "no"
9033965SjdpSUBDIR+=	tests
9133965Sjdp.endif
9233965Sjdp.if ${MK_OFED} != "no"
9333965SjdpSUBDIR+=contrib/ofed
9433965Sjdp.endif
9533965Sjdp#
9633965Sjdp# We must do etc/ last for install/distribute to work.
9733965Sjdp#
9833965SjdpSUBDIR+=etc
9933965Sjdp
10033965Sjdp# These are last, since it is nice to at least get the base system
10133965Sjdp# rebuilt before you do them.
10233965Sjdp.for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS}
10333965Sjdp.if exists(${.CURDIR}/${_DIR}/Makefile)
10433965SjdpSUBDIR+= ${_DIR}
10533965Sjdp.endif
10633965Sjdp.endfor
10733965Sjdp.endif
10833965Sjdp
10933965Sjdp.if defined(NOCLEAN)
11033965SjdpNO_CLEAN=	${NOCLEAN}
11133965Sjdp.endif
11233965Sjdp.if defined(NO_CLEANDIR)
11333965SjdpCLEANDIR=	clean cleandepend
11433965Sjdp.else
11533965SjdpCLEANDIR=	cleandir
11633965Sjdp.endif
11733965Sjdp
11833965SjdpLOCAL_TOOL_DIRS?=
11933965Sjdp
12033965SjdpBUILDENV_SHELL?=/bin/sh
12133965Sjdp
12277298SobrienSVN?=		/usr/local/bin/svn
12377298SobrienSVNFLAGS?=	-r HEAD
12433965Sjdp
12533965SjdpMAKEOBJDIRPREFIX?=	/usr/obj
12689857Sobrien.if !defined(OSRELDATE)
12789857Sobrien.if exists(/usr/include/osreldate.h)
12833965SjdpOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
12933965Sjdp		/usr/include/osreldate.h
13033965Sjdp.else
13133965SjdpOSRELDATE=	0
13260484Sobrien.endif
13360484Sobrien.endif
13460484Sobrien
13560484Sobrien.if !defined(VERSION)
13660484SobrienREVISION!=	make -C ${SRCDIR}/release -V REVISION
13760484SobrienBRANCH!=	make -C ${SRCDIR}/release -V BRANCH
13860484SobrienSRCRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
13960484Sobrien		${SRCDIR}/sys/sys/param.h
14033965SjdpVERSION=	FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
14133965Sjdp.endif
14233965Sjdp
14333965SjdpKNOWN_ARCHES?=	amd64 arm armeb/arm armv6/arm i386 i386/pc98 ia64 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
14433965Sjdp.if ${TARGET} == ${TARGET_ARCH}
14533965Sjdp_t=		${TARGET}
14633965Sjdp.else
14733965Sjdp_t=		${TARGET_ARCH}/${TARGET}
14833965Sjdp.endif
14933965Sjdp.for _t in ${_t}
15033965Sjdp.if empty(KNOWN_ARCHES:M${_t})
15133965Sjdp.error Unknown target ${TARGET_ARCH}:${TARGET}.
15233965Sjdp.endif
15333965Sjdp.endfor
15433965Sjdp
15533965Sjdp.if ${TARGET} == ${MACHINE}
15633965SjdpTARGET_CPUTYPE?=${CPUTYPE}
15733965Sjdp.else
15833965SjdpTARGET_CPUTYPE?=
15933965Sjdp.endif
16033965Sjdp
16133965Sjdp.if !empty(TARGET_CPUTYPE)
16233965Sjdp_TARGET_CPUTYPE=${TARGET_CPUTYPE}
16333965Sjdp.else
16433965Sjdp_TARGET_CPUTYPE=dummy
16533965Sjdp.endif
16633965Sjdp_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
16733965Sjdp		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
16833965Sjdp.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
16933965Sjdp.error CPUTYPE global should be set with ?=.
17033965Sjdp.endif
17133965Sjdp.if make(buildworld)
17233965SjdpBUILD_ARCH!=	uname -p
17377298Sobrien.if ${MACHINE_ARCH} != ${BUILD_ARCH}
17460484Sobrien.error To cross-build, set TARGET_ARCH.
17560484Sobrien.endif
17633965Sjdp.endif
17733965Sjdp.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
17833965SjdpOBJTREE=	${MAKEOBJDIRPREFIX}
17933965Sjdp.else
18033965SjdpOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
18133965Sjdp.endif
18233965SjdpWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
18333965Sjdp# /usr/games added for fortune which depend on strfile
18433965SjdpBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
18533965SjdpXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
18633965SjdpSTRICTTMPPATH=	${BPATH}:${XPATH}
18733965SjdpTMPPATH=	${STRICTTMPPATH}:${PATH}
18833965Sjdp
18933965Sjdp#
19089857Sobrien# Avoid running mktemp(1) unless actually needed.
19189857Sobrien# It may not be functional, e.g., due to new ABI
19289857Sobrien# when in the middle of installing over this system.
19389857Sobrien#
19433965Sjdp.if make(distributeworld) || make(installworld)
19533965SjdpINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
19689857Sobrien.endif
19789857Sobrien
19889857Sobrien#
19989857Sobrien# Building a world goes through the following stages
20033965Sjdp#
20133965Sjdp# 1. legacy stage [BMAKE]
20233965Sjdp#	This stage is responsible for creating compatibility
20377298Sobrien#	shims that are needed by the bootstrap-tools,
20433965Sjdp#	build-tools and cross-tools stages.
20533965Sjdp# 1. bootstrap-tools stage [BMAKE]
20689857Sobrien#	This stage is responsible for creating programs that
20733965Sjdp#	are needed for backward compatibility reasons. They
20833965Sjdp#	are not built as cross-tools.
20989857Sobrien# 2. build-tools stage [TMAKE]
21033965Sjdp#	This stage is responsible for creating the object
21133965Sjdp#	tree and building any tools that are needed during
21260484Sobrien#	the build process.
21360484Sobrien# 3. cross-tools stage [XMAKE]
21489857Sobrien#	This stage is responsible for creating any tools that
21560484Sobrien#	are needed for cross-builds. A cross-compiler is one
21689857Sobrien#	of them.
21760484Sobrien# 4. world stage [WMAKE]
21889857Sobrien#	This stage actually builds the world.
21989857Sobrien# 5. install stage (optional) [IMAKE]
22089857Sobrien#	This stage installs a previously built world.
22189857Sobrien#
22289857Sobrien
22389857SobrienBOOTSTRAPPING?=	0
22489857Sobrien
22589857Sobrien# Common environment for world related stages
22689857SobrienCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
22789857Sobrien		MACHINE_ARCH=${TARGET_ARCH} \
22889857Sobrien		MACHINE=${TARGET} \
22933965Sjdp		CPUTYPE=${TARGET_CPUTYPE}
23033965Sjdp.if ${MK_GROFF} != "no"
23133965SjdpCROSSENV+=	GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
23277298Sobrien		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
23333965Sjdp		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
23433965Sjdp.endif
23589857Sobrien
23633965Sjdp# bootstrap-tools stage
23733965SjdpBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
23833965Sjdp		PATH=${BPATH}:${PATH} \
23989857Sobrien		WORLDTMP=${WORLDTMP} \
24033965Sjdp		VERSION="${VERSION}" \
24189857Sobrien		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
24233965Sjdp		COMPILER_TYPE=${COMPILER_TYPE}
24389857SobrienBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
24489857Sobrien		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
24589857Sobrien		DESTDIR= \
24689857Sobrien		BOOTSTRAPPING=${OSRELDATE} \
24789857Sobrien		SSP_CFLAGS= \
24889857Sobrien		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
24989857Sobrien		-DNO_PIC -DNO_PROFILE -DNO_SHARED \
25089857Sobrien		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD -DNO_TESTS
25189857Sobrien
25289857Sobrien# build-tools stage
25389857SobrienTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
25489857Sobrien		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
25589857Sobrien		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
25689857Sobrien		DESTDIR= \
25733965Sjdp		BOOTSTRAPPING=${OSRELDATE} \
25833965Sjdp		SSP_CFLAGS= \
25933965Sjdp		-DNO_LINT \
26077298Sobrien		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD -DNO_TESTS
26133965Sjdp
26233965Sjdp# cross-tools stage
26333965SjdpXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
26433965Sjdp		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
26533965Sjdp		-DWITHOUT_GDB -DNO_TESTS
26633965Sjdp
26733965Sjdp# kernel-tools stage
26877298SobrienKTMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
26933965Sjdp		PATH=${BPATH}:${PATH} \
27089857Sobrien		WORLDTMP=${WORLDTMP} \
27189857Sobrien		VERSION="${VERSION}" \
27289857Sobrien		COMPILER_TYPE=${COMPILER_TYPE}
27377298SobrienKTMAKE=		TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
27489857Sobrien		${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
27577298Sobrien		DESTDIR= \
27689857Sobrien		BOOTSTRAPPING=${OSRELDATE} \
27789857Sobrien		SSP_CFLAGS= \
27889857Sobrien		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
27989857Sobrien		-DNO_PIC -DNO_PROFILE -DNO_SHARED \
28089857Sobrien		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
28189857Sobrien
28289857Sobrien# world stage
28389857SobrienWMAKEENV=	${CROSSENV} \
28489857Sobrien		_SHLIBDIRPREFIX=${WORLDTMP} \
28589857Sobrien		_LDSCRIPTROOT= \
28633965Sjdp		VERSION="${VERSION}" \
28733965Sjdp		INSTALL="sh ${.CURDIR}/tools/install.sh" \
28833965Sjdp		PATH=${TMPPATH}
28977298Sobrien
29033965Sjdp# make hierarchy
29133965SjdpHMAKE=		PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
29233965Sjdp.if defined(NO_ROOT)
29333965SjdpHMAKE+=		PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
29433965Sjdp.endif
29533965Sjdp
29633965Sjdp.if ${MK_CDDL} == "no"
29789857SobrienWMAKEENV+=	NO_CTF=1
29877298Sobrien.endif
29933965Sjdp
30077298Sobrien.if defined(CROSS_TOOLCHAIN_PREFIX)
30189857SobrienCROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
30289857SobrienCROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
30389857Sobrien.endif
30477298SobrienXCOMPILERS=	CC CXX CPP
30589857Sobrien.for COMPILER in ${XCOMPILERS}
30677298Sobrien.if defined(CROSS_COMPILER_PREFIX)
30789857SobrienX${COMPILER}?=	${CROSS_COMPILER_PREFIX}${${COMPILER}}
30889857Sobrien.else
30989857SobrienX${COMPILER}?=	${${COMPILER}}
31089857Sobrien.endif
31189857Sobrien.endfor
31289857SobrienXBINUTILS=	AS AR LD NM OBJDUMP RANLIB STRINGS
31389857Sobrien.for BINUTIL in ${XBINUTILS}
31489857Sobrien.if defined(CROSS_BINUTILS_PREFIX)
31589857SobrienX${BINUTIL}?=	${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
31689857Sobrien.else
31789857SobrienX${BINUTIL}?=	${${BINUTIL}}
31889857Sobrien.endif
31989857Sobrien.endfor
32089857SobrienWMAKEENV+=	CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
32189857Sobrien		CPP="${XCPP} ${XFLAGS}" \
32289857Sobrien		AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
32333965Sjdp		OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
32433965Sjdp
32533965Sjdp.if ${XCC:T:Mgcc} == "gcc"
32677298SobrienWMAKE_COMPILER_TYPE=	gcc
32733965Sjdp.elif ${XCC:T:Mclang} == "clang"
32833965SjdpWMAKE_COMPILER_TYPE=	clang
32933965Sjdp.elif ${MK_CLANG_IS_CC} == "no"
33033965SjdpWMAKE_COMPILER_TYPE=	gcc
33133965Sjdp.else
33233965SjdpWMAKE_COMPILER_TYPE=	clang
33333965Sjdp.endif
33460484SobrienIMAKE_COMPILER_TYPE=	COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
33560484Sobrien
33689857Sobrien.if ${XCC:M/*}
33789857SobrienXFLAGS=		--sysroot=${WORLDTMP}
33889857Sobrien.if defined(CROSS_BINUTILS_PREFIX)
33960484Sobrien# In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
34089857Sobrien# directory, but the compiler will look in the right place for it's
34160484Sobrien# tools so we don't need to tell it where to look.
34289857Sobrien.if exists(${CROSS_BINUTILS_PREFIX})
34389857SobrienXFLAGS+=	-B${CROSS_BINUTILS_PREFIX}
34489857Sobrien.endif
34589857Sobrien.else
34689857SobrienXFLAGS+=	-B${WORLDTMP}/usr/bin
34789857Sobrien.endif
34889857Sobrien.if ${TARGET_ARCH} != ${MACHINE_ARCH} && ${WMAKE_COMPILER_TYPE} == "clang"
34933965Sjdp.if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
35033965Sjdp${MK_ARM_EABI} != "no"
35133965SjdpTARGET_ABI=	gnueabi
35233965Sjdp.else
35333965SjdpTARGET_ABI=	unknown
35477298Sobrien.endif
35533965SjdpTARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
35633965SjdpXFLAGS+=	-target ${TARGET_TRIPLE}
35733965Sjdp.endif
35833965Sjdp.endif
35933965Sjdp
36033965SjdpWMAKEENV+=	COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
36133965SjdpWMAKE=		${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
36277298Sobrien
36389857Sobrien.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
36489857Sobrien# 32 bit world
36589857SobrienLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
36689857Sobrien
36789857Sobrien.if ${TARGET_ARCH} == "amd64"
36889857Sobrien.if empty(TARGET_CPUTYPE)
36989857SobrienLIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
37089857Sobrien.else
37189857SobrienLIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
37289857Sobrien.endif
37333965SjdpLIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
37433965Sjdp		MACHINE_CPU="i686 mmx sse sse2"
37533965SjdpLIB32WMAKEFLAGS=	\
37677298Sobrien		AS="${AS} --32" \
37733965Sjdp		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
37833965Sjdp
37933965Sjdp.elif ${TARGET_ARCH} == "powerpc64"
38033965Sjdp.if empty(TARGET_CPUTYPE)
38133965SjdpLIB32CPUFLAGS=	-mcpu=powerpc
38233965Sjdp.else
38333965SjdpLIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
38460484Sobrien.endif
38560484SobrienLIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
38689857SobrienLIB32WMAKEFLAGS=	\
38789857Sobrien		LD="${LD} -m elf32ppc_fbsd"
38889857Sobrien.endif
38960484Sobrien
39060484Sobrien
39189857SobrienLIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
39289857Sobrien		-isystem ${LIB32TMP}/usr/include/ \
39360484Sobrien		-L${LIB32TMP}/usr/lib32 \
39460484Sobrien		-B${LIB32TMP}/usr/lib32
39560484Sobrien.if ${XCC:M/*}
39689857SobrienLIB32FLAGS+=		--sysroot=${WORLDTMP}
39789857Sobrien.endif
39860484Sobrien
39989857Sobrien# Yes, the flags are redundant.
40089857SobrienLIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
40189857Sobrien		_SHLIBDIRPREFIX=${LIB32TMP} \
40233965Sjdp		_LDSCRIPTROOT=${LIB32TMP} \
40333965Sjdp		VERSION="${VERSION}" \
40433965Sjdp		INSTALL="sh ${.CURDIR}/tools/install.sh" \
40533965Sjdp		PATH=${TMPPATH} \
40633965Sjdp		LIBDIR=/usr/lib32 \
40733965Sjdp		SHLIBDIR=/usr/lib32 \
40833965Sjdp		LIBPRIVATEDIR=/usr/lib32/private \
40933965Sjdp		COMPILER_TYPE=${WMAKE_COMPILER_TYPE} \
41077298Sobrien		DTRACE="${DTRACE} -32"
41189857SobrienLIB32WMAKEFLAGS+=	\
41289857Sobrien		CC="${XCC} ${LIB32FLAGS}" \
41389857Sobrien		CXX="${XCXX} ${LIB32FLAGS}" \
41489857Sobrien		DESTDIR=${LIB32TMP} \
41589857Sobrien		-DCOMPAT_32BIT \
41689857Sobrien		-DLIBRARIES_ONLY \
41789857Sobrien		-DNO_CPU_CFLAGS \
41889857Sobrien		-DNO_CTF \
41933965Sjdp		-DNO_LINT \
42033965Sjdp		-DNO_TESTS
42177298Sobrien
42233965SjdpLIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
42333965Sjdp		-DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
42433965SjdpLIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
42533965Sjdp		${IMAKE_INSTALL}
42633965Sjdp.endif
42733965Sjdp
42889857SobrienIMAKEENV=	${CROSSENV:N_LDSCRIPTROOT=*}
42989857SobrienIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1 \
43033965Sjdp		${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
43133965Sjdp.if empty(.MAKEFLAGS:M-n)
43233965SjdpIMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
43333965Sjdp		LD_LIBRARY_PATH=${INSTALLTMP} \
43433965Sjdp		PATH_LOCALE=${INSTALLTMP}/locale
43533965SjdpIMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
43633965Sjdp.else
43733965SjdpIMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
43889857Sobrien.endif
43989857Sobrien.if defined(DB_FROM_SRC)
44089857SobrienINSTALLFLAGS+=	-N ${.CURDIR}/etc
44133965SjdpMTREEFLAGS+=	-N ${.CURDIR}/etc
44233965Sjdp.endif
44377298Sobrien_INSTALL_DDIR=	${DESTDIR}/${DISTDIR}
44433965SjdpINSTALL_DDIR=	${_INSTALL_DDIR:S://:/:g:C:/$::}
44533965Sjdp.if defined(NO_ROOT)
44633965SjdpMETALOG?=	${DESTDIR}/${DISTDIR}/METALOG
44733965SjdpIMAKE+=		-DNO_ROOT METALOG=${METALOG}
44833965SjdpINSTALLFLAGS+=	-U -M ${METALOG} -D ${INSTALL_DDIR}
44933965SjdpMTREEFLAGS+=	-W
45089857Sobrien.endif
45189857Sobrien.if defined(DB_FROM_SRC) || defined(NO_ROOT)
45233965SjdpIMAKE_INSTALL=	INSTALL="install ${INSTALLFLAGS}"
45333965SjdpIMAKE_MTREE=	MTREE_CMD="nmtree ${MTREEFLAGS}"
45433965Sjdp.endif
45533965Sjdp
45633965Sjdp# kernel stage
45733965SjdpKMAKEENV=	${WMAKEENV}
45833965SjdpKMAKE=		${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
45933965Sjdp
46089857Sobrien#
46189857Sobrien# buildworld
46289857Sobrien#
46333965Sjdp# Attempt to rebuild the entire system, with reasonable chance of
46433965Sjdp# success, regardless of how old your existing system is.
46533965Sjdp#
46633965Sjdp_worldtmp:
46733965Sjdp.if ${.CURDIR:C/[^,]//g} != ""
46833965Sjdp#	The m4 build of sendmail files doesn't like it if ',' is used
46933965Sjdp#	anywhere in the path of it's files.
47033965Sjdp	@echo
47133965Sjdp	@echo "*** Error: path to source tree contains a comma ','"
47233965Sjdp	@echo
47389857Sobrien	false
47489857Sobrien.endif
47533965Sjdp	@echo
47633965Sjdp	@echo "--------------------------------------------------------------"
47733965Sjdp	@echo ">>> Rebuilding the temporary build tree"
47860484Sobrien	@echo "--------------------------------------------------------------"
47933965Sjdp.if !defined(NO_CLEAN)
48033965Sjdp	rm -rf ${WORLDTMP}
48160484Sobrien.if defined(LIB32TMP)
48233965Sjdp	rm -rf ${LIB32TMP}
48360484Sobrien.endif
48460484Sobrien.else
48589857Sobrien	rm -rf ${WORLDTMP}/legacy/usr/include
48689857Sobrien#	XXX - These three can depend on any header file.
48733965Sjdp	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
48833965Sjdp	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
48933965Sjdp	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
49033965Sjdp.endif
49133965Sjdp.for _dir in \
49233965Sjdp    lib usr legacy/bin legacy/usr
49333965Sjdp	mkdir -p ${WORLDTMP}/${_dir}
49433965Sjdp.endfor
49533965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
49633965Sjdp	    -p ${WORLDTMP}/legacy/usr >/dev/null
49733965Sjdp.if ${MK_GROFF} != "no"
49833965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
49933965Sjdp	    -p ${WORLDTMP}/legacy/usr >/dev/null
50033965Sjdp.endif
50133965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
50233965Sjdp	    -p ${WORLDTMP}/usr >/dev/null
50333965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
50433965Sjdp	    -p ${WORLDTMP}/usr/include >/dev/null
50533965Sjdp	ln -sf ${.CURDIR}/sys ${WORLDTMP}
50689857Sobrien.if ${MK_DEBUG_FILES} != "no"
50789857Sobrien	# We could instead disable debug files for these build stages
50889857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
50989857Sobrien	    -p ${WORLDTMP}/legacy/usr/lib >/dev/null
51089857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
51189857Sobrien	    -p ${WORLDTMP}/usr/lib >/dev/null
51289857Sobrien.endif
51389857Sobrien.if ${MK_TESTS} != "no"
51489857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
51589857Sobrien	    -p ${WORLDTMP}/usr >/dev/null
51633965Sjdp.endif
51733965Sjdp.for _mtree in ${LOCAL_MTREE}
51833965Sjdp	mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
51933965Sjdp.endfor
52033965Sjdp_legacy:
52133965Sjdp	@echo
52233965Sjdp	@echo "--------------------------------------------------------------"
52333965Sjdp	@echo ">>> stage 1.1: legacy release compatibility shims"
52433965Sjdp	@echo "--------------------------------------------------------------"
52533965Sjdp	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
52633965Sjdp_bootstrap-tools:
52733965Sjdp	@echo
52833965Sjdp	@echo "--------------------------------------------------------------"
52933965Sjdp	@echo ">>> stage 1.2: bootstrap tools"
53033965Sjdp	@echo "--------------------------------------------------------------"
53189857Sobrien	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
53289857Sobrien_cleanobj:
53333965Sjdp.if !defined(NO_CLEAN)
53433965Sjdp	@echo
53533965Sjdp	@echo "--------------------------------------------------------------"
53689857Sobrien	@echo ">>> stage 2.1: cleaning up the object tree"
53733965Sjdp	@echo "--------------------------------------------------------------"
53833965Sjdp	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
53989857Sobrien.if defined(LIB32TMP)
54033965Sjdp	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
54189857Sobrien.endif
54277298Sobrien.endif
54333965Sjdp_obj:
54433965Sjdp	@echo
54589857Sobrien	@echo "--------------------------------------------------------------"
54689857Sobrien	@echo ">>> stage 2.2: rebuilding the object tree"
54733965Sjdp	@echo "--------------------------------------------------------------"
54833965Sjdp	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
54933965Sjdp_build-tools:
55033965Sjdp	@echo
55133965Sjdp	@echo "--------------------------------------------------------------"
55233965Sjdp	@echo ">>> stage 2.3: build tools"
55333965Sjdp	@echo "--------------------------------------------------------------"
55433965Sjdp	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
55533965Sjdp_cross-tools:
55633965Sjdp	@echo
55733965Sjdp	@echo "--------------------------------------------------------------"
55877298Sobrien	@echo ">>> stage 3: cross tools"
55933965Sjdp	@echo "--------------------------------------------------------------"
56033965Sjdp	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
56133965Sjdp	${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
56233965Sjdp_includes:
56333965Sjdp	@echo
56433965Sjdp	@echo "--------------------------------------------------------------"
56533965Sjdp	@echo ">>> stage 4.1: building includes"
56633965Sjdp	@echo "--------------------------------------------------------------"
56733965Sjdp	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
56833965Sjdp_libraries:
56933965Sjdp	@echo
57033965Sjdp	@echo "--------------------------------------------------------------"
57133965Sjdp	@echo ">>> stage 4.2: building libraries"
57233965Sjdp	@echo "--------------------------------------------------------------"
57333965Sjdp	${_+_}cd ${.CURDIR}; \
57433965Sjdp	    ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
57533965Sjdp	    -DWITHOUT_MAN -DNO_PROFILE -DNO_TESTS libraries
57633965Sjdp_depend:
57733965Sjdp	@echo
57833965Sjdp	@echo "--------------------------------------------------------------"
57933965Sjdp	@echo ">>> stage 4.3: make dependencies"
58033965Sjdp	@echo "--------------------------------------------------------------"
58133965Sjdp	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
58233965Sjdpeverything:
58333965Sjdp	@echo
58489857Sobrien	@echo "--------------------------------------------------------------"
58589857Sobrien	@echo ">>> stage 4.4: building everything"
58633965Sjdp	@echo "--------------------------------------------------------------"
58733965Sjdp	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
58889857Sobrien.if defined(LIB32TMP)
58933965Sjdpbuild32:
59033965Sjdp	@echo
59189857Sobrien	@echo "--------------------------------------------------------------"
59289857Sobrien	@echo ">>> stage 5.1: building 32 bit shim libraries"
59389857Sobrien	@echo "--------------------------------------------------------------"
59489857Sobrien	mkdir -p ${LIB32TMP}/usr/include
59589857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
59689857Sobrien	    -p ${LIB32TMP}/usr >/dev/null
59789857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
59889857Sobrien	    -p ${LIB32TMP}/usr/include >/dev/null
59989857Sobrien.if ${MK_DEBUG_FILES} != "no"
60089857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
60189857Sobrien	    -p ${LIB32TMP}/usr/lib >/dev/null
60289857Sobrien.endif
60333965Sjdp	mkdir -p ${WORLDTMP}
60433965Sjdp	ln -sf ${.CURDIR}/sys ${WORLDTMP}
60533965Sjdp.for _t in obj includes
60633965Sjdp	cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
60733965Sjdp	cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
60833965Sjdp.if ${MK_CDDL} != "no"
60933965Sjdp	cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
61060484Sobrien.endif
61160484Sobrien	cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
61260484Sobrien.if ${MK_CRYPT} != "no"
61360484Sobrien	cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
61489857Sobrien.endif
61589857Sobrien.if ${MK_KERBEROS} != "no"
61689857Sobrien	cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
61733965Sjdp.endif
61833965Sjdp.endfor
61933965Sjdp.for _dir in usr.bin/lex/lib
62033965Sjdp	cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
62189857Sobrien.endfor
62289857Sobrien.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
62333965Sjdp	cd ${.CURDIR}/${_dir}; \
62433965Sjdp	    WORLDTMP=${WORLDTMP} \
62533965Sjdp	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
62633965Sjdp	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
62733965Sjdp	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
62833965Sjdp	    -DEARLY_BUILD build-tools
62933965Sjdp.endfor
63033965Sjdp	cd ${.CURDIR}; \
63133965Sjdp	    ${LIB32WMAKE} -f Makefile.inc1 libraries
63233965Sjdp.for _t in obj depend all
63333965Sjdp	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
63433965Sjdp	    DIRPRFX=libexec/rtld-elf/ ${_t}
63533965Sjdp	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
63633965Sjdp	    DIRPRFX=usr.bin/ldd ${_t}
63733965Sjdp.endfor
63833965Sjdp
63933965Sjdpdistribute32 install32:
64033965Sjdp	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
64133965Sjdp.if ${MK_CDDL} != "no"
64233965Sjdp	cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
64333965Sjdp.endif
64433965Sjdp	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
64533965Sjdp.if ${MK_CRYPT} != "no"
64633965Sjdp	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
64733965Sjdp.endif
64833965Sjdp.if ${MK_KERBEROS} != "no"
64933965Sjdp	cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
65033965Sjdp.endif
65133965Sjdp	cd ${.CURDIR}/libexec/rtld-elf; \
65233965Sjdp	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
65333965Sjdp	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
65433965Sjdp.endif
65533965Sjdp
65633965SjdpWMAKE_TGTS=
65733965Sjdp.if !defined(SUBDIR_OVERRIDE)
65833965SjdpWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
65933965Sjdp.endif
66033965SjdpWMAKE_TGTS+=	_cleanobj _obj _build-tools
66133965Sjdp.if !defined(SUBDIR_OVERRIDE)
66233965SjdpWMAKE_TGTS+=	_cross-tools
66333965Sjdp.endif
66433965SjdpWMAKE_TGTS+=	_includes _libraries _depend everything
66533965Sjdp.if defined(LIB32TMP) && ${MK_LIB32} != "no"
66633965SjdpWMAKE_TGTS+=	build32
66733965Sjdp.endif
66833965Sjdp
66960484Sobrienbuildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
67060484Sobrien.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
67160484Sobrien
67260484Sobrienbuildworld_prologue:
67360484Sobrien	@echo "--------------------------------------------------------------"
67433965Sjdp	@echo ">>> World build started on `LC_ALL=C date`"
67577298Sobrien	@echo "--------------------------------------------------------------"
67677298Sobrien
67733965Sjdpbuildworld_epilogue:
67889857Sobrien	@echo
67989857Sobrien	@echo "--------------------------------------------------------------"
68033965Sjdp	@echo ">>> World build completed on `LC_ALL=C date`"
68189857Sobrien	@echo "--------------------------------------------------------------"
68289857Sobrien
68389857Sobrien#
68489857Sobrien# We need to have this as a target because the indirection between Makefile
68589857Sobrien# and Makefile.inc1 causes the correct PATH to be used, rather than a
68633965Sjdp# modification of the current environment's PATH.  In addition, we need
68789857Sobrien# to quote multiword values.
68889857Sobrien#
68989857Sobrienbuildenvvars:
69089857Sobrien	@echo ${WMAKEENV:Q}
69189857Sobrien
69289857Sobrienbuildenv:
69389857Sobrien	@echo Entering world for ${TARGET_ARCH}:${TARGET}
69489857Sobrien	@cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
69589857Sobrien
69689857SobrienTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
69789857Sobrientoolchain: ${TOOLCHAIN_TGTS}
69889857Sobrienkernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
69989857Sobrien
70089857Sobrien#
70133965Sjdp# installcheck
70289857Sobrien#
70389857Sobrien# Checks to be sure system is ready for installworld/installkernel.
70489857Sobrien#
70589857Sobrieninstallcheck: _installcheck_world _installcheck_kernel
70689857Sobrien_installcheck_world:
70789857Sobrien_installcheck_kernel:
70833965Sjdp
70989857Sobrien#
71089857Sobrien# Require DESTDIR to be set if installing for a different architecture or
71189857Sobrien# using the user/group database in the source tree.
71289857Sobrien#
71389857Sobrien.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
71489857Sobrien    defined(DB_FROM_SRC)
71589857Sobrien.if !make(distributeworld)
71689857Sobrien_installcheck_world: __installcheck_DESTDIR
71733965Sjdp_installcheck_kernel: __installcheck_DESTDIR
71889857Sobrien__installcheck_DESTDIR:
71989857Sobrien.if !defined(DESTDIR) || empty(DESTDIR)
72089857Sobrien	@echo "ERROR: Please set DESTDIR!"; \
72189857Sobrien	false
72289857Sobrien.endif
72389857Sobrien.endif
72489857Sobrien.endif
72589857Sobrien
72689857Sobrien.if !defined(DB_FROM_SRC)
72789857Sobrien#
72889857Sobrien# Check for missing UIDs/GIDs.
72989857Sobrien#
73089857SobrienCHECK_UIDS=	auditdistd
73189857SobrienCHECK_GIDS=	audit
73289857Sobrien.if ${MK_SENDMAIL} != "no"
73389857SobrienCHECK_UIDS+=	smmsp
73489857SobrienCHECK_GIDS+=	smmsp
73589857Sobrien.endif
73689857Sobrien.if ${MK_PF} != "no"
73789857SobrienCHECK_UIDS+=	proxy
73889857SobrienCHECK_GIDS+=	proxy authpf
73989857Sobrien.endif
74089857Sobrien.if ${MK_UNBOUND} != "no"
74189857SobrienCHECK_UIDS+=	unbound
74289857SobrienCHECK_GIDS+=	unbound
74389857Sobrien.endif
74489857Sobrien_installcheck_world: __installcheck_UGID
74589857Sobrien__installcheck_UGID:
74689857Sobrien.for uid in ${CHECK_UIDS}
74789857Sobrien	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
74889857Sobrien		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
74989857Sobrien		false; \
75033965Sjdp	fi
75189857Sobrien.endfor
75233965Sjdp.for gid in ${CHECK_GIDS}
75333965Sjdp	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
75433965Sjdp		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
75533965Sjdp		false; \
75633965Sjdp	fi
75733965Sjdp.endfor
75833965Sjdp.endif
75933965Sjdp
76033965Sjdp#
76133965Sjdp# Required install tools to be saved in a scratch dir for safety.
76233965Sjdp#
76333965Sjdp.if ${MK_INFO} != "no"
76433965Sjdp_install-info=	install-info
76533965Sjdp.endif
76689857Sobrien.if ${MK_ZONEINFO} != "no"
76789857Sobrien_zoneinfo=	zic tzsetup
76833965Sjdp.endif
76933965Sjdp
77089857Sobrien.if exists(/usr/sbin/nmtree)
77133965Sjdp_nmtree_itools=	nmtree
77233965Sjdp.endif
77333965Sjdp
77433965SjdpITOOLS=	[ awk cap_mkdb cat chflags chmod chown \
77533965Sjdp	date echo egrep find grep id install ${_install-info} \
77633965Sjdp	ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
77789857Sobrien	rm sed sh sysctl test true uname wc ${_zoneinfo} \
77833965Sjdp	${LOCAL_ITOOLS}
77933965Sjdp
78033965Sjdp#
78133965Sjdp# distributeworld
78233965Sjdp#
78333965Sjdp# Distributes everything compiled by a `buildworld'.
78433965Sjdp#
78577298Sobrien# installworld
78633965Sjdp#
78733965Sjdp# Installs everything compiled by a 'buildworld'.
78833965Sjdp#
78933965Sjdp
79089857Sobrien# Non-base distributions produced by the base system
79189857SobrienEXTRA_DISTRIBUTIONS=	doc
79289857Sobrien.if ${MK_GAMES} != "no"
79333965SjdpEXTRA_DISTRIBUTIONS+=	games
79489857Sobrien.endif
79589857Sobrien.if defined(LIB32TMP) && ${MK_LIB32} != "no"
79689857SobrienEXTRA_DISTRIBUTIONS+=	lib32
79733965Sjdp.endif
79889857Sobrien.if ${MK_TESTS} != "no"
79989857SobrienEXTRA_DISTRIBUTIONS+=	tests
80089857Sobrien.endif
80189857Sobrien
80289857SobrienMTREE_MAGIC?=	mtree 2.0
80389857Sobrien
80489857Sobriendistributeworld installworld: _installcheck_world
80589857Sobrien	mkdir -p ${INSTALLTMP}
80689857Sobrien	progs=$$(for prog in ${ITOOLS}; do \
80789857Sobrien		if progpath=`which $$prog`; then \
80889857Sobrien			echo $$progpath; \
80933965Sjdp		else \
81033965Sjdp			echo "Required tool $$prog not found in PATH." >&2; \
81133965Sjdp			exit 1; \
81233965Sjdp		fi; \
81333965Sjdp	    done); \
81433965Sjdp	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
81533965Sjdp	    while read line; do \
81633965Sjdp		set -- $$line; \
81733965Sjdp		if [ "$$2 $$3" != "not found" ]; then \
81833965Sjdp			echo $$2; \
81933965Sjdp		else \
82033965Sjdp			echo "Required library $$1 not found." >&2; \
82133965Sjdp			exit 1; \
82233965Sjdp		fi; \
82333965Sjdp	    done); \
82433965Sjdp	cp $$libs $$progs ${INSTALLTMP}
82533965Sjdp	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
82633965Sjdp.if defined(NO_ROOT)
82733965Sjdp	echo "#${MTREE_MAGIC}" > ${METALOG}
82833965Sjdp.endif
82933965Sjdp.if make(distributeworld)
83033965Sjdp.for dist in ${EXTRA_DISTRIBUTIONS}
83133965Sjdp	-mkdir ${DESTDIR}/${DISTDIR}/${dist}
83233965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
83333965Sjdp	    -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
83433965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
83533965Sjdp	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
83633965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
83733965Sjdp	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
83889857Sobrien.if ${MK_DEBUG_FILES} != "no"
83989857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
84089857Sobrien	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
84189857Sobrien.endif
84233965Sjdp.if ${MK_TESTS} != "no" && ${dist} == "tests"
84333965Sjdp	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
84460484Sobrien	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
84577298Sobrien.endif
84677298Sobrien.if defined(NO_ROOT)
84777298Sobrien	${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
84877298Sobrien	    sed -e 's#^\./#./${dist}/#' >> ${METALOG}
84977298Sobrien	${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
85077298Sobrien	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
85177298Sobrien	${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
85277298Sobrien	    sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
85377298Sobrien.endif
85433965Sjdp.endfor
85589857Sobrien	-mkdir ${DESTDIR}/${DISTDIR}/base
85660484Sobrien	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
85789857Sobrien	    METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
85833965Sjdp	    DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
85989857Sobrien	    LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
86089857Sobrien.endif
86189857Sobrien	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
86289857Sobrien	    ${IMAKEENV} rm -rf ${INSTALLTMP}
86389857Sobrien.if make(distributeworld)
86489857Sobrien.for dist in ${EXTRA_DISTRIBUTIONS}
86589857Sobrien	find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
86689857Sobrien.endfor
86789857Sobrien.if defined(NO_ROOT)
86889857Sobrien.for dist in base ${EXTRA_DISTRIBUTIONS}
86989857Sobrien	@# For each file that exists in this dist, print the corresponding
87033965Sjdp	@# line from the METALOG.  This relies on the fact that
87133965Sjdp	@# a line containing only the filename will sort immediatly before
87233965Sjdp	@# the relevant mtree line.
87333965Sjdp	cd ${DESTDIR}/${DISTDIR}; \
87433965Sjdp	find ./${dist} | sort -u ${METALOG} - | \
87533965Sjdp	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
87677298Sobrien	${DESTDIR}/${DISTDIR}/${dist}.meta
87777298Sobrien.endfor
87833965Sjdp.if ${MK_DEBUG_FILES} != "no"
87933965Sjdp. for dist in base ${EXTRA_DISTRIBUTIONS}
88033965Sjdp	@# For each file that exists in this dist, print the corresponding
88133965Sjdp	@# line from the METALOG.  This relies on the fact that
88233965Sjdp	@# a line containing only the filename will sort immediatly before
88333965Sjdp	@# the relevant mtree line.
88433965Sjdp	cd ${DESTDIR}/${DISTDIR}; \
88533965Sjdp	find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
88633965Sjdp	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
88760484Sobrien	${DESTDIR}/${DISTDIR}/${dist}.debug.meta
88833965Sjdp. endfor
88933965Sjdp.endif
89033965Sjdp.endif
89133965Sjdp.endif
89233965Sjdp
89333965Sjdppackageworld:
89433965Sjdp.for dist in base ${EXTRA_DISTRIBUTIONS}
89533965Sjdp.if defined(NO_ROOT)
89633965Sjdp	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
89733965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
89833965Sjdp	    --exclude usr/lib/debug \
89933965Sjdp	    @${DESTDIR}/${DISTDIR}/${dist}.meta
90033965Sjdp.else
90133965Sjdp	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
90233965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
90333965Sjdp	    --exclude usr/lib/debug .
90433965Sjdp.endif
90533965Sjdp.endfor
90633965Sjdp
90733965Sjdp.if ${MK_DEBUG_FILES} != "no"
90833965Sjdp. for dist in base ${EXTRA_DISTRIBUTIONS}
90933965Sjdp.  if defined(NO_ROOT)
91033965Sjdp	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
91133965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
91233965Sjdp	    @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
91333965Sjdp.  else
91433965Sjdp	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
91560484Sobrien	    tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
91660484Sobrien	    usr/lib/debug
91760484Sobrien.  endif
91860484Sobrien. endfor
91960484Sobrien.endif
92060484Sobrien
92160484Sobrien#
92260484Sobrien# reinstall
92360484Sobrien#
92460484Sobrien# If you have a build server, you can NFS mount the source and obj directories
92577298Sobrien# and do a 'make reinstall' on the *client* to install new binaries from the
92633965Sjdp# most recent server build.
92733965Sjdp#
92833965Sjdpreinstall:
92933965Sjdp	@echo "--------------------------------------------------------------"
93033965Sjdp	@echo ">>> Making hierarchy"
93133965Sjdp	@echo "--------------------------------------------------------------"
93233965Sjdp	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
93333965Sjdp	    LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
93433965Sjdp	@echo
93533965Sjdp	@echo "--------------------------------------------------------------"
93633965Sjdp	@echo ">>> Installing everything"
93733965Sjdp	@echo "--------------------------------------------------------------"
93833965Sjdp	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
93933965Sjdp.if defined(LIB32TMP) && ${MK_LIB32} != "no"
94033965Sjdp	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
94133965Sjdp.endif
94233965Sjdp
94333965Sjdpredistribute:
94433965Sjdp	@echo "--------------------------------------------------------------"
94533965Sjdp	@echo ">>> Distributing everything"
94633965Sjdp	@echo "--------------------------------------------------------------"
94733965Sjdp	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
94833965Sjdp.if defined(LIB32TMP) && ${MK_LIB32} != "no"
94933965Sjdp	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
95033965Sjdp	    DISTRIBUTION=lib32
95133965Sjdp.endif
95233965Sjdp
95333965Sjdpdistrib-dirs distribution:
95433965Sjdp	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
95533965Sjdp	    ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
95633965Sjdp
95733965Sjdp#
95833965Sjdp# buildkernel and installkernel
95933965Sjdp#
96033965Sjdp# Which kernels to build and/or install is specified by setting
96133965Sjdp# KERNCONF. If not defined a GENERIC kernel is built/installed.
96233965Sjdp# Only the existing (depending TARGET) config files are used
96333965Sjdp# for building kernels and only the first of these is designated
96433965Sjdp# as the one being installed.
96533965Sjdp#
96633965Sjdp# Note that we have to use TARGET instead of TARGET_ARCH when
96733965Sjdp# we're in kernel-land. Since only TARGET_ARCH is (expected) to
96833965Sjdp# be set to cross-build, we have to make sure TARGET is set
96933965Sjdp# properly.
97033965Sjdp
97133965Sjdp.if defined(KERNFAST)
97233965SjdpNO_KERNELCLEAN=	t
97333965SjdpNO_KERNELCONFIG=	t
97433965SjdpNO_KERNELDEPEND=	t
97533965SjdpNO_KERNELOBJ=		t
97633965Sjdp# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
97733965Sjdp.if !defined(KERNCONF) && ${KERNFAST} != "1"
97833965SjdpKERNCONF=${KERNFAST}
97933965Sjdp.endif
98033965Sjdp.endif
98133965Sjdp.if ${TARGET_ARCH} == "powerpc64"
98233965SjdpKERNCONF?=	GENERIC64
98333965Sjdp.else
98433965SjdpKERNCONF?=	GENERIC
98533965Sjdp.endif
98633965SjdpINSTKERNNAME?=	kernel
98733965Sjdp
98833965SjdpKERNSRCDIR?=	${.CURDIR}/sys
98933965SjdpKRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
99033965SjdpKRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
99133965SjdpKERNCONFDIR?=	${KRNLCONFDIR}
99233965Sjdp
99333965SjdpBUILDKERNELS=
99433965SjdpINSTALLKERNEL=
99533965Sjdp.for _kernel in ${KERNCONF}
99633965Sjdp.if exists(${KERNCONFDIR}/${_kernel})
99733965SjdpBUILDKERNELS+=	${_kernel}
99833965Sjdp.if empty(INSTALLKERNEL)
99933965SjdpINSTALLKERNEL= ${_kernel}
100033965Sjdp.endif
100133965Sjdp.endif
100233965Sjdp.endfor
100333965Sjdp
100433965Sjdpbuildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
100533965Sjdp
100633965Sjdp#
100760484Sobrien# buildkernel
100860484Sobrien#
100933965Sjdp# Builds all kernels defined by BUILDKERNELS.
101033965Sjdp#
101133965Sjdpbuildkernel:
101233965Sjdp.if empty(BUILDKERNELS)
101333965Sjdp	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
101433965Sjdp	false
101533965Sjdp.endif
101633965Sjdp	@echo
101733965Sjdp.for _kernel in ${BUILDKERNELS}
101833965Sjdp	@echo "--------------------------------------------------------------"
101933965Sjdp	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
102033965Sjdp	@echo "--------------------------------------------------------------"
102160484Sobrien	@echo "===> ${_kernel}"
102260484Sobrien	mkdir -p ${KRNLOBJDIR}
102333965Sjdp.if !defined(NO_KERNELCONFIG)
102433965Sjdp	@echo
102533965Sjdp	@echo "--------------------------------------------------------------"
102633965Sjdp	@echo ">>> stage 1: configuring the kernel"
102733965Sjdp	@echo "--------------------------------------------------------------"
102833965Sjdp	cd ${KRNLCONFDIR}; \
102933965Sjdp		PATH=${TMPPATH} \
103033965Sjdp		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
103133965Sjdp			-I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
103233965Sjdp.endif
103333965Sjdp.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
103433965Sjdp	@echo
103533965Sjdp	@echo "--------------------------------------------------------------"
103633965Sjdp	@echo ">>> stage 2.1: cleaning up the object tree"
103733965Sjdp	@echo "--------------------------------------------------------------"
103833965Sjdp	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
103933965Sjdp.endif
104033965Sjdp.if !defined(NO_KERNELOBJ)
104133965Sjdp	@echo
104289857Sobrien	@echo "--------------------------------------------------------------"
104333965Sjdp	@echo ">>> stage 2.2: rebuilding the object tree"
104433965Sjdp	@echo "--------------------------------------------------------------"
104533965Sjdp	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
104633965Sjdp.endif
104733965Sjdp	@echo
104889857Sobrien	@echo "--------------------------------------------------------------"
104989857Sobrien	@echo ">>> stage 2.3: build tools"
105033965Sjdp	@echo "--------------------------------------------------------------"
105133965Sjdp	${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
105233965Sjdp.if !defined(NO_KERNELDEPEND)
105333965Sjdp	@echo
105433965Sjdp	@echo "--------------------------------------------------------------"
105533965Sjdp	@echo ">>> stage 3.1: making dependencies"
105633965Sjdp	@echo "--------------------------------------------------------------"
105733965Sjdp	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
105833965Sjdp.endif
105933965Sjdp	@echo
106033965Sjdp	@echo "--------------------------------------------------------------"
106133965Sjdp	@echo ">>> stage 3.2: building everything"
106233965Sjdp	@echo "--------------------------------------------------------------"
106333965Sjdp	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
106433965Sjdp	@echo "--------------------------------------------------------------"
106533965Sjdp	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
106633965Sjdp	@echo "--------------------------------------------------------------"
106789857Sobrien.endfor
106833965Sjdp
106933965Sjdp#
107033965Sjdp# installkernel, etc.
107133965Sjdp#
107277298Sobrien# Install the kernel defined by INSTALLKERNEL
107333965Sjdp#
107433965Sjdpinstallkernel installkernel.debug \
107533965Sjdpreinstallkernel reinstallkernel.debug: _installcheck_kernel
107633965Sjdp.if empty(INSTALLKERNEL)
107733965Sjdp	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
107889857Sobrien	false
107933965Sjdp.endif
108089857Sobrien	@echo "--------------------------------------------------------------"
108133965Sjdp	@echo ">>> Installing kernel ${INSTALLKERNEL}"
108233965Sjdp	@echo "--------------------------------------------------------------"
108389857Sobrien	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
108489857Sobrien	    ${CROSSENV} PATH=${TMPPATH} \
108589857Sobrien	    ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
108689857Sobrien
108789857Sobriendistributekernel distributekernel.debug:
108889857Sobrien.if empty(INSTALLKERNEL)
108989857Sobrien	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
109077298Sobrien	false
109189857Sobrien.endif
109289857Sobrien	mkdir -p ${DESTDIR}/${DISTDIR}
109389857Sobrien.if defined(NO_ROOT)
109433965Sjdp	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
109533965Sjdp.endif
109633965Sjdp	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
109789857Sobrien	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
109833965Sjdp	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
109933965Sjdp	    DESTDIR=${INSTALL_DDIR}/kernel \
110089857Sobrien	    ${.TARGET:S/distributekernel/install/}
110133965Sjdp.if defined(NO_ROOT)
110289857Sobrien	sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
110389857Sobrien	    ${DESTDIR}/${DISTDIR}/kernel.meta
110489857Sobrien.endif
110589857Sobrien.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
110633965Sjdp.if defined(NO_ROOT)
110733965Sjdp	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
110889857Sobrien.endif
110933965Sjdp	cd ${KRNLOBJDIR}/${_kernel}; \
111033965Sjdp	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
111177298Sobrien	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
111233965Sjdp	    KERNEL=${INSTKERNNAME}.${_kernel} \
111333965Sjdp	    DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
111433965Sjdp	    ${.TARGET:S/distributekernel/install/}
111533965Sjdp.if defined(NO_ROOT)
111633965Sjdp	sed -e 's|^./kernel|.|' \
111733965Sjdp	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
111833965Sjdp	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
111933965Sjdp.endif
112033965Sjdp.endfor
112133965Sjdp
112233965Sjdppackagekernel:
112333965Sjdp.if defined(NO_ROOT)
112438889Sjdp	cd ${DESTDIR}/${DISTDIR}/kernel; \
112533965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
112633965Sjdp	    @${DESTDIR}/${DISTDIR}/kernel.meta
112733965Sjdp.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
112833965Sjdp	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
112989857Sobrien	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
113033965Sjdp	    @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
113189857Sobrien.endfor
113233965Sjdp.else
113333965Sjdp	cd ${DESTDIR}/${DISTDIR}/kernel; \
113433965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
113533965Sjdp.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
113633965Sjdp	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
113733965Sjdp	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
113833965Sjdp.endfor
113933965Sjdp.endif
114033965Sjdp
114177298Sobrien#
114233965Sjdp# doxygen
114333965Sjdp#
114433965Sjdp# Build the API documentation with doxygen
114589857Sobrien#
114689857Sobriendoxygen:
114733965Sjdp	@if [ ! -x `/usr/bin/which doxygen` ]; then \
114889857Sobrien		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
114933965Sjdp		exit 1; \
115089857Sobrien	fi
115189857Sobrien	cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
115289857Sobrien
115389857Sobrien#
115489857Sobrien# update
115589857Sobrien#
115689857Sobrien# Update the source tree(s), by running svn/svnup to update to the
115789857Sobrien# latest copy.
115889857Sobrien#
115989857Sobrienupdate:
116089857Sobrien.if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
116189857Sobrien	@echo "--------------------------------------------------------------"
116289857Sobrien	@echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
116333965Sjdp	@echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
116433965Sjdp	@echo "--------------------------------------------------------------"
116533965Sjdp	@exit 1
116633965Sjdp.endif
116733965Sjdp.if defined(SVN_UPDATE)
116833965Sjdp	@echo "--------------------------------------------------------------"
116933965Sjdp	@echo ">>> Updating ${.CURDIR} using Subversion"
117033965Sjdp	@echo "--------------------------------------------------------------"
117133965Sjdp	@(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
117233965Sjdp.endif
117333965Sjdp
117433965Sjdp#
117533965Sjdp# ------------------------------------------------------------------------
117633965Sjdp#
117733965Sjdp# From here onwards are utility targets used by the 'make world' and
117833965Sjdp# related targets.  If your 'world' breaks, you may like to try to fix
117933965Sjdp# the problem and manually run the following targets to attempt to
118033965Sjdp# complete the build.  Beware, this is *not* guaranteed to work, you
118189857Sobrien# need to have a pretty good grip on the current state of the system
118289857Sobrien# to attempt to manually finish it.  If in doubt, 'make world' again.
118333965Sjdp#
118433965Sjdp
118533965Sjdp#
118633965Sjdp# legacy: Build compatibility shims for the next three targets
118733965Sjdp#
118833965Sjdplegacy:
118933965Sjdp.if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
119038889Sjdp	@echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
119133965Sjdp	false
119289857Sobrien.endif
119389857Sobrien.for _tool in tools/build
119433965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
119589857Sobrien	    cd ${.CURDIR}/${_tool} && \
119689857Sobrien	    ${MAKE} DIRPRFX=${_tool}/ obj && \
119789857Sobrien	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
119833965Sjdp	    ${MAKE} DIRPRFX=${_tool}/ depend && \
119989857Sobrien	    ${MAKE} DIRPRFX=${_tool}/ all && \
120033965Sjdp	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
120133965Sjdp.endfor
120233965Sjdp
120389857Sobrien#
120489857Sobrien# bootstrap-tools: Build tools needed for compatibility
120589857Sobrien#
120689857Sobrien.if ${MK_GAMES} != "no"
120733965Sjdp_strfile=	games/fortune/strfile
120833965Sjdp.endif
120989857Sobrien
121033965Sjdp.if ${MK_CXX} != "no"
121133965Sjdp_gperf=		gnu/usr.bin/gperf
121233965Sjdp.endif
121333965Sjdp
121433965Sjdp.if ${MK_GROFF} != "no"
121533965Sjdp_groff=		gnu/usr.bin/groff
121633965Sjdp.endif
121733965Sjdp
121860484Sobrien.if ${BOOTSTRAPPING} < 800022
121933965Sjdp_ar=		usr.bin/ar
122033965Sjdp.endif
122133965Sjdp
122233965Sjdp.if ${BOOTSTRAPPING} < 800013
122333965Sjdp_mklocale=	usr.bin/mklocale
122433965Sjdp.endif
122533965Sjdp
122633965Sjdp.if ${BOOTSTRAPPING} < 900002
122733965Sjdp_sed=		usr.bin/sed
122833965Sjdp.endif
122933965Sjdp
123033965Sjdp.if ${BOOTSTRAPPING} < 1000002
123133965Sjdp_m4=		lib/libohash \
123233965Sjdp		usr.bin/m4
123333965Sjdp.endif
123433965Sjdp
123533965Sjdp.if ${BOOTSTRAPPING} < 1000013
123633965Sjdp_yacc=		lib/liby \
123789857Sobrien		usr.bin/yacc
123833965Sjdp.endif
123933965Sjdp
124033965Sjdp.if ${BOOTSTRAPPING} < 1000014
124133965Sjdp_crunch=	usr.sbin/crunch
124233965Sjdp.endif
124333965Sjdp
124433965Sjdp.if ${BOOTSTRAPPING} < 1000026
124589857Sobrien_nmtree=	lib/libnetbsd \
124689857Sobrien		usr.sbin/nmtree
124733965Sjdp.endif
124833965Sjdp
124933965Sjdp.if ${BOOTSTRAPPING} < 1000027
125033965Sjdp_cat=		bin/cat
125133965Sjdp.endif
125233965Sjdp
125333965Sjdp.if ${BOOTSTRAPPING} < 1000033
125433965Sjdp_lex=		usr.bin/lex
125533965Sjdp.endif
125633965Sjdp
125733965Sjdp.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
125833965Sjdp_awk=		usr.bin/awk
125989857Sobrien.endif
126033965Sjdp
126189857Sobrien.if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
126289857Sobrien_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
126389857Sobrien.endif
126489857Sobrien
126589857Sobrien.if ${MK_CLANG} != "no"
126633965Sjdp_clang_tblgen= \
126733965Sjdp	lib/clang/libllvmsupport \
126833965Sjdp	lib/clang/libllvmtablegen \
126933965Sjdp	usr.bin/clang/tblgen \
127033965Sjdp	usr.bin/clang/clang-tblgen
127133965Sjdp.endif
127233965Sjdp
127333965Sjdp# dtrace tools are required for older bootstrap env and cross-build
127433965Sjdp.if ${MK_CDDL} != "no" && \
127533965Sjdp    ((${BOOTSTRAPPING} < 1000034 && \
127633965Sjdp          !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
127733965Sjdp      || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
127833965Sjdp_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
127933965Sjdp    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
128033965Sjdp.endif
128133965Sjdp
128233965Sjdp# Default to building the GPL DTC, but build the BSDL one if users explicitly
128333965Sjdp# request it.
128433965Sjdp_dtc= usr.bin/dtc
128533965Sjdp.if ${MK_GPL_DTC} != "no"
128633965Sjdp_dtc= gnu/usr.bin/dtc
128733965Sjdp.endif
128833965Sjdp
128933965Sjdp.if ${MK_KERBEROS} != "no"
129033965Sjdp_kerberos5_bootstrap_tools= \
129133965Sjdp	kerberos5/tools/make-roken \
129233965Sjdp	kerberos5/lib/libroken \
129333965Sjdp	kerberos5/lib/libvers \
129433965Sjdp	kerberos5/tools/asn1_compile \
129533965Sjdp	kerberos5/tools/slc \
129633965Sjdp	usr.bin/compile_et
129733965Sjdp.endif
129833965Sjdp
129933965Sjdp#	Please document (add comment) why something is in 'bootstrap-tools'.
130033965Sjdp#	Try to bound the building of the bootstrap-tool to just the
130133965Sjdp#	FreeBSD versions that need the tool built at this stage of the build.
130233965Sjdpbootstrap-tools: .MAKE
130333965Sjdp.for _tool in \
130433965Sjdp    ${_clang_tblgen} \
130533965Sjdp    ${_kerberos5_bootstrap_tools} \
130633965Sjdp    ${_dtrace_tools} \
130733965Sjdp    ${_strfile} \
130833965Sjdp    ${_gperf} \
130933965Sjdp    ${_groff} \
131033965Sjdp    ${_ar} \
131133965Sjdp    ${_dtc} \
131233965Sjdp    ${_awk} \
131333965Sjdp    ${_cat} \
131433965Sjdp    usr.bin/lorder \
131533965Sjdp    usr.bin/makewhatis \
131633965Sjdp    ${_mklocale} \
131733965Sjdp    usr.bin/rpcgen \
131833965Sjdp    ${_sed} \
131933965Sjdp    ${_yacc} \
132033965Sjdp    ${_m4} \
132133965Sjdp    ${_lex} \
132233965Sjdp    lib/libmd \
132333965Sjdp    usr.bin/xinstall \
132433965Sjdp    ${_gensnmptree} \
132533965Sjdp    usr.sbin/config \
132633965Sjdp    ${_crunch} \
132733965Sjdp    ${_nmtree}
132833965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
132933965Sjdp		cd ${.CURDIR}/${_tool} && \
133033965Sjdp		${MAKE} DIRPRFX=${_tool}/ obj && \
133133965Sjdp		${MAKE} DIRPRFX=${_tool}/ depend && \
133233965Sjdp		${MAKE} DIRPRFX=${_tool}/ all && \
133333965Sjdp		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
133433965Sjdp.endfor
133533965Sjdp
133633965Sjdp#
133733965Sjdp# build-tools: Build special purpose build tools
133833965Sjdp#
133933965Sjdp.if !defined(NO_SHARE)
134033965Sjdp_share=	share/syscons/scrnmaps
134133965Sjdp.endif
134233965Sjdp
134333965Sjdp.if ${MK_GCC} != "no"
134433965Sjdp_gcc_tools= gnu/usr.bin/cc/cc_tools
134533965Sjdp.endif
134633965Sjdp
134733965Sjdp.if ${MK_RESCUE} != "no"
134833965Sjdp_rescue= rescue/rescue
134933965Sjdp.endif
135033965Sjdp
135133965Sjdpbuild-tools: .MAKE
135233965Sjdp.for _tool in \
135333965Sjdp    bin/csh \
135433965Sjdp    bin/sh \
135533965Sjdp    ${_rescue} \
135633965Sjdp    ${LOCAL_TOOL_DIRS} \
135733965Sjdp    lib/ncurses/ncurses \
135833965Sjdp    lib/ncurses/ncursesw \
135933965Sjdp    ${_share} \
136033965Sjdp    usr.bin/awk \
136133965Sjdp    lib/libmagic \
136233965Sjdp    usr.bin/mkesdb_static \
136333965Sjdp    usr.bin/mkcsmapper_static \
136433965Sjdp    usr.bin/vi/catalog
136533965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
136633965Sjdp		cd ${.CURDIR}/${_tool} && \
136733965Sjdp		${MAKE} DIRPRFX=${_tool}/ obj && \
136833965Sjdp		${MAKE} DIRPRFX=${_tool}/ build-tools
136933965Sjdp.endfor
137033965Sjdp.for _tool in \
137133965Sjdp    ${_gcc_tools}
137233965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
137333965Sjdp		cd ${.CURDIR}/${_tool} && \
137433965Sjdp		${MAKE} DIRPRFX=${_tool}/ obj && \
137589857Sobrien		${MAKE} DIRPRFX=${_tool}/ depend && \
137689857Sobrien		${MAKE} DIRPRFX=${_tool}/ all
137733965Sjdp.endfor
137833965Sjdp
137933965Sjdp#
138033965Sjdp# kernel-tools: Build kernel-building tools
138133965Sjdp#
138289857Sobrienkernel-tools: .MAKE
138333965Sjdp	mkdir -p ${MAKEOBJDIRPREFIX}/usr
138489857Sobrien	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
138589857Sobrien	    -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
138633965Sjdp.for _tool in \
138733965Sjdp    sys/dev/aic7xxx/aicasm
138833965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
138933965Sjdp		cd ${.CURDIR}/${_tool} && \
139033965Sjdp		${MAKE} DIRPRFX=${_tool}/ obj && \
139133965Sjdp		${MAKE} DIRPRFX=${_tool}/ depend && \
139233965Sjdp		${MAKE} DIRPRFX=${_tool}/ all && \
139377298Sobrien		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
139460484Sobrien.endfor
139533965Sjdp
139633965Sjdp#
139760484Sobrien# cross-tools: Build cross-building tools
139860484Sobrien#
139933965Sjdp.if !defined(TARGET_ARCH) && defined(XDEV_ARCH)
140033965SjdpTARGET_ARCH=	${XDEV_ARCH}
140160484Sobrien.endif
140260484Sobrien.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
140360484Sobrien.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
140433965Sjdp_btxld=		usr.sbin/btxld
140533965Sjdp.endif
140633965Sjdp.endif
140733965Sjdp.if ${TARGET_ARCH} != ${MACHINE_ARCH}
140833965Sjdp.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
140933965Sjdp_crunchide=	usr.sbin/crunch/crunchide
141033965Sjdp.endif
141133965Sjdp.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
141233965Sjdp_kgzip=		usr.sbin/kgzip
141333965Sjdp.endif
141489857Sobrien.endif
141533965Sjdp
141633965Sjdp.if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
141733965Sjdp_binutils=	gnu/usr.bin/binutils
141833965Sjdp.endif
141989857Sobrien
142033965Sjdp# If an full path to an external cross compiler is given, don't build
142133965Sjdp# a cross compiler.
142233965Sjdp.if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
142333965Sjdp.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
142433965Sjdp_clang=		usr.bin/clang
142533965Sjdp_clang_libs=	lib/clang
142633965Sjdp.else
142733965Sjdp_cc=		gnu/usr.bin/cc
142833965Sjdp.endif
142933965Sjdp
143033965Sjdp# The boot2 for pc98 requires gcc.
143133965Sjdp.if ${TARGET} == "pc98"
143233965Sjdp_cc=		gnu/usr.bin/cc
143333965Sjdp.endif
143433965Sjdp.endif
143533965Sjdp
143633965Sjdpcross-tools: .MAKE
143733965Sjdp.for _tool in \
143833965Sjdp    ${_clang_libs} \
143933965Sjdp    ${_clang} \
144033965Sjdp    ${_binutils} \
144133965Sjdp    ${_cc} \
144233965Sjdp    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
144333965Sjdp    ${_btxld} \
144433965Sjdp    ${_crunchide} \
144533965Sjdp    ${_kgzip}
144633965Sjdp	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
144733965Sjdp		cd ${.CURDIR}/${_tool} && \
144833965Sjdp		${MAKE} DIRPRFX=${_tool}/ obj && \
144933965Sjdp		${MAKE} DIRPRFX=${_tool}/ depend && \
145033965Sjdp		${MAKE} DIRPRFX=${_tool}/ all && \
145133965Sjdp		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
145233965Sjdp.endfor
145333965Sjdp
145433965Sjdp#
145533965Sjdp# hierarchy - ensure that all the needed directories are present
145633965Sjdp#
145733965Sjdphierarchy hier:
145833965Sjdp	cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
145933965Sjdp
146033965Sjdp#
146133965Sjdp# libraries - build all libraries, and install them under ${DESTDIR}.
146233965Sjdp#
146333965Sjdp# The list of libraries with dependents (${_prebuild_libs}) and their
146433965Sjdp# interdependencies (__L) are built automatically by the
146533965Sjdp# ${.CURDIR}/tools/make_libdeps.sh script.
146633965Sjdp#
146733965Sjdplibraries: .MAKE
146833965Sjdp	cd ${.CURDIR} && \
146933965Sjdp	    ${MAKE} -f Makefile.inc1 _prereq_libs && \
147033965Sjdp	    ${MAKE} -f Makefile.inc1 _startup_libs && \
147133965Sjdp	    ${MAKE} -f Makefile.inc1 _prebuild_libs && \
147233965Sjdp	    ${MAKE} -f Makefile.inc1 _generic_libs
147333965Sjdp
147433965Sjdp#
147533965Sjdp# static libgcc.a prerequisite for shared libc
147633965Sjdp#
147733965Sjdp_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
147833965Sjdp
147933965Sjdp# These dependencies are not automatically generated:
148033965Sjdp#
148133965Sjdp# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
148233965Sjdp# all shared libraries for ELF.
148333965Sjdp#
148433965Sjdp_startup_libs=	gnu/lib/csu
148533965Sjdp.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
148633965Sjdp_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
148733965Sjdp.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
148833965Sjdp_startup_libs+=	lib/csu/${MACHINE_ARCH}
148933965Sjdp.else
149060484Sobrien_startup_libs+=	lib/csu/${MACHINE_CPUARCH}
149160484Sobrien.endif
149277298Sobrien_startup_libs+=	gnu/lib/libgcc
149360484Sobrien_startup_libs+=	lib/libcompiler_rt
149460484Sobrien_startup_libs+=	lib/libc
149560484Sobrien_startup_libs+=	lib/libc_nonshared
149660484Sobrien.if ${MK_LIBCPLUSPLUS} != "no"
149760484Sobrien_startup_libs+=	lib/libcxxrt
149860484Sobrien.endif
149960484Sobrien
150060484Sobriengnu/lib/libgcc__L: lib/libc__L
150160484Sobriengnu/lib/libgcc__L: lib/libc_nonshared__L
150260484Sobrien.if ${MK_LIBCPLUSPLUS} != "no"
150360484Sobrienlib/libcxxrt__L: gnu/lib/libgcc__L
150460484Sobrien.endif
150589857Sobrien
150660484Sobrien_prebuild_libs=	${_kerberos5_lib_libasn1} \
150760484Sobrien		${_kerberos5_lib_libhdb} \
150860484Sobrien		${_kerberos5_lib_libheimbase} \
150960484Sobrien		${_kerberos5_lib_libheimntlm} \
151060484Sobrien		${_kerberos5_lib_libheimsqlite} \
151160484Sobrien		${_kerberos5_lib_libheimipcc} \
151260484Sobrien		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
151360484Sobrien		${_kerberos5_lib_libroken} \
151460484Sobrien		${_kerberos5_lib_libwind} \
151560484Sobrien		${_lib_atf} \
151660484Sobrien		lib/libbz2 ${_libcom_err} lib/libcrypt \
151778828Sobrien		lib/libelf lib/libexpat \
151860484Sobrien		${_lib_libgssapi} ${_lib_libipx} \
151978828Sobrien		lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
152060484Sobrien		lib/ncurses/ncurses lib/ncurses/ncursesw \
152160484Sobrien		lib/libopie lib/libpam ${_lib_libthr} \
152260484Sobrien		lib/libradius lib/libsbuf lib/libtacplus \
152360484Sobrien		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
152460484Sobrien		${_cddl_lib_libavl} \
152560484Sobrien		${_cddl_lib_libzfs_core} \
152660484Sobrien		lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
152760484Sobrien		${_secure_lib_libcrypto} ${_lib_libldns} \
152860484Sobrien		${_secure_lib_libssh} ${_secure_lib_libssl}
152960484Sobrien.if ${MK_GNUCXX} != no
153060484Sobrien_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
153160484Sobriengnu/lib/libstdc++__L: lib/msun__L
153260484Sobrien.endif
153360484Sobrien
153460484Sobrien.if defined(WITH_ATF) || ${MK_TESTS} != "no"
153560484Sobrien.if !defined(WITH_ATF)
153678828Sobrien# Ensure that the ATF libraries will be built during make libraries, even
153760484Sobrien# though they will have -DNO_TESTS
153860484SobrienMAKE+=		-DWITH_ATF
153960484Sobrien.endif
154060484Sobrien_lib_atf=	lib/atf
154189857Sobrien.endif
154289857Sobrien
154360484Sobrien.if ${MK_LIBTHR} != "no"
154460484Sobrien_lib_libthr=	lib/libthr
154560484Sobrien.endif
154660484Sobrien
154760484Sobrien.if ${MK_OFED} != "no"
154860484Sobrien_ofed_lib=	contrib/ofed/usr.lib/
154960484Sobrien.endif
155060484Sobrien
155177298Sobrien_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
155277298Sobrien.for _DIR in ${LOCAL_LIB_DIRS}
155360484Sobrien.if exists(${.CURDIR}/${_DIR}/Makefile)
155460484Sobrien_generic_libs+= ${_DIR}
155560484Sobrien.endif
155660484Sobrien.endfor
155760484Sobrien
155860484Sobrienlib/libopie__L lib/libtacplus__L: lib/libmd__L
155960484Sobrien
156060484Sobrien.if ${MK_CDDL} != "no"
156160484Sobrien_cddl_lib_libumem= cddl/lib/libumem
156260484Sobrien_cddl_lib_libnvpair= cddl/lib/libnvpair
156333965Sjdp_cddl_lib_libavl= cddl/lib/libavl
156433965Sjdp_cddl_lib_libzfs_core= cddl/lib/libzfs_core
156533965Sjdp_cddl_lib= cddl/lib
156633965Sjdpcddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
156733965Sjdp.endif
156833965Sjdp
156933965Sjdp.if ${MK_CRYPT} != "no"
157033965Sjdp.if ${MK_OPENSSL} != "no"
157133965Sjdp_secure_lib_libcrypto= secure/lib/libcrypto
157233965Sjdp_secure_lib_libssl= secure/lib/libssl
157333965Sjdplib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
157433965Sjdp.if ${MK_LDNS} != "no"
157533965Sjdp_lib_libldns= lib/libldns
157633965Sjdplib/libldns__L: secure/lib/libcrypto__L
157733965Sjdp.endif
157833965Sjdp.if ${MK_OPENSSH} != "no"
157933965Sjdp_secure_lib_libssh= secure/lib/libssh
158033965Sjdpsecure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
158133965Sjdp.if ${MK_LDNS} != "no"
158233965Sjdpsecure/lib/libssh__L: lib/libldns__L
158333965Sjdp.endif
158433965Sjdp.if ${MK_KERBEROS_SUPPORT} != "no"
158533965Sjdpsecure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
158633965Sjdp    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
158733965Sjdp    lib/libmd__L kerberos5/lib/libroken__L
158833965Sjdp.endif
158933965Sjdp.endif
159033965Sjdp.endif
159133965Sjdp_secure_lib=	secure/lib
159233965Sjdp.endif
159333965Sjdp
159433965Sjdp.if ${MK_KERBEROS} != "no"
159533965Sjdpkerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
159633965Sjdpkerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
159733965Sjdp    kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
159833965Sjdp    kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
159933965Sjdpkerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
160033965Sjdp    kerberos5/lib/libroken__L lib/libcom_err__L
160133965Sjdpkerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
160233965Sjdp    secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
160333965Sjdpkerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
160433965Sjdp    lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
160533965Sjdp    kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
160633965Sjdp    kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
160733965Sjdpkerberos5/lib/libroken__L: lib/libcrypt__L
160833965Sjdpkerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
160933965Sjdpkerberos5/lib/libheimbase__L: lib/libthr__L
161033965Sjdpkerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
161133965Sjdpkerberos5/lib/libheimsqlite__L: lib/libthr__L
161233965Sjdp.endif
161333965Sjdp
161433965Sjdp.if ${MK_GSSAPI} != "no"
161533965Sjdp_lib_libgssapi=	lib/libgssapi
161633965Sjdp.endif
161733965Sjdp
161833965Sjdp.if ${MK_IPX} != "no"
161933965Sjdp_lib_libipx=	lib/libipx
162033965Sjdp.endif
162133965Sjdp
162233965Sjdp.if ${MK_KERBEROS} != "no"
162333965Sjdp_kerberos5_lib=	kerberos5/lib
162433965Sjdp_kerberos5_lib_libasn1= kerberos5/lib/libasn1
162533965Sjdp_kerberos5_lib_libhdb= kerberos5/lib/libhdb
162633965Sjdp_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
162733965Sjdp_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
162833965Sjdp_kerberos5_lib_libhx509= kerberos5/lib/libhx509
162933965Sjdp_kerberos5_lib_libroken= kerberos5/lib/libroken
163033965Sjdp_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
163133965Sjdp_kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
163233965Sjdp_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
163333965Sjdp_kerberos5_lib_libwind= kerberos5/lib/libwind
163433965Sjdp_libcom_err= lib/libcom_err
163533965Sjdp.endif
163633965Sjdp
163733965Sjdp.if ${MK_NIS} != "no"
163833965Sjdp_lib_libypclnt=	lib/libypclnt
163933965Sjdp.endif
164033965Sjdp
164133965Sjdp.if ${MK_OPENSSL} == "no"
164233965Sjdplib/libradius__L: lib/libmd__L
164333965Sjdp.endif
164433965Sjdp
164533965Sjdp.for _lib in ${_prereq_libs}
164633965Sjdp${_lib}__PL: .PHONY .MAKE
164733965Sjdp.if exists(${.CURDIR}/${_lib})
164833965Sjdp	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
164933965Sjdp		cd ${.CURDIR}/${_lib} && \
165033965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ obj && \
165133965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ depend && \
165233965Sjdp		${MAKE} -DNO_TESTS -DNO_PROFILE -DNO_PIC \
165333965Sjdp		    DIRPRFX=${_lib}/ all && \
165433965Sjdp		${MAKE} -DNO_TESTS -DNO_PROFILE -DNO_PIC \
165533965Sjdp		    DIRPRFX=${_lib}/ install
165633965Sjdp.endif
165733965Sjdp.endfor
165833965Sjdp
165933965Sjdp.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
166033965Sjdp${_lib}__L: .PHONY .MAKE
166133965Sjdp.if exists(${.CURDIR}/${_lib})
166233965Sjdp	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
166333965Sjdp		cd ${.CURDIR}/${_lib} && \
166433965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ obj && \
166533965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ depend && \
166633965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ all && \
166733965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ install
166833965Sjdp.endif
166933965Sjdp.endfor
167033965Sjdp
167133965Sjdp# libpam is special: we need to build static PAM modules before
167233965Sjdp# static PAM library, and dynamic PAM library before dynamic PAM
167333965Sjdp# modules.
167433965Sjdplib/libpam__L: .PHONY .MAKE
167533965Sjdp	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
167633965Sjdp		cd ${.CURDIR}/lib/libpam && \
167733965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ obj && \
167833965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ depend && \
167933965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ \
168033965Sjdp		    -D_NO_LIBPAM_SO_YET all && \
168133965Sjdp		${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ \
168233965Sjdp		    -D_NO_LIBPAM_SO_YET install
168333965Sjdp
168433965Sjdp_prereq_libs: ${_prereq_libs:S/$/__PL/}
168533965Sjdp_startup_libs: ${_startup_libs:S/$/__L/}
168633965Sjdp_prebuild_libs: ${_prebuild_libs:S/$/__L/}
168733965Sjdp_generic_libs: ${_generic_libs:S/$/__L/}
168833965Sjdp
168933965Sjdp.for __target in all clean cleandepend cleandir depend includes obj
169033965Sjdp.for entry in ${SUBDIR}
169177298Sobrien${entry}.${__target}__D: .PHONY .MAKE
169260484Sobrien	${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
169333965Sjdp		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
169433965Sjdp		edir=${entry}.${MACHINE_ARCH}; \
169533965Sjdp		cd ${.CURDIR}/$${edir}; \
169633965Sjdp	else \
169777298Sobrien		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
169833965Sjdp		edir=${entry}; \
169933965Sjdp		cd ${.CURDIR}/$${edir}; \
170033965Sjdp	fi; \
170160484Sobrien	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
170260484Sobrien.endfor
170360484Sobrienpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
170460484Sobrien.endfor
170560484Sobrien
170660484Sobrien.include <bsd.subdir.mk>
170733965Sjdp
1708.if make(check-old) || make(check-old-dirs) || \
1709    make(check-old-files) || make(check-old-libs) || \
1710    make(delete-old) || make(delete-old-dirs) || \
1711    make(delete-old-files) || make(delete-old-libs)
1712
1713#
1714# check for / delete old files section
1715#
1716
1717.include "ObsoleteFiles.inc"
1718
1719OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1720else you can not start such an application. Consult UPDATING for more \
1721information regarding how to cope with the removal/revision bump of a \
1722specific library."
1723
1724.if !defined(BATCH_DELETE_OLD_FILES)
1725RM_I=-i
1726.else
1727RM_I=-v
1728.endif
1729
1730delete-old-files:
1731	@echo ">>> Removing old files (only deletes safe to delete libs)"
1732# Ask for every old file if the user really wants to remove it.
1733# It's annoying, but better safe than sorry.
1734# NB: We cannot pass the list of OLD_FILES as a parameter because the
1735# argument list will get too long. Using .for/.endfor make "loops" will make
1736# the Makefile parser segfault.
1737	@exec 3<&0; \
1738	cd ${.CURDIR}; \
1739	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1740	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1741	while read file; do \
1742		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1743			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1744			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1745		fi; \
1746	done
1747# Remove catpages without corresponding manpages.
1748	@exec 3<&0; \
1749	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1750	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1751	while read catpage; do \
1752		read manpage; \
1753		if [ ! -e "$${manpage}" ]; then \
1754			rm ${RM_I} $${catpage} <&3; \
1755	        fi; \
1756	done
1757	@echo ">>> Old files removed"
1758
1759check-old-files:
1760	@echo ">>> Checking for old files"
1761	@cd ${.CURDIR}; \
1762	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1763	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1764	while read file; do \
1765		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1766		 	echo "${DESTDIR}/$${file}"; \
1767		fi; \
1768	done
1769# Check for catpages without corresponding manpages.
1770	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1771	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1772	while read catpage; do \
1773		read manpage; \
1774		if [ ! -e "$${manpage}" ]; then \
1775			echo $${catpage}; \
1776	        fi; \
1777	done
1778
1779delete-old-libs:
1780	@echo ">>> Removing old libraries"
1781	@echo "${OLD_LIBS_MESSAGE}" | fmt
1782	@exec 3<&0; \
1783	cd ${.CURDIR}; \
1784	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1785	    -V OLD_LIBS | xargs -n1 | \
1786	while read file; do \
1787		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1788			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1789			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1790		fi; \
1791		for ext in debug symbols; do \
1792		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1793		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1794			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1795			      <&3; \
1796		  fi; \
1797		done; \
1798	done
1799	@echo ">>> Old libraries removed"
1800
1801check-old-libs:
1802	@echo ">>> Checking for old libraries"
1803	@cd ${.CURDIR}; \
1804	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1805	    -V OLD_LIBS | xargs -n1 | \
1806	while read file; do \
1807		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1808			echo "${DESTDIR}/$${file}"; \
1809		fi; \
1810		for ext in debug symbols; do \
1811		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1812			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1813		  fi; \
1814		done; \
1815	done
1816
1817delete-old-dirs:
1818	@echo ">>> Removing old directories"
1819	@cd ${.CURDIR}; \
1820	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1821	    -V OLD_DIRS | xargs -n1 | sort -r | \
1822	while read dir; do \
1823		if [ -d "${DESTDIR}/$${dir}" ]; then \
1824			rmdir -v "${DESTDIR}/$${dir}" || true; \
1825		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1826			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1827		fi; \
1828	done
1829	@echo ">>> Old directories removed"
1830
1831check-old-dirs:
1832	@echo ">>> Checking for old directories"
1833	@cd ${.CURDIR}; \
1834	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1835	    -V OLD_DIRS | xargs -n1 | \
1836	while read dir; do \
1837		if [ -d "${DESTDIR}/$${dir}" ]; then \
1838			echo "${DESTDIR}/$${dir}"; \
1839		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1840			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1841		fi; \
1842	done
1843
1844delete-old: delete-old-files delete-old-dirs
1845	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1846
1847check-old: check-old-files check-old-libs check-old-dirs
1848	@echo "To remove old files and directories run '${MAKE} delete-old'."
1849	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1850
1851.endif
1852
1853#
1854# showconfig - show build configuration.
1855#
1856showconfig:
1857	@${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1858
1859.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1860DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1861
1862.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1863.if exists(${KERNCONFDIR}/${KERNCONF})
1864FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1865	'${KERNCONFDIR}/${KERNCONF}' ; echo
1866.endif
1867.endif
1868
1869.endif
1870
1871.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1872DTBOUTPUTPATH= ${.CURDIR}
1873.endif
1874
1875#
1876# Build 'standalone' Device Tree Blob
1877#
1878builddtb:
1879	@if [ "${FDT_DTS_FILE}" = "" ]; then \
1880		echo "ERROR: FDT_DTS_FILE must be specified!"; \
1881		exit 1; \
1882	fi;	\
1883	if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${MACHINE}/${FDT_DTS_FILE} ]; then \
1884		echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1885			exist!"; \
1886		exit 1;	\
1887	fi;	\
1888	if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then	\
1889		echo "WARNING: DTB will be placed in the current working \
1890			directory"; \
1891	fi
1892	@PATH=${TMPPATH} \
1893	${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
1894	    ${FDT_DTS_FILE} \
1895	    ${DTBOUTPUTPATH}/`basename ${FDT_DTS_FILE} .dts`
1896
1897###############
1898
1899.if defined(XDEV) && defined(XDEV_ARCH)
1900
1901.if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1902XDEV_CPUTYPE?=${CPUTYPE}
1903.else
1904XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1905.endif
1906
1907NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1908	-DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1909	-DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_TESTS -DNO_WARNS \
1910	TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1911	CPUTYPE=${XDEV_CPUTYPE}
1912
1913XDDIR=${XDEV_ARCH}-freebsd
1914XDTP?=/usr/${XDDIR}
1915.if ${XDTP:N/*}
1916.error XDTP variable should be an absolute path
1917.endif
1918
1919CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1920	INSTALL="sh ${.CURDIR}/tools/install.sh"
1921CDENV= ${CDBENV} \
1922	_SHLIBDIRPREFIX=${XDDESTDIR} \
1923	TOOLS_PREFIX=${XDTP}
1924CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1925	--sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
1926	-B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
1927CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
1928	CPP="${CPP} ${CD2CFLAGS}" \
1929	MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1930
1931CDTMP=	${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1932CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1933CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1934XDDESTDIR=${DESTDIR}/${XDTP}
1935.if !defined(OSREL)
1936OSREL!= uname -r | sed -e 's/[-(].*//'
1937.endif
1938
1939.ORDER: xdev-build xdev-install
1940xdev: xdev-build xdev-install
1941
1942.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1943xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1944
1945_xb-worldtmp:
1946	mkdir -p ${CDTMP}/usr
1947	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1948	    -p ${CDTMP}/usr >/dev/null
1949
1950_xb-bootstrap-tools:
1951.for _tool in \
1952    ${_clang_tblgen}
1953	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1954	cd ${.CURDIR}/${_tool} && \
1955	${CDMAKE} DIRPRFX=${_tool}/ obj && \
1956	${CDMAKE} DIRPRFX=${_tool}/ depend && \
1957	${CDMAKE} DIRPRFX=${_tool}/ all && \
1958	${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1959.endfor
1960
1961_xb-build-tools:
1962	${_+_}@cd ${.CURDIR}; \
1963	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1964
1965_xb-cross-tools:
1966.for _tool in \
1967    ${_binutils} \
1968    usr.bin/ar \
1969    ${_clang_libs} \
1970    ${_clang} \
1971    ${_cc}
1972	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1973	cd ${.CURDIR}/${_tool} && \
1974	${CDMAKE} DIRPRFX=${_tool}/ obj && \
1975	${CDMAKE} DIRPRFX=${_tool}/ depend && \
1976	${CDMAKE} DIRPRFX=${_tool}/ all
1977.endfor
1978
1979_xi-mtree:
1980	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1981	mkdir -p ${XDDESTDIR}
1982	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1983	    -p ${XDDESTDIR} >/dev/null
1984	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1985	    -p ${XDDESTDIR}/usr >/dev/null
1986	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1987	    -p ${XDDESTDIR}/usr/include >/dev/null
1988.if ${MK_TESTS} != "no"
1989	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1990	    -p ${XDDESTDIR}/usr >/dev/null
1991.endif
1992
1993.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1994xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1995
1996_xi-cross-tools:
1997	@echo "_xi-cross-tools"
1998.for _tool in \
1999    ${_binutils} \
2000    usr.bin/ar \
2001    ${_clang_libs} \
2002    ${_clang} \
2003    ${_cc}
2004	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2005	cd ${.CURDIR}/${_tool}; \
2006	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2007.endfor
2008
2009_xi-includes:
2010	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2011		DESTDIR=${XDDESTDIR}
2012
2013_xi-libraries:
2014	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2015		DESTDIR=${XDDESTDIR}
2016
2017_xi-links:
2018	${_+_}cd ${XDDESTDIR}/usr/bin; \
2019       mkdir -p ../../../../usr/bin; \
2020		for i in *; do \
2021			ln -sf ../../${XDTP}/usr/bin/$$i \
2022			    ../../../../usr/bin/${XDDIR}-$$i; \
2023			ln -sf ../../${XDTP}/usr/bin/$$i \
2024			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2025		done
2026.else
2027xdev xdev-build xdev-install:
2028	@echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
2029.endif
2030