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