Makefile.inc1 revision 272350
1141580Sru#
2141580Sru# $FreeBSD: head/Makefile.inc1 272350 2014-10-01 08:26:51Z andrew $
364775Sbrian#
4141580Sru# Make command line options:
5141580Sru#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6141580Sru#	-DNO_CLEAN do not clean at all
7141580Sru#	-DDB_FROM_SRC use the user/group databases in src/etc instead of
8141580Sru#	    the system database when installing.
9141580Sru#	-DNO_SHARE do not go into share subdir
10141580Sru#	-DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11141580Sru#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1264775Sbrian#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13141580Sru#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14141580Sru#	-DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15141580Sru#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
16141580Sru#	-DNO_ROOT install without using root privilege
17141580Sru#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
18141580Sru#	-DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19141580Sru#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20141580Sru#	LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21141580Sru#	LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22141580Sru#	LOCAL_MTREE="list of mtree files" to process to allow local directories
23141580Sru#	    to be created before files are installed
2464775Sbrian#	LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25141580Sru#	    list
2664775Sbrian#	METALOG="path to metadata log" to write permission and ownership
2764775Sbrian#	    when NO_ROOT is set.  (default: ${DESTDIR}/METALOG)
2864775Sbrian#	TARGET="machine" to crossbuild world for a different machine type
2964790Ssheldonh#	TARGET_ARCH= may be required when a TARGET supports multiple endians
3064775Sbrian#	BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
3164775Sbrian#	WORLD_FLAGS= additional flags to pass to make(1) during buildworld
3264775Sbrian#	KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
3364775Sbrian
3464775Sbrian#
3564775Sbrian# The intended user-driven targets are:
3664775Sbrian# buildworld  - rebuild *everything*, including glue to help do upgrades
3764790Ssheldonh# installworld- install everything built by "buildworld"
3864775Sbrian# doxygen     - build API documentation of the kernel
3964775Sbrian# update      - convenient way to update your source tree (eg: svn/svnup)
4064775Sbrian#
4165064Sbrian# Standard targets (not defined here) are documented in the makefiles in
4265064Sbrian# /usr/share/mk.  These include:
4364775Sbrian#		obj depend all install clean cleandepend cleanobj
4464775Sbrian
4564775Sbrian.if !defined(TARGET) || !defined(TARGET_ARCH)
4664775Sbrian.error "Both TARGET and TARGET_ARCH must be defined."
4765064Sbrian.endif
4865064Sbrian
4965064Sbrian.include "share/mk/src.opts.mk"
5065064Sbrian.include <bsd.arch.inc.mk>
5165064Sbrian.include <bsd.compiler.mk>
52140420Sru
53140420Sru# We must do share/info early so that installation of info `dir'
54140420Sru# entries works correctly.  Do it first since it is less likely to
55140420Sru# grow dependencies on include and lib than vice versa.
56140420Sru#
57140420Sru# We must do lib/ and libexec/ before bin/, because if installworld
5864775Sbrian# installs a new /bin/sh, the 'make' command will *immediately*
5964775Sbrian# use that new version.  And the new (dynamically-linked) /bin/sh
6064775Sbrian# will expect to find appropriate libraries in /lib and /libexec.
6164775Sbrian#
6264775SbrianSRCDIR?=	${.CURDIR}
6364775Sbrian.if defined(SUBDIR_OVERRIDE)
6464775SbrianSUBDIR=	${SUBDIR_OVERRIDE}
6564775Sbrian.else
6664775SbrianSUBDIR=	share/info lib libexec
6764775SbrianSUBDIR+=bin
6864775Sbrian.if ${MK_GAMES} != "no"
6965064SbrianSUBDIR+=games
7064775Sbrian.endif
7165064Sbrian.if ${MK_CDDL} != "no"
7265064SbrianSUBDIR+=cddl
7365064Sbrian.endif
7465064SbrianSUBDIR+=gnu include
7564775Sbrian.if ${MK_KERBEROS} != "no"
7664775SbrianSUBDIR+=kerberos5
7764775Sbrian.endif
7864775Sbrian.if ${MK_RESCUE} != "no"
7964775SbrianSUBDIR+=rescue
8064775Sbrian.endif
8164775SbrianSUBDIR+=sbin
8264775Sbrian.if ${MK_CRYPT} != "no"
8364775SbrianSUBDIR+=secure
8464775Sbrian.endif
8564775Sbrian.if !defined(NO_SHARE)
8664790SsheldonhSUBDIR+=share
8764775Sbrian.endif
8864775SbrianSUBDIR+=sys usr.bin usr.sbin
8964790Ssheldonh.if ${MK_TESTS} != "no"
9064775SbrianSUBDIR+=	tests
9165093Sbrian.endif
92.if ${MK_OFED} != "no"
93SUBDIR+=contrib/ofed
94.endif
95#
96# We must do etc/ last for install/distribute to work.
97#
98SUBDIR+=etc
99
100# These are last, since it is nice to at least get the base system
101# rebuilt before you do them.
102.for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS}
103.if exists(${.CURDIR}/${_DIR}/Makefile)
104SUBDIR+= ${_DIR}
105.endif
106.endfor
107.endif
108
109.if defined(NOCLEAN)
110NO_CLEAN=	${NOCLEAN}
111.endif
112.if defined(NO_CLEANDIR)
113CLEANDIR=	clean cleandepend
114.else
115CLEANDIR=	cleandir
116.endif
117
118LOCAL_TOOL_DIRS?=
119
120BUILDENV_SHELL?=/bin/sh
121
122SVN?=		/usr/local/bin/svn
123SVNFLAGS?=	-r HEAD
124
125MAKEOBJDIRPREFIX?=	/usr/obj
126.if !defined(OSRELDATE)
127.if exists(/usr/include/osreldate.h)
128OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
129		/usr/include/osreldate.h
130.else
131OSRELDATE=	0
132.endif
133.endif
134
135.if !defined(VERSION)
136REVISION!=	${MAKE} -C ${SRCDIR}/release -V REVISION
137BRANCH!=	${MAKE} -C ${SRCDIR}/release -V BRANCH
138SRCRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
139		${SRCDIR}/sys/sys/param.h
140VERSION=	FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
141.endif
142
143KNOWN_ARCHES?=	amd64 arm armeb/arm armv6/arm armv6hf/arm i386 i386/pc98 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
144.if ${TARGET} == ${TARGET_ARCH}
145_t=		${TARGET}
146.else
147_t=		${TARGET_ARCH}/${TARGET}
148.endif
149.for _t in ${_t}
150.if empty(KNOWN_ARCHES:M${_t})
151.error Unknown target ${TARGET_ARCH}:${TARGET}.
152.endif
153.endfor
154
155.if ${TARGET} == ${MACHINE}
156TARGET_CPUTYPE?=${CPUTYPE}
157.else
158TARGET_CPUTYPE?=
159.endif
160
161.if !empty(TARGET_CPUTYPE)
162_TARGET_CPUTYPE=${TARGET_CPUTYPE}
163.else
164_TARGET_CPUTYPE=dummy
165.endif
166_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
167		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
168.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
169.error CPUTYPE global should be set with ?=.
170.endif
171.if make(buildworld)
172BUILD_ARCH!=	uname -p
173.if ${MACHINE_ARCH} != ${BUILD_ARCH}
174.error To cross-build, set TARGET_ARCH.
175.endif
176.endif
177.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
178OBJTREE=	${MAKEOBJDIRPREFIX}
179.else
180OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
181.endif
182WORLDTMP=	${OBJTREE}${.CURDIR}/tmp
183# /usr/games added for fortune which depend on strfile
184BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
185XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
186STRICTTMPPATH=	${BPATH}:${XPATH}
187TMPPATH=	${STRICTTMPPATH}:${PATH}
188
189#
190# Avoid running mktemp(1) unless actually needed.
191# It may not be functional, e.g., due to new ABI
192# when in the middle of installing over this system.
193#
194.if make(distributeworld) || make(installworld)
195INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
196.endif
197
198#
199# Building a world goes through the following stages
200#
201# 1. legacy stage [BMAKE]
202#	This stage is responsible for creating compatibility
203#	shims that are needed by the bootstrap-tools,
204#	build-tools and cross-tools stages.
205# 1. bootstrap-tools stage [BMAKE]
206#	This stage is responsible for creating programs that
207#	are needed for backward compatibility reasons. They
208#	are not built as cross-tools.
209# 2. build-tools stage [TMAKE]
210#	This stage is responsible for creating the object
211#	tree and building any tools that are needed during
212#	the build process.
213# 3. cross-tools stage [XMAKE]
214#	This stage is responsible for creating any tools that
215#	are needed for cross-builds. A cross-compiler is one
216#	of them.
217# 4. world stage [WMAKE]
218#	This stage actually builds the world.
219# 5. install stage (optional) [IMAKE]
220#	This stage installs a previously built world.
221#
222
223BOOTSTRAPPING?=	0
224
225# Common environment for world related stages
226CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
227		MACHINE_ARCH=${TARGET_ARCH} \
228		MACHINE=${TARGET} \
229		CPUTYPE=${TARGET_CPUTYPE}
230.if ${MK_GROFF} != "no"
231CROSSENV+=	GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
232		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
233		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
234.endif
235.if defined(TARGET_CFLAGS)
236CROSSENV+=	${TARGET_CFLAGS}
237.endif
238
239# bootstrap-tools stage
240BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
241		PATH=${BPATH}:${PATH} \
242		WORLDTMP=${WORLDTMP} \
243		VERSION="${VERSION}" \
244		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
245BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
246		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
247		DESTDIR= \
248		BOOTSTRAPPING=${OSRELDATE} \
249		SSP_CFLAGS= \
250		MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
251		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
252		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
253		MK_CLANG_FULL=no MK_LLDB=no MK_TESTS=no
254
255# build-tools stage
256TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
257		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
258		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
259		DESTDIR= \
260		BOOTSTRAPPING=${OSRELDATE} \
261		SSP_CFLAGS= \
262		-DNO_LINT \
263		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no MK_CLANG_FULL=no MK_LLDB=no MK_TESTS=no
264
265# cross-tools stage
266XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
267		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
268		MK_GDB=no MK_TESTS=no
269
270# kernel-tools stage
271KTMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
272		PATH=${BPATH}:${PATH} \
273		WORLDTMP=${WORLDTMP} \
274		VERSION="${VERSION}"
275KTMAKE=		TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
276		${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
277		DESTDIR= \
278		BOOTSTRAPPING=${OSRELDATE} \
279		SSP_CFLAGS= \
280		MK_HTML=no MK_INFO=no -DNO_LINT MK_MAN=no \
281		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
282		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
283
284# world stage
285WMAKEENV=	${CROSSENV} \
286		_SHLIBDIRPREFIX=${WORLDTMP} \
287		_LDSCRIPTROOT= \
288		VERSION="${VERSION}" \
289		INSTALL="sh ${.CURDIR}/tools/install.sh" \
290		PATH=${TMPPATH}
291
292# make hierarchy
293HMAKE=		PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
294.if defined(NO_ROOT)
295HMAKE+=		PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
296.endif
297
298.if ${MK_CDDL} == "no"
299WMAKEENV+=	MK_CTF=no
300.endif
301
302.if defined(CROSS_TOOLCHAIN_PREFIX)
303CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
304CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
305.endif
306XCOMPILERS=	CC CXX CPP
307.for COMPILER in ${XCOMPILERS}
308.if defined(CROSS_COMPILER_PREFIX)
309X${COMPILER}?=	${CROSS_COMPILER_PREFIX}${${COMPILER}}
310.else
311X${COMPILER}?=	${${COMPILER}}
312.endif
313.endfor
314XBINUTILS=	AS AR LD NM OBJDUMP RANLIB STRINGS
315.for BINUTIL in ${XBINUTILS}
316.if defined(CROSS_BINUTILS_PREFIX)
317X${BINUTIL}?=	${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
318.else
319X${BINUTIL}?=	${${BINUTIL}}
320.endif
321.endfor
322WMAKEENV+=	CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
323		CPP="${XCPP} ${XFLAGS}" \
324		AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
325		OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
326
327.if ${XCC:M/*}
328XFLAGS=		--sysroot=${WORLDTMP}
329.if defined(CROSS_BINUTILS_PREFIX)
330# In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
331# directory, but the compiler will look in the right place for it's
332# tools so we don't need to tell it where to look.
333.if exists(${CROSS_BINUTILS_PREFIX})
334XFLAGS+=	-B${CROSS_BINUTILS_PREFIX}
335.endif
336.else
337XFLAGS+=	-B${WORLDTMP}/usr/bin
338.endif
339.if ${TARGET} == "arm"
340.if ${TARGET_ARCH:M*eb*} == ""
341TARGET_ABI=	gnueabi
342.elif ${TARGET_ARCH} == "armv6hf"
343TARGET_ABI=	gnueabihf
344.endif
345.endif
346TARGET_ABI?=	unknown
347TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
348XFLAGS+=	-target ${TARGET_TRIPLE}
349.endif
350
351WMAKE=		${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
352
353.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
354# 32 bit world
355LIB32_OBJTREE=	${OBJTREE}${.CURDIR}/world32
356LIB32TMP=	${OBJTREE}${.CURDIR}/lib32
357
358.if ${TARGET_ARCH} == "amd64"
359.if empty(TARGET_CPUTYPE)
360LIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
361.else
362LIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
363.endif
364LIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
365		MACHINE_CPU="i686 mmx sse sse2"
366LIB32WMAKEFLAGS=	\
367		AS="${AS} --32" \
368		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
369
370.elif ${TARGET_ARCH} == "powerpc64"
371.if empty(TARGET_CPUTYPE)
372LIB32CPUFLAGS=	-mcpu=powerpc
373.else
374LIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
375.endif
376LIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
377LIB32WMAKEFLAGS=	\
378		LD="${LD} -m elf32ppc_fbsd"
379.endif
380
381
382LIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
383		-isystem ${LIB32TMP}/usr/include/ \
384		-L${LIB32TMP}/usr/lib32 \
385		-B${LIB32TMP}/usr/lib32
386.if ${XCC:M/*}
387LIB32FLAGS+=		--sysroot=${WORLDTMP}
388.endif
389
390# Yes, the flags are redundant.
391LIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
392		_SHLIBDIRPREFIX=${LIB32TMP} \
393		_LDSCRIPTROOT=${LIB32TMP} \
394		VERSION="${VERSION}" \
395		INSTALL="sh ${.CURDIR}/tools/install.sh" \
396		PATH=${TMPPATH} \
397		LIBDIR=/usr/lib32 \
398		SHLIBDIR=/usr/lib32 \
399		LIBPRIVATEDIR=/usr/lib32/private \
400		DTRACE="${DTRACE} -32"
401LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
402		CXX="${XCXX} ${LIB32FLAGS}" \
403		DESTDIR=${LIB32TMP} \
404		-DCOMPAT_32BIT \
405		-DLIBRARIES_ONLY \
406		-DNO_CPU_CFLAGS \
407		MK_CTF=no \
408		-DNO_LINT \
409		MK_TESTS=no
410
411LIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
412		MK_MAN=no MK_INFO=no MK_HTML=no
413LIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
414		MK_TOOLCHAIN=no ${IMAKE_INSTALL}
415.endif
416
417IMAKEENV=	${CROSSENV:N_LDSCRIPTROOT=*}
418IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1 \
419		${IMAKE_INSTALL} ${IMAKE_MTREE}
420.if empty(.MAKEFLAGS:M-n)
421IMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
422		LD_LIBRARY_PATH=${INSTALLTMP} \
423		PATH_LOCALE=${INSTALLTMP}/locale
424IMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
425.else
426IMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
427.endif
428.if defined(DB_FROM_SRC)
429INSTALLFLAGS+=	-N ${.CURDIR}/etc
430MTREEFLAGS+=	-N ${.CURDIR}/etc
431.endif
432_INSTALL_DDIR=	${DESTDIR}/${DISTDIR}
433INSTALL_DDIR=	${_INSTALL_DDIR:S://:/:g:C:/$::}
434.if defined(NO_ROOT)
435METALOG?=	${DESTDIR}/${DISTDIR}/METALOG
436IMAKE+=		-DNO_ROOT METALOG=${METALOG}
437INSTALLFLAGS+=	-U -M ${METALOG} -D ${INSTALL_DDIR}
438MTREEFLAGS+=	-W
439.endif
440.if defined(DB_FROM_SRC) || defined(NO_ROOT)
441IMAKE_INSTALL=	INSTALL="install ${INSTALLFLAGS}"
442IMAKE_MTREE=	MTREE_CMD="mtree ${MTREEFLAGS}"
443.endif
444
445# kernel stage
446KMAKEENV=	${WMAKEENV}
447KMAKE=		${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
448
449#
450# buildworld
451#
452# Attempt to rebuild the entire system, with reasonable chance of
453# success, regardless of how old your existing system is.
454#
455_worldtmp:
456.if ${.CURDIR:C/[^,]//g} != ""
457#	The m4 build of sendmail files doesn't like it if ',' is used
458#	anywhere in the path of it's files.
459	@echo
460	@echo "*** Error: path to source tree contains a comma ','"
461	@echo
462	false
463.endif
464	@echo
465	@echo "--------------------------------------------------------------"
466	@echo ">>> Rebuilding the temporary build tree"
467	@echo "--------------------------------------------------------------"
468.if !defined(NO_CLEAN)
469	rm -rf ${WORLDTMP}
470.if defined(LIB32TMP)
471	rm -rf ${LIB32TMP}
472.endif
473.else
474	rm -rf ${WORLDTMP}/legacy/usr/include
475#	XXX - These three can depend on any header file.
476	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
477	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
478	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
479.endif
480.for _dir in \
481    lib usr legacy/bin legacy/usr
482	mkdir -p ${WORLDTMP}/${_dir}
483.endfor
484	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
485	    -p ${WORLDTMP}/legacy/usr >/dev/null
486.if ${MK_GROFF} != "no"
487	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
488	    -p ${WORLDTMP}/legacy/usr >/dev/null
489.endif
490	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
491	    -p ${WORLDTMP}/usr >/dev/null
492	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
493	    -p ${WORLDTMP}/usr/include >/dev/null
494	ln -sf ${.CURDIR}/sys ${WORLDTMP}
495.if ${MK_DEBUG_FILES} != "no"
496	# We could instead disable debug files for these build stages
497	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
498	    -p ${WORLDTMP}/legacy/usr/lib >/dev/null
499	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
500	    -p ${WORLDTMP}/usr/lib >/dev/null
501.endif
502.if ${MK_TESTS} != "no"
503	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
504	    -p ${WORLDTMP}/usr >/dev/null
505.endif
506.for _mtree in ${LOCAL_MTREE}
507	mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
508.endfor
509_legacy:
510	@echo
511	@echo "--------------------------------------------------------------"
512	@echo ">>> stage 1.1: legacy release compatibility shims"
513	@echo "--------------------------------------------------------------"
514	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
515_bootstrap-tools:
516	@echo
517	@echo "--------------------------------------------------------------"
518	@echo ">>> stage 1.2: bootstrap tools"
519	@echo "--------------------------------------------------------------"
520	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
521_cleanobj:
522.if !defined(NO_CLEAN)
523	@echo
524	@echo "--------------------------------------------------------------"
525	@echo ">>> stage 2.1: cleaning up the object tree"
526	@echo "--------------------------------------------------------------"
527	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
528.if defined(LIB32TMP)
529	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
530.endif
531.endif
532_obj:
533	@echo
534	@echo "--------------------------------------------------------------"
535	@echo ">>> stage 2.2: rebuilding the object tree"
536	@echo "--------------------------------------------------------------"
537	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
538_build-tools:
539	@echo
540	@echo "--------------------------------------------------------------"
541	@echo ">>> stage 2.3: build tools"
542	@echo "--------------------------------------------------------------"
543	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
544_cross-tools:
545	@echo
546	@echo "--------------------------------------------------------------"
547	@echo ">>> stage 3: cross tools"
548	@echo "--------------------------------------------------------------"
549	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
550	${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
551_includes:
552	@echo
553	@echo "--------------------------------------------------------------"
554	@echo ">>> stage 4.1: building includes"
555	@echo "--------------------------------------------------------------"
556	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
557_libraries:
558	@echo
559	@echo "--------------------------------------------------------------"
560	@echo ">>> stage 4.2: building libraries"
561	@echo "--------------------------------------------------------------"
562	${_+_}cd ${.CURDIR}; \
563	    ${WMAKE} -DNO_FSCHG MK_HTML=no MK_INFO=no -DNO_LINT MK_MAN=no \
564	    MK_PROFILE=no  MK_TESTS=no libraries
565_depend:
566	@echo
567	@echo "--------------------------------------------------------------"
568	@echo ">>> stage 4.3: make dependencies"
569	@echo "--------------------------------------------------------------"
570	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
571everything:
572	@echo
573	@echo "--------------------------------------------------------------"
574	@echo ">>> stage 4.4: building everything"
575	@echo "--------------------------------------------------------------"
576	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
577.if defined(LIB32TMP)
578build32:
579	@echo
580	@echo "--------------------------------------------------------------"
581	@echo ">>> stage 5.1: building 32 bit shim libraries"
582	@echo "--------------------------------------------------------------"
583	mkdir -p ${LIB32TMP}/usr/include
584	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
585	    -p ${LIB32TMP}/usr >/dev/null
586	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
587	    -p ${LIB32TMP}/usr/include >/dev/null
588.if ${MK_DEBUG_FILES} != "no"
589	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
590	    -p ${LIB32TMP}/usr/lib >/dev/null
591.endif
592	mkdir -p ${WORLDTMP}
593	ln -sf ${.CURDIR}/sys ${WORLDTMP}
594.for _t in obj includes
595	cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
596	cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
597.if ${MK_CDDL} != "no"
598	cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
599.endif
600	cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
601.if ${MK_CRYPT} != "no"
602	cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
603.endif
604.if ${MK_KERBEROS} != "no"
605	cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
606.endif
607.endfor
608.for _dir in usr.bin/lex/lib
609	cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
610.endfor
611.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
612	cd ${.CURDIR}/${_dir}; \
613	    WORLDTMP=${WORLDTMP} \
614	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
615	    MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
616	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
617	    build-tools
618.endfor
619	cd ${.CURDIR}; \
620	    ${LIB32WMAKE} -f Makefile.inc1 libraries
621.for _t in obj depend all
622	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
623	    DIRPRFX=libexec/rtld-elf/ ${_t}
624	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
625	    DIRPRFX=usr.bin/ldd ${_t}
626.endfor
627
628distribute32 install32:
629	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
630.if ${MK_CDDL} != "no"
631	cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
632.endif
633	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
634.if ${MK_CRYPT} != "no"
635	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
636.endif
637.if ${MK_KERBEROS} != "no"
638	cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
639.endif
640	cd ${.CURDIR}/libexec/rtld-elf; \
641	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
642	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
643.endif
644
645WMAKE_TGTS=
646.if !defined(SUBDIR_OVERRIDE)
647WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
648.endif
649WMAKE_TGTS+=	_cleanobj _obj _build-tools
650.if !defined(SUBDIR_OVERRIDE)
651WMAKE_TGTS+=	_cross-tools
652.endif
653WMAKE_TGTS+=	_includes _libraries _depend everything
654.if defined(LIB32TMP) && ${MK_LIB32} != "no"
655WMAKE_TGTS+=	build32
656.endif
657
658buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
659.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
660
661buildworld_prologue:
662	@echo "--------------------------------------------------------------"
663	@echo ">>> World build started on `LC_ALL=C date`"
664	@echo "--------------------------------------------------------------"
665
666buildworld_epilogue:
667	@echo
668	@echo "--------------------------------------------------------------"
669	@echo ">>> World build completed on `LC_ALL=C date`"
670	@echo "--------------------------------------------------------------"
671
672#
673# We need to have this as a target because the indirection between Makefile
674# and Makefile.inc1 causes the correct PATH to be used, rather than a
675# modification of the current environment's PATH.  In addition, we need
676# to quote multiword values.
677#
678buildenvvars:
679	@echo ${WMAKEENV:Q}
680
681buildenv:
682	@echo Entering world for ${TARGET_ARCH}:${TARGET}
683	@cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
684
685TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
686toolchain: ${TOOLCHAIN_TGTS}
687kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
688
689#
690# installcheck
691#
692# Checks to be sure system is ready for installworld/installkernel.
693#
694installcheck: _installcheck_world _installcheck_kernel
695_installcheck_world:
696_installcheck_kernel:
697
698#
699# Require DESTDIR to be set if installing for a different architecture or
700# using the user/group database in the source tree.
701#
702.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
703    defined(DB_FROM_SRC)
704.if !make(distributeworld)
705_installcheck_world: __installcheck_DESTDIR
706_installcheck_kernel: __installcheck_DESTDIR
707__installcheck_DESTDIR:
708.if !defined(DESTDIR) || empty(DESTDIR)
709	@echo "ERROR: Please set DESTDIR!"; \
710	false
711.endif
712.endif
713.endif
714
715.if !defined(DB_FROM_SRC)
716#
717# Check for missing UIDs/GIDs.
718#
719CHECK_UIDS=	auditdistd
720CHECK_GIDS=	audit
721.if ${MK_SENDMAIL} != "no"
722CHECK_UIDS+=	smmsp
723CHECK_GIDS+=	smmsp
724.endif
725.if ${MK_PF} != "no"
726CHECK_UIDS+=	proxy
727CHECK_GIDS+=	proxy authpf
728.endif
729.if ${MK_UNBOUND} != "no"
730CHECK_UIDS+=	unbound
731CHECK_GIDS+=	unbound
732.endif
733_installcheck_world: __installcheck_UGID
734__installcheck_UGID:
735.for uid in ${CHECK_UIDS}
736	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
737		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
738		false; \
739	fi
740.endfor
741.for gid in ${CHECK_GIDS}
742	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
743		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
744		false; \
745	fi
746.endfor
747.endif
748
749#
750# Required install tools to be saved in a scratch dir for safety.
751#
752.if ${MK_INFO} != "no"
753_install-info=	install-info
754.endif
755.if ${MK_ZONEINFO} != "no"
756_zoneinfo=	zic tzsetup
757.endif
758
759ITOOLS=	[ awk cap_mkdb cat chflags chmod chown \
760	date echo egrep find grep id install ${_install-info} \
761	ln lockf make mkdir mtree mv pwd_mkdb \
762	rm sed services_mkdb sh sysctl test true uname wc ${_zoneinfo} \
763	${LOCAL_ITOOLS}
764
765#
766# distributeworld
767#
768# Distributes everything compiled by a `buildworld'.
769#
770# installworld
771#
772# Installs everything compiled by a 'buildworld'.
773#
774
775# Non-base distributions produced by the base system
776EXTRA_DISTRIBUTIONS=	doc
777.if ${MK_GAMES} != "no"
778EXTRA_DISTRIBUTIONS+=	games
779.endif
780.if defined(LIB32TMP) && ${MK_LIB32} != "no"
781EXTRA_DISTRIBUTIONS+=	lib32
782.endif
783.if ${MK_TESTS} != "no"
784EXTRA_DISTRIBUTIONS+=	tests
785.endif
786
787DEBUG_DISTRIBUTIONS=
788.if ${MK_DEBUG_FILES} != "no"
789DEBUG_DISTRIBUTIONS+=	base ${EXTRA_DISTRIBUTIONS:S,doc,,}
790.endif
791
792MTREE_MAGIC?=	mtree 2.0
793
794distributeworld installworld: _installcheck_world
795	mkdir -p ${INSTALLTMP}
796	progs=$$(for prog in ${ITOOLS}; do \
797		if progpath=`which $$prog`; then \
798			echo $$progpath; \
799		else \
800			echo "Required tool $$prog not found in PATH." >&2; \
801			exit 1; \
802		fi; \
803	    done); \
804	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
805	    while read line; do \
806		set -- $$line; \
807		if [ "$$2 $$3" != "not found" ]; then \
808			echo $$2; \
809		else \
810			echo "Required library $$1 not found." >&2; \
811			exit 1; \
812		fi; \
813	    done); \
814	cp $$libs $$progs ${INSTALLTMP}
815	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
816.if defined(NO_ROOT)
817	echo "#${MTREE_MAGIC}" > ${METALOG}
818.endif
819.if make(distributeworld)
820.for dist in ${EXTRA_DISTRIBUTIONS}
821	-mkdir ${DESTDIR}/${DISTDIR}/${dist}
822	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
823	    -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
824	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
825	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
826	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
827	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
828.if ${MK_DEBUG_FILES} != "no"
829	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
830	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
831.endif
832.if ${MK_TESTS} != "no" && ${dist} == "tests"
833	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
834	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
835.endif
836.if defined(NO_ROOT)
837	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
838	    sed -e 's#^\./#./${dist}/#' >> ${METALOG}
839	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
840	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
841	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
842	    sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
843.endif
844.endfor
845	-mkdir ${DESTDIR}/${DISTDIR}/base
846	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
847	    METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
848	    DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
849	    LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
850.endif
851	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
852	    ${IMAKEENV} rm -rf ${INSTALLTMP}
853.if make(distributeworld)
854.for dist in ${EXTRA_DISTRIBUTIONS}
855	find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
856.endfor
857.if defined(NO_ROOT)
858.for dist in base ${EXTRA_DISTRIBUTIONS}
859	@# For each file that exists in this dist, print the corresponding
860	@# line from the METALOG.  This relies on the fact that
861	@# a line containing only the filename will sort immediatly before
862	@# the relevant mtree line.
863	cd ${DESTDIR}/${DISTDIR}; \
864	find ./${dist} | sort -u ${METALOG} - | \
865	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
866	${DESTDIR}/${DISTDIR}/${dist}.meta
867.endfor
868.for dist in ${DEBUG_DISTRIBUTIONS}
869	@# For each file that exists in this dist, print the corresponding
870	@# line from the METALOG.  This relies on the fact that
871	@# a line containing only the filename will sort immediatly before
872	@# the relevant mtree line.
873	cd ${DESTDIR}/${DISTDIR}; \
874	find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
875	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
876	${DESTDIR}/${DISTDIR}/${dist}.debug.meta
877.endfor
878.endif
879.endif
880
881packageworld:
882.for dist in base ${EXTRA_DISTRIBUTIONS}
883.if defined(NO_ROOT)
884	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
885	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
886	    --exclude usr/lib/debug \
887	    @${DESTDIR}/${DISTDIR}/${dist}.meta
888.else
889	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
890	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
891	    --exclude usr/lib/debug .
892.endif
893.endfor
894
895.for dist in ${DEBUG_DISTRIBUTIONS}
896. if defined(NO_ROOT)
897	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
898	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
899	    @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
900. else
901	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
902	    tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
903	    usr/lib/debug
904. endif
905.endfor
906
907#
908# reinstall
909#
910# If you have a build server, you can NFS mount the source and obj directories
911# and do a 'make reinstall' on the *client* to install new binaries from the
912# most recent server build.
913#
914reinstall: .MAKE
915	@echo "--------------------------------------------------------------"
916	@echo ">>> Making hierarchy"
917	@echo "--------------------------------------------------------------"
918	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
919	    LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
920	@echo
921	@echo "--------------------------------------------------------------"
922	@echo ">>> Installing everything"
923	@echo "--------------------------------------------------------------"
924	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
925.if defined(LIB32TMP) && ${MK_LIB32} != "no"
926	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
927.endif
928
929redistribute: .MAKE
930	@echo "--------------------------------------------------------------"
931	@echo ">>> Distributing everything"
932	@echo "--------------------------------------------------------------"
933	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
934.if defined(LIB32TMP) && ${MK_LIB32} != "no"
935	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
936	    DISTRIBUTION=lib32
937.endif
938
939distrib-dirs distribution: .MAKE
940	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
941	    ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
942
943#
944# buildkernel and installkernel
945#
946# Which kernels to build and/or install is specified by setting
947# KERNCONF. If not defined a GENERIC kernel is built/installed.
948# Only the existing (depending TARGET) config files are used
949# for building kernels and only the first of these is designated
950# as the one being installed.
951#
952# Note that we have to use TARGET instead of TARGET_ARCH when
953# we're in kernel-land. Since only TARGET_ARCH is (expected) to
954# be set to cross-build, we have to make sure TARGET is set
955# properly.
956
957.if defined(KERNFAST)
958NO_KERNELCLEAN=	t
959NO_KERNELCONFIG=	t
960NO_KERNELDEPEND=	t
961NO_KERNELOBJ=		t
962# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
963.if !defined(KERNCONF) && ${KERNFAST} != "1"
964KERNCONF=${KERNFAST}
965.endif
966.endif
967.if ${TARGET_ARCH} == "powerpc64"
968KERNCONF?=	GENERIC64
969.else
970KERNCONF?=	GENERIC
971.endif
972INSTKERNNAME?=	kernel
973
974KERNSRCDIR?=	${.CURDIR}/sys
975KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
976KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
977KERNCONFDIR?=	${KRNLCONFDIR}
978
979BUILDKERNELS=
980INSTALLKERNEL=
981.for _kernel in ${KERNCONF}
982.if exists(${KERNCONFDIR}/${_kernel})
983BUILDKERNELS+=	${_kernel}
984.if empty(INSTALLKERNEL)
985INSTALLKERNEL= ${_kernel}
986.endif
987.endif
988.endfor
989
990buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
991
992#
993# buildkernel
994#
995# Builds all kernels defined by BUILDKERNELS.
996#
997buildkernel:
998.if empty(BUILDKERNELS)
999	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1000	false
1001.endif
1002	@echo
1003.for _kernel in ${BUILDKERNELS}
1004	@echo "--------------------------------------------------------------"
1005	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1006	@echo "--------------------------------------------------------------"
1007	@echo "===> ${_kernel}"
1008	mkdir -p ${KRNLOBJDIR}
1009.if !defined(NO_KERNELCONFIG)
1010	@echo
1011	@echo "--------------------------------------------------------------"
1012	@echo ">>> stage 1: configuring the kernel"
1013	@echo "--------------------------------------------------------------"
1014	cd ${KRNLCONFDIR}; \
1015		PATH=${TMPPATH} \
1016		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1017			-I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1018.endif
1019.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1020	@echo
1021	@echo "--------------------------------------------------------------"
1022	@echo ">>> stage 2.1: cleaning up the object tree"
1023	@echo "--------------------------------------------------------------"
1024	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1025.endif
1026.if !defined(NO_KERNELOBJ)
1027	@echo
1028	@echo "--------------------------------------------------------------"
1029	@echo ">>> stage 2.2: rebuilding the object tree"
1030	@echo "--------------------------------------------------------------"
1031	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1032.endif
1033	@echo
1034	@echo "--------------------------------------------------------------"
1035	@echo ">>> stage 2.3: build tools"
1036	@echo "--------------------------------------------------------------"
1037	${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1038.if !defined(NO_KERNELDEPEND)
1039	@echo
1040	@echo "--------------------------------------------------------------"
1041	@echo ">>> stage 3.1: making dependencies"
1042	@echo "--------------------------------------------------------------"
1043	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1044.endif
1045	@echo
1046	@echo "--------------------------------------------------------------"
1047	@echo ">>> stage 3.2: building everything"
1048	@echo "--------------------------------------------------------------"
1049	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1050	@echo "--------------------------------------------------------------"
1051	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1052	@echo "--------------------------------------------------------------"
1053.endfor
1054
1055#
1056# installkernel, etc.
1057#
1058# Install the kernel defined by INSTALLKERNEL
1059#
1060installkernel installkernel.debug \
1061reinstallkernel reinstallkernel.debug: _installcheck_kernel
1062.if empty(INSTALLKERNEL)
1063	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1064	false
1065.endif
1066	@echo "--------------------------------------------------------------"
1067	@echo ">>> Installing kernel ${INSTALLKERNEL}"
1068	@echo "--------------------------------------------------------------"
1069	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1070	    ${CROSSENV} PATH=${TMPPATH} \
1071	    ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1072
1073distributekernel distributekernel.debug:
1074.if empty(INSTALLKERNEL)
1075	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1076	false
1077.endif
1078	mkdir -p ${DESTDIR}/${DISTDIR}
1079.if defined(NO_ROOT)
1080	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1081.endif
1082	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1083	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1084	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1085	    DESTDIR=${INSTALL_DDIR}/kernel \
1086	    ${.TARGET:S/distributekernel/install/}
1087.if defined(NO_ROOT)
1088	sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1089	    ${DESTDIR}/${DISTDIR}/kernel.meta
1090.endif
1091.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1092.if defined(NO_ROOT)
1093	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1094.endif
1095	cd ${KRNLOBJDIR}/${_kernel}; \
1096	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1097	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1098	    KERNEL=${INSTKERNNAME}.${_kernel} \
1099	    DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1100	    ${.TARGET:S/distributekernel/install/}
1101.if defined(NO_ROOT)
1102	sed -e 's|^./kernel|.|' \
1103	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1104	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1105.endif
1106.endfor
1107
1108packagekernel:
1109.if defined(NO_ROOT)
1110	cd ${DESTDIR}/${DISTDIR}/kernel; \
1111	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1112	    @${DESTDIR}/${DISTDIR}/kernel.meta
1113.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1114	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1115	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1116	    @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1117.endfor
1118.else
1119	cd ${DESTDIR}/${DISTDIR}/kernel; \
1120	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1121.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1122	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1123	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1124.endfor
1125.endif
1126
1127#
1128# doxygen
1129#
1130# Build the API documentation with doxygen
1131#
1132doxygen:
1133	@if [ ! -x `/usr/bin/which doxygen` ]; then \
1134		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1135		exit 1; \
1136	fi
1137	cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1138
1139#
1140# update
1141#
1142# Update the source tree(s), by running svn/svnup to update to the
1143# latest copy.
1144#
1145update:
1146.if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1147	@echo "--------------------------------------------------------------"
1148	@echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1149	@echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1150	@echo "--------------------------------------------------------------"
1151	@exit 1
1152.endif
1153.if defined(SVN_UPDATE)
1154	@echo "--------------------------------------------------------------"
1155	@echo ">>> Updating ${.CURDIR} using Subversion"
1156	@echo "--------------------------------------------------------------"
1157	@(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1158.endif
1159
1160#
1161# ------------------------------------------------------------------------
1162#
1163# From here onwards are utility targets used by the 'make world' and
1164# related targets.  If your 'world' breaks, you may like to try to fix
1165# the problem and manually run the following targets to attempt to
1166# complete the build.  Beware, this is *not* guaranteed to work, you
1167# need to have a pretty good grip on the current state of the system
1168# to attempt to manually finish it.  If in doubt, 'make world' again.
1169#
1170
1171#
1172# legacy: Build compatibility shims for the next three targets
1173#
1174legacy:
1175.if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1176	@echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
1177	false
1178.endif
1179.for _tool in tools/build
1180	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1181	    cd ${.CURDIR}/${_tool} && \
1182	    ${MAKE} DIRPRFX=${_tool}/ obj && \
1183	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1184	    ${MAKE} DIRPRFX=${_tool}/ depend && \
1185	    ${MAKE} DIRPRFX=${_tool}/ all && \
1186	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1187.endfor
1188
1189#
1190# bootstrap-tools: Build tools needed for compatibility
1191#
1192.if ${MK_GAMES} != "no"
1193_strfile=	games/fortune/strfile
1194.endif
1195
1196.if ${MK_CXX} != "no"
1197_gperf=		gnu/usr.bin/gperf
1198.endif
1199
1200.if ${MK_GROFF} != "no"
1201_groff=		gnu/usr.bin/groff
1202.endif
1203
1204.if ${MK_VT} != "no"
1205_vtfontcvt=	usr.bin/vtfontcvt
1206.endif
1207
1208.if ${BOOTSTRAPPING} < 900002
1209_sed=		usr.bin/sed
1210.endif
1211
1212.if ${BOOTSTRAPPING} < 1000002
1213_m4=		lib/libohash \
1214		usr.bin/m4
1215.endif
1216
1217.if ${BOOTSTRAPPING} < 1000013
1218_yacc=		lib/liby \
1219		usr.bin/yacc
1220.endif
1221
1222.if ${BOOTSTRAPPING} < 1000014
1223_crunch=	usr.sbin/crunch
1224.endif
1225
1226.if ${BOOTSTRAPPING} < 1000026
1227_nmtree=	lib/libnetbsd \
1228		usr.sbin/nmtree
1229.endif
1230
1231.if ${BOOTSTRAPPING} < 1000027
1232_cat=		bin/cat
1233.endif
1234
1235.if ${BOOTSTRAPPING} < 1000033
1236_lex=		usr.bin/lex
1237.endif
1238
1239.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1240_awk=		usr.bin/awk
1241.endif
1242
1243.if ${MK_BSNMP} != "no"
1244_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
1245.endif
1246
1247# We need to build tblgen when we're building clang either as
1248# the bootstrap compiler, or as the part of the normal build.
1249.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1250_clang_tblgen= \
1251	lib/clang/libllvmsupport \
1252	lib/clang/libllvmtablegen \
1253	usr.bin/clang/tblgen \
1254	usr.bin/clang/clang-tblgen
1255.endif
1256
1257# dtrace tools are required for older bootstrap env and cross-build
1258# pre libdwarf
1259.if ${MK_CDDL} != "no" && (${BOOTSTRAPPING} < 1100006 \
1260      || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1261_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1262    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1263.endif
1264
1265# Default to building the GPL DTC, but build the BSDL one if users explicitly
1266# request it.
1267_dtc= usr.bin/dtc
1268.if ${MK_GPL_DTC} != "no"
1269_dtc= gnu/usr.bin/dtc
1270.endif
1271
1272.if ${MK_KERBEROS} != "no"
1273_kerberos5_bootstrap_tools= \
1274	kerberos5/tools/make-roken \
1275	kerberos5/lib/libroken \
1276	kerberos5/lib/libvers \
1277	kerberos5/tools/asn1_compile \
1278	kerberos5/tools/slc \
1279	usr.bin/compile_et
1280.endif
1281
1282#	Please document (add comment) why something is in 'bootstrap-tools'.
1283#	Try to bound the building of the bootstrap-tool to just the
1284#	FreeBSD versions that need the tool built at this stage of the build.
1285bootstrap-tools: .MAKE
1286.for _tool in \
1287    ${_clang_tblgen} \
1288    ${_kerberos5_bootstrap_tools} \
1289    ${_dtrace_tools} \
1290    ${_strfile} \
1291    ${_gperf} \
1292    ${_groff} \
1293    ${_dtc} \
1294    ${_awk} \
1295    ${_cat} \
1296    usr.bin/lorder \
1297    usr.bin/makewhatis \
1298    usr.bin/rpcgen \
1299    ${_sed} \
1300    ${_yacc} \
1301    ${_m4} \
1302    ${_lex} \
1303    lib/libmd \
1304    usr.bin/xinstall \
1305    ${_gensnmptree} \
1306    usr.sbin/config \
1307    ${_crunch} \
1308    ${_nmtree} \
1309    ${_vtfontcvt}
1310	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1311		cd ${.CURDIR}/${_tool} && \
1312		${MAKE} DIRPRFX=${_tool}/ obj && \
1313		${MAKE} DIRPRFX=${_tool}/ depend && \
1314		${MAKE} DIRPRFX=${_tool}/ all && \
1315		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1316.endfor
1317
1318#
1319# build-tools: Build special purpose build tools
1320#
1321.if !defined(NO_SHARE)
1322_share=	share/syscons/scrnmaps
1323.endif
1324
1325.if ${MK_GCC} != "no"
1326_gcc_tools= gnu/usr.bin/cc/cc_tools
1327.endif
1328
1329.if ${MK_RESCUE} != "no"
1330_rescue= rescue/rescue
1331.endif
1332
1333build-tools: .MAKE
1334.for _tool in \
1335    bin/csh \
1336    bin/sh \
1337    ${_rescue} \
1338    ${LOCAL_TOOL_DIRS} \
1339    lib/ncurses/ncurses \
1340    lib/ncurses/ncursesw \
1341    ${_share} \
1342    usr.bin/awk \
1343    lib/libmagic \
1344    usr.bin/mkesdb_static \
1345    usr.bin/mkcsmapper_static \
1346    usr.bin/vi/catalog
1347	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1348		cd ${.CURDIR}/${_tool} && \
1349		${MAKE} DIRPRFX=${_tool}/ obj && \
1350		${MAKE} DIRPRFX=${_tool}/ build-tools
1351.endfor
1352.for _tool in \
1353    ${_gcc_tools}
1354	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1355		cd ${.CURDIR}/${_tool} && \
1356		${MAKE} DIRPRFX=${_tool}/ obj && \
1357		${MAKE} DIRPRFX=${_tool}/ depend && \
1358		${MAKE} DIRPRFX=${_tool}/ all
1359.endfor
1360
1361#
1362# kernel-tools: Build kernel-building tools
1363#
1364kernel-tools: .MAKE
1365	mkdir -p ${MAKEOBJDIRPREFIX}/usr
1366	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1367	    -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1368
1369#
1370# cross-tools: Build cross-building tools
1371#
1372.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1373.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1374_btxld=		usr.sbin/btxld
1375.endif
1376.endif
1377.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1378.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1379_crunchide=	usr.sbin/crunch/crunchide
1380.endif
1381.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1382_kgzip=		usr.sbin/kgzip
1383.endif
1384.endif
1385
1386# If we're given an XAS, don't build binutils.
1387.if ${XAS:M/*} == "" && ${MK_BINUTILS_BOOTSTRAP} != "no"
1388_binutils=	gnu/usr.bin/binutils
1389.endif
1390
1391# If an full path to an external cross compiler is given, don't build
1392# a cross compiler.
1393.if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1394.if ${MK_CLANG_BOOTSTRAP} != "no"
1395_clang=		usr.bin/clang
1396_clang_libs=	lib/clang
1397.endif
1398.if ${MK_GCC_BOOTSTRAP} != "no"
1399_cc=		gnu/usr.bin/cc
1400.endif
1401.endif
1402
1403cross-tools: .MAKE
1404.for _tool in \
1405    ${_clang_libs} \
1406    ${_clang} \
1407    ${_binutils} \
1408    ${_cc} \
1409    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1410    ${_btxld} \
1411    ${_crunchide} \
1412    ${_kgzip} \
1413    sys/boot/usb/tools
1414	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1415		cd ${.CURDIR}/${_tool} && \
1416		${MAKE} DIRPRFX=${_tool}/ obj && \
1417		${MAKE} DIRPRFX=${_tool}/ depend && \
1418		${MAKE} DIRPRFX=${_tool}/ all && \
1419		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1420.endfor
1421
1422NXBENV=		MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1423		INSTALL="sh ${.CURDIR}/tools/install.sh" \
1424		VERSION="${VERSION}"
1425NXBMAKE=	${NXBENV} ${MAKE} \
1426		TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1427		CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1428		MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1429		MK_GDB=no MK_TESTS=no \
1430		SSP_CFLAGS= \
1431		MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
1432		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
1433		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1434		MK_CLANG_FULL=no MK_LLDB=no
1435
1436native-xtools: .MAKE
1437	mkdir -p ${OBJTREE}/nxb-bin/usr
1438	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1439	    -p ${OBJTREE}/nxb-bin/usr >/dev/null
1440	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1441	    -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1442.for _tool in \
1443    ${_clang_tblgen} \
1444    usr.bin/ar \
1445    ${_binutils} \
1446    ${_cc} \
1447    ${_gcc_tools} \
1448    ${_clang_libs} \
1449    ${_clang} \
1450    usr.bin/awk \
1451    usr.bin/bmake \
1452    usr.bin/lex \
1453    usr.bin/lorder \
1454    usr.bin/sed \
1455    usr.bin/yacc
1456	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1457		cd ${.CURDIR}/${_tool} && \
1458		${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1459		${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1460		${NXBMAKE} DIRPRFX=${_tool}/ all && \
1461		${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1462.endfor
1463
1464#
1465# hierarchy - ensure that all the needed directories are present
1466#
1467hierarchy hier: .MAKE
1468	cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1469
1470#
1471# libraries - build all libraries, and install them under ${DESTDIR}.
1472#
1473# The list of libraries with dependents (${_prebuild_libs}) and their
1474# interdependencies (__L) are built automatically by the
1475# ${.CURDIR}/tools/make_libdeps.sh script.
1476#
1477libraries: .MAKE
1478	cd ${.CURDIR} && \
1479	    ${MAKE} -f Makefile.inc1 _prereq_libs && \
1480	    ${MAKE} -f Makefile.inc1 _startup_libs && \
1481	    ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1482	    ${MAKE} -f Makefile.inc1 _generic_libs
1483
1484#
1485# static libgcc.a prerequisite for shared libc
1486#
1487_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1488
1489# These dependencies are not automatically generated:
1490#
1491# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1492# all shared libraries for ELF.
1493#
1494_startup_libs=	gnu/lib/csu
1495.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1496_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
1497.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1498_startup_libs+=	lib/csu/${MACHINE_ARCH}
1499.else
1500_startup_libs+=	lib/csu/${MACHINE_CPUARCH}
1501.endif
1502_startup_libs+=	gnu/lib/libgcc
1503_startup_libs+=	lib/libcompiler_rt
1504_startup_libs+=	lib/libc
1505_startup_libs+=	lib/libc_nonshared
1506.if ${MK_LIBCPLUSPLUS} != "no"
1507_startup_libs+=	lib/libcxxrt
1508.endif
1509
1510gnu/lib/libgcc__L: lib/libc__L
1511gnu/lib/libgcc__L: lib/libc_nonshared__L
1512.if ${MK_LIBCPLUSPLUS} != "no"
1513lib/libcxxrt__L: gnu/lib/libgcc__L
1514.endif
1515
1516_prebuild_libs=	${_kerberos5_lib_libasn1} \
1517		${_kerberos5_lib_libhdb} \
1518		${_kerberos5_lib_libheimbase} \
1519		${_kerberos5_lib_libheimntlm} \
1520		${_kerberos5_lib_libheimsqlite} \
1521		${_kerberos5_lib_libheimipcc} \
1522		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1523		${_kerberos5_lib_libroken} \
1524		${_kerberos5_lib_libwind} \
1525		${_lib_atf} \
1526		lib/libbz2 ${_libcom_err} lib/libcrypt \
1527		lib/libelf lib/libexpat \
1528		${_lib_libgssapi} \
1529		lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1530		${_lib_libcapsicum} \
1531		lib/ncurses/ncurses lib/ncurses/ncursesw \
1532		lib/libopie lib/libpam ${_lib_libthr} \
1533		lib/libradius lib/libsbuf lib/libtacplus \
1534		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1535		${_cddl_lib_libavl} \
1536		${_cddl_lib_libzfs_core} \
1537		lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1538		${_secure_lib_libcrypto} ${_lib_libldns} \
1539		${_secure_lib_libssh} ${_secure_lib_libssl}
1540.if ${MK_GNUCXX} != "no"
1541_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1542gnu/lib/libstdc++__L: lib/msun__L
1543gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1544.endif
1545
1546.if defined(WITH_ATF) || ${MK_TESTS} != "no"
1547.if !defined(WITH_ATF)
1548# Ensure that the ATF libraries will be built during make libraries, even
1549# though they will have WITHOUT_TESTS
1550MAKE+=		-DWITH_ATF
1551.endif
1552_lib_atf=	lib/atf
1553.endif
1554
1555.if ${MK_LIBTHR} != "no"
1556_lib_libthr=	lib/libthr
1557.endif
1558
1559.if ${MK_OFED} != "no"
1560_ofed_lib=	contrib/ofed/usr.lib/
1561.endif
1562
1563.if ${MK_CASPER} != "no"
1564_lib_libcapsicum=lib/libcapsicum
1565.endif
1566
1567lib/libcapsicum__L: lib/libnv__L
1568lib/libpjdlog__L: lib/libutil__L
1569
1570_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1571.for _DIR in ${LOCAL_LIB_DIRS}
1572.if exists(${.CURDIR}/${_DIR}/Makefile)
1573_generic_libs+= ${_DIR}
1574.endif
1575.endfor
1576
1577lib/libopie__L lib/libtacplus__L: lib/libmd__L
1578
1579.if ${MK_CDDL} != "no"
1580_cddl_lib_libumem= cddl/lib/libumem
1581_cddl_lib_libnvpair= cddl/lib/libnvpair
1582_cddl_lib_libavl= cddl/lib/libavl
1583_cddl_lib_libzfs_core= cddl/lib/libzfs_core
1584_cddl_lib= cddl/lib
1585cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1586.endif
1587
1588.if ${MK_CRYPT} != "no"
1589.if ${MK_OPENSSL} != "no"
1590_secure_lib_libcrypto= secure/lib/libcrypto
1591_secure_lib_libssl= secure/lib/libssl
1592lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1593.if ${MK_LDNS} != "no"
1594_lib_libldns= lib/libldns
1595lib/libldns__L: secure/lib/libcrypto__L
1596.endif
1597.if ${MK_OPENSSH} != "no"
1598_secure_lib_libssh= secure/lib/libssh
1599secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1600.if ${MK_LDNS} != "no"
1601secure/lib/libssh__L: lib/libldns__L
1602.endif
1603.if ${MK_KERBEROS_SUPPORT} != "no"
1604secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1605    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1606    lib/libmd__L kerberos5/lib/libroken__L
1607.endif
1608.endif
1609.endif
1610_secure_lib=	secure/lib
1611.endif
1612
1613.if ${MK_KERBEROS} != "no"
1614kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1615kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1616    kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1617    kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1618kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1619    kerberos5/lib/libroken__L lib/libcom_err__L
1620kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1621    secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1622kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1623    lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1624    kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1625    kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1626kerberos5/lib/libroken__L: lib/libcrypt__L
1627kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1628kerberos5/lib/libheimbase__L: lib/libthr__L
1629kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1630kerberos5/lib/libheimsqlite__L: lib/libthr__L
1631.endif
1632
1633.if ${MK_GSSAPI} != "no"
1634_lib_libgssapi=	lib/libgssapi
1635.endif
1636
1637.if ${MK_KERBEROS} != "no"
1638_kerberos5_lib=	kerberos5/lib
1639_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1640_kerberos5_lib_libhdb= kerberos5/lib/libhdb
1641_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1642_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1643_kerberos5_lib_libhx509= kerberos5/lib/libhx509
1644_kerberos5_lib_libroken= kerberos5/lib/libroken
1645_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1646_kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1647_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1648_kerberos5_lib_libwind= kerberos5/lib/libwind
1649_libcom_err= lib/libcom_err
1650.endif
1651
1652.if ${MK_NIS} != "no"
1653_lib_libypclnt=	lib/libypclnt
1654.endif
1655
1656.if ${MK_OPENSSL} == "no"
1657lib/libradius__L: lib/libmd__L
1658.endif
1659
1660.for _lib in ${_prereq_libs}
1661${_lib}__PL: .PHONY .MAKE
1662.if exists(${.CURDIR}/${_lib})
1663	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1664		cd ${.CURDIR}/${_lib} && \
1665		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1666		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1667		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1668		    DIRPRFX=${_lib}/ all && \
1669		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1670		    DIRPRFX=${_lib}/ install
1671.endif
1672.endfor
1673
1674.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1675${_lib}__L: .PHONY .MAKE
1676.if exists(${.CURDIR}/${_lib})
1677	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1678		cd ${.CURDIR}/${_lib} && \
1679		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1680		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1681		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1682		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1683.endif
1684.endfor
1685
1686# libpam is special: we need to build static PAM modules before
1687# static PAM library, and dynamic PAM library before dynamic PAM
1688# modules.
1689lib/libpam__L: .PHONY .MAKE
1690	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1691		cd ${.CURDIR}/lib/libpam && \
1692		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1693		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1694		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1695		    -D_NO_LIBPAM_SO_YET all && \
1696		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1697		    -D_NO_LIBPAM_SO_YET install
1698
1699_prereq_libs: ${_prereq_libs:S/$/__PL/}
1700_startup_libs: ${_startup_libs:S/$/__L/}
1701_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1702_generic_libs: ${_generic_libs:S/$/__L/}
1703
1704.for __target in all clean cleandepend cleandir depend includes obj
1705.for entry in ${SUBDIR}
1706${entry}.${__target}__D: .PHONY .MAKE
1707	${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1708		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1709		edir=${entry}.${MACHINE_ARCH}; \
1710		cd ${.CURDIR}/$${edir}; \
1711	else \
1712		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1713		edir=${entry}; \
1714		cd ${.CURDIR}/$${edir}; \
1715	fi; \
1716	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1717.endfor
1718par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1719.endfor
1720
1721.include <bsd.subdir.mk>
1722
1723.if make(check-old) || make(check-old-dirs) || \
1724    make(check-old-files) || make(check-old-libs) || \
1725    make(delete-old) || make(delete-old-dirs) || \
1726    make(delete-old-files) || make(delete-old-libs)
1727
1728#
1729# check for / delete old files section
1730#
1731
1732.include "ObsoleteFiles.inc"
1733
1734OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1735else you can not start such an application. Consult UPDATING for more \
1736information regarding how to cope with the removal/revision bump of a \
1737specific library."
1738
1739.if !defined(BATCH_DELETE_OLD_FILES)
1740RM_I=-i
1741.else
1742RM_I=-v
1743.endif
1744
1745delete-old-files:
1746	@echo ">>> Removing old files (only deletes safe to delete libs)"
1747# Ask for every old file if the user really wants to remove it.
1748# It's annoying, but better safe than sorry.
1749# NB: We cannot pass the list of OLD_FILES as a parameter because the
1750# argument list will get too long. Using .for/.endfor make "loops" will make
1751# the Makefile parser segfault.
1752	@exec 3<&0; \
1753	cd ${.CURDIR}; \
1754	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1755	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1756	while read file; do \
1757		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1758			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1759			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1760		fi; \
1761	done
1762# Remove catpages without corresponding manpages.
1763	@exec 3<&0; \
1764	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1765	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1766	while read catpage; do \
1767		read manpage; \
1768		if [ ! -e "$${manpage}" ]; then \
1769			rm ${RM_I} $${catpage} <&3; \
1770	        fi; \
1771	done
1772	@echo ">>> Old files removed"
1773
1774check-old-files:
1775	@echo ">>> Checking for old files"
1776	@cd ${.CURDIR}; \
1777	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1778	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1779	while read file; do \
1780		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1781		 	echo "${DESTDIR}/$${file}"; \
1782		fi; \
1783	done
1784# Check for catpages without corresponding manpages.
1785	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1786	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1787	while read catpage; do \
1788		read manpage; \
1789		if [ ! -e "$${manpage}" ]; then \
1790			echo $${catpage}; \
1791	        fi; \
1792	done
1793
1794delete-old-libs:
1795	@echo ">>> Removing old libraries"
1796	@echo "${OLD_LIBS_MESSAGE}" | fmt
1797	@exec 3<&0; \
1798	cd ${.CURDIR}; \
1799	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1800	    -V OLD_LIBS | xargs -n1 | \
1801	while read file; do \
1802		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1803			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1804			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1805		fi; \
1806		for ext in debug symbols; do \
1807		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1808		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1809			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1810			      <&3; \
1811		  fi; \
1812		done; \
1813	done
1814	@echo ">>> Old libraries removed"
1815
1816check-old-libs:
1817	@echo ">>> Checking for old libraries"
1818	@cd ${.CURDIR}; \
1819	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1820	    -V OLD_LIBS | xargs -n1 | \
1821	while read file; do \
1822		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1823			echo "${DESTDIR}/$${file}"; \
1824		fi; \
1825		for ext in debug symbols; do \
1826		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1827			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1828		  fi; \
1829		done; \
1830	done
1831
1832delete-old-dirs:
1833	@echo ">>> Removing old directories"
1834	@cd ${.CURDIR}; \
1835	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1836	    -V OLD_DIRS | xargs -n1 | sort -r | \
1837	while read dir; do \
1838		if [ -d "${DESTDIR}/$${dir}" ]; then \
1839			rmdir -v "${DESTDIR}/$${dir}" || true; \
1840		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1841			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1842		fi; \
1843	done
1844	@echo ">>> Old directories removed"
1845
1846check-old-dirs:
1847	@echo ">>> Checking for old directories"
1848	@cd ${.CURDIR}; \
1849	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1850	    -V OLD_DIRS | xargs -n1 | \
1851	while read dir; do \
1852		if [ -d "${DESTDIR}/$${dir}" ]; then \
1853			echo "${DESTDIR}/$${dir}"; \
1854		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1855			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1856		fi; \
1857	done
1858
1859delete-old: delete-old-files delete-old-dirs
1860	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1861
1862check-old: check-old-files check-old-libs check-old-dirs
1863	@echo "To remove old files and directories run '${MAKE} delete-old'."
1864	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1865
1866.endif
1867
1868#
1869# showconfig - show build configuration.
1870#
1871showconfig:
1872	@${MAKE} -n -f src.opts.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1873
1874.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1875DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1876
1877.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1878.if exists(${KERNCONFDIR}/${KERNCONF})
1879FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1880	'${KERNCONFDIR}/${KERNCONF}' ; echo
1881.endif
1882.endif
1883
1884.endif
1885
1886.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1887DTBOUTPUTPATH= ${.CURDIR}
1888.endif
1889
1890#
1891# Build 'standalone' Device Tree Blob
1892#
1893builddtb:
1894	@PATH=${TMPPATH} MACHINE=${TARGET} \
1895	${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
1896	    "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
1897
1898###############
1899
1900.if defined(TARGET) && defined(TARGET_ARCH)
1901
1902.if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
1903XDEV_CPUTYPE?=${CPUTYPE}
1904.else
1905XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1906.endif
1907
1908NOFUN=-DNO_FSCHG MK_HTML=no MK_INFO=no -DNO_LINT \
1909	MK_MAN=no MK_NLS=no MK_PROFILE=no \
1910	MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
1911	TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
1912	CPUTYPE=${XDEV_CPUTYPE}
1913
1914XDDIR=${TARGET_ARCH}-freebsd
1915XDTP?=/usr/${XDDIR}
1916.if ${XDTP:N/*}
1917.error XDTP variable should be an absolute path
1918.endif
1919
1920CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1921	INSTALL="sh ${.CURDIR}/tools/install.sh"
1922CDENV= ${CDBENV} \
1923	_SHLIBDIRPREFIX=${XDDESTDIR} \
1924	TOOLS_PREFIX=${XDTP}
1925CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1926	--sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
1927	-B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
1928CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
1929	CPP="${CPP} ${CD2CFLAGS}" \
1930	MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
1931
1932CDTMP=	${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1933CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1934CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1935XDDESTDIR=${DESTDIR}/${XDTP}
1936.if !defined(OSREL)
1937OSREL!= uname -r | sed -e 's/[-(].*//'
1938.endif
1939
1940.ORDER: xdev-build xdev-install xdev-links
1941xdev: xdev-build xdev-install
1942
1943.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1944xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1945
1946_xb-worldtmp:
1947	mkdir -p ${CDTMP}/usr
1948	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1949	    -p ${CDTMP}/usr >/dev/null
1950
1951_xb-bootstrap-tools:
1952.for _tool in \
1953    ${_clang_tblgen}
1954	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1955	cd ${.CURDIR}/${_tool} && \
1956	${CDMAKE} DIRPRFX=${_tool}/ obj && \
1957	${CDMAKE} DIRPRFX=${_tool}/ depend && \
1958	${CDMAKE} DIRPRFX=${_tool}/ all && \
1959	${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1960.endfor
1961
1962_xb-build-tools:
1963	${_+_}@cd ${.CURDIR}; \
1964	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1965
1966_xb-cross-tools:
1967.for _tool in \
1968    ${_binutils} \
1969    usr.bin/ar \
1970    ${_clang_libs} \
1971    ${_clang} \
1972    ${_cc}
1973	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1974	cd ${.CURDIR}/${_tool} && \
1975	${CDMAKE} DIRPRFX=${_tool}/ obj && \
1976	${CDMAKE} DIRPRFX=${_tool}/ depend && \
1977	${CDMAKE} DIRPRFX=${_tool}/ all
1978.endfor
1979
1980_xi-mtree:
1981	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1982	mkdir -p ${XDDESTDIR}
1983	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1984	    -p ${XDDESTDIR} >/dev/null
1985	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1986	    -p ${XDDESTDIR}/usr >/dev/null
1987	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1988	    -p ${XDDESTDIR}/usr/include >/dev/null
1989.if ${MK_TESTS} != "no"
1990	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1991	    -p ${XDDESTDIR}/usr >/dev/null
1992.endif
1993
1994.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
1995xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
1996
1997_xi-cross-tools:
1998	@echo "_xi-cross-tools"
1999.for _tool in \
2000    ${_binutils} \
2001    usr.bin/ar \
2002    ${_clang_libs} \
2003    ${_clang} \
2004    ${_cc}
2005	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2006	cd ${.CURDIR}/${_tool}; \
2007	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2008.endfor
2009
2010_xi-includes:
2011	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2012		DESTDIR=${XDDESTDIR}
2013
2014_xi-libraries:
2015	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2016		DESTDIR=${XDDESTDIR}
2017
2018xdev-links:
2019	${_+_}cd ${XDDESTDIR}/usr/bin; \
2020	mkdir -p ../../../../usr/bin; \
2021		for i in *; do \
2022			ln -sf ../../${XDTP}/usr/bin/$$i \
2023			    ../../../../usr/bin/${XDDIR}-$$i; \
2024			ln -sf ../../${XDTP}/usr/bin/$$i \
2025			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2026		done
2027.else
2028xdev xdev-build xdev-install xdev-links:
2029	@echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2030.endif
2031