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