Makefile.inc1 revision 296399
1#
2# $FreeBSD: head/Makefile.inc1 296399 2016-03-04 22:37:16Z 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.if ${MK_MANDOCDB} != "no"
1533_libopenbsd?=	lib/libopenbsd
1534_makewhatis=	lib/libsqlite3 \
1535		usr.bin/mandoc
1536${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1537.else
1538_makewhatis=usr.bin/makewhatis
1539.endif
1540
1541bootstrap-tools: .PHONY
1542
1543#	Please document (add comment) why something is in 'bootstrap-tools'.
1544#	Try to bound the building of the bootstrap-tool to just the
1545#	FreeBSD versions that need the tool built at this stage of the build.
1546.for _tool in \
1547    ${_clang_tblgen} \
1548    ${_kerberos5_bootstrap_tools} \
1549    ${_strfile} \
1550    ${_gperf} \
1551    ${_groff} \
1552    ${_dtc} \
1553    ${_awk} \
1554    ${_cat} \
1555    ${_dd} \
1556    usr.bin/lorder \
1557    ${_libopenbsd} \
1558    ${_makewhatis} \
1559    usr.bin/rpcgen \
1560    ${_sed} \
1561    ${_yacc} \
1562    ${_m4} \
1563    ${_lex} \
1564    usr.bin/xinstall \
1565    ${_gensnmptree} \
1566    usr.sbin/config \
1567    ${_crunch} \
1568    ${_nmtree} \
1569    ${_vtfontcvt} \
1570    usr.bin/localedef
1571${_bt}-${_tool}: .PHONY .MAKE
1572	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1573		cd ${.CURDIR}/${_tool}; \
1574		${MAKE} DIRPRFX=${_tool}/ obj; \
1575		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1576		${MAKE} DIRPRFX=${_tool}/ all; \
1577		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1578
1579bootstrap-tools: ${_bt}-${_tool}
1580.endfor
1581
1582#
1583# build-tools: Build special purpose build tools
1584#
1585.if !defined(NO_SHARE)
1586_share=	share/syscons/scrnmaps
1587.endif
1588
1589.if ${MK_GCC} != "no"
1590_gcc_tools= gnu/usr.bin/cc/cc_tools
1591.endif
1592
1593.if ${MK_RESCUE} != "no"
1594# rescue includes programs that have build-tools targets
1595_rescue=rescue/rescue
1596.endif
1597
1598.for _tool in \
1599    bin/csh \
1600    bin/sh \
1601    ${LOCAL_TOOL_DIRS} \
1602    lib/ncurses/ncurses \
1603    lib/ncurses/ncursesw \
1604    ${_rescue} \
1605    ${_share} \
1606    usr.bin/awk \
1607    lib/libmagic \
1608    usr.bin/mkesdb_static \
1609    usr.bin/mkcsmapper_static \
1610    usr.bin/vi/catalog
1611build-tools_${_tool}: .PHONY
1612	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1613		cd ${.CURDIR}/${_tool}; \
1614		${MAKE} DIRPRFX=${_tool}/ obj; \
1615		${MAKE} DIRPRFX=${_tool}/ build-tools
1616build-tools: build-tools_${_tool}
1617.endfor
1618.for _tool in \
1619    ${_gcc_tools}
1620build-tools_${_tool}: .PHONY
1621	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1622		cd ${.CURDIR}/${_tool}; \
1623		${MAKE} DIRPRFX=${_tool}/ obj; \
1624		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1625		${MAKE} DIRPRFX=${_tool}/ all
1626build-tools: build-tools_${_tool}
1627.endfor
1628
1629#
1630# kernel-tools: Build kernel-building tools
1631#
1632kernel-tools:
1633	mkdir -p ${MAKEOBJDIRPREFIX}/usr
1634	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1635	    -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1636
1637#
1638# cross-tools: All the tools needed to build the rest of the system after
1639# we get done with the earlier stages. It is the last set of tools needed
1640# to begin building the target binaries.
1641#
1642.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1643.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1644_btxld=		usr.sbin/btxld
1645.endif
1646.endif
1647
1648# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1649# resulting from missing bug fixes or ELF Toolchain updates.
1650.if ${MK_CDDL} != "no"
1651_dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1652    cddl/usr.bin/ctfmerge
1653.endif
1654
1655# If we're given an XAS, don't build binutils.
1656.if ${XAS:M/*} == ""
1657.if ${MK_BINUTILS_BOOTSTRAP} != "no"
1658_binutils=	gnu/usr.bin/binutils
1659.endif
1660.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1661_elftctools=	lib/libelftc \
1662		lib/libpe \
1663		usr.bin/elfcopy \
1664		usr.bin/nm \
1665		usr.bin/size \
1666		usr.bin/strings
1667# These are not required by the build, but can be useful for developers who
1668# cross-build on a FreeBSD 10 host:
1669_elftctools+=	usr.bin/addr2line
1670.endif
1671.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1672# If cross-building with an external binutils we still need to build strip for
1673# the target (for at least crunchide).
1674_elftctools=	lib/libelftc \
1675		lib/libpe \
1676		usr.bin/elfcopy
1677.endif
1678
1679# If an full path to an external cross compiler is given, don't build
1680# a cross compiler.
1681.if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1682.if ${MK_CLANG_BOOTSTRAP} != "no"
1683_clang=		usr.bin/clang
1684_clang_libs=	lib/clang
1685.endif
1686.if ${MK_GCC_BOOTSTRAP} != "no"
1687_cc=		gnu/usr.bin/cc
1688.endif
1689.endif
1690.if ${MK_USB} != "no"
1691_usb_tools=	sys/boot/usb/tools
1692.endif
1693
1694cross-tools: .MAKE .PHONY
1695.for _tool in \
1696    ${_clang_libs} \
1697    ${_clang} \
1698    ${_binutils} \
1699    ${_elftctools} \
1700    ${_dtrace_tools} \
1701    ${_cc} \
1702    ${_btxld} \
1703    ${_crunchide} \
1704    ${_usb_tools}
1705	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1706		cd ${.CURDIR}/${_tool}; \
1707		${MAKE} DIRPRFX=${_tool}/ obj; \
1708		if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1709		${MAKE} DIRPRFX=${_tool}/ all; \
1710		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1711.endfor
1712
1713NXBDESTDIR=	${OBJTREE}/nxb-bin
1714NXBENV=		MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1715		INSTALL="sh ${.CURDIR}/tools/install.sh" \
1716		PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1717NXBMAKE=	${NXBENV} ${MAKE} \
1718		TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1719		CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1720		MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1721		MK_GDB=no MK_TESTS=no \
1722		SSP_CFLAGS= \
1723		MK_HTML=no NO_LINT=yes MK_MAN=no \
1724		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
1725		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1726		MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1727		MK_LLDB=no MK_DEBUG_FILES=no
1728
1729# native-xtools is the current target for qemu-user cross builds of ports
1730# via poudriere and the imgact_binmisc kernel module.
1731# For non-clang enabled targets that are still using the in tree gcc
1732# we must build a gperf binary for one instance of its Makefiles.  On
1733# clang-enabled systems, the gperf binary is obsolete.
1734native-xtools: .PHONY
1735.if ${MK_GCC_BOOTSTRAP} != "no"
1736	mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1737	${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1738	cd ${.CURDIR}/${_gperf}; \
1739	${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1740	if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1741	${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1742	${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1743.endif
1744	mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1745	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1746	    -p ${NXBDESTDIR}/usr >/dev/null
1747	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1748	    -p ${NXBDESTDIR}/usr/include >/dev/null
1749.if ${MK_DEBUG_FILES} != "no"
1750	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1751	    -p ${NXBDESTDIR}/usr/lib >/dev/null
1752.endif
1753.for _tool in \
1754    bin/cat \
1755    bin/chmod \
1756    bin/cp \
1757    bin/csh \
1758    bin/echo \
1759    bin/expr \
1760    bin/hostname \
1761    bin/ln \
1762    bin/ls \
1763    bin/mkdir \
1764    bin/mv \
1765    bin/ps \
1766    bin/realpath \
1767    bin/rm \
1768    bin/rmdir \
1769    bin/sh \
1770    bin/sleep \
1771    ${_clang_tblgen} \
1772    usr.bin/ar \
1773    ${_binutils} \
1774    ${_elftctools} \
1775    ${_cc} \
1776    ${_gcc_tools} \
1777    ${_clang_libs} \
1778    ${_clang} \
1779    sbin/md5 \
1780    sbin/sysctl \
1781    gnu/usr.bin/diff \
1782    usr.bin/awk \
1783    usr.bin/basename \
1784    usr.bin/bmake \
1785    usr.bin/bzip2 \
1786    usr.bin/cmp \
1787    usr.bin/dirname \
1788    usr.bin/env \
1789    usr.bin/fetch \
1790    usr.bin/find \
1791    usr.bin/grep \
1792    usr.bin/gzip \
1793    usr.bin/id \
1794    usr.bin/lex \
1795    usr.bin/lorder \
1796    usr.bin/mktemp \
1797    usr.bin/mt \
1798    usr.bin/patch \
1799    usr.bin/sed \
1800    usr.bin/sort \
1801    usr.bin/tar \
1802    usr.bin/touch \
1803    usr.bin/tr \
1804    usr.bin/true \
1805    usr.bin/uniq \
1806    usr.bin/unzip \
1807    usr.bin/xargs \
1808    usr.bin/xinstall \
1809    usr.bin/xz \
1810    usr.bin/yacc \
1811    usr.sbin/chown
1812	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1813		cd ${.CURDIR}/${_tool}; \
1814		${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1815		if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1816		${NXBMAKE} DIRPRFX=${_tool}/ all; \
1817		${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1818.endfor
1819
1820#
1821# hierarchy - ensure that all the needed directories are present
1822#
1823hierarchy hier: .MAKE .PHONY
1824	${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1825
1826#
1827# libraries - build all libraries, and install them under ${DESTDIR}.
1828#
1829# The list of libraries with dependents (${_prebuild_libs}) and their
1830# interdependencies (__L) are built automatically by the
1831# ${.CURDIR}/tools/make_libdeps.sh script.
1832#
1833libraries: .MAKE .PHONY
1834	${_+_}cd ${.CURDIR}; \
1835	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1836	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1837	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1838	    ${MAKE} -f Makefile.inc1 _generic_libs
1839
1840#
1841# static libgcc.a prerequisite for shared libc
1842#
1843_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1844
1845# These dependencies are not automatically generated:
1846#
1847# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1848# all shared libraries for ELF.
1849#
1850_startup_libs=	gnu/lib/csu
1851_startup_libs+=	lib/csu
1852_startup_libs+=	gnu/lib/libgcc
1853_startup_libs+=	lib/libcompiler_rt
1854_startup_libs+=	lib/libc
1855_startup_libs+=	lib/libc_nonshared
1856.if ${MK_LIBCPLUSPLUS} != "no"
1857_startup_libs+=	lib/libcxxrt
1858.endif
1859
1860gnu/lib/libgcc__L: lib/libc__L
1861gnu/lib/libgcc__L: lib/libc_nonshared__L
1862.if ${MK_LIBCPLUSPLUS} != "no"
1863lib/libcxxrt__L: gnu/lib/libgcc__L
1864.endif
1865
1866_prebuild_libs=	${_kerberos5_lib_libasn1} \
1867		${_kerberos5_lib_libhdb} \
1868		${_kerberos5_lib_libheimbase} \
1869		${_kerberos5_lib_libheimntlm} \
1870		${_libsqlite3} \
1871		${_kerberos5_lib_libheimipcc} \
1872		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1873		${_kerberos5_lib_libroken} \
1874		${_kerberos5_lib_libwind} \
1875		lib/libbz2 ${_libcom_err} lib/libcrypt \
1876		lib/libelf lib/libexpat \
1877		lib/libfigpar \
1878		${_lib_libgssapi} \
1879		lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1880		${_lib_casper} \
1881		lib/ncurses/ncurses lib/ncurses/ncursesw \
1882		lib/libopie lib/libpam ${_lib_libthr} \
1883		${_lib_libradius} lib/libsbuf lib/libtacplus \
1884		lib/libgeom \
1885		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1886		${_cddl_lib_libuutil} \
1887		${_cddl_lib_libavl} \
1888		${_cddl_lib_libzfs_core} \
1889		${_cddl_lib_libctf} \
1890		lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1891		${_secure_lib_libcrypto} ${_lib_libldns} \
1892		${_secure_lib_libssh} ${_secure_lib_libssl} \
1893		gnu/lib/libdialog
1894.if ${MK_GNUCXX} != "no"
1895_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1896gnu/lib/libstdc++__L: lib/msun__L
1897gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1898.endif
1899
1900.if ${MK_LIBCPLUSPLUS} != "no"
1901_prebuild_libs+= lib/libc++
1902.endif
1903
1904lib/libgeom__L: lib/libexpat__L
1905lib/libkvm__L: lib/libelf__L
1906
1907.if ${MK_LIBTHR} != "no"
1908_lib_libthr=	lib/libthr
1909.endif
1910
1911.if ${MK_RADIUS_SUPPORT} != "no"
1912_lib_libradius=	lib/libradius
1913.endif
1914
1915.if ${MK_OFED} != "no"
1916_ofed_lib=		contrib/ofed/usr.lib
1917_prebuild_libs+=	contrib/ofed/usr.lib/libosmcomp
1918_prebuild_libs+=	contrib/ofed/usr.lib/libopensm
1919_prebuild_libs+=	contrib/ofed/usr.lib/libibcommon
1920_prebuild_libs+=	contrib/ofed/usr.lib/libibverbs
1921_prebuild_libs+=	contrib/ofed/usr.lib/libibumad
1922
1923contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1924contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1925contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1926.endif
1927
1928.if ${MK_CASPER} != "no"
1929_lib_casper=	lib/libcasper
1930.endif
1931
1932lib/libpjdlog__L: lib/libutil__L
1933lib/libcasper__L: lib/libnv__L
1934lib/liblzma__L: lib/libthr__L
1935
1936_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1937.for _DIR in ${LOCAL_LIB_DIRS}
1938.if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1939_generic_libs+= ${_DIR}
1940.endif
1941.endfor
1942
1943lib/libopie__L lib/libtacplus__L: lib/libmd__L
1944
1945.if ${MK_CDDL} != "no"
1946_cddl_lib_libumem= cddl/lib/libumem
1947_cddl_lib_libnvpair= cddl/lib/libnvpair
1948_cddl_lib_libavl= cddl/lib/libavl
1949_cddl_lib_libuutil= cddl/lib/libuutil
1950_cddl_lib_libzfs_core= cddl/lib/libzfs_core
1951_cddl_lib_libctf= cddl/lib/libctf
1952_cddl_lib= cddl/lib
1953cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1954cddl/lib/libzfs__L: lib/libgeom__L
1955cddl/lib/libctf__L: lib/libz__L
1956.endif
1957# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1958# on select architectures though (see cddl/lib/Makefile)
1959.if ${MACHINE_CPUARCH} != "sparc64"
1960_prebuild_libs+=	lib/libproc lib/librtld_db
1961.endif
1962
1963.if ${MK_CRYPT} != "no"
1964.if ${MK_OPENSSL} != "no"
1965_secure_lib_libcrypto= secure/lib/libcrypto
1966_secure_lib_libssl= secure/lib/libssl
1967lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1968.if ${MK_LDNS} != "no"
1969_lib_libldns= lib/libldns
1970lib/libldns__L: secure/lib/libcrypto__L
1971.endif
1972.if ${MK_OPENSSH} != "no"
1973_secure_lib_libssh= secure/lib/libssh
1974secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1975.if ${MK_LDNS} != "no"
1976secure/lib/libssh__L: lib/libldns__L
1977.endif
1978.if ${MK_KERBEROS_SUPPORT} != "no"
1979secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1980    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1981    lib/libmd__L kerberos5/lib/libroken__L
1982.endif
1983.endif
1984.endif
1985_secure_lib=	secure/lib
1986.endif
1987
1988.if ${MK_KERBEROS} != "no"
1989kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1990kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1991    kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1992    kerberos5/lib/libwind__L lib/libsqlite3__L
1993kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1994    kerberos5/lib/libroken__L lib/libcom_err__L
1995kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1996    secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1997kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1998    lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1999    kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2000    kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2001kerberos5/lib/libroken__L: lib/libcrypt__L
2002kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2003kerberos5/lib/libheimbase__L: lib/libthr__L
2004kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2005.endif
2006
2007lib/libsqlite3__L: lib/libthr__L
2008
2009.if ${MK_GSSAPI} != "no"
2010_lib_libgssapi=	lib/libgssapi
2011.endif
2012
2013.if ${MK_KERBEROS} != "no"
2014_kerberos5_lib=	kerberos5/lib
2015_kerberos5_lib_libasn1= kerberos5/lib/libasn1
2016_kerberos5_lib_libhdb= kerberos5/lib/libhdb
2017_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2018_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2019_kerberos5_lib_libhx509= kerberos5/lib/libhx509
2020_kerberos5_lib_libroken= kerberos5/lib/libroken
2021_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2022_libsqlite3= lib/libsqlite3
2023_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2024_kerberos5_lib_libwind= kerberos5/lib/libwind
2025_libcom_err= lib/libcom_err
2026.endif
2027
2028.if ${MK_NIS} != "no"
2029_lib_libypclnt=	lib/libypclnt
2030.endif
2031
2032.if ${MK_OPENSSL} == "no"
2033lib/libradius__L: lib/libmd__L
2034.endif
2035
2036lib/libproc__L: \
2037    ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2038.if ${MK_CXX} != "no"
2039.if ${MK_LIBCPLUSPLUS} != "no"
2040lib/libproc__L: lib/libcxxrt__L
2041.else # This implies MK_GNUCXX != "no"; see lib/libproc
2042lib/libproc__L: gnu/lib/libsupc++__L
2043.endif
2044.endif
2045
2046gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2047
2048.for _lib in ${_prereq_libs}
2049${_lib}__PL: .PHONY .MAKE
2050.if exists(${.CURDIR}/${_lib})
2051	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2052		cd ${.CURDIR}/${_lib}; \
2053		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2054		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2055		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2056		    DIRPRFX=${_lib}/ all; \
2057		${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2058		    DIRPRFX=${_lib}/ install
2059.endif
2060.endfor
2061
2062.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2063${_lib}__L: .PHONY .MAKE
2064.if exists(${.CURDIR}/${_lib})
2065	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2066		cd ${.CURDIR}/${_lib}; \
2067		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2068		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2069		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2070		${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2071.endif
2072.endfor
2073
2074# libpam is special: we need to build static PAM modules before
2075# static PAM library, and dynamic PAM library before dynamic PAM
2076# modules.
2077lib/libpam__L: .PHONY .MAKE
2078	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2079		cd ${.CURDIR}/lib/libpam; \
2080		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2081		if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2082		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2083		    -D_NO_LIBPAM_SO_YET all; \
2084		${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2085		    -D_NO_LIBPAM_SO_YET install
2086
2087_prereq_libs: ${_prereq_libs:S/$/__PL/}
2088_startup_libs: ${_startup_libs:S/$/__L/}
2089_prebuild_libs: ${_prebuild_libs:S/$/__L/}
2090_generic_libs: ${_generic_libs:S/$/__L/}
2091
2092# Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2093# 'everything' with _PARALLEL_SUBDIR_OK set.  This is because it is unlikely
2094# that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2095# or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2096# parallel.  This is safe for the world stage of buildworld though since it has
2097# already built libraries in a proper order and installed includes into
2098# WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2099# avoid trashing a system if it crashes mid-install.
2100.if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2101SUBDIR_PARALLEL=
2102.endif
2103
2104.include <bsd.subdir.mk>
2105
2106.if make(check-old) || make(check-old-dirs) || \
2107    make(check-old-files) || make(check-old-libs) || \
2108    make(delete-old) || make(delete-old-dirs) || \
2109    make(delete-old-files) || make(delete-old-libs)
2110
2111#
2112# check for / delete old files section
2113#
2114
2115.include "ObsoleteFiles.inc"
2116
2117OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2118else you can not start such an application. Consult UPDATING for more \
2119information regarding how to cope with the removal/revision bump of a \
2120specific library."
2121
2122.if !defined(BATCH_DELETE_OLD_FILES)
2123RM_I=-i
2124.else
2125RM_I=-v
2126.endif
2127
2128delete-old-files:
2129	@echo ">>> Removing old files (only deletes safe to delete libs)"
2130# Ask for every old file if the user really wants to remove it.
2131# It's annoying, but better safe than sorry.
2132# NB: We cannot pass the list of OLD_FILES as a parameter because the
2133# argument list will get too long. Using .for/.endfor make "loops" will make
2134# the Makefile parser segfault.
2135	@exec 3<&0; \
2136	cd ${.CURDIR}; \
2137	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2138	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2139	while read file; do \
2140		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2141			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2142			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2143		fi; \
2144		for ext in debug symbols; do \
2145		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2146		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2147			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2148			      <&3; \
2149		  fi; \
2150		done; \
2151	done
2152# Remove catpages without corresponding manpages.
2153	@exec 3<&0; \
2154	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2155	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2156	while read catpage; do \
2157		read manpage; \
2158		if [ ! -e "$${manpage}" ]; then \
2159			rm ${RM_I} $${catpage} <&3; \
2160	        fi; \
2161	done
2162	@echo ">>> Old files removed"
2163
2164check-old-files:
2165	@echo ">>> Checking for old files"
2166	@cd ${.CURDIR}; \
2167	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2168	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2169	while read file; do \
2170		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2171		 	echo "${DESTDIR}/$${file}"; \
2172		fi; \
2173		for ext in debug symbols; do \
2174		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2175			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2176		  fi; \
2177		done; \
2178	done
2179# Check for catpages without corresponding manpages.
2180	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2181	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2182	while read catpage; do \
2183		read manpage; \
2184		if [ ! -e "$${manpage}" ]; then \
2185			echo $${catpage}; \
2186	        fi; \
2187	done
2188
2189delete-old-libs:
2190	@echo ">>> Removing old libraries"
2191	@echo "${OLD_LIBS_MESSAGE}" | fmt
2192	@exec 3<&0; \
2193	cd ${.CURDIR}; \
2194	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2195	    -V OLD_LIBS | xargs -n1 | \
2196	while read file; do \
2197		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2198			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2199			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2200		fi; \
2201		for ext in debug symbols; do \
2202		  if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2203		      "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2204			  rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2205			      <&3; \
2206		  fi; \
2207		done; \
2208	done
2209	@echo ">>> Old libraries removed"
2210
2211check-old-libs:
2212	@echo ">>> Checking for old libraries"
2213	@cd ${.CURDIR}; \
2214	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2215	    -V OLD_LIBS | xargs -n1 | \
2216	while read file; do \
2217		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2218			echo "${DESTDIR}/$${file}"; \
2219		fi; \
2220		for ext in debug symbols; do \
2221		  if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2222			  echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2223		  fi; \
2224		done; \
2225	done
2226
2227delete-old-dirs:
2228	@echo ">>> Removing old directories"
2229	@cd ${.CURDIR}; \
2230	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2231	    -V OLD_DIRS | xargs -n1 | sort -r | \
2232	while read dir; do \
2233		if [ -d "${DESTDIR}/$${dir}" ]; then \
2234			rmdir -v "${DESTDIR}/$${dir}" || true; \
2235		elif [ -L "${DESTDIR}/$${dir}" ]; then \
2236			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2237		fi; \
2238	done
2239	@echo ">>> Old directories removed"
2240
2241check-old-dirs:
2242	@echo ">>> Checking for old directories"
2243	@cd ${.CURDIR}; \
2244	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2245	    -V OLD_DIRS | xargs -n1 | \
2246	while read dir; do \
2247		if [ -d "${DESTDIR}/$${dir}" ]; then \
2248			echo "${DESTDIR}/$${dir}"; \
2249		elif [ -L "${DESTDIR}/$${dir}" ]; then \
2250			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2251		fi; \
2252	done
2253
2254delete-old: delete-old-files delete-old-dirs
2255	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
2256
2257check-old: check-old-files check-old-libs check-old-dirs
2258	@echo "To remove old files and directories run '${MAKE} delete-old'."
2259	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
2260
2261.endif
2262
2263#
2264# showconfig - show build configuration.
2265#
2266showconfig:
2267	@(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2268	  ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2269
2270.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2271DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2272
2273.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2274.if exists(${KERNCONFDIR}/${KERNCONF})
2275FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2276	'${KERNCONFDIR}/${KERNCONF}' ; echo
2277.endif
2278.endif
2279
2280.endif
2281
2282.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2283DTBOUTPUTPATH= ${.CURDIR}
2284.endif
2285
2286#
2287# Build 'standalone' Device Tree Blob
2288#
2289builddtb:
2290	@PATH=${TMPPATH} MACHINE=${TARGET} \
2291	${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2292	    "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2293
2294###############
2295
2296# cleanworld
2297# In the following, the first 'rm' in a series will usually remove all
2298# files and directories.  If it does not, then there are probably some
2299# files with file flags set, so this unsets them and tries the 'rm' a
2300# second time.  There are situations where this target will be cleaning
2301# some directories via more than one method, but that duplication is
2302# needed to correctly handle all the possible situations.  Removing all
2303# files without file flags set in the first 'rm' instance saves time,
2304# because 'chflags' will need to operate on fewer files afterwards.
2305#
2306# It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2307# created by bsd.obj.mk, except that we don't want to .include that file
2308# in this makefile.
2309#
2310BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2311cleanworld: .PHONY
2312.if exists(${BW_CANONICALOBJDIR}/)
2313	-rm -rf ${BW_CANONICALOBJDIR}/*
2314	-chflags -R 0 ${BW_CANONICALOBJDIR}
2315	rm -rf ${BW_CANONICALOBJDIR}/*
2316.endif
2317.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2318	#   To be safe in this case, fall back to a 'make cleandir'
2319	${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2320.endif
2321
2322.if defined(TARGET) && defined(TARGET_ARCH)
2323
2324.if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2325XDEV_CPUTYPE?=${CPUTYPE}
2326.else
2327XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2328.endif
2329
2330NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2331	MK_MAN=no MK_NLS=no MK_PROFILE=no \
2332	MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2333	TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2334	CPUTYPE=${XDEV_CPUTYPE}
2335
2336XDDIR=${TARGET_ARCH}-freebsd
2337XDTP?=/usr/${XDDIR}
2338.if ${XDTP:N/*}
2339.error XDTP variable should be an absolute path
2340.endif
2341
2342CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2343	INSTALL="sh ${.CURDIR}/tools/install.sh"
2344CDENV= ${CDBENV} \
2345	TOOLS_PREFIX=${XDTP}
2346CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2347	--sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2348	-B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2349CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2350	CPP="${CPP} ${CD2CFLAGS}" \
2351	MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2352
2353CDTMP=	${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2354CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2355CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2356XDDESTDIR=${DESTDIR}/${XDTP}
2357.if !defined(OSREL)
2358OSREL!= uname -r | sed -e 's/[-(].*//'
2359.endif
2360
2361.ORDER: xdev-build xdev-install xdev-links
2362xdev: xdev-build xdev-install
2363
2364.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2365xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2366
2367_xb-worldtmp: .PHONY
2368	mkdir -p ${CDTMP}/usr
2369	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2370	    -p ${CDTMP}/usr >/dev/null
2371
2372_xb-bootstrap-tools: .PHONY
2373.for _tool in \
2374    ${_clang_tblgen} \
2375    ${_gperf}
2376	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2377	cd ${.CURDIR}/${_tool}; \
2378	${CDMAKE} DIRPRFX=${_tool}/ obj; \
2379	if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2380	${CDMAKE} DIRPRFX=${_tool}/ all; \
2381	${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2382.endfor
2383
2384_xb-build-tools: .PHONY
2385	${_+_}@cd ${.CURDIR}; \
2386	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2387
2388_xb-cross-tools: .PHONY
2389.for _tool in \
2390    ${_binutils} \
2391    ${_elftctools} \
2392    usr.bin/ar \
2393    ${_clang_libs} \
2394    ${_clang} \
2395    ${_cc}
2396	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2397	cd ${.CURDIR}/${_tool}; \
2398	${CDMAKE} DIRPRFX=${_tool}/ obj; \
2399	if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2400	${CDMAKE} DIRPRFX=${_tool}/ all
2401.endfor
2402
2403_xi-mtree: .PHONY
2404	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2405	mkdir -p ${XDDESTDIR}
2406	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2407	    -p ${XDDESTDIR} >/dev/null
2408	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2409	    -p ${XDDESTDIR}/usr >/dev/null
2410	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2411	    -p ${XDDESTDIR}/usr/include >/dev/null
2412.if ${MK_LIB32} != "no"
2413	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2414	    -p ${XDDESTDIR}/usr >/dev/null
2415.endif
2416.if ${MK_TESTS} != "no"
2417	mkdir -p ${XDDESTDIR}${TESTSBASE}
2418	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2419	    -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2420.endif
2421
2422.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2423xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2424
2425_xi-cross-tools: .PHONY
2426	@echo "_xi-cross-tools"
2427.for _tool in \
2428    ${_binutils} \
2429    ${_elftctools} \
2430    usr.bin/ar \
2431    ${_clang_libs} \
2432    ${_clang} \
2433    ${_cc}
2434	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2435	cd ${.CURDIR}/${_tool}; \
2436	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2437.endfor
2438
2439_xi-includes: .PHONY
2440	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2441		DESTDIR=${XDDESTDIR}
2442
2443_xi-libraries: .PHONY
2444	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2445		DESTDIR=${XDDESTDIR}
2446
2447xdev-links: .PHONY
2448	${_+_}cd ${XDDESTDIR}/usr/bin; \
2449	mkdir -p ../../../../usr/bin; \
2450		for i in *; do \
2451			ln -sf ../../${XDTP}/usr/bin/$$i \
2452			    ../../../../usr/bin/${XDDIR}-$$i; \
2453			ln -sf ../../${XDTP}/usr/bin/$$i \
2454			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2455		done
2456.else
2457xdev xdev-build xdev-install xdev-links:
2458	@echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2459.endif
2460