Makefile.inc1 revision 211560
1274955Ssvnmir#
2274955Ssvnmir# $FreeBSD: head/Makefile.inc1 211560 2010-08-21 13:42:12Z rpaulo $
3274955Ssvnmir#
4274955Ssvnmir# Make command line options:
5274955Ssvnmir#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6274955Ssvnmir#	-DNO_CLEAN do not clean at all
7274955Ssvnmir#	-DNO_SHARE do not go into share subdir
8274955Ssvnmir#	-DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
9274955Ssvnmir#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10274955Ssvnmir#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11274955Ssvnmir#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12274955Ssvnmir#	-DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13274955Ssvnmir#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
14274955Ssvnmir#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
15274955Ssvnmir#	-DNO_CTF do not run the DTrace CTF conversion tools on built objects
16274955Ssvnmir#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
17274955Ssvnmir#	TARGET="machine" to crossbuild world for a different machine type
18274955Ssvnmir#	TARGET_ARCH= may be required when a TARGET supports multiple endians
19274955Ssvnmir
20274955Ssvnmir#
21274955Ssvnmir# The intended user-driven targets are:
22274955Ssvnmir# buildworld  - rebuild *everything*, including glue to help do upgrades
23274955Ssvnmir# installworld- install everything built by "buildworld"
24274955Ssvnmir# doxygen     - build API documentation of the kernel
25274955Ssvnmir# update      - convenient way to update your source tree (eg: cvsup/cvs)
26274955Ssvnmir#
27274955Ssvnmir# Standard targets (not defined here) are documented in the makefiles in
28274955Ssvnmir# /usr/share/mk.  These include:
29274955Ssvnmir#		obj depend all install clean cleandepend cleanobj
30277320Sdim
31277320Sdim.include <bsd.own.mk>
32277320Sdim
33274955Ssvnmir.include <bsd.arch.inc.mk>
34274955Ssvnmir
35274955Ssvnmir# We must do share/info early so that installation of info `dir'
36274955Ssvnmir# entries works correctly.  Do it first since it is less likely to
37274955Ssvnmir# grow dependencies on include and lib than vice versa.
38274955Ssvnmir#
39277320Sdim# We must do lib/ and libexec/ before bin/, because if installworld
40277320Sdim# installs a new /bin/sh, the 'make' command will *immediately*
41277320Sdim# use that new version.  And the new (dynamically-linked) /bin/sh
42274955Ssvnmir# will expect to find appropriate libraries in /lib and /libexec.
43274955Ssvnmir#
44274955SsvnmirSUBDIR=	share/info lib libexec
45274955SsvnmirSUBDIR+=bin
46274955Ssvnmir.if ${MK_GAMES} != "no"
47274955SsvnmirSUBDIR+=games
48274955Ssvnmir.endif
49274955Ssvnmir.if ${MK_CDDL} != "no"
50277320SdimSUBDIR+=cddl
51277320Sdim.else
52277320SdimNO_CTF=1
53274955Ssvnmir.endif
54274955SsvnmirSUBDIR+=gnu include
55274955Ssvnmir.if ${MK_KERBEROS} != "no"
56274955SsvnmirSUBDIR+=kerberos5
57277320Sdim.endif
58277320Sdim.if ${MK_RESCUE} != "no"
59277320SdimSUBDIR+=rescue
60274955Ssvnmir.endif
61274955SsvnmirSUBDIR+=sbin
62274955Ssvnmir.if ${MK_CRYPT} != "no"
63274955SsvnmirSUBDIR+=secure
64274955Ssvnmir.endif
65274955Ssvnmir.if !defined(NO_SHARE)
66274955SsvnmirSUBDIR+=share
67274955Ssvnmir.endif
68274955SsvnmirSUBDIR+=sys usr.bin usr.sbin
69274955Ssvnmir#
70274955Ssvnmir# We must do etc/ last for install/distribute to work.
71274955Ssvnmir#
72274955SsvnmirSUBDIR+=etc
73274955Ssvnmir
74274955Ssvnmir# These are last, since it is nice to at least get the base system
75274955Ssvnmir# rebuilt before you do them.
76274955Ssvnmir.for _DIR in ${LOCAL_DIRS}
77274955Ssvnmir.if exists(${.CURDIR}/${_DIR}/Makefile)
78274955SsvnmirSUBDIR+= ${_DIR}
79274955Ssvnmir.endif
80274955Ssvnmir.endfor
81296417Sdim
82274955Ssvnmir.if defined(SUBDIR_OVERRIDE)
83274955SsvnmirSUBDIR=		${SUBDIR_OVERRIDE}
84274955Ssvnmir.endif
85288943Sdim
86274955Ssvnmir.if defined(NOCLEAN)
87274955SsvnmirNO_CLEAN=	${NOCLEAN}
88274955Ssvnmir.endif
89274955Ssvnmir.if defined(NO_CLEANDIR)
90274955SsvnmirCLEANDIR=	clean cleandepend
91288943Sdim.else
92274955SsvnmirCLEANDIR=	cleandir
93274955Ssvnmir.endif
94274955Ssvnmir
95296417SdimCVS?=		cvs
96274955SsvnmirCVSFLAGS?=	-A -P -d -I!
97274955SsvnmirSVN?=		svn
98274955SsvnmirSVNFLAGS?=	-r HEAD
99274955SsvnmirSUP?=		/usr/bin/csup
100274955SsvnmirSUPFLAGS?=	-g -L 2
101274955Ssvnmir.if defined(SUPHOST)
102274955SsvnmirSUPFLAGS+=	-h ${SUPHOST}
103274955Ssvnmir.endif
104274955Ssvnmir
105274955SsvnmirMAKEOBJDIRPREFIX?=	/usr/obj
106274955Ssvnmir.if !defined(OSRELDATE)
107274955Ssvnmir.if exists(/usr/include/osreldate.h)
108274955SsvnmirOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
109274955Ssvnmir		/usr/include/osreldate.h
110274955Ssvnmir.else
111296417SdimOSRELDATE=	0
112274955Ssvnmir.endif
113274955Ssvnmir.endif
114274955Ssvnmir
115274955Ssvnmir.if !defined(VERSION)
116274955SsvnmirVERSION!=	uname -srp
117274955SsvnmirVERSION+=	${OSRELDATE}
118274955Ssvnmir.endif
119274955Ssvnmir
120274955Ssvnmir# Guess machine architecture from machine type, and vice versa.
121296417Sdim.if !defined(TARGET_ARCH) && defined(TARGET)
122288943SdimTARGET_ARCH=	${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
123296417Sdim.elif !defined(TARGET) && defined(TARGET_ARCH) && \
124296417Sdim    ${TARGET_ARCH} != ${MACHINE_ARCH}
125288943SdimTARGET=		${TARGET_ARCH}
126274955Ssvnmir.endif
127274955Ssvnmir# Otherwise, default to current machine type and architecture.
128274955SsvnmirTARGET?=	${MACHINE}
129274955SsvnmirTARGET_ARCH?=	${MACHINE_ARCH}
130274955Ssvnmir
131274955SsvnmirKNOWN_ARCHES?=	amd64 arm i386 i386/pc98 ia64 mips powerpc powerpc64/powerpc sparc64 sparc64/sun4v
132274955Ssvnmir.if ${TARGET} == ${TARGET_ARCH}
133274955Ssvnmir_t=		${TARGET}
134274955Ssvnmir.else
135274955Ssvnmir_t=		${TARGET_ARCH}/${TARGET}
136274955Ssvnmir.endif
137274955Ssvnmir.for _t in ${_t}
138280031Sdim.if empty(KNOWN_ARCHES:M${_t})
139280031Sdim.error Unknown target ${TARGET_ARCH}:${TARGET}.
140280031Sdim.endif
141274955Ssvnmir.endfor
142274955Ssvnmir
143274955Ssvnmir.if ${TARGET} == ${MACHINE}
144274955SsvnmirTARGET_CPUTYPE?=${CPUTYPE}
145274955Ssvnmir.else
146274955SsvnmirTARGET_CPUTYPE?=
147274955Ssvnmir.endif
148274955Ssvnmir
149274955Ssvnmir.if !empty(TARGET_CPUTYPE)
150288943Sdim_TARGET_CPUTYPE=${TARGET_CPUTYPE}
151288943Sdim.else
152274955Ssvnmir_TARGET_CPUTYPE=dummy
153274955Ssvnmir.endif
154274955Ssvnmir_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
155274955Ssvnmir		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
156274955Ssvnmir.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
157274955Ssvnmir.error CPUTYPE global should be set with ?=.
158274955Ssvnmir.endif
159274955Ssvnmir.if make(buildworld)
160274955SsvnmirBUILD_ARCH!=	uname -p
161274955Ssvnmir.if ${MACHINE_ARCH} != ${BUILD_ARCH}
162296417Sdim.error To cross-build, set TARGET_ARCH.
163274955Ssvnmir.endif
164274955Ssvnmir.endif
165274955Ssvnmir.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
166274955SsvnmirOBJTREE=	${MAKEOBJDIRPREFIX}
167274955Ssvnmir.else
168274955SsvnmirOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
169274955Ssvnmir.endif
170274955SsvnmirWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
171274955Ssvnmir# /usr/games added for fortune which depend on strfile
172274955SsvnmirBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
173274955SsvnmirXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
174288943SdimSTRICTTMPPATH=	${BPATH}:${XPATH}
175296417SdimTMPPATH=	${STRICTTMPPATH}:${PATH}
176296417Sdim
177274955Ssvnmir#
178274955Ssvnmir# Avoid running mktemp(1) unless actually needed.
179274955Ssvnmir# It may not be functional, e.g., due to new ABI
180274955Ssvnmir# when in the middle of installing over this system.
181274955Ssvnmir#
182274955Ssvnmir.if make(distributeworld) || make(installworld)
183274955SsvnmirINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
184274955Ssvnmir.endif
185274955Ssvnmir
186274955Ssvnmir#
187274955Ssvnmir# Building a world goes through the following stages
188274955Ssvnmir#
189274955Ssvnmir# 1. legacy stage [BMAKE]
190274955Ssvnmir#	This stage is responsible for creating compatibility
191274955Ssvnmir#	shims that are needed by the bootstrap-tools,
192274955Ssvnmir#	build-tools and cross-tools stages.
193274955Ssvnmir# 1. bootstrap-tools stage [BMAKE]
194274955Ssvnmir#	This stage is responsible for creating programs that
195274955Ssvnmir#	are needed for backward compatibility reasons. They
196274955Ssvnmir#	are not built as cross-tools.
197274955Ssvnmir# 2. build-tools stage [TMAKE]
198274955Ssvnmir#	This stage is responsible for creating the object
199274955Ssvnmir#	tree and building any tools that are needed during
200274955Ssvnmir#	the build process.
201274955Ssvnmir# 3. cross-tools stage [XMAKE]
202274955Ssvnmir#	This stage is responsible for creating any tools that
203274955Ssvnmir#	are needed for cross-builds. A cross-compiler is one
204274955Ssvnmir#	of them.
205274955Ssvnmir# 4. world stage [WMAKE]
206274955Ssvnmir#	This stage actually builds the world.
207274955Ssvnmir# 5. install stage (optional) [IMAKE]
208274955Ssvnmir#	This stage installs a previously built world.
209274955Ssvnmir#
210274955Ssvnmir
211274955SsvnmirBOOTSTRAPPING?=	0
212274955Ssvnmir
213274955Ssvnmir# Common environment for world related stages
214274955SsvnmirCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
215274955Ssvnmir		MACHINE_ARCH=${TARGET_ARCH} \
216274955Ssvnmir		MACHINE=${TARGET} \
217274955Ssvnmir		CPUTYPE=${TARGET_CPUTYPE} \
218274955Ssvnmir		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
219274955Ssvnmir		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
220274955Ssvnmir		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
221274955Ssvnmir.if ${OSRELDATE} < 700044
222274955SsvnmirCROSSENV+=	AR=gnu-ar RANLIB=gnu-ranlib
223274955Ssvnmir.endif
224274955Ssvnmir
225274955Ssvnmir# bootstrap-tools stage
226274955SsvnmirBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
227274955Ssvnmir		PATH=${BPATH}:${PATH} \
228274955Ssvnmir		WORLDTMP=${WORLDTMP} \
229274955Ssvnmir		VERSION="${VERSION}" \
230274955Ssvnmir		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
231274955SsvnmirBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
232274955Ssvnmir		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
233274955Ssvnmir		DESTDIR= \
234274955Ssvnmir		BOOTSTRAPPING=${OSRELDATE} \
235274955Ssvnmir		SSP_CFLAGS= \
236274955Ssvnmir		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
237274955Ssvnmir		-DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
238274955Ssvnmir		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
239274955Ssvnmir
240274955Ssvnmir# build-tools stage
241274955SsvnmirTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
242274955Ssvnmir		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
243280031Sdim		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
244280031Sdim		DESTDIR= \
245280031Sdim		SSP_CFLAGS= \
246288943Sdim		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
247296417Sdim		-DNO_WARNS -DNO_CTF
248274955Ssvnmir
249274955Ssvnmir# cross-tools stage
250274955SsvnmirXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
251274955Ssvnmir		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
252274955Ssvnmir		-DWITHOUT_GDB
253274955Ssvnmir
254274955Ssvnmir# world stage
255274955SsvnmirWMAKEENV=	${CROSSENV} \
256274955Ssvnmir		_SHLIBDIRPREFIX=${WORLDTMP} \
257280031Sdim		VERSION="${VERSION}" \
258280031Sdim		INSTALL="sh ${.CURDIR}/tools/install.sh" \
259274955Ssvnmir		PATH=${TMPPATH}
260280031Sdim.if ${MK_CDDL} == "no"
261274955SsvnmirWMAKEENV+=	NO_CTF=1
262296417Sdim.endif
263274955SsvnmirWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
264274955Ssvnmir
265280031Sdim.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
266274955Ssvnmir# 32 bit world
267274955SsvnmirLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
268280031Sdim
269280031Sdim.if ${TARGET_ARCH} == "amd64"
270280031Sdim.if empty(TARGET_CPUTYPE)
271288943SdimLIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
272288943Sdim.else
273280031SdimLIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
274280031Sdim.endif
275280031SdimLIB32CPUFLAGS+=	-mfancy-math-387
276280031SdimLIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
277274955Ssvnmir		MACHINE_CPU="i686 mmx sse sse2" \
278274955Ssvnmir		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
279280031Sdim		AS="${AS} --32"
280274955Ssvnmir
281274955Ssvnmir.elif ${TARGET_ARCH} == "powerpc64"
282274955Ssvnmir.if empty(TARGET_CPUTYPE)
283274955SsvnmirLIB32CPUFLAGS=	-mcpu=powerpc
284274955Ssvnmir.else
285274955SsvnmirLIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
286274955Ssvnmir.endif
287274955SsvnmirLIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc \
288274955Ssvnmir		LD="${LD} -m elf32ppc"
289274955Ssvnmir.endif
290274955Ssvnmir
291274955Ssvnmir
292274955SsvnmirLIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
293274955Ssvnmir		-isystem ${LIB32TMP}/usr/include/ \
294274955Ssvnmir		-L${LIB32TMP}/usr/lib32 \
295274955Ssvnmir		-B${LIB32TMP}/usr/lib32
296274955Ssvnmir
297274955Ssvnmir# Yes, the flags are redundant.
298274955SsvnmirLIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
299296417Sdim		_SHLIBDIRPREFIX=${LIB32TMP} \
300274955Ssvnmir		VERSION="${VERSION}" \
301274955Ssvnmir		INSTALL="sh ${.CURDIR}/tools/install.sh" \
302274955Ssvnmir		PATH=${TMPPATH} \
303274955Ssvnmir		CC="${CC} ${LIB32FLAGS}" \
304274955Ssvnmir		CXX="${CXX} ${LIB32FLAGS}" \
305274955Ssvnmir		OBJC="${OBJC} ${LIB32FLAGS}" \
306274955Ssvnmir		LIBDIR=/usr/lib32 \
307274955Ssvnmir		SHLIBDIR=/usr/lib32
308274955Ssvnmir
309274955SsvnmirLIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
310274955Ssvnmir		-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
311274955Ssvnmir		-DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
312274955SsvnmirLIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
313274955Ssvnmir.endif
314274955Ssvnmir
315274955Ssvnmir# install stage
316274955SsvnmirIMAKEENV=	${CROSSENV}
317274955SsvnmirIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
318274955Ssvnmir.if empty(.MAKEFLAGS:M-n)
319274955SsvnmirIMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
320274955Ssvnmir		LD_LIBRARY_PATH=${INSTALLTMP} \
321274955Ssvnmir		PATH_LOCALE=${INSTALLTMP}/locale
322274955SsvnmirIMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
323274955Ssvnmir.else
324274955SsvnmirIMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
325274955Ssvnmir.endif
326274955Ssvnmir
327274955Ssvnmir# kernel stage
328274955SsvnmirKMAKEENV=	${WMAKEENV}
329274955SsvnmirKMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
330274955Ssvnmir
331274955Ssvnmir#
332274955Ssvnmir# buildworld
333274955Ssvnmir#
334274955Ssvnmir# Attempt to rebuild the entire system, with reasonable chance of
335274955Ssvnmir# success, regardless of how old your existing system is.
336274955Ssvnmir#
337274955Ssvnmir_worldtmp:
338274955Ssvnmir.if ${.CURDIR:C/[^,]//g} != ""
339274955Ssvnmir#	The m4 build of sendmail files doesn't like it if ',' is used
340274955Ssvnmir#	anywhere in the path of it's files.
341274955Ssvnmir	@echo
342274955Ssvnmir	@echo "*** Error: path to source tree contains a comma ','"
343274955Ssvnmir	@echo
344274955Ssvnmir	false
345274955Ssvnmir.endif
346274955Ssvnmir	@echo
347274955Ssvnmir	@echo "--------------------------------------------------------------"
348274955Ssvnmir	@echo ">>> Rebuilding the temporary build tree"
349274955Ssvnmir	@echo "--------------------------------------------------------------"
350274955Ssvnmir.if !defined(NO_CLEAN)
351274955Ssvnmir	rm -rf ${WORLDTMP}
352274955Ssvnmir.if defined(LIB32TMP)
353274955Ssvnmir	rm -rf ${LIB32TMP}
354274955Ssvnmir.endif
355274955Ssvnmir.else
356274955Ssvnmir	rm -rf ${WORLDTMP}/legacy/usr/include
357274955Ssvnmir#	XXX - These three can depend on any header file.
358274955Ssvnmir	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
359274955Ssvnmir	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
360274955Ssvnmir	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
361274955Ssvnmir.endif
362274955Ssvnmir.for _dir in \
363274955Ssvnmir    lib usr legacy/usr
364274955Ssvnmir	mkdir -p ${WORLDTMP}/${_dir}
365274955Ssvnmir.endfor
366274955Ssvnmir	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
367274955Ssvnmir	    -p ${WORLDTMP}/legacy/usr >/dev/null
368274955Ssvnmir	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
369296417Sdim	    -p ${WORLDTMP}/usr >/dev/null
370274955Ssvnmir	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
371274955Ssvnmir	    -p ${WORLDTMP}/usr/include >/dev/null
372274955Ssvnmir	ln -sf ${.CURDIR}/sys ${WORLDTMP}
373280031Sdim.if ${MK_BIND_LIBS} != "no"
374280031Sdim	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
375274955Ssvnmir	    -p ${WORLDTMP}/usr/include >/dev/null
376274955Ssvnmir.endif
377274955Ssvnmir_legacy:
378274955Ssvnmir	@echo
379274955Ssvnmir	@echo "--------------------------------------------------------------"
380274955Ssvnmir	@echo ">>> stage 1.1: legacy release compatibility shims"
381274955Ssvnmir	@echo "--------------------------------------------------------------"
382274955Ssvnmir	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
383274955Ssvnmir_bootstrap-tools:
384274955Ssvnmir	@echo
385274955Ssvnmir	@echo "--------------------------------------------------------------"
386274955Ssvnmir	@echo ">>> stage 1.2: bootstrap tools"
387274955Ssvnmir	@echo "--------------------------------------------------------------"
388274955Ssvnmir	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
389274955Ssvnmir_cleanobj:
390274955Ssvnmir.if !defined(NO_CLEAN)
391274955Ssvnmir	@echo
392280031Sdim	@echo "--------------------------------------------------------------"
393280031Sdim	@echo ">>> stage 2.1: cleaning up the object tree"
394280031Sdim	@echo "--------------------------------------------------------------"
395280031Sdim	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
396280031Sdim.if defined(LIB32TMP)
397280031Sdim	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
398280031Sdim.endif
399288943Sdim.endif
400288943Sdim_obj:
401288943Sdim	@echo
402296417Sdim	@echo "--------------------------------------------------------------"
403274955Ssvnmir	@echo ">>> stage 2.2: rebuilding the object tree"
404274955Ssvnmir	@echo "--------------------------------------------------------------"
405274955Ssvnmir	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
406274955Ssvnmir_build-tools:
407274955Ssvnmir	@echo
408274955Ssvnmir	@echo "--------------------------------------------------------------"
409274955Ssvnmir	@echo ">>> stage 2.3: build tools"
410280031Sdim	@echo "--------------------------------------------------------------"
411280031Sdim	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
412280031Sdim_cross-tools:
413280031Sdim	@echo
414280031Sdim	@echo "--------------------------------------------------------------"
415274955Ssvnmir	@echo ">>> stage 3: cross tools"
416274955Ssvnmir	@echo "--------------------------------------------------------------"
417274955Ssvnmir	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
418280031Sdim_includes:
419280031Sdim	@echo
420280031Sdim	@echo "--------------------------------------------------------------"
421280031Sdim	@echo ">>> stage 4.1: building includes"
422280031Sdim	@echo "--------------------------------------------------------------"
423288943Sdim	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
424288943Sdim_libraries:
425280031Sdim	@echo
426280031Sdim	@echo "--------------------------------------------------------------"
427280031Sdim	@echo ">>> stage 4.2: building libraries"
428280031Sdim	@echo "--------------------------------------------------------------"
429280031Sdim	${_+_}cd ${.CURDIR}; \
430280031Sdim	    ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
431274955Ssvnmir	    -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
432274955Ssvnmir_depend:
433280031Sdim	@echo
434274955Ssvnmir	@echo "--------------------------------------------------------------"
435274955Ssvnmir	@echo ">>> stage 4.3: make dependencies"
436274955Ssvnmir	@echo "--------------------------------------------------------------"
437274955Ssvnmir	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
438274955Ssvnmireverything:
439274955Ssvnmir	@echo
440274955Ssvnmir	@echo "--------------------------------------------------------------"
441274955Ssvnmir	@echo ">>> stage 4.4: building everything"
442296417Sdim	@echo "--------------------------------------------------------------"
443274955Ssvnmir	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
444274955Ssvnmir.if defined(LIB32TMP)
445274955Ssvnmirbuild32:
446274955Ssvnmir	@echo
447296417Sdim	@echo "--------------------------------------------------------------"
448274955Ssvnmir	@echo ">>> stage 5.1: building 32 bit shim libraries"
449274955Ssvnmir	@echo "--------------------------------------------------------------"
450296417Sdim	mkdir -p ${LIB32TMP}/usr/lib32
451296417Sdim	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
452274955Ssvnmir	    -p ${LIB32TMP}/usr >/dev/null
453274955Ssvnmir	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
454274955Ssvnmir	    -p ${LIB32TMP}/usr/include >/dev/null
455274955Ssvnmir	mkdir -p ${WORLDTMP}
456274955Ssvnmir	ln -sf ${.CURDIR}/sys ${WORLDTMP}
457274955Ssvnmir.if ${MK_KERBEROS} != "no"
458274955Ssvnmir.for _t in obj depend all
459274955Ssvnmir	cd ${.CURDIR}/kerberos5/tools; \
460274955Ssvnmir	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
461274955Ssvnmir	    ${_t}
462274955Ssvnmir.endfor
463274955Ssvnmir.endif
464274955Ssvnmir.for _t in obj includes
465274955Ssvnmir	cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
466274955Ssvnmir	cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
467274955Ssvnmir.if ${MK_CDDL} != "no"
468274955Ssvnmir	cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
469274955Ssvnmir.endif
470274955Ssvnmir	cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
471274955Ssvnmir.if ${MK_CRYPT} != "no"
472274955Ssvnmir	cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
473274955Ssvnmir.endif
474274955Ssvnmir.if ${MK_KERBEROS} != "no"
475274955Ssvnmir	cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
476296417Sdim.endif
477274955Ssvnmir.endfor
478274955Ssvnmir.for _dir in usr.bin/lex/lib
479274955Ssvnmir	cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
480274955Ssvnmir.endfor
481296417Sdim.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
482274955Ssvnmir	cd ${.CURDIR}/${_dir}; \
483274955Ssvnmir	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
484274955Ssvnmir	    build-tools
485274955Ssvnmir.endfor
486274955Ssvnmir	cd ${.CURDIR}; \
487274955Ssvnmir	    ${LIB32WMAKE} -f Makefile.inc1 libraries
488274955Ssvnmir.for _t in obj depend all
489274955Ssvnmir	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
490274955Ssvnmir	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
491274955Ssvnmir.endfor
492274955Ssvnmir
493274955Ssvnmirdistribute32 install32:
494274955Ssvnmir.if make(distribute32)
495274955Ssvnmir	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32	# XXX add to mtree
496274955Ssvnmir	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace	# XXX add to mtree
497274955Ssvnmir.else
498274955Ssvnmir	mkdir -p ${DESTDIR}/usr/lib32			# XXX add to mtree
499274955Ssvnmir	mkdir -p ${DESTDIR}/usr/lib32/dtrace		# XXX add to mtree
500274955Ssvnmir.endif
501274955Ssvnmir	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
502274955Ssvnmir.if ${MK_CDDL} != "no"
503274955Ssvnmir	cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
504274955Ssvnmir.endif
505274955Ssvnmir	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
506274955Ssvnmir.if ${MK_CRYPT} != "no"
507274955Ssvnmir	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
508274955Ssvnmir.endif
509274955Ssvnmir.if ${MK_KERBEROS} != "no"
510274955Ssvnmir	cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
511274955Ssvnmir.endif
512274955Ssvnmir	cd ${.CURDIR}/libexec/rtld-elf; \
513274955Ssvnmir	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
514274955Ssvnmir	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
515274955Ssvnmir.endif
516274955Ssvnmir
517274955SsvnmirWMAKE_TGTS=
518274955Ssvnmir.if !defined(SUBDIR_OVERRIDE)
519274955SsvnmirWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
520274955Ssvnmir.endif
521274955SsvnmirWMAKE_TGTS+=	_cleanobj _obj _build-tools
522274955Ssvnmir.if !defined(SUBDIR_OVERRIDE)
523274955SsvnmirWMAKE_TGTS+=	_cross-tools
524274955Ssvnmir.endif
525274955SsvnmirWMAKE_TGTS+=	_includes _libraries _depend everything
526274955Ssvnmir.if defined(LIB32TMP) && ${MK_LIB32} != "no"
527274955SsvnmirWMAKE_TGTS+=	build32
528274955Ssvnmir.endif
529274955Ssvnmir
530274955Ssvnmirbuildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
531274955Ssvnmir.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
532274955Ssvnmir
533274955Ssvnmirbuildworld_prologue:
534280031Sdim	@echo "--------------------------------------------------------------"
535274955Ssvnmir	@echo ">>> World build started on `LC_ALL=C date`"
536274955Ssvnmir	@echo "--------------------------------------------------------------"
537274955Ssvnmir
538274955Ssvnmirbuildworld_epilogue:
539274955Ssvnmir	@echo
540274955Ssvnmir	@echo "--------------------------------------------------------------"
541274955Ssvnmir	@echo ">>> World build completed on `LC_ALL=C date`"
542274955Ssvnmir	@echo "--------------------------------------------------------------"
543274955Ssvnmir
544274955Ssvnmir#
545274955Ssvnmir# We need to have this as a target because the indirection between Makefile
546274955Ssvnmir# and Makefile.inc1 causes the correct PATH to be used, rather than a
547274955Ssvnmir# modification of the current environment's PATH.  In addition, we need
548274955Ssvnmir# to quote multiword values.
549274955Ssvnmir#
550274955Ssvnmirbuildenvvars:
551274955Ssvnmir	@echo ${WMAKEENV:Q}
552274955Ssvnmir
553274955Ssvnmirbuildenv:
554274955Ssvnmir	@echo Entering world for ${TARGET_ARCH}:${TARGET}
555274955Ssvnmir	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
556274955Ssvnmir
557274955SsvnmirTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
558274955Ssvnmirtoolchain: ${TOOLCHAIN_TGTS}
559274955Ssvnmirkernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
560274955Ssvnmir
561274955Ssvnmir#
562274955Ssvnmir# installcheck
563296417Sdim#
564274955Ssvnmir# Checks to be sure system is ready for installworld/installkernel.
565274955Ssvnmir#
566274955Ssvnmirinstallcheck:
567274955Ssvnmir
568288943Sdim#
569296417Sdim# Require DESTDIR to be set if installing for a different architecture.
570274955Ssvnmir#
571274955Ssvnmir.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
572274955Ssvnmir.if !make(distributeworld)
573274955Ssvnmirinstallcheck: installcheck_DESTDIR
574274955Ssvnmirinstallcheck_DESTDIR:
575274955Ssvnmir.if !defined(DESTDIR) || empty(DESTDIR)
576274955Ssvnmir	@echo "ERROR: Please set DESTDIR!"; \
577296417Sdim	false
578274955Ssvnmir.endif
579274955Ssvnmir.endif
580274955Ssvnmir.endif
581274955Ssvnmir
582274955Ssvnmir#
583274955Ssvnmir# Check for missing UIDs/GIDs.
584274955Ssvnmir#
585274955SsvnmirCHECK_UIDS=
586274955SsvnmirCHECK_GIDS=	audit
587274955Ssvnmir.if ${MK_SENDMAIL} != "no"
588CHECK_UIDS+=	smmsp
589CHECK_GIDS+=	smmsp
590.endif
591.if ${MK_PF} != "no"
592CHECK_UIDS+=	proxy
593CHECK_GIDS+=	proxy authpf
594.endif
595installcheck: installcheck_UGID
596installcheck_UGID:
597.for uid in ${CHECK_UIDS}
598	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
599		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
600		false; \
601	fi
602.endfor
603.for gid in ${CHECK_GIDS}
604	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
605		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
606		false; \
607	fi
608.endfor
609
610#
611# Required install tools to be saved in a scratch dir for safety.
612#
613.if ${MK_INFO} != "no"
614_install-info=	install-info
615.endif
616.if ${MK_ZONEINFO} != "no"
617_zoneinfo=	zic tzsetup
618.endif
619
620ITOOLS=	[ awk cap_mkdb cat chflags chmod chown \
621	date echo egrep find grep ${_install-info} \
622	ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
623	test true uname wc ${_zoneinfo}
624
625#
626# distributeworld
627#
628# Distributes everything compiled by a `buildworld'.
629#
630# installworld
631#
632# Installs everything compiled by a 'buildworld'.
633#
634distributeworld installworld: installcheck
635	mkdir -p ${INSTALLTMP}
636	progs=$$(for prog in ${ITOOLS}; do \
637		if progpath=`which $$prog`; then \
638			echo $$progpath; \
639		else \
640			echo "Required tool $$prog not found in PATH." >&2; \
641			exit 1; \
642		fi; \
643	    done); \
644	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
645	    while read line; do \
646		set -- $$line; \
647		if [ "$$2 $$3" != "not found" ]; then \
648			echo $$2; \
649		else \
650			echo "Required library $$1 not found." >&2; \
651			exit 1; \
652		fi; \
653	    done); \
654	cp $$libs $$progs ${INSTALLTMP}
655	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
656	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
657	    ${IMAKEENV} rm -rf ${INSTALLTMP}
658
659#
660# reinstall
661#
662# If you have a build server, you can NFS mount the source and obj directories
663# and do a 'make reinstall' on the *client* to install new binaries from the
664# most recent server build.
665#
666reinstall:
667	@echo "--------------------------------------------------------------"
668	@echo ">>> Making hierarchy"
669	@echo "--------------------------------------------------------------"
670	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
671	@echo
672	@echo "--------------------------------------------------------------"
673	@echo ">>> Installing everything"
674	@echo "--------------------------------------------------------------"
675	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
676.if defined(LIB32TMP) && ${MK_LIB32} != "no"
677	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
678.endif
679
680redistribute:
681	@echo "--------------------------------------------------------------"
682	@echo ">>> Distributing everything"
683	@echo "--------------------------------------------------------------"
684	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
685.if defined(LIB32TMP) && ${MK_LIB32} != "no"
686	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
687	    DISTRIBUTION=lib32
688.endif
689
690distrib-dirs distribution:
691	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
692
693#
694# buildkernel and installkernel
695#
696# Which kernels to build and/or install is specified by setting
697# KERNCONF. If not defined a GENERIC kernel is built/installed.
698# Only the existing (depending TARGET) config files are used
699# for building kernels and only the first of these is designated
700# as the one being installed.
701#
702# Note that we have to use TARGET instead of TARGET_ARCH when
703# we're in kernel-land. Since only TARGET_ARCH is (expected) to
704# be set to cross-build, we have to make sure TARGET is set
705# properly.
706
707.if defined(KERNFAST)
708NO_KERNELCLEAN=	t
709NO_KERNELCONFIG=	t
710NO_KERNELDEPEND=	t
711NO_KERNELOBJ=		t
712# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
713.if !defined(KERNCONF) && ${KERNFAST} != "1"
714KERNCONF=${KERNFAST}
715.endif
716.endif
717.if !defined(KERNCONF) && defined(KERNEL)
718KERNCONF=	${KERNEL}
719KERNWARN=
720.else
721.if ${TARGET_ARCH} == "powerpc64"
722KERNCONF?=	GENERIC64
723.else
724KERNCONF?=	GENERIC
725.endif
726.endif
727INSTKERNNAME?=	kernel
728
729KERNSRCDIR?=	${.CURDIR}/sys
730KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
731KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
732KERNCONFDIR?=	${KRNLCONFDIR}
733
734BUILDKERNELS=
735INSTALLKERNEL=
736.for _kernel in ${KERNCONF}
737.if exists(${KERNCONFDIR}/${_kernel})
738BUILDKERNELS+=	${_kernel}
739.if empty(INSTALLKERNEL)
740INSTALLKERNEL= ${_kernel}
741.endif
742.endif
743.endfor
744
745#
746# buildkernel
747#
748# Builds all kernels defined by BUILDKERNELS.
749#
750buildkernel:
751.if empty(BUILDKERNELS)
752	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
753	false
754.endif
755.if defined(KERNWARN)
756	@echo "--------------------------------------------------------------"
757	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
758	@echo "--------------------------------------------------------------"
759	@sleep 3
760.endif
761	@echo
762.for _kernel in ${BUILDKERNELS}
763	@echo "--------------------------------------------------------------"
764	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
765	@echo "--------------------------------------------------------------"
766	@echo "===> ${_kernel}"
767	mkdir -p ${KRNLOBJDIR}
768.if !defined(NO_KERNELCONFIG)
769	@echo
770	@echo "--------------------------------------------------------------"
771	@echo ">>> stage 1: configuring the kernel"
772	@echo "--------------------------------------------------------------"
773	cd ${KRNLCONFDIR}; \
774		PATH=${TMPPATH} \
775		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
776			${KERNCONFDIR}/${_kernel}
777.endif
778.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
779	@echo
780	@echo "--------------------------------------------------------------"
781	@echo ">>> stage 2.1: cleaning up the object tree"
782	@echo "--------------------------------------------------------------"
783	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
784.endif
785.if !defined(NO_KERNELOBJ)
786	@echo
787	@echo "--------------------------------------------------------------"
788	@echo ">>> stage 2.2: rebuilding the object tree"
789	@echo "--------------------------------------------------------------"
790	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
791.endif
792	@echo
793	@echo "--------------------------------------------------------------"
794	@echo ">>> stage 2.3: build tools"
795	@echo "--------------------------------------------------------------"
796	cd ${KRNLOBJDIR}/${_kernel}; \
797	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
798	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS \
799	    -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
800# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
801.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
802.for target in obj depend all
803	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
804	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
805	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
806.endfor
807.endif
808.if !defined(NO_KERNELDEPEND)
809	@echo
810	@echo "--------------------------------------------------------------"
811	@echo ">>> stage 3.1: making dependencies"
812	@echo "--------------------------------------------------------------"
813	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
814.endif
815	@echo
816	@echo "--------------------------------------------------------------"
817	@echo ">>> stage 3.2: building everything"
818	@echo "--------------------------------------------------------------"
819	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
820	@echo "--------------------------------------------------------------"
821	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
822	@echo "--------------------------------------------------------------"
823.endfor
824
825#
826# installkernel, etc.
827#
828# Install the kernel defined by INSTALLKERNEL
829#
830installkernel installkernel.debug \
831reinstallkernel reinstallkernel.debug: installcheck
832.if empty(INSTALLKERNEL)
833	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
834	false
835.endif
836	@echo "--------------------------------------------------------------"
837	@echo ">>> Installing kernel"
838	@echo "--------------------------------------------------------------"
839	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
840	    ${CROSSENV} PATH=${TMPPATH} \
841	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
842
843#
844# doxygen
845#
846# Build the API documentation with doxygen
847#
848doxygen:
849	@if [ ! -x `/usr/bin/which doxygen` ]; then \
850		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
851		exit 1; \
852	fi
853	cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
854
855#
856# update
857#
858# Update the source tree, by running cvsup and/or running cvs to update to the
859# latest copy.
860#
861update:
862.if defined(SUP_UPDATE)
863	@echo "--------------------------------------------------------------"
864	@echo ">>> Running ${SUP}"
865	@echo "--------------------------------------------------------------"
866.if defined(SUPFILE)
867	@${SUP} ${SUPFLAGS} ${SUPFILE}
868.endif
869.if defined(SUPFILE1)
870	@${SUP} ${SUPFLAGS} ${SUPFILE1}
871.endif
872.if defined(SUPFILE2)
873	@${SUP} ${SUPFLAGS} ${SUPFILE2}
874.endif
875.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
876	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
877.endif
878.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
879	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
880.endif
881.endif
882.if defined(CVS_UPDATE)
883	@cd ${.CURDIR} ; \
884	if [ -d CVS ] ; then \
885		echo "--------------------------------------------------------------" ; \
886		echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
887		echo "--------------------------------------------------------------" ; \
888		echo ${CVS} -R -q update ${CVSFLAGS} ; \
889		${CVS} -R -q update ${CVSFLAGS} ; \
890	fi
891.endif
892.if defined(SVN_UPDATE)
893	@cd ${.CURDIR} ; \
894	if [ -d .svn ] ; then \
895		echo "--------------------------------------------------------------" ; \
896		echo ">>> Updating ${.CURDIR} using Subversion" ; \
897		echo "--------------------------------------------------------------" ; \
898		echo ${SVN} update ${SVNFLAGS} ; \
899		${SVN} update ${SVNFLAGS} ; \
900	fi
901.endif
902
903#
904# ------------------------------------------------------------------------
905#
906# From here onwards are utility targets used by the 'make world' and
907# related targets.  If your 'world' breaks, you may like to try to fix
908# the problem and manually run the following targets to attempt to
909# complete the build.  Beware, this is *not* guaranteed to work, you
910# need to have a pretty good grip on the current state of the system
911# to attempt to manually finish it.  If in doubt, 'make world' again.
912#
913
914#
915# legacy: Build compatibility shims for the next three targets
916#
917legacy:
918.if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
919	@echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
920	false
921.endif
922.for _tool in tools/build
923	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
924	    cd ${.CURDIR}/${_tool}; \
925	    ${MAKE} DIRPRFX=${_tool}/ obj; \
926	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
927	    ${MAKE} DIRPRFX=${_tool}/ depend; \
928	    ${MAKE} DIRPRFX=${_tool}/ all; \
929	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
930.endfor
931
932#
933# bootstrap-tools: Build tools needed for compatibility
934#
935.if ${MK_GAMES} != "no"
936_strfile=	games/fortune/strfile
937.endif
938
939.if ${MK_CXX} != "no"
940_gperf=		gnu/usr.bin/gperf
941.if ${BOOTSTRAPPING} < 700004
942_groff=		gnu/usr.bin/groff
943.else
944_groff=		gnu/usr.bin/groff/tmac
945.endif
946.endif
947
948.if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
949_ar=		usr.bin/ar
950.endif
951
952.if ${BOOTSTRAPPING} < 800013
953_mklocale=	usr.bin/mklocale
954.endif
955
956.if ${BOOTSTRAPPING} < 900002
957_sed=		usr.bin/sed
958.endif
959
960.if ${BOOTSTRAPPING} < 900006
961_lex=		usr.bin/lex
962_yacc=		usr.bin/yacc
963.endif
964
965.if ${BOOTSTRAPPING} < 700018
966_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
967.endif
968
969.if ${MK_RESCUE} != "no" && \
970    ${BOOTSTRAPPING} < 700026
971_crunchgen=	usr.sbin/crunch/crunchgen
972.endif
973
974# XXX: There is no way to specify bootstrap tools depending on MK-flags
975# with different per-architecture default values. Always build tblgen.
976_clang_tblgen= \
977	lib/clang/libllvmsupport \
978	lib/clang/libllvmsystem \
979	usr.bin/clang/tblgen
980
981.if ${MK_CDDL} != "no"
982_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
983    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
984.endif
985
986.if ${MK_FDT} != "no"
987_dtc= gnu/usr.bin/dtc
988.endif
989
990bootstrap-tools:
991.for _tool in \
992    ${_clang_tblgen} \
993    ${_dtrace_tools} \
994    ${_strfile} \
995    ${_gperf} \
996    ${_groff} \
997    ${_ar} \
998    ${_dtc} \
999    usr.bin/lorder \
1000    usr.bin/makewhatis \
1001    ${_mklocale} \
1002    usr.bin/rpcgen \
1003    ${_sed} \
1004    ${_lex} \
1005    ${_yacc} \
1006    usr.bin/xinstall \
1007    ${_gensnmptree} \
1008    usr.sbin/config \
1009    ${_crunchgen}
1010	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1011		cd ${.CURDIR}/${_tool}; \
1012		${MAKE} DIRPRFX=${_tool}/ obj; \
1013		${MAKE} DIRPRFX=${_tool}/ depend; \
1014		${MAKE} DIRPRFX=${_tool}/ all; \
1015		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1016.endfor
1017
1018#
1019# build-tools: Build special purpose build tools
1020#
1021.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1022_aicasm= sys/modules/aic7xxx/aicasm
1023.endif
1024
1025.if !defined(NO_SHARE)
1026_share=	share/syscons/scrnmaps
1027.endif
1028
1029.if ${MK_KERBEROS} != "no"
1030_kerberos5_tools= kerberos5/tools
1031.endif
1032
1033.if ${MK_RESCUE} != "no"
1034_rescue= rescue/rescue
1035.endif
1036
1037build-tools:
1038.for _tool in \
1039    bin/csh \
1040    bin/sh \
1041    ${_rescue} \
1042    lib/ncurses/ncurses \
1043    lib/ncurses/ncursesw \
1044    ${_share} \
1045    ${_aicasm} \
1046    usr.bin/awk \
1047    lib/libmagic \
1048    usr.sbin/sysinstall
1049	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1050		cd ${.CURDIR}/${_tool}; \
1051		${MAKE} DIRPRFX=${_tool}/ obj; \
1052		${MAKE} DIRPRFX=${_tool}/ build-tools
1053.endfor
1054.for _tool in \
1055    gnu/usr.bin/cc/cc_tools \
1056    ${_kerberos5_tools}
1057	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1058		cd ${.CURDIR}/${_tool}; \
1059		${MAKE} DIRPRFX=${_tool}/ obj; \
1060		${MAKE} DIRPRFX=${_tool}/ depend; \
1061		${MAKE} DIRPRFX=${_tool}/ all
1062.endfor
1063
1064#
1065# cross-tools: Build cross-building tools
1066#
1067.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1068.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1069_btxld=		usr.sbin/btxld
1070.endif
1071.endif
1072.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1073.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1074_crunchide=	usr.sbin/crunch/crunchide
1075.endif
1076.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1077_kgzip=		usr.sbin/kgzip
1078.endif
1079.endif
1080
1081cross-tools:
1082.for _tool in \
1083    gnu/usr.bin/binutils \
1084    gnu/usr.bin/cc \
1085    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1086    ${_btxld} \
1087    ${_crunchide} \
1088    ${_kgzip}
1089	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1090		cd ${.CURDIR}/${_tool}; \
1091		${MAKE} DIRPRFX=${_tool}/ obj; \
1092		${MAKE} DIRPRFX=${_tool}/ depend; \
1093		${MAKE} DIRPRFX=${_tool}/ all; \
1094		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1095.endfor
1096
1097#
1098# hierarchy - ensure that all the needed directories are present
1099#
1100hierarchy:
1101	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
1102
1103#
1104# libraries - build all libraries, and install them under ${DESTDIR}.
1105#
1106# The list of libraries with dependents (${_prebuild_libs}) and their
1107# interdependencies (__L) are built automatically by the
1108# ${.CURDIR}/tools/make_libdeps.sh script.
1109#
1110libraries:
1111	cd ${.CURDIR}; \
1112	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1113	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1114	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1115	    ${MAKE} -f Makefile.inc1 _generic_libs;
1116
1117#
1118# static libgcc.a prerequisite for shared libc
1119#
1120_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1121
1122# These dependencies are not automatically generated:
1123#
1124# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1125# all shared libraries for ELF.
1126#
1127_startup_libs=	gnu/lib/csu
1128.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1129_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
1130.elif exists(${.CURDIR}/lib/csu/${MACHINE_CPUARCH}-elf)
1131_startup_libs+=	lib/csu/${MACHINE_CPUARCH}-elf
1132.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1133_startup_libs+=	lib/csu/${MACHINE_ARCH}
1134.else
1135_startup_libs+=	lib/csu/${MACHINE_CPUARCH}
1136.endif
1137_startup_libs+=	gnu/lib/libgcc
1138_startup_libs+=	lib/libc
1139
1140gnu/lib/libgcc__L: lib/libc__L
1141
1142_prebuild_libs=	${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1143		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1144		${_kerberos5_lib_libroken} \
1145		lib/libbz2 lib/libcom_err lib/libcrypt lib/libelf \
1146		lib/libexpat lib/libfetch \
1147		${_lib_libgssapi} ${_lib_libipx} \
1148		lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1149		lib/ncurses/ncurses lib/ncurses/ncursesw \
1150		lib/libopie lib/libpam ${_lib_libthr} \
1151		lib/libradius lib/libsbuf lib/libtacplus \
1152		lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1153		${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1154		${_secure_lib_libssl}
1155
1156.if ${MK_LIBTHR} != "no"
1157_lib_libthr=	lib/libthr
1158.endif
1159
1160_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1161
1162lib/libopie__L lib/libtacplus__L: lib/libmd__L
1163
1164.if ${MK_CDDL} != "no"
1165_cddl_lib= cddl/lib
1166.endif
1167
1168.if ${MK_CRYPT} != "no"
1169.if ${MK_OPENSSL} != "no"
1170_secure_lib_libcrypto= secure/lib/libcrypto
1171_secure_lib_libssl= secure/lib/libssl
1172lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1173lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L
1174.if ${MK_OPENSSH} != "no"
1175_secure_lib_libssh= secure/lib/libssh
1176secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1177.if ${MK_KERBEROS_SUPPORT} != "no"
1178secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1179    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1180    lib/libmd__L kerberos5/lib/libroken__L
1181.endif
1182.endif
1183.endif
1184_secure_lib=	secure/lib
1185.endif
1186
1187.if ${MK_GSSAPI} != "no"
1188_lib_libgssapi=	lib/libgssapi
1189.endif
1190
1191.if ${MK_IPX} != "no"
1192_lib_libipx=	lib/libipx
1193.endif
1194
1195.if ${MK_KERBEROS} != "no"
1196_kerberos5_lib=	kerberos5/lib
1197_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1198_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1199_kerberos5_lib_libhx509= kerberos5/lib/libhx509
1200_kerberos5_lib_libroken= kerberos5/lib/libroken
1201_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1202.endif
1203
1204.if ${MK_NIS} != "no"
1205_lib_libypclnt=	lib/libypclnt
1206.endif
1207
1208.if ${MK_OPENSSL} == "no"
1209lib/libfetch__L lib/libradius__L: lib/libmd__L
1210.endif
1211
1212.for _lib in ${_prereq_libs}
1213${_lib}__PL: .PHONY
1214.if exists(${.CURDIR}/${_lib})
1215	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1216		cd ${.CURDIR}/${_lib}; \
1217		${MAKE} DIRPRFX=${_lib}/ obj; \
1218		${MAKE} DIRPRFX=${_lib}/ depend; \
1219		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1220		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1221.endif
1222.endfor
1223
1224.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1225${_lib}__L: .PHONY
1226.if exists(${.CURDIR}/${_lib})
1227	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1228		cd ${.CURDIR}/${_lib}; \
1229		${MAKE} DIRPRFX=${_lib}/ obj; \
1230		${MAKE} DIRPRFX=${_lib}/ depend; \
1231		${MAKE} DIRPRFX=${_lib}/ all; \
1232		${MAKE} DIRPRFX=${_lib}/ install
1233.endif
1234.endfor
1235
1236# libpam is special: we need to build static PAM modules before
1237# static PAM library, and dynamic PAM library before dynamic PAM
1238# modules.
1239lib/libpam__L: .PHONY
1240	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1241		cd ${.CURDIR}/lib/libpam; \
1242		${MAKE} DIRPRFX=lib/libpam/ obj; \
1243		${MAKE} DIRPRFX=lib/libpam/ depend; \
1244		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1245		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1246
1247_prereq_libs: ${_prereq_libs:S/$/__PL/}
1248_startup_libs: ${_startup_libs:S/$/__L/}
1249_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1250_generic_libs: ${_generic_libs:S/$/__L/}
1251
1252.for __target in all clean cleandepend cleandir depend includes obj
1253.for entry in ${SUBDIR}
1254${entry}.${__target}__D: .PHONY
1255	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1256		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1257		edir=${entry}.${MACHINE_ARCH}; \
1258		cd ${.CURDIR}/$${edir}; \
1259	else \
1260		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1261		edir=${entry}; \
1262		cd ${.CURDIR}/$${edir}; \
1263	fi; \
1264	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1265.endfor
1266par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1267.endfor
1268
1269.include <bsd.subdir.mk>
1270
1271.if make(check-old) || make(check-old-dirs) || \
1272    make(check-old-files) || make(check-old-libs) || \
1273    make(delete-old) || make(delete-old-dirs) || \
1274    make(delete-old-files) || make(delete-old-libs)
1275
1276#
1277# check for / delete old files section
1278#
1279
1280.include "ObsoleteFiles.inc"
1281
1282OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1283else you can not start such an application. Consult UPDATING for more \
1284information regarding how to cope with the removal/revision bump of a \
1285specific library."
1286
1287.if !defined(BATCH_DELETE_OLD_FILES)
1288RM_I=-i
1289.else
1290RM_I=-v
1291.endif
1292
1293delete-old-files:
1294	@echo ">>> Removing old files (only deletes safe to delete libs)"
1295# Ask for every old file if the user really wants to remove it.
1296# It's annoying, but better safe than sorry.
1297	@for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \
1298		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1299			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1300			rm ${RM_I} "${DESTDIR}/$${file}"; \
1301		fi; \
1302	done
1303# Remove catpages without corresponding manpages.
1304	@exec 3<&0; \
1305	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1306	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1307	while read catpage; do \
1308		read manpage; \
1309		if [ ! -e "$${manpage}" ]; then \
1310			rm ${RM_I} $${catpage} <&3 ; \
1311	        fi; \
1312	done
1313	@echo ">>> Old files removed"
1314
1315check-old-files:
1316	@echo ">>> Checking for old files"
1317	@for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \
1318		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1319		 	echo "${DESTDIR}/$${file}"; \
1320		fi; \
1321	done
1322# Check for catpages without corresponding manpages.
1323	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1324	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1325	while read catpage; do \
1326		read manpage; \
1327		if [ ! -e "$${manpage}" ]; then \
1328			echo $${catpage} ; \
1329	        fi; \
1330	done
1331
1332delete-old-libs:
1333	@echo ">>> Removing old libraries"
1334	@echo "${OLD_LIBS_MESSAGE}" | fmt
1335	@for file in ${OLD_LIBS}; do \
1336		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1337			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1338			rm ${RM_I} "${DESTDIR}/$${file}"; \
1339		fi; \
1340	done
1341	@echo ">>> Old libraries removed"
1342
1343check-old-libs:
1344	@echo ">>> Checking for old libraries"
1345	@for file in ${OLD_LIBS}; do \
1346		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1347			echo "${DESTDIR}/$${file}"; \
1348		fi; \
1349	done
1350
1351delete-old-dirs:
1352	@echo ">>> Removing old directories"
1353	@for dir in ${OLD_DIRS}; do \
1354		if [ -d "${DESTDIR}/$${dir}" ]; then \
1355			rmdir -v "${DESTDIR}/$${dir}" || true; \
1356		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1357			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1358		fi; \
1359	done
1360	@echo ">>> Old directories removed"
1361
1362check-old-dirs:
1363	@echo ">>> Checking for old directories"
1364	@for dir in ${OLD_DIRS}; do \
1365		if [ -d "${DESTDIR}/$${dir}" ]; then \
1366			echo "${DESTDIR}/$${dir}"; \
1367		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1368			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1369		fi; \
1370	done
1371
1372delete-old: delete-old-files delete-old-dirs
1373	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1374
1375check-old: check-old-files check-old-libs check-old-dirs
1376	@echo "To remove old files and directories run '${MAKE} delete-old'."
1377	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1378
1379.endif
1380
1381#
1382# showconfig - show build configuration.
1383#
1384showconfig:
1385	@${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1386
1387
1388###############
1389
1390.if defined(XDEV) && defined(XDEV_ARCH)
1391
1392NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1393	-DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1394	-DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1395
1396XDDIR=${XDEV}-freebsd
1397XDTP=/usr/${XDDIR}
1398CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1399	TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1400CDENV= ${CDBENV} \
1401	_SHLIBDIRPREFIX=${XDTP} \
1402	TOOLS_PREFIX=${XDTP}
1403CD2ENV=${CDENV} \
1404	MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1405
1406CDTMP=	${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1407CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1408CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1409XDDESTDIR=${DESTDIR}${XDTP}
1410.if !defined(OSREL)
1411OSREL!= uname -r | sed -e 's/[-(].*//'
1412.endif
1413
1414.ORDER: xdev-build xdev-install
1415xdev: xdev-build xdev-install
1416
1417.ORDER: _xb-build-tools _xb-cross-tools
1418xdev-build: _xb-build-tools _xb-cross-tools
1419
1420_xb-build-tools:
1421	${_+_}cd ${.CURDIR}; \
1422	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1423
1424_xb-cross-tools:
1425.for _tool in \
1426    gnu/usr.bin/binutils \
1427    gnu/usr.bin/cc
1428	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1429	cd ${.CURDIR}/${_tool}; \
1430	${CDMAKE} DIRPRFX=${_tool}/ obj; \
1431	${CDMAKE} DIRPRFX=${_tool}/ depend; \
1432	${CDMAKE} DIRPRFX=${_tool}/ all
1433.endfor
1434
1435_xi-mtree:
1436	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1437	mkdir -p ${XDDESTDIR}
1438	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1439	    -p ${XDDESTDIR} >/dev/null
1440	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1441	    -p ${XDDESTDIR}/usr >/dev/null
1442	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1443	    -p ${XDDESTDIR}/usr/include >/dev/null
1444
1445.ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1446xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1447
1448_xi-cross-tools:
1449	@echo "_xi-cross-tools"
1450.for _tool in \
1451    gnu/usr.bin/binutils \
1452    gnu/usr.bin/cc
1453	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1454	cd ${.CURDIR}/${_tool}; \
1455	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1456.endfor
1457
1458_xi-includes:
1459	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1460		DESTDIR=${XDDESTDIR}
1461
1462_xi-libraries:
1463	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1464		DESTDIR=${XDDESTDIR}
1465
1466_xi-links:
1467	${_+_}cd ${XDDESTDIR}/usr/bin; \
1468		for i in *; do \
1469			ln -sf ../../${XDTP}/usr/bin/$$i \
1470			    ../../../../usr/bin/${XDDIR}-$$i; \
1471			ln -sf ../../${XDTP}/usr/bin/$$i \
1472			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1473		done
1474.endif
1475
1476.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1477DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1478
1479.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1480.if exists(${KERNCONFDIR}/${KERNCONF})
1481FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1482	${KERNCONFDIR}/${KERNCONF}
1483.endif
1484.endif
1485
1486.endif
1487
1488.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1489DTBOUTPUTPATH= ${.CURDIR}
1490.endif
1491
1492#
1493# Build 'standalone' Device Tree Blob
1494#
1495builddtb:
1496	@if [ "${FDT_DTS_FILE}" = "" ]; then \
1497		echo "ERROR: FDT_DTS_FILE must be specified!"; \
1498		exit 1; \
1499	fi;	\
1500	if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1501		echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1502			exist!"; \
1503		exit 1;	\
1504	fi;	\
1505	if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then	\
1506		echo "WARNING: DTB will be placed in the current working \
1507			directory"; \
1508	fi
1509	@PATH=${TMPPATH} \
1510	dtc -O dtb -o \
1511	    ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1512	    -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1513