Makefile.inc1 revision 296405
1#
2# $FreeBSD: head/Makefile.inc1 296405 2016-03-05 05:08:57Z bdrewery $
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:${SHELL})
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#	SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34#	    All libraries and includes, and some build tools will still build.
35
36#
37# The intended user-driven targets are:
38# buildworld  - rebuild *everything*, including glue to help do upgrades
39# installworld- install everything built by "buildworld"
40# checkworld  - run test suite on installed world
41# doxygen     - build API documentation of the kernel
42# update      - convenient way to update your source tree (eg: svn/svnup)
43#
44# Standard targets (not defined here) are documented in the makefiles in
45# /usr/share/mk.  These include:
46#		obj depend all install clean cleandepend cleanobj
47
48.if !defined(TARGET) || !defined(TARGET_ARCH)
49.error "Both TARGET and TARGET_ARCH must be defined."
50.endif
51
52LOCALBASE?=	/usr/local
53
54# Cross toolchain changes must be in effect before bsd.compiler.mk
55# so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56.if defined(CROSS_TOOLCHAIN)
57.include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
59.endif
60.include <bsd.compiler.mk>		# don't depend on src.opts.mk doing it
61.include "share/mk/src.opts.mk"	
62
63# We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64# keep the users system reasonably usable.  For static->dynamic root upgrades,
65# we don't want to install a dynamic binary without rtld and the needed
66# libraries.  More commonly, for dynamic root, we don't want to install a
67# binary that requires a newer library version that hasn't been installed yet.
68# This ordering is not a guarantee though.  The only guarantee of a working
69# system here would require fine-grained ordering of all components based
70# on their dependencies.
71SRCDIR?=	${.CURDIR}
72.if !empty(SUBDIR_OVERRIDE)
73SUBDIR=	${SUBDIR_OVERRIDE}
74.else
75SUBDIR=	lib libexec
76.if !defined(NO_ROOT) && (make(installworld) || make(install))
77# Ensure libraries are installed before progressing.
78SUBDIR+=.WAIT
79.endif
80SUBDIR+=bin
81.if ${MK_CDDL} != "no"
82SUBDIR+=cddl
83.endif
84SUBDIR+=gnu include
85.if ${MK_KERBEROS} != "no"
86SUBDIR+=kerberos5
87.endif
88.if ${MK_RESCUE} != "no"
89SUBDIR+=rescue
90.endif
91SUBDIR+=sbin
92.if ${MK_CRYPT} != "no"
93SUBDIR+=secure
94.endif
95.if !defined(NO_SHARE)
96SUBDIR+=share
97.endif
98SUBDIR+=sys usr.bin usr.sbin
99.if ${MK_TESTS} != "no"
100SUBDIR+=	tests
101.endif
102.if ${MK_OFED} != "no"
103SUBDIR+=contrib/ofed
104.endif
105
106# Local directories are last, since it is nice to at least get the base
107# system rebuilt before you do them.
108.for _DIR in ${LOCAL_DIRS}
109.if exists(${.CURDIR}/${_DIR}/Makefile)
110SUBDIR+=	${_DIR}
111.endif
112.endfor
113# Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114# of a LOCAL_DIRS directory.  This allows LOCAL_DIRS=foo and
115# LOCAL_LIB_DIRS=foo/lib to behave as expected.
116.for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117_REDUNDENT_LIB_DIRS+=    ${LOCAL_LIB_DIRS:M${_DIR}*}
118.endfor
119.for _DIR in ${LOCAL_LIB_DIRS}
120.if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
121SUBDIR+=	${_DIR}
122.else
123.warning ${_DIR} not added to SUBDIR list.  See UPDATING 20141121.
124.endif
125.endfor
126
127# We must do etc/ last as it hooks into building the man whatis file
128# by calling 'makedb' in share/man.  This is only relevant for
129# install/distribute so they build the whatis file after every manpage is
130# installed.
131.if make(installworld) || make(install)
132SUBDIR+=.WAIT
133.endif
134SUBDIR+=etc
135
136.endif	# !empty(SUBDIR_OVERRIDE)
137
138.if defined(NOCLEAN)
139.warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
140NO_CLEAN=	${NOCLEAN}
141.endif
142.if defined(NO_CLEANDIR)
143CLEANDIR=	clean cleandepend
144.else
145CLEANDIR=	cleandir
146.endif
147
148# FAST_DEPEND can skip depend tree-walks.
149.if ${MK_FAST_DEPEND} == "yes"
150NO_DEPEND=	t
151NO_KERNELDEPEND=t
152.endif
153# Ensure shell checks later have a value.
154.if defined(NO_DEPEND)
155NO_DEPEND=	t
156.endif
157
158LOCAL_TOOL_DIRS?=
159PACKAGEDIR?=	${DESTDIR}/${DISTDIR}
160
161.if empty(SHELL:M*csh*)
162BUILDENV_SHELL?=${SHELL}
163.else
164BUILDENV_SHELL?=/bin/sh
165.endif
166
167SVN?=		/usr/local/bin/svn
168SVNFLAGS?=	-r HEAD
169
170MAKEOBJDIRPREFIX?=	/usr/obj
171.if !defined(OSRELDATE)
172.if exists(/usr/include/osreldate.h)
173OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174		/usr/include/osreldate.h
175.else
176OSRELDATE=	0
177.endif
178.export OSRELDATE
179.endif
180
181# Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182.if !defined(VERSION) && !make(showconfig)
183REVISION!=	${MAKE} -C ${SRCDIR}/release -V REVISION
184BRANCH!=	${MAKE} -C ${SRCDIR}/release -V BRANCH
185SRCRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186		${SRCDIR}/sys/sys/param.h
187VERSION=	FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
188.export VERSION
189.endif
190
191KNOWN_ARCHES?=	aarch64/arm64 \
192		amd64 \
193		arm \
194		armeb/arm \
195		armv6/arm \
196		armv6hf/arm \
197		i386 \
198		i386/pc98 \
199		mips \
200		mipsel/mips \
201		mips64el/mips \
202		mips64/mips \
203		mipsn32el/mips \
204		mipsn32/mips \
205		powerpc \
206		powerpc64/powerpc \
207		riscv64/riscv \
208		sparc64
209
210.if ${TARGET} == ${TARGET_ARCH}
211_t=		${TARGET}
212.else
213_t=		${TARGET_ARCH}/${TARGET}
214.endif
215.for _t in ${_t}
216.if empty(KNOWN_ARCHES:M${_t})
217.error Unknown target ${TARGET_ARCH}:${TARGET}.
218.endif
219.endfor
220
221.if ${TARGET} == ${MACHINE}
222TARGET_CPUTYPE?=${CPUTYPE}
223.else
224TARGET_CPUTYPE?=
225.endif
226
227.if !empty(TARGET_CPUTYPE)
228_TARGET_CPUTYPE=${TARGET_CPUTYPE}
229.else
230_TARGET_CPUTYPE=dummy
231.endif
232# Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
233.if !make(showconfig)
234_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
235		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
236.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
237.error CPUTYPE global should be set with ?=.
238.endif
239.endif
240.if make(buildworld)
241BUILD_ARCH!=	uname -p
242.if ${MACHINE_ARCH} != ${BUILD_ARCH}
243.error To cross-build, set TARGET_ARCH.
244.endif
245.endif
246.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
247OBJTREE=	${MAKEOBJDIRPREFIX}
248.else
249OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
250.endif
251WORLDTMP=	${OBJTREE}${.CURDIR}/tmp
252BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
253XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
254STRICTTMPPATH=	${BPATH}:${XPATH}
255TMPPATH=	${STRICTTMPPATH}:${PATH}
256
257#
258# Avoid running mktemp(1) unless actually needed.
259# It may not be functional, e.g., due to new ABI
260# when in the middle of installing over this system.
261#
262.if make(distributeworld) || make(installworld)
263INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
264.endif
265
266#
267# Building a world goes through the following stages
268#
269# 1. legacy stage [BMAKE]
270#	This stage is responsible for creating compatibility
271#	shims that are needed by the bootstrap-tools,
272#	build-tools and cross-tools stages. These are generally
273#	APIs that tools from one of those three stages need to
274#	build that aren't present on the host.
275# 1. bootstrap-tools stage [BMAKE]
276#	This stage is responsible for creating programs that
277#	are needed for backward compatibility reasons. They
278#	are not built as cross-tools.
279# 2. build-tools stage [TMAKE]
280#	This stage is responsible for creating the object
281#	tree and building any tools that are needed during
282#	the build process. Some programs are listed during
283#	this phase because they build binaries to generate
284#	files needed to build these programs. This stage also
285#	builds the 'build-tools' target rather than 'all'.
286# 3. cross-tools stage [XMAKE]
287#	This stage is responsible for creating any tools that
288#	are needed for building the system. A cross-compiler is one
289#	of them. This differs from build tools in two ways:
290#	1. the 'all' target is built rather than 'build-tools'
291#	2. these tools are installed into TMPPATH for stage 4.
292# 4. world stage [WMAKE]
293#	This stage actually builds the world.
294# 5. install stage (optional) [IMAKE]
295#	This stage installs a previously built world.
296#
297
298BOOTSTRAPPING?=	0
299
300# Common environment for world related stages
301CROSSENV+=	MAKEOBJDIRPREFIX=${OBJTREE} \
302		MACHINE_ARCH=${TARGET_ARCH} \
303		MACHINE=${TARGET} \
304		CPUTYPE=${TARGET_CPUTYPE}
305.if ${MK_GROFF} != "no"
306CROSSENV+=	GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
307		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
308		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
309.endif
310.if defined(TARGET_CFLAGS)
311CROSSENV+=	${TARGET_CFLAGS}
312.endif
313
314# bootstrap-tools stage
315BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
316		PATH=${BPATH}:${PATH} \
317		WORLDTMP=${WORLDTMP} \
318		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
319# need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
320BSARGS= 	DESTDIR= \
321		BOOTSTRAPPING=${OSRELDATE} \
322		SSP_CFLAGS= \
323		MK_HTML=no NO_LINT=yes MK_MAN=no \
324		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
325		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
326		MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
327		MK_LLDB=no MK_TESTS=no \
328		MK_INCLUDES=yes
329
330BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
331		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
332		${BSARGS}
333
334# build-tools stage
335TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
336		${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
337		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
338		DESTDIR= \
339		BOOTSTRAPPING=${OSRELDATE} \
340		SSP_CFLAGS= \
341		-DNO_LINT \
342		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
343		MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
344		MK_LLDB=no MK_TESTS=no
345
346# cross-tools stage
347XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
348		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
349		MK_GDB=no MK_TESTS=no
350
351# kernel-tools stage
352KTMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
353		PATH=${BPATH}:${PATH} \
354		WORLDTMP=${WORLDTMP}
355KTMAKE=		TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
356		${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
357		DESTDIR= \
358		BOOTSTRAPPING=${OSRELDATE} \
359		SSP_CFLAGS= \
360		MK_HTML=no -DNO_LINT MK_MAN=no \
361		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
362		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
363
364# world stage
365WMAKEENV=	${CROSSENV} \
366		_LDSCRIPTROOT= \
367		INSTALL="sh ${.CURDIR}/tools/install.sh" \
368		PATH=${TMPPATH}
369
370# make hierarchy
371HMAKE=		PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
372.if defined(NO_ROOT)
373HMAKE+=		PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
374.endif
375
376.if defined(CROSS_TOOLCHAIN_PREFIX)
377CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
378CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
379.endif
380
381# If we do not have a bootstrap binutils (because the in-tree one does not
382# support the target architecture), provide a default cross-binutils prefix.
383# This allows aarch64 builds, for example, to automatically use the
384# aarch64-binutils port or package.
385.if !make(showconfig)
386.if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
387    !defined(CROSS_BINUTILS_PREFIX)
388CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
389.if !exists(${CROSS_BINUTILS_PREFIX})
390.error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
391.endif
392.endif
393.endif
394
395XCOMPILERS=	CC CXX CPP
396.for COMPILER in ${XCOMPILERS}
397.if defined(CROSS_COMPILER_PREFIX)
398X${COMPILER}?=	${CROSS_COMPILER_PREFIX}${${COMPILER}}
399.else
400X${COMPILER}?=	${${COMPILER}}
401.endif
402.endfor
403XBINUTILS=	AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
404.for BINUTIL in ${XBINUTILS}
405.if defined(CROSS_BINUTILS_PREFIX) && \
406    exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
407X${BINUTIL}?=	${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
408.else
409X${BINUTIL}?=	${${BINUTIL}}
410.endif
411.endfor
412CROSSENV+=	CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
413		DEPFLAGS="${DEPFLAGS}" \
414		CPP="${XCPP} ${XCFLAGS}" \
415		AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
416		OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
417		RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
418		SIZE="${XSIZE}"
419
420.if ${XCC:N${CCACHE_BIN}:M/*}
421.if defined(CROSS_BINUTILS_PREFIX)
422# In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
423# directory, but the compiler will look in the right place for it's
424# tools so we don't need to tell it where to look.
425.if exists(${CROSS_BINUTILS_PREFIX})
426BFLAGS+=	-B${CROSS_BINUTILS_PREFIX}
427.endif
428.else
429BFLAGS+=	-B${WORLDTMP}/usr/bin
430.endif
431.if ${TARGET} == "arm"
432.if ${TARGET_ARCH:M*hf*} != ""
433TARGET_ABI=	gnueabihf
434.else
435TARGET_ABI=	gnueabi
436.endif
437.endif
438.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
439XCFLAGS+=	-isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
440XCXXFLAGS+=	-I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
441# XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
442# due to CXX="${XCXX} ${XCXXFLAGS}".  bsd.dep.mk does use CXXFLAGS when
443# building C++ files so this can come out if passing CXXFLAGS down is fixed.
444DEPFLAGS+=	-I${WORLDTMP}/usr/include/c++/v1
445.else
446TARGET_ABI?=	unknown
447TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
448XCFLAGS+=	-target ${TARGET_TRIPLE}
449.endif
450XCFLAGS+=	--sysroot=${WORLDTMP} ${BFLAGS}
451XCXXFLAGS+=	--sysroot=${WORLDTMP} ${BFLAGS}
452.else
453.if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
454BFLAGS+=	-B${CROSS_BINUTILS_PREFIX}
455XCFLAGS+=	${BFLAGS}
456XCXXFLAGS+=	${BFLAGS}
457.endif
458.endif # ${XCC:M/*}
459
460WMAKE=		${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
461
462.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
463# 32 bit world
464LIB32_OBJTREE=	${OBJTREE}${.CURDIR}/world32
465LIB32TMP=	${OBJTREE}${.CURDIR}/lib32
466
467.if ${TARGET_ARCH} == "amd64"
468.if empty(TARGET_CPUTYPE)
469LIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
470.else
471LIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
472.endif
473LIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
474		MACHINE_CPU="i686 mmx sse sse2"
475LIB32WMAKEFLAGS=	\
476		AS="${XAS} --32" \
477		LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
478		OBJCOPY="${XOBJCOPY}"
479
480.elif ${TARGET_ARCH} == "powerpc64"
481.if empty(TARGET_CPUTYPE)
482LIB32CPUFLAGS=	-mcpu=powerpc
483.else
484LIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
485.endif
486LIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
487LIB32WMAKEFLAGS=	\
488		LD="${XLD} -m elf32ppc_fbsd" \
489		OBJCOPY="${XOBJCOPY}"
490.endif
491
492
493LIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
494		-isystem ${LIB32TMP}/usr/include/ \
495		-L${LIB32TMP}/usr/lib32 \
496		-B${LIB32TMP}/usr/lib32
497.if ${XCC:N${CCACHE_BIN}:M/*}
498LIB32FLAGS+=		--sysroot=${WORLDTMP}
499.endif
500
501# Yes, the flags are redundant.
502LIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
503		_LDSCRIPTROOT=${LIB32TMP} \
504		INSTALL="sh ${.CURDIR}/tools/install.sh" \
505		PATH=${TMPPATH} \
506		LIBDIR=/usr/lib32 \
507		SHLIBDIR=/usr/lib32 \
508		DTRACE="${DTRACE} -32"
509LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
510		CXX="${XCXX} ${LIB32FLAGS}" \
511		DESTDIR=${LIB32TMP} \
512		-DCOMPAT_32BIT \
513		-DLIBRARIES_ONLY \
514		-DNO_CPU_CFLAGS \
515		MK_CTF=no \
516		-DNO_LINT \
517		MK_TESTS=no
518
519LIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
520		MK_MAN=no MK_HTML=no
521LIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
522		MK_TOOLCHAIN=no ${IMAKE_INSTALL}
523.endif
524
525IMAKEENV=	${CROSSENV:N_LDSCRIPTROOT=*}
526IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1 \
527		${IMAKE_INSTALL} ${IMAKE_MTREE}
528.if empty(.MAKEFLAGS:M-n)
529IMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
530		LD_LIBRARY_PATH=${INSTALLTMP} \
531		PATH_LOCALE=${INSTALLTMP}/locale
532IMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
533.else
534IMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
535.endif
536.if defined(DB_FROM_SRC)
537INSTALLFLAGS+=	-N ${.CURDIR}/etc
538MTREEFLAGS+=	-N ${.CURDIR}/etc
539.endif
540_INSTALL_DDIR=	${DESTDIR}/${DISTDIR}
541INSTALL_DDIR=	${_INSTALL_DDIR:S://:/:g:C:/$::}
542.if defined(NO_ROOT)
543METALOG?=	${DESTDIR}/${DISTDIR}/METALOG
544IMAKE+=		-DNO_ROOT METALOG=${METALOG}
545INSTALLFLAGS+=	-U -M ${METALOG} -D ${INSTALL_DDIR}
546MTREEFLAGS+=	-W
547.endif
548.if defined(DB_FROM_SRC) || defined(NO_ROOT)
549IMAKE_INSTALL=	INSTALL="install ${INSTALLFLAGS}"
550IMAKE_MTREE=	MTREE_CMD="mtree ${MTREEFLAGS}"
551.endif
552
553# kernel stage
554KMAKEENV=	${WMAKEENV}
555KMAKE=		${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
556
557#
558# buildworld
559#
560# Attempt to rebuild the entire system, with reasonable chance of
561# success, regardless of how old your existing system is.
562#
563_worldtmp: .PHONY
564.if ${.CURDIR:C/[^,]//g} != ""
565#	The m4 build of sendmail files doesn't like it if ',' is used
566#	anywhere in the path of it's files.
567	@echo
568	@echo "*** Error: path to source tree contains a comma ','"
569	@echo
570	false
571.endif
572	@echo
573	@echo "--------------------------------------------------------------"
574	@echo ">>> Rebuilding the temporary build tree"
575	@echo "--------------------------------------------------------------"
576.if !defined(NO_CLEAN)
577	rm -rf ${WORLDTMP}
578.if defined(LIB32TMP)
579	rm -rf ${LIB32TMP}
580.endif
581.else
582	rm -rf ${WORLDTMP}/legacy/usr/include
583#	XXX - These can depend on any header file.
584	rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
585	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
586.endif
587.for _dir in \
588    lib lib/casper usr legacy/bin legacy/usr
589	mkdir -p ${WORLDTMP}/${_dir}
590.endfor
591	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
592	    -p ${WORLDTMP}/legacy/usr >/dev/null
593.if ${MK_GROFF} != "no"
594	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
595	    -p ${WORLDTMP}/legacy/usr >/dev/null
596.endif
597	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
598	    -p ${WORLDTMP}/usr >/dev/null
599	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
600	    -p ${WORLDTMP}/usr/include >/dev/null
601	ln -sf ${.CURDIR}/sys ${WORLDTMP}
602.if ${MK_DEBUG_FILES} != "no"
603	# We could instead disable debug files for these build stages
604	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
605	    -p ${WORLDTMP}/legacy/usr/lib >/dev/null
606	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
607	    -p ${WORLDTMP}/usr/lib >/dev/null
608.endif
609.if ${MK_LIB32} != "no"
610	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
611	    -p ${WORLDTMP}/usr >/dev/null
612.if ${MK_DEBUG_FILES} != "no"
613	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
614	    -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
615	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
616	    -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
617.endif
618.endif
619.if ${MK_TESTS} != "no"
620	mkdir -p ${WORLDTMP}${TESTSBASE}
621	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
622	    -p ${WORLDTMP}${TESTSBASE} >/dev/null
623.if ${MK_DEBUG_FILES} != "no"
624	mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
625	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
626	    -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
627.endif
628.endif
629.for _mtree in ${LOCAL_MTREE}
630	mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
631.endfor
632_legacy:
633	@echo
634	@echo "--------------------------------------------------------------"
635	@echo ">>> stage 1.1: legacy release compatibility shims"
636	@echo "--------------------------------------------------------------"
637	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
638_bootstrap-tools:
639	@echo
640	@echo "--------------------------------------------------------------"
641	@echo ">>> stage 1.2: bootstrap tools"
642	@echo "--------------------------------------------------------------"
643	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
644_cleanobj:
645.if !defined(NO_CLEAN)
646	@echo
647	@echo "--------------------------------------------------------------"
648	@echo ">>> stage 2.1: cleaning up the object tree"
649	@echo "--------------------------------------------------------------"
650	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
651.if defined(LIB32TMP)
652	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
653.endif
654.endif
655_obj:
656	@echo
657	@echo "--------------------------------------------------------------"
658	@echo ">>> stage 2.2: rebuilding the object tree"
659	@echo "--------------------------------------------------------------"
660	${_+_}cd ${.CURDIR}; ${WMAKE} obj
661_build-tools:
662	@echo
663	@echo "--------------------------------------------------------------"
664	@echo ">>> stage 2.3: build tools"
665	@echo "--------------------------------------------------------------"
666	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
667_cross-tools:
668	@echo
669	@echo "--------------------------------------------------------------"
670	@echo ">>> stage 3: cross tools"
671	@echo "--------------------------------------------------------------"
672	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
673	${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
674_includes:
675	@echo
676	@echo "--------------------------------------------------------------"
677	@echo ">>> stage 4.1: building includes"
678	@echo "--------------------------------------------------------------"
679# Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
680# headers from default SUBDIR.  Do SUBDIR_OVERRIDE includes last.
681	${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
682	    includes
683.if !empty(SUBDIR_OVERRIDE) && make(buildworld)
684	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
685.endif
686_libraries:
687	@echo
688	@echo "--------------------------------------------------------------"
689	@echo ">>> stage 4.2: building libraries"
690	@echo "--------------------------------------------------------------"
691	${_+_}cd ${.CURDIR}; \
692	    ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
693	    MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
694_depend:
695	@echo
696	@echo "--------------------------------------------------------------"
697	@echo ">>> stage 4.3: make dependencies"
698	@echo "--------------------------------------------------------------"
699	${_+_}cd ${.CURDIR}; ${WMAKE} depend
700everything:
701	@echo
702	@echo "--------------------------------------------------------------"
703	@echo ">>> stage 4.4: building everything"
704	@echo "--------------------------------------------------------------"
705	${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
706.if defined(LIB32TMP)
707build32: .PHONY
708	@echo
709	@echo "--------------------------------------------------------------"
710	@echo ">>> stage 5.1: building 32 bit shim libraries"
711	@echo "--------------------------------------------------------------"
712	mkdir -p ${LIB32TMP}/usr/include
713	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
714	    -p ${LIB32TMP}/usr >/dev/null
715	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
716	    -p ${LIB32TMP}/usr/include >/dev/null
717	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
718	    -p ${LIB32TMP}/usr >/dev/null
719.if ${MK_DEBUG_FILES} != "no"
720	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
721	    -p ${LIB32TMP}/usr/lib >/dev/null
722	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
723	    -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
724.endif
725	mkdir -p ${WORLDTMP}
726	ln -sf ${.CURDIR}/sys ${WORLDTMP}
727.for _t in obj includes
728	${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
729	${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
730.if ${MK_CDDL} != "no"
731	${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
732.endif
733	${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
734.if ${MK_CRYPT} != "no"
735	${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
736.endif
737.if ${MK_KERBEROS} != "no"
738	${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
739.endif
740.endfor
741.for _dir in usr.bin/lex/lib
742	${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
743.endfor
744.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
745	${_+_}cd ${.CURDIR}/${_dir}; \
746	    WORLDTMP=${WORLDTMP} \
747	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
748	    MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
749	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
750	    build-tools
751.endfor
752	${_+_}cd ${.CURDIR}; \
753	    ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
754.for _t in obj depend all
755	${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
756	    -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
757	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
758	    DIRPRFX=usr.bin/ldd ${_t}
759.endfor
760
761distribute32 install32: .MAKE .PHONY
762	${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
763.if ${MK_CDDL} != "no"
764	${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
765.endif
766	${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
767.if ${MK_CRYPT} != "no"
768	${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
769.endif
770.if ${MK_KERBEROS} != "no"
771	${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
772.endif
773	${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
774	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
775	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
776	    ${.TARGET:S/32$//}
777.endif
778
779WMAKE_TGTS=
780WMAKE_TGTS+=	_worldtmp _legacy
781.if empty(SUBDIR_OVERRIDE)
782WMAKE_TGTS+=	_bootstrap-tools
783.endif
784WMAKE_TGTS+=	_cleanobj _obj _build-tools _cross-tools
785WMAKE_TGTS+=	_includes _libraries
786.if !defined(NO_DEPEND)
787WMAKE_TGTS+=	_depend
788.endif
789WMAKE_TGTS+=	everything
790.if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
791WMAKE_TGTS+=	build32
792.endif
793
794buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
795.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
796
797buildworld_prologue:
798	@echo "--------------------------------------------------------------"
799	@echo ">>> World build started on `LC_ALL=C date`"
800	@echo "--------------------------------------------------------------"
801
802buildworld_epilogue:
803	@echo
804	@echo "--------------------------------------------------------------"
805	@echo ">>> World build completed on `LC_ALL=C date`"
806	@echo "--------------------------------------------------------------"
807
808#
809# We need to have this as a target because the indirection between Makefile
810# and Makefile.inc1 causes the correct PATH to be used, rather than a
811# modification of the current environment's PATH.  In addition, we need
812# to quote multiword values.
813#
814buildenvvars: .PHONY
815	@echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
816
817.if ${.TARGETS:Mbuildenv}
818.if ${.MAKEFLAGS:M-j}
819.error The buildenv target is incompatible with -j
820.endif
821.endif
822BUILDENV_DIR?=	${.CURDIR}
823buildenv: .PHONY
824	@echo Entering world for ${TARGET_ARCH}:${TARGET}
825.if ${BUILDENV_SHELL:M*zsh*}
826	@echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
827.endif
828	@cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
829	    || true
830
831TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
832toolchain: ${TOOLCHAIN_TGTS}
833kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
834
835#
836# installcheck
837#
838# Checks to be sure system is ready for installworld/installkernel.
839#
840installcheck: _installcheck_world _installcheck_kernel
841_installcheck_world:
842_installcheck_kernel:
843
844#
845# Require DESTDIR to be set if installing for a different architecture or
846# using the user/group database in the source tree.
847#
848.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
849    defined(DB_FROM_SRC)
850.if !make(distributeworld)
851_installcheck_world: __installcheck_DESTDIR
852_installcheck_kernel: __installcheck_DESTDIR
853__installcheck_DESTDIR:
854.if !defined(DESTDIR) || empty(DESTDIR)
855	@echo "ERROR: Please set DESTDIR!"; \
856	false
857.endif
858.endif
859.endif
860
861.if !defined(DB_FROM_SRC)
862#
863# Check for missing UIDs/GIDs.
864#
865CHECK_UIDS=	auditdistd
866CHECK_GIDS=	audit
867.if ${MK_SENDMAIL} != "no"
868CHECK_UIDS+=	smmsp
869CHECK_GIDS+=	smmsp
870.endif
871.if ${MK_PF} != "no"
872CHECK_UIDS+=	proxy
873CHECK_GIDS+=	proxy authpf
874.endif
875.if ${MK_UNBOUND} != "no"
876CHECK_UIDS+=	unbound
877CHECK_GIDS+=	unbound
878.endif
879_installcheck_world: __installcheck_UGID
880__installcheck_UGID:
881.for uid in ${CHECK_UIDS}
882	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
883		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
884		false; \
885	fi
886.endfor
887.for gid in ${CHECK_GIDS}
888	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
889		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
890		false; \
891	fi
892.endfor
893.endif
894
895#
896# Required install tools to be saved in a scratch dir for safety.
897#
898.if ${MK_ZONEINFO} != "no"
899_zoneinfo=	zic tzsetup
900.endif
901
902ITOOLS=	[ awk cap_mkdb cat chflags chmod chown cmp cp \
903	date echo egrep find grep id install ${_install-info} \
904	ln make mkdir mtree mv pwd_mkdb \
905	rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
906	${LOCAL_ITOOLS}
907
908# Needed for share/man
909.if ${MK_MAN} != "no"
910ITOOLS+=makewhatis
911.endif
912
913#
914# distributeworld
915#
916# Distributes everything compiled by a `buildworld'.
917#
918# installworld
919#
920# Installs everything compiled by a 'buildworld'.
921#
922
923# Non-base distributions produced by the base system
924EXTRA_DISTRIBUTIONS=	doc
925.if defined(LIB32TMP) && ${MK_LIB32} != "no"
926EXTRA_DISTRIBUTIONS+=	lib32
927.endif
928.if ${MK_TESTS} != "no"
929EXTRA_DISTRIBUTIONS+=	tests
930.endif
931
932DEBUG_DISTRIBUTIONS=
933.if ${MK_DEBUG_FILES} != "no"
934DEBUG_DISTRIBUTIONS+=	base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
935.endif
936
937MTREE_MAGIC?=	mtree 2.0
938
939distributeworld installworld: _installcheck_world
940	mkdir -p ${INSTALLTMP}
941	progs=$$(for prog in ${ITOOLS}; do \
942		if progpath=`which $$prog`; then \
943			echo $$progpath; \
944		else \
945			echo "Required tool $$prog not found in PATH." >&2; \
946			exit 1; \
947		fi; \
948	    done); \
949	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
950	    while read line; do \
951		set -- $$line; \
952		if [ "$$2 $$3" != "not found" ]; then \
953			echo $$2; \
954		else \
955			echo "Required library $$1 not found." >&2; \
956			exit 1; \
957		fi; \
958	    done); \
959	cp $$libs $$progs ${INSTALLTMP}
960	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
961.if defined(NO_ROOT)
962	-mkdir -p ${METALOG:H}
963	echo "#${MTREE_MAGIC}" > ${METALOG}
964.endif
965.if make(distributeworld)
966.for dist in ${EXTRA_DISTRIBUTIONS}
967	-mkdir ${DESTDIR}/${DISTDIR}/${dist}
968	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
969	    -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
970	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
971	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
972	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
973	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
974.if ${MK_DEBUG_FILES} != "no"
975	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
976	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
977.endif
978.if ${MK_LIB32} != "no"
979	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
980	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
981.if ${MK_DEBUG_FILES} != "no"
982	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
983	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
984.endif
985.endif
986.if ${MK_TESTS} != "no" && ${dist} == "tests"
987	-mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
988	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
989	    -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
990.if ${MK_DEBUG_FILES} != "no"
991	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
992	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
993.endif
994.endif
995.if defined(NO_ROOT)
996	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
997	    sed -e 's#^\./#./${dist}/#' >> ${METALOG}
998	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
999	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1000	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1001	    sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1002.if ${MK_LIB32} != "no"
1003	${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1004	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1005.endif
1006.endif
1007.endfor
1008	-mkdir ${DESTDIR}/${DISTDIR}/base
1009	${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1010	    METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1011	    DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1012	    LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1013.endif
1014	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1015	    ${IMAKEENV} rm -rf ${INSTALLTMP}
1016.if make(distributeworld)
1017.for dist in ${EXTRA_DISTRIBUTIONS}
1018	find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1019.endfor
1020.if defined(NO_ROOT)
1021.for dist in base ${EXTRA_DISTRIBUTIONS}
1022	@# For each file that exists in this dist, print the corresponding
1023	@# line from the METALOG.  This relies on the fact that
1024	@# a line containing only the filename will sort immediatly before
1025	@# the relevant mtree line.
1026	cd ${DESTDIR}/${DISTDIR}; \
1027	find ./${dist} | sort -u ${METALOG} - | \
1028	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1029	${DESTDIR}/${DISTDIR}/${dist}.meta
1030.endfor
1031.for dist in ${DEBUG_DISTRIBUTIONS}
1032	@# For each file that exists in this dist, print the corresponding
1033	@# line from the METALOG.  This relies on the fact that
1034	@# a line containing only the filename will sort immediatly before
1035	@# the relevant mtree line.
1036	cd ${DESTDIR}/${DISTDIR}; \
1037	find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1038	awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1039	${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1040.endfor
1041.endif
1042.endif
1043
1044packageworld:
1045.for dist in base ${EXTRA_DISTRIBUTIONS}
1046.if defined(NO_ROOT)
1047	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1048	    tar cvf - --exclude usr/lib/debug \
1049	    @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1050	    ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1051.else
1052	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1053	    tar cvf - --exclude usr/lib/debug . | \
1054	    ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1055.endif
1056.endfor
1057
1058.for dist in ${DEBUG_DISTRIBUTIONS}
1059. if defined(NO_ROOT)
1060	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1061	    tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1062	    ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1063. else
1064	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1065	    tar cvLf - usr/lib/debug | \
1066	    ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1067. endif
1068.endfor
1069
1070#
1071# reinstall
1072#
1073# If you have a build server, you can NFS mount the source and obj directories
1074# and do a 'make reinstall' on the *client* to install new binaries from the
1075# most recent server build.
1076#
1077reinstall: .MAKE .PHONY
1078	@echo "--------------------------------------------------------------"
1079	@echo ">>> Making hierarchy"
1080	@echo "--------------------------------------------------------------"
1081	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1082	    LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1083	@echo
1084	@echo "--------------------------------------------------------------"
1085	@echo ">>> Installing everything"
1086	@echo "--------------------------------------------------------------"
1087	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1088.if defined(LIB32TMP) && ${MK_LIB32} != "no"
1089	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1090.endif
1091
1092redistribute: .MAKE .PHONY
1093	@echo "--------------------------------------------------------------"
1094	@echo ">>> Distributing everything"
1095	@echo "--------------------------------------------------------------"
1096	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1097.if defined(LIB32TMP) && ${MK_LIB32} != "no"
1098	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1099	    DISTRIBUTION=lib32
1100.endif
1101
1102distrib-dirs distribution: .MAKE .PHONY
1103	${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1104	    ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1105.if make(distribution)
1106	${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1107		${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1108		METALOG=${METALOG} MK_TESTS=no installconfig
1109.endif
1110
1111#
1112# buildkernel and installkernel
1113#
1114# Which kernels to build and/or install is specified by setting
1115# KERNCONF. If not defined a GENERIC kernel is built/installed.
1116# Only the existing (depending TARGET) config files are used
1117# for building kernels and only the first of these is designated
1118# as the one being installed.
1119#
1120# Note that we have to use TARGET instead of TARGET_ARCH when
1121# we're in kernel-land. Since only TARGET_ARCH is (expected) to
1122# be set to cross-build, we have to make sure TARGET is set
1123# properly.
1124
1125.if defined(KERNFAST)
1126NO_KERNELCLEAN=	t
1127NO_KERNELCONFIG=	t
1128NO_KERNELDEPEND=	t
1129NO_KERNELOBJ=		t
1130# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1131.if !defined(KERNCONF) && ${KERNFAST} != "1"
1132KERNCONF=${KERNFAST}
1133.endif
1134.endif
1135.if ${TARGET_ARCH} == "powerpc64"
1136KERNCONF?=	GENERIC64
1137.else
1138KERNCONF?=	GENERIC
1139.endif
1140INSTKERNNAME?=	kernel
1141
1142KERNSRCDIR?=	${.CURDIR}/sys
1143KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
1144KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
1145KERNCONFDIR?=	${KRNLCONFDIR}
1146
1147BUILDKERNELS=
1148INSTALLKERNEL=
1149.if defined(NO_INSTALLKERNEL)
1150# All of the BUILDKERNELS loops start at index 1.
1151BUILDKERNELS+= dummy
1152.endif
1153.for _kernel in ${KERNCONF}
1154.if exists(${KERNCONFDIR}/${_kernel})
1155BUILDKERNELS+=	${_kernel}
1156.if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1157INSTALLKERNEL= ${_kernel}
1158.endif
1159.endif
1160.endfor
1161
1162${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1163
1164#
1165# buildkernel
1166#
1167# Builds all kernels defined by BUILDKERNELS.
1168#
1169buildkernel: .MAKE .PHONY
1170.if empty(BUILDKERNELS:Ndummy)
1171	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1172	false
1173.endif
1174	@echo
1175.for _kernel in ${BUILDKERNELS:Ndummy}
1176	@echo "--------------------------------------------------------------"
1177	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1178	@echo "--------------------------------------------------------------"
1179	@echo "===> ${_kernel}"
1180	mkdir -p ${KRNLOBJDIR}
1181.if !defined(NO_KERNELCONFIG)
1182	@echo
1183	@echo "--------------------------------------------------------------"
1184	@echo ">>> stage 1: configuring the kernel"
1185	@echo "--------------------------------------------------------------"
1186	cd ${KRNLCONFDIR}; \
1187		PATH=${TMPPATH} \
1188		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1189			-I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1190.endif
1191.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1192	@echo
1193	@echo "--------------------------------------------------------------"
1194	@echo ">>> stage 2.1: cleaning up the object tree"
1195	@echo "--------------------------------------------------------------"
1196	${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1197.endif
1198.if !defined(NO_KERNELOBJ)
1199	@echo
1200	@echo "--------------------------------------------------------------"
1201	@echo ">>> stage 2.2: rebuilding the object tree"
1202	@echo "--------------------------------------------------------------"
1203	${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1204.endif
1205	@echo
1206	@echo "--------------------------------------------------------------"
1207	@echo ">>> stage 2.3: build tools"
1208	@echo "--------------------------------------------------------------"
1209	${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1210.if !defined(NO_KERNELDEPEND)
1211	@echo
1212	@echo "--------------------------------------------------------------"
1213	@echo ">>> stage 3.1: making dependencies"
1214	@echo "--------------------------------------------------------------"
1215	${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1216.endif
1217	@echo
1218	@echo "--------------------------------------------------------------"
1219	@echo ">>> stage 3.2: building everything"
1220	@echo "--------------------------------------------------------------"
1221	${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1222	@echo "--------------------------------------------------------------"
1223	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1224	@echo "--------------------------------------------------------------"
1225.endfor
1226
1227#
1228# installkernel, etc.
1229#
1230# Install the kernel defined by INSTALLKERNEL
1231#
1232installkernel installkernel.debug \
1233reinstallkernel reinstallkernel.debug: _installcheck_kernel
1234.if !defined(NO_INSTALLKERNEL)
1235.if empty(INSTALLKERNEL)
1236	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1237	false
1238.endif
1239	@echo "--------------------------------------------------------------"
1240	@echo ">>> Installing kernel ${INSTALLKERNEL}"
1241	@echo "--------------------------------------------------------------"
1242	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1243	    ${CROSSENV} PATH=${TMPPATH} \
1244	    ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1245.endif
1246.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1247.for _kernel in ${BUILDKERNELS:[2..-1]}
1248	@echo "--------------------------------------------------------------"
1249	@echo ">>> Installing kernel ${_kernel}"
1250	@echo "--------------------------------------------------------------"
1251	cd ${KRNLOBJDIR}/${_kernel}; \
1252	    ${CROSSENV} PATH=${TMPPATH} \
1253	    ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1254.endfor
1255.endif
1256
1257distributekernel distributekernel.debug:
1258.if !defined(NO_INSTALLKERNEL)
1259.if empty(INSTALLKERNEL)
1260	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1261	false
1262.endif
1263	mkdir -p ${DESTDIR}/${DISTDIR}
1264.if defined(NO_ROOT)
1265	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1266.endif
1267	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1268	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1269	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1270	    DESTDIR=${INSTALL_DDIR}/kernel \
1271	    ${.TARGET:S/distributekernel/install/}
1272.if defined(NO_ROOT)
1273	sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1274	    ${DESTDIR}/${DISTDIR}/kernel.meta
1275.endif
1276.endif
1277.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1278.for _kernel in ${BUILDKERNELS:[2..-1]}
1279.if defined(NO_ROOT)
1280	echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1281.endif
1282	cd ${KRNLOBJDIR}/${_kernel}; \
1283	    ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1284	    ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1285	    KERNEL=${INSTKERNNAME}.${_kernel} \
1286	    DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1287	    ${.TARGET:S/distributekernel/install/}
1288.if defined(NO_ROOT)
1289	sed -e 's|^./kernel|.|' \
1290	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1291	    ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1292.endif
1293.endfor
1294.endif
1295
1296packagekernel:
1297.if defined(NO_ROOT)
1298.if !defined(NO_INSTALLKERNEL)
1299	cd ${DESTDIR}/${DISTDIR}/kernel; \
1300	    tar cvf - --exclude '*.debug' \
1301	    @${DESTDIR}/${DISTDIR}/kernel.meta | \
1302	    ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1303.endif
1304	cd ${DESTDIR}/${DISTDIR}/kernel; \
1305	    tar cvf - --include '*/*/*.debug' \
1306	    @${DESTDIR}/${DISTDIR}/kernel.meta | \
1307	    ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1308.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1309.for _kernel in ${BUILDKERNELS:[2..-1]}
1310	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1311	    tar cvf - --exclude '*.debug' \
1312	    @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1313	    ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1314	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1315	    tar cvf - --include '*/*/*.debug' \
1316	    @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1317	    ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1318.endfor
1319.endif
1320.else
1321.if !defined(NO_INSTALLKERNEL)
1322	cd ${DESTDIR}/${DISTDIR}/kernel; \
1323	    tar cvf - --exclude '*.debug' . | \
1324	    ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1325.endif
1326	cd ${DESTDIR}/${DISTDIR}/kernel; \
1327	    tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1328	    ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1329.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1330.for _kernel in ${BUILDKERNELS:[2..-1]}
1331	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1332	    tar cvf - --exclude '*.debug' . | \
1333	    ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1334	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1335	    tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1336	    ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1337.endfor
1338.endif
1339.endif
1340
1341#
1342#
1343# checkworld
1344#
1345# Run test suite on installed world.
1346#
1347checkworld: .PHONY
1348	@if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1349		echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1350		exit 1; \
1351	fi
1352	${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1353
1354#
1355#
1356# doxygen
1357#
1358# Build the API documentation with doxygen
1359#
1360doxygen: .PHONY
1361	@if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1362		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1363		exit 1; \
1364	fi
1365	${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1366
1367#
1368# update
1369#
1370# Update the source tree(s), by running svn/svnup to update to the
1371# latest copy.
1372#
1373update:
1374.if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1375	@echo "--------------------------------------------------------------"
1376	@echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1377	@echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1378	@echo "--------------------------------------------------------------"
1379	@exit 1
1380.endif
1381.if defined(SVN_UPDATE)
1382	@echo "--------------------------------------------------------------"
1383	@echo ">>> Updating ${.CURDIR} using Subversion"
1384	@echo "--------------------------------------------------------------"
1385	@(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1386.endif
1387
1388#
1389# ------------------------------------------------------------------------
1390#
1391# From here onwards are utility targets used by the 'make world' and
1392# related targets.  If your 'world' breaks, you may like to try to fix
1393# the problem and manually run the following targets to attempt to
1394# complete the build.  Beware, this is *not* guaranteed to work, you
1395# need to have a pretty good grip on the current state of the system
1396# to attempt to manually finish it.  If in doubt, 'make world' again.
1397#
1398
1399#
1400# legacy: Build compatibility shims for the next three targets. This is a
1401# minimal set of tools and shims necessary to compensate for older systems
1402# which don't have the APIs required by the targets built in bootstrap-tools,
1403# build-tools or cross-tools.
1404#
1405
1406# ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1407.if ${BOOTSTRAPPING} < 1100006
1408_elftoolchain_libs= lib/libelf lib/libdwarf
1409.endif
1410
1411legacy:
1412.if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1413	@echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1414	false
1415.endif
1416.for _tool in tools/build ${_elftoolchain_libs}
1417	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1418	    cd ${.CURDIR}/${_tool}; \
1419	    ${MAKE} DIRPRFX=${_tool}/ obj; \
1420	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1421	    if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1422	    ${MAKE} DIRPRFX=${_tool}/ all; \
1423	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1424.endfor
1425
1426#
1427# bootstrap-tools: Build tools needed for compatibility. These are binaries that
1428# are built to build other binaries in the system. However, the focus of these
1429# binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1430# libraries, augmented by -legacy.
1431#
1432_bt=		_bootstrap-tools
1433
1434.if ${MK_GAMES} != "no"
1435_strfile=	usr.bin/fortune/strfile
1436.endif
1437
1438.if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1439_gperf=		gnu/usr.bin/gperf
1440.endif
1441
1442.if ${MK_GROFF} != "no"
1443_groff=		gnu/usr.bin/groff \
1444		usr.bin/soelim
1445.endif
1446
1447.if ${MK_VT} != "no"
1448_vtfontcvt=	usr.bin/vtfontcvt
1449.endif
1450
1451.if ${BOOTSTRAPPING} < 900002
1452_sed=		usr.bin/sed
1453.endif
1454
1455.if ${BOOTSTRAPPING} < 1000033
1456_libopenbsd=	lib/libopenbsd
1457_m4=		usr.bin/m4
1458_lex=		usr.bin/lex
1459
1460${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1461${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1462.endif
1463
1464.if ${BOOTSTRAPPING} < 1000026
1465_nmtree=	lib/libnetbsd \
1466		usr.sbin/nmtree
1467
1468${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1469.endif
1470
1471.if ${BOOTSTRAPPING} < 1000027
1472_cat=		bin/cat
1473.endif
1474
1475# r264059 support for status=
1476.if ${BOOTSTRAPPING} < 1100017
1477_dd=		bin/dd
1478.endif
1479
1480# r277259 crunchide: Correct 64-bit section header offset
1481# r281674 crunchide: always include both 32- and 64-bit ELF support
1482# r285986 crunchen: use STRIPBIN rather than STRIP
1483.if ${BOOTSTRAPPING} < 1100078
1484_crunch=	usr.sbin/crunch
1485.endif
1486
1487.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1488_awk=		usr.bin/awk
1489.endif
1490
1491_yacc=		lib/liby \
1492		usr.bin/yacc
1493
1494${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1495
1496.if ${MK_BSNMP} != "no"
1497_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
1498.endif
1499
1500# We need to build tblgen when we're building clang either as
1501# the bootstrap compiler, or as the part of the normal build.
1502.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1503_clang_tblgen= \
1504	lib/clang/libllvmsupport \
1505	lib/clang/libllvmtablegen \
1506	usr.bin/clang/tblgen \
1507	usr.bin/clang/clang-tblgen
1508
1509${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1510${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1511.endif
1512
1513# Default to building the GPL DTC, but build the BSDL one if users explicitly
1514# request it.
1515_dtc= usr.bin/dtc
1516.if ${MK_GPL_DTC} != "no"
1517_dtc= gnu/usr.bin/dtc
1518.endif
1519
1520.if ${MK_KERBEROS} != "no"
1521_kerberos5_bootstrap_tools= \
1522	kerberos5/tools/make-roken \
1523	kerberos5/lib/libroken \
1524	kerberos5/lib/libvers \
1525	kerberos5/tools/asn1_compile \
1526	kerberos5/tools/slc \
1527	usr.bin/compile_et
1528
1529.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1530.endif
1531
1532# r283777 makewhatis(1) replaced with mandoc version which builds a database.
1533.if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1534_libopenbsd?=	lib/libopenbsd
1535_makewhatis=	lib/libsqlite3 \
1536		usr.bin/mandoc
1537${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1538.endif
1539
1540bootstrap-tools: .PHONY
1541
1542#	Please document (add comment) why something is in 'bootstrap-tools'.
1543#	Try to bound the building of the bootstrap-tool to just the
1544#	FreeBSD versions that need the tool built at this stage of the build.
1545.for _tool in \
1546    ${_clang_tblgen} \
1547    ${_kerberos5_bootstrap_tools} \
1548    ${_strfile} \
1549    ${_gperf} \
1550    ${_groff} \
1551    ${_dtc} \
1552    ${_awk} \
1553    ${_cat} \
1554    ${_dd} \
1555    usr.bin/lorder \
1556    ${_libopenbsd} \
1557    ${_makewhatis} \
1558    usr.bin/rpcgen \
1559    ${_sed} \
1560    ${_yacc} \
1561    ${_m4} \
1562    ${_lex} \
1563    usr.bin/xinstall \
1564    ${_gensnmptree} \
1565    usr.sbin/config \
1566    ${_crunch} \
1567    ${_nmtree} \
1568    ${_vtfontcvt} \
1569    usr.bin/localedef
1570${_bt}-${_tool}: .PHONY .MAKE
1571	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1572		cd ${.CURDIR}/${_tool}; \
1573		${MAKE} DIRPRFX=${_tool}/ obj; \
1574		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1575		${MAKE} DIRPRFX=${_tool}/ all; \
1576		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1577
1578bootstrap-tools: ${_bt}-${_tool}
1579.endfor
1580
1581#
1582# build-tools: Build special purpose build tools
1583#
1584.if !defined(NO_SHARE)
1585_share=	share/syscons/scrnmaps
1586.endif
1587
1588.if ${MK_GCC} != "no"
1589_gcc_tools= gnu/usr.bin/cc/cc_tools
1590.endif
1591
1592.if ${MK_RESCUE} != "no"
1593# rescue includes programs that have build-tools targets
1594_rescue=rescue/rescue
1595.endif
1596
1597.for _tool in \
1598    bin/csh \
1599    bin/sh \
1600    ${LOCAL_TOOL_DIRS} \
1601    lib/ncurses/ncurses \
1602    lib/ncurses/ncursesw \
1603    ${_rescue} \
1604    ${_share} \
1605    usr.bin/awk \
1606    lib/libmagic \
1607    usr.bin/mkesdb_static \
1608    usr.bin/mkcsmapper_static \
1609    usr.bin/vi/catalog
1610build-tools_${_tool}: .PHONY
1611	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1612		cd ${.CURDIR}/${_tool}; \
1613		${MAKE} DIRPRFX=${_tool}/ obj; \
1614		${MAKE} DIRPRFX=${_tool}/ build-tools
1615build-tools: build-tools_${_tool}
1616.endfor
1617.for _tool in \
1618    ${_gcc_tools}
1619build-tools_${_tool}: .PHONY
1620	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1621		cd ${.CURDIR}/${_tool}; \
1622		${MAKE} DIRPRFX=${_tool}/ obj; \
1623		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1624		${MAKE} DIRPRFX=${_tool}/ all
1625build-tools: build-tools_${_tool}
1626.endfor
1627
1628#
1629# kernel-tools: Build kernel-building tools
1630#
1631kernel-tools:
1632	mkdir -p ${MAKEOBJDIRPREFIX}/usr
1633	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1634	    -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1635
1636#
1637# cross-tools: All the tools needed to build the rest of the system after
1638# we get done with the earlier stages. It is the last set of tools needed
1639# to begin building the target binaries.
1640#
1641.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1642.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1643_btxld=		usr.sbin/btxld
1644.endif
1645.endif
1646
1647# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1648# resulting from missing bug fixes or ELF Toolchain updates.
1649.if ${MK_CDDL} != "no"
1650_dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1651    cddl/usr.bin/ctfmerge
1652.endif
1653
1654# If we're given an XAS, don't build binutils.
1655.if ${XAS:M/*} == ""
1656.if ${MK_BINUTILS_BOOTSTRAP} != "no"
1657_binutils=	gnu/usr.bin/binutils
1658.endif
1659.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1660_elftctools=	lib/libelftc \
1661		lib/libpe \
1662		usr.bin/elfcopy \
1663		usr.bin/nm \
1664		usr.bin/size \
1665		usr.bin/strings
1666# These are not required by the build, but can be useful for developers who
1667# cross-build on a FreeBSD 10 host:
1668_elftctools+=	usr.bin/addr2line
1669.endif
1670.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1671# If cross-building with an external binutils we still need to build strip for
1672# the target (for at least crunchide).
1673_elftctools=	lib/libelftc \
1674		lib/libpe \
1675		usr.bin/elfcopy
1676.endif
1677
1678# If an full path to an external cross compiler is given, don't build
1679# a cross compiler.
1680.if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1681.if ${MK_CLANG_BOOTSTRAP} != "no"
1682_clang=		usr.bin/clang
1683_clang_libs=	lib/clang
1684.endif
1685.if ${MK_GCC_BOOTSTRAP} != "no"
1686_cc=		gnu/usr.bin/cc
1687.endif
1688.endif
1689.if ${MK_USB} != "no"
1690_usb_tools=	sys/boot/usb/tools
1691.endif
1692
1693cross-tools: .MAKE .PHONY
1694.for _tool in \
1695    ${_clang_libs} \
1696    ${_clang} \
1697    ${_binutils} \
1698    ${_elftctools} \
1699    ${_dtrace_tools} \
1700    ${_cc} \
1701    ${_btxld} \
1702    ${_crunchide} \
1703    ${_usb_tools}
1704	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1705		cd ${.CURDIR}/${_tool}; \
1706		${MAKE} DIRPRFX=${_tool}/ obj; \
1707		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1708		${MAKE} DIRPRFX=${_tool}/ all; \
1709		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1710.endfor
1711
1712NXBDESTDIR=	${OBJTREE}/nxb-bin
1713NXBENV=		MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1714		INSTALL="sh ${.CURDIR}/tools/install.sh" \
1715		PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1716NXBMAKE=	${NXBENV} ${MAKE} \
1717		TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1718		CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1719		MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1720		MK_GDB=no MK_TESTS=no \
1721		SSP_CFLAGS= \
1722		MK_HTML=no NO_LINT=yes MK_MAN=no \
1723		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
1724		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1725		MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1726		MK_LLDB=no MK_DEBUG_FILES=no
1727
1728# native-xtools is the current target for qemu-user cross builds of ports
1729# via poudriere and the imgact_binmisc kernel module.
1730# For non-clang enabled targets that are still using the in tree gcc
1731# we must build a gperf binary for one instance of its Makefiles.  On
1732# clang-enabled systems, the gperf binary is obsolete.
1733native-xtools: .PHONY
1734.if ${MK_GCC_BOOTSTRAP} != "no"
1735	mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1736	${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1737	cd ${.CURDIR}/${_gperf}; \
1738	${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1739	if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1740	${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1741	${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1742.endif
1743	mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1744	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1745	    -p ${NXBDESTDIR}/usr >/dev/null
1746	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1747	    -p ${NXBDESTDIR}/usr/include >/dev/null
1748.if ${MK_DEBUG_FILES} != "no"
1749	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1750	    -p ${NXBDESTDIR}/usr/lib >/dev/null
1751.endif
1752.for _tool in \
1753    bin/cat \
1754    bin/chmod \
1755    bin/cp \
1756    bin/csh \
1757    bin/echo \
1758    bin/expr \
1759    bin/hostname \
1760    bin/ln \
1761    bin/ls \
1762    bin/mkdir \
1763    bin/mv \
1764    bin/ps \
1765    bin/realpath \
1766    bin/rm \
1767    bin/rmdir \
1768    bin/sh \
1769    bin/sleep \
1770    ${_clang_tblgen} \
1771    usr.bin/ar \
1772    ${_binutils} \
1773    ${_elftctools} \
1774    ${_cc} \
1775    ${_gcc_tools} \
1776    ${_clang_libs} \
1777    ${_clang} \
1778    sbin/md5 \
1779    sbin/sysctl \
1780    gnu/usr.bin/diff \
1781    usr.bin/awk \
1782    usr.bin/basename \
1783    usr.bin/bmake \
1784    usr.bin/bzip2 \
1785    usr.bin/cmp \
1786    usr.bin/dirname \
1787    usr.bin/env \
1788    usr.bin/fetch \
1789    usr.bin/find \
1790    usr.bin/grep \
1791    usr.bin/gzip \
1792    usr.bin/id \
1793    usr.bin/lex \
1794    usr.bin/lorder \
1795    usr.bin/mktemp \
1796    usr.bin/mt \
1797    usr.bin/patch \
1798    usr.bin/sed \
1799    usr.bin/sort \
1800    usr.bin/tar \
1801    usr.bin/touch \
1802    usr.bin/tr \
1803    usr.bin/true \
1804    usr.bin/uniq \
1805    usr.bin/unzip \
1806    usr.bin/xargs \
1807    usr.bin/xinstall \
1808    usr.bin/xz \
1809    usr.bin/yacc \
1810    usr.sbin/chown
1811	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1812		cd ${.CURDIR}/${_tool}; \
1813		${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1814		if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1815		${NXBMAKE} DIRPRFX=${_tool}/ all; \
1816		${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1817.endfor
1818
1819#
1820# hierarchy - ensure that all the needed directories are present
1821#
1822hierarchy hier: .MAKE .PHONY
1823	${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1824
1825#
1826# libraries - build all libraries, and install them under ${DESTDIR}.
1827#
1828# The list of libraries with dependents (${_prebuild_libs}) and their
1829# interdependencies (__L) are built automatically by the
1830# ${.CURDIR}/tools/make_libdeps.sh script.
1831#
1832libraries: .MAKE .PHONY
1833	${_+_}cd ${.CURDIR}; \
1834	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1835	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1836	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1837	    ${MAKE} -f Makefile.inc1 _generic_libs
1838
1839#
1840# static libgcc.a prerequisite for shared libc
1841#
1842_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1843
1844# These dependencies are not automatically generated:
1845#
1846# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1847# all shared libraries for ELF.
1848#
1849_startup_libs=	gnu/lib/csu
1850_startup_libs+=	lib/csu
1851_startup_libs+=	gnu/lib/libgcc
1852_startup_libs+=	lib/libcompiler_rt
1853_startup_libs+=	lib/libc
1854_startup_libs+=	lib/libc_nonshared
1855.if ${MK_LIBCPLUSPLUS} != "no"
1856_startup_libs+=	lib/libcxxrt
1857.endif
1858
1859gnu/lib/libgcc__L: lib/libc__L
1860gnu/lib/libgcc__L: lib/libc_nonshared__L
1861.if ${MK_LIBCPLUSPLUS} != "no"
1862lib/libcxxrt__L: gnu/lib/libgcc__L
1863.endif
1864
1865_prebuild_libs=	${_kerberos5_lib_libasn1} \
1866		${_kerberos5_lib_libhdb} \
1867		${_kerberos5_lib_libheimbase} \
1868		${_kerberos5_lib_libheimntlm} \
1869		${_libsqlite3} \
1870		${_kerberos5_lib_libheimipcc} \
1871		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1872		${_kerberos5_lib_libroken} \
1873		${_kerberos5_lib_libwind} \
1874		lib/libbz2 ${_libcom_err} lib/libcrypt \
1875		lib/libelf lib/libexpat \
1876		lib/libfigpar \
1877		${_lib_libgssapi} \
1878		lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1879		${_lib_casper} \
1880		lib/ncurses/ncurses lib/ncurses/ncursesw \
1881		lib/libopie lib/libpam ${_lib_libthr} \
1882		${_lib_libradius} lib/libsbuf lib/libtacplus \
1883		lib/libgeom \
1884		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1885		${_cddl_lib_libuutil} \
1886		${_cddl_lib_libavl} \
1887		${_cddl_lib_libzfs_core} \
1888		${_cddl_lib_libctf} \
1889		lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1890		${_secure_lib_libcrypto} ${_lib_libldns} \
1891		${_secure_lib_libssh} ${_secure_lib_libssl} \
1892		gnu/lib/libdialog
1893.if ${MK_GNUCXX} != "no"
1894_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1895gnu/lib/libstdc++__L: lib/msun__L
1896gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1897.endif
1898
1899.if ${MK_LIBCPLUSPLUS} != "no"
1900_prebuild_libs+= lib/libc++
1901.endif
1902
1903lib/libgeom__L: lib/libexpat__L
1904lib/libkvm__L: lib/libelf__L
1905
1906.if ${MK_LIBTHR} != "no"
1907_lib_libthr=	lib/libthr
1908.endif
1909
1910.if ${MK_RADIUS_SUPPORT} != "no"
1911_lib_libradius=	lib/libradius
1912.endif
1913
1914.if ${MK_OFED} != "no"
1915_ofed_lib=		contrib/ofed/usr.lib
1916_prebuild_libs+=	contrib/ofed/usr.lib/libosmcomp
1917_prebuild_libs+=	contrib/ofed/usr.lib/libopensm
1918_prebuild_libs+=	contrib/ofed/usr.lib/libibcommon
1919_prebuild_libs+=	contrib/ofed/usr.lib/libibverbs
1920_prebuild_libs+=	contrib/ofed/usr.lib/libibumad
1921
1922contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1923contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1924contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1925.endif
1926
1927.if ${MK_CASPER} != "no"
1928_lib_casper=	lib/libcasper
1929.endif
1930
1931lib/libpjdlog__L: lib/libutil__L
1932lib/libcasper__L: lib/libnv__L
1933lib/liblzma__L: lib/libthr__L
1934
1935_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1936.for _DIR in ${LOCAL_LIB_DIRS}
1937.if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1938_generic_libs+= ${_DIR}
1939.endif
1940.endfor
1941
1942lib/libopie__L lib/libtacplus__L: lib/libmd__L
1943
1944.if ${MK_CDDL} != "no"
1945_cddl_lib_libumem= cddl/lib/libumem
1946_cddl_lib_libnvpair= cddl/lib/libnvpair
1947_cddl_lib_libavl= cddl/lib/libavl
1948_cddl_lib_libuutil= cddl/lib/libuutil
1949_cddl_lib_libzfs_core= cddl/lib/libzfs_core
1950_cddl_lib_libctf= cddl/lib/libctf
1951_cddl_lib= cddl/lib
1952cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1953cddl/lib/libzfs__L: lib/libgeom__L
1954cddl/lib/libctf__L: lib/libz__L
1955.endif
1956# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1957# on select architectures though (see cddl/lib/Makefile)
1958.if ${MACHINE_CPUARCH} != "sparc64"
1959_prebuild_libs+=	lib/libproc lib/librtld_db
1960.endif
1961
1962.if ${MK_CRYPT} != "no"
1963.if ${MK_OPENSSL} != "no"
1964_secure_lib_libcrypto= secure/lib/libcrypto
1965_secure_lib_libssl= secure/lib/libssl
1966lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1967.if ${MK_LDNS} != "no"
1968_lib_libldns= lib/libldns
1969lib/libldns__L: secure/lib/libcrypto__L
1970.endif
1971.if ${MK_OPENSSH} != "no"
1972_secure_lib_libssh= secure/lib/libssh
1973secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1974.if ${MK_LDNS} != "no"
1975secure/lib/libssh__L: lib/libldns__L
1976.endif
1977.if ${MK_KERBEROS_SUPPORT} != "no"
1978secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1979    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1980    lib/libmd__L kerberos5/lib/libroken__L
1981.endif
1982.endif
1983.endif
1984_secure_lib=	secure/lib
1985.endif
1986
1987.if ${MK_KERBEROS} != "no"
1988kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1989kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1990    kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1991    kerberos5/lib/libwind__L lib/libsqlite3__L
1992kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1993    kerberos5/lib/libroken__L lib/libcom_err__L
1994kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1995    secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1996kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1997    lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1998    kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1999    kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2000kerberos5/lib/libroken__L: lib/libcrypt__L
2001kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2002kerberos5/lib/libheimbase__L: lib/libthr__L
2003kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2004.endif
2005
2006lib/libsqlite3__L: lib/libthr__L
2007
2008.if ${MK_GSSAPI} != "no"
2009_lib_libgssapi=	lib/libgssapi
2010.endif
2011
2012.if ${MK_KERBEROS} != "no"
2013_kerberos5_lib=	kerberos5/lib
2014_kerberos5_lib_libasn1= kerberos5/lib/libasn1
2015_kerberos5_lib_libhdb= kerberos5/lib/libhdb
2016_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2017_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2018_kerberos5_lib_libhx509= kerberos5/lib/libhx509
2019_kerberos5_lib_libroken= kerberos5/lib/libroken
2020_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2021_libsqlite3= lib/libsqlite3
2022_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2023_kerberos5_lib_libwind= kerberos5/lib/libwind
2024_libcom_err= lib/libcom_err
2025.endif
2026
2027.if ${MK_NIS} != "no"
2028_lib_libypclnt=	lib/libypclnt
2029.endif
2030
2031.if ${MK_OPENSSL} == "no"
2032lib/libradius__L: lib/libmd__L
2033.endif
2034
2035lib/libproc__L: \
2036    ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2037.if ${MK_CXX} != "no"
2038.if ${MK_LIBCPLUSPLUS} != "no"
2039lib/libproc__L: lib/libcxxrt__L
2040.else # This implies MK_GNUCXX != "no"; see lib/libproc
2041lib/libproc__L: gnu/lib/libsupc++__L
2042.endif
2043.endif
2044
2045gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2046
2047.for _lib in ${_prereq_libs}
2048${_lib}__PL: .PHONY .MAKE
2049.if exists(${.CURDIR}/${_lib})
2050	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2051		cd ${.CURDIR}/${_lib}; \
2052		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2053		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2054		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2055		    DIRPRFX=${_lib}/ all; \
2056		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2057		    DIRPRFX=${_lib}/ install
2058.endif
2059.endfor
2060
2061.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2062${_lib}__L: .PHONY .MAKE
2063.if exists(${.CURDIR}/${_lib})
2064	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2065		cd ${.CURDIR}/${_lib}; \
2066		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2067		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2068		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2069		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2070.endif
2071.endfor
2072
2073# libpam is special: we need to build static PAM modules before
2074# static PAM library, and dynamic PAM library before dynamic PAM
2075# modules.
2076lib/libpam__L: .PHONY .MAKE
2077	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2078		cd ${.CURDIR}/lib/libpam; \
2079		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2080		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2081		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2082		    -D_NO_LIBPAM_SO_YET all; \
2083		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2084		    -D_NO_LIBPAM_SO_YET install
2085
2086_prereq_libs: ${_prereq_libs:S/$/__PL/}
2087_startup_libs: ${_startup_libs:S/$/__L/}
2088_prebuild_libs: ${_prebuild_libs:S/$/__L/}
2089_generic_libs: ${_generic_libs:S/$/__L/}
2090
2091# Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2092# 'everything' with _PARALLEL_SUBDIR_OK set.  This is because it is unlikely
2093# that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2094# or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2095# parallel.  This is safe for the world stage of buildworld though since it has
2096# already built libraries in a proper order and installed includes into
2097# WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2098# avoid trashing a system if it crashes mid-install.
2099.if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2100SUBDIR_PARALLEL=
2101.endif
2102
2103.include <bsd.subdir.mk>
2104
2105.if make(check-old) || make(check-old-dirs) || \
2106    make(check-old-files) || make(check-old-libs) || \
2107    make(delete-old) || make(delete-old-dirs) || \
2108    make(delete-old-files) || make(delete-old-libs)
2109
2110#
2111# check for / delete old files section
2112#
2113
2114.include "ObsoleteFiles.inc"
2115
2116OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2117else you can not start such an application. Consult UPDATING for more \
2118information regarding how to cope with the removal/revision bump of a \
2119specific library."
2120
2121.if !defined(BATCH_DELETE_OLD_FILES)
2122RM_I=-i
2123.else
2124RM_I=-v
2125.endif
2126
2127delete-old-files:
2128	@echo ">>> Removing old files (only deletes safe to delete libs)"
2129# Ask for every old file if the user really wants to remove it.
2130# It's annoying, but better safe than sorry.
2131# NB: We cannot pass the list of OLD_FILES as a parameter because the
2132# argument list will get too long. Using .for/.endfor make "loops" will make
2133# the Makefile parser segfault.
2134	@exec 3<&0; \
2135	cd ${.CURDIR}; \
2136	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2137	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2138	while read file; do \
2139		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2140			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2141			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2142		fi; \
2143		for ext in debug symbols; do \
2144		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2145		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2146			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2147			      <&3; \
2148		  fi; \
2149		done; \
2150	done
2151# Remove catpages without corresponding manpages.
2152	@exec 3<&0; \
2153	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2154	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2155	while read catpage; do \
2156		read manpage; \
2157		if [ ! -e "$${manpage}" ]; then \
2158			rm ${RM_I} $${catpage} <&3; \
2159	        fi; \
2160	done
2161	@echo ">>> Old files removed"
2162
2163check-old-files:
2164	@echo ">>> Checking for old files"
2165	@cd ${.CURDIR}; \
2166	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2167	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2168	while read file; do \
2169		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2170		 	echo "${DESTDIR}/$${file}"; \
2171		fi; \
2172		for ext in debug symbols; do \
2173		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2174			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2175		  fi; \
2176		done; \
2177	done
2178# Check for catpages without corresponding manpages.
2179	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2180	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2181	while read catpage; do \
2182		read manpage; \
2183		if [ ! -e "$${manpage}" ]; then \
2184			echo $${catpage}; \
2185	        fi; \
2186	done
2187
2188delete-old-libs:
2189	@echo ">>> Removing old libraries"
2190	@echo "${OLD_LIBS_MESSAGE}" | fmt
2191	@exec 3<&0; \
2192	cd ${.CURDIR}; \
2193	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2194	    -V OLD_LIBS | xargs -n1 | \
2195	while read file; do \
2196		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2197			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2198			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2199		fi; \
2200		for ext in debug symbols; do \
2201		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2202		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2203			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2204			      <&3; \
2205		  fi; \
2206		done; \
2207	done
2208	@echo ">>> Old libraries removed"
2209
2210check-old-libs:
2211	@echo ">>> Checking for old libraries"
2212	@cd ${.CURDIR}; \
2213	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2214	    -V OLD_LIBS | xargs -n1 | \
2215	while read file; do \
2216		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2217			echo "${DESTDIR}/$${file}"; \
2218		fi; \
2219		for ext in debug symbols; do \
2220		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2221			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2222		  fi; \
2223		done; \
2224	done
2225
2226delete-old-dirs:
2227	@echo ">>> Removing old directories"
2228	@cd ${.CURDIR}; \
2229	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2230	    -V OLD_DIRS | xargs -n1 | sort -r | \
2231	while read dir; do \
2232		if [ -d "${DESTDIR}/$${dir}" ]; then \
2233			rmdir -v "${DESTDIR}/$${dir}" || true; \
2234		elif [ -L "${DESTDIR}/$${dir}" ]; then \
2235			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2236		fi; \
2237	done
2238	@echo ">>> Old directories removed"
2239
2240check-old-dirs:
2241	@echo ">>> Checking for old directories"
2242	@cd ${.CURDIR}; \
2243	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2244	    -V OLD_DIRS | xargs -n1 | \
2245	while read dir; do \
2246		if [ -d "${DESTDIR}/$${dir}" ]; then \
2247			echo "${DESTDIR}/$${dir}"; \
2248		elif [ -L "${DESTDIR}/$${dir}" ]; then \
2249			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2250		fi; \
2251	done
2252
2253delete-old: delete-old-files delete-old-dirs
2254	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
2255
2256check-old: check-old-files check-old-libs check-old-dirs
2257	@echo "To remove old files and directories run '${MAKE} delete-old'."
2258	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
2259
2260.endif
2261
2262#
2263# showconfig - show build configuration.
2264#
2265showconfig:
2266	@(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2267	  ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2268
2269.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2270DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2271
2272.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2273.if exists(${KERNCONFDIR}/${KERNCONF})
2274FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2275	'${KERNCONFDIR}/${KERNCONF}' ; echo
2276.endif
2277.endif
2278
2279.endif
2280
2281.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2282DTBOUTPUTPATH= ${.CURDIR}
2283.endif
2284
2285#
2286# Build 'standalone' Device Tree Blob
2287#
2288builddtb:
2289	@PATH=${TMPPATH} MACHINE=${TARGET} \
2290	${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2291	    "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2292
2293###############
2294
2295# cleanworld
2296# In the following, the first 'rm' in a series will usually remove all
2297# files and directories.  If it does not, then there are probably some
2298# files with file flags set, so this unsets them and tries the 'rm' a
2299# second time.  There are situations where this target will be cleaning
2300# some directories via more than one method, but that duplication is
2301# needed to correctly handle all the possible situations.  Removing all
2302# files without file flags set in the first 'rm' instance saves time,
2303# because 'chflags' will need to operate on fewer files afterwards.
2304#
2305# It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2306# created by bsd.obj.mk, except that we don't want to .include that file
2307# in this makefile.
2308#
2309BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2310cleanworld: .PHONY
2311.if exists(${BW_CANONICALOBJDIR}/)
2312	-rm -rf ${BW_CANONICALOBJDIR}/*
2313	-chflags -R 0 ${BW_CANONICALOBJDIR}
2314	rm -rf ${BW_CANONICALOBJDIR}/*
2315.endif
2316.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2317	#   To be safe in this case, fall back to a 'make cleandir'
2318	${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2319.endif
2320
2321.if defined(TARGET) && defined(TARGET_ARCH)
2322
2323.if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2324XDEV_CPUTYPE?=${CPUTYPE}
2325.else
2326XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2327.endif
2328
2329NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2330	MK_MAN=no MK_NLS=no MK_PROFILE=no \
2331	MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2332	TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2333	CPUTYPE=${XDEV_CPUTYPE}
2334
2335XDDIR=${TARGET_ARCH}-freebsd
2336XDTP?=/usr/${XDDIR}
2337.if ${XDTP:N/*}
2338.error XDTP variable should be an absolute path
2339.endif
2340
2341CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2342	INSTALL="sh ${.CURDIR}/tools/install.sh"
2343CDENV= ${CDBENV} \
2344	TOOLS_PREFIX=${XDTP}
2345CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2346	--sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2347	-B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2348CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2349	CPP="${CPP} ${CD2CFLAGS}" \
2350	MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2351
2352CDTMP=	${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2353CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2354CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2355XDDESTDIR=${DESTDIR}/${XDTP}
2356.if !defined(OSREL)
2357OSREL!= uname -r | sed -e 's/[-(].*//'
2358.endif
2359
2360.ORDER: xdev-build xdev-install xdev-links
2361xdev: xdev-build xdev-install
2362
2363.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2364xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2365
2366_xb-worldtmp: .PHONY
2367	mkdir -p ${CDTMP}/usr
2368	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2369	    -p ${CDTMP}/usr >/dev/null
2370
2371_xb-bootstrap-tools: .PHONY
2372.for _tool in \
2373    ${_clang_tblgen} \
2374    ${_gperf}
2375	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2376	cd ${.CURDIR}/${_tool}; \
2377	${CDMAKE} DIRPRFX=${_tool}/ obj; \
2378	if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2379	${CDMAKE} DIRPRFX=${_tool}/ all; \
2380	${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2381.endfor
2382
2383_xb-build-tools: .PHONY
2384	${_+_}@cd ${.CURDIR}; \
2385	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2386
2387_xb-cross-tools: .PHONY
2388.for _tool in \
2389    ${_binutils} \
2390    ${_elftctools} \
2391    usr.bin/ar \
2392    ${_clang_libs} \
2393    ${_clang} \
2394    ${_cc}
2395	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2396	cd ${.CURDIR}/${_tool}; \
2397	${CDMAKE} DIRPRFX=${_tool}/ obj; \
2398	if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2399	${CDMAKE} DIRPRFX=${_tool}/ all
2400.endfor
2401
2402_xi-mtree: .PHONY
2403	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2404	mkdir -p ${XDDESTDIR}
2405	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2406	    -p ${XDDESTDIR} >/dev/null
2407	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2408	    -p ${XDDESTDIR}/usr >/dev/null
2409	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2410	    -p ${XDDESTDIR}/usr/include >/dev/null
2411.if ${MK_LIB32} != "no"
2412	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2413	    -p ${XDDESTDIR}/usr >/dev/null
2414.endif
2415.if ${MK_TESTS} != "no"
2416	mkdir -p ${XDDESTDIR}${TESTSBASE}
2417	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2418	    -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2419.endif
2420
2421.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2422xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2423
2424_xi-cross-tools: .PHONY
2425	@echo "_xi-cross-tools"
2426.for _tool in \
2427    ${_binutils} \
2428    ${_elftctools} \
2429    usr.bin/ar \
2430    ${_clang_libs} \
2431    ${_clang} \
2432    ${_cc}
2433	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2434	cd ${.CURDIR}/${_tool}; \
2435	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2436.endfor
2437
2438_xi-includes: .PHONY
2439	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2440		DESTDIR=${XDDESTDIR}
2441
2442_xi-libraries: .PHONY
2443	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2444		DESTDIR=${XDDESTDIR}
2445
2446xdev-links: .PHONY
2447	${_+_}cd ${XDDESTDIR}/usr/bin; \
2448	mkdir -p ../../../../usr/bin; \
2449		for i in *; do \
2450			ln -sf ../../${XDTP}/usr/bin/$$i \
2451			    ../../../../usr/bin/${XDDIR}-$$i; \
2452			ln -sf ../../${XDTP}/usr/bin/$$i \
2453			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2454		done
2455.else
2456xdev xdev-build xdev-install xdev-links:
2457	@echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2458.endif
2459