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