Makefile.inc1 revision 241312
1177595Sweongyo#
2177595Sweongyo# $FreeBSD: head/Makefile.inc1 241312 2012-10-07 17:48:38Z marcel $
3177595Sweongyo#
4177595Sweongyo# Make command line options:
5177595Sweongyo#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6177595Sweongyo#	-DNO_CLEAN do not clean at all
7177595Sweongyo#	-DNO_SHARE do not go into share subdir
8177595Sweongyo#	-DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
9177595Sweongyo#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10177595Sweongyo#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11177595Sweongyo#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12177595Sweongyo#	-DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13177595Sweongyo#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
14177595Sweongyo#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
15177595Sweongyo#	-DNO_WWWUPDATE do not update www in ${MAKE} update
16177595Sweongyo#	-DNO_CTF do not run the DTrace CTF conversion tools on built objects
17177595Sweongyo#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
18177595Sweongyo#	LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
19177595Sweongyo#	LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
20177595Sweongyo#	    list
21177595Sweongyo#	TARGET="machine" to crossbuild world for a different machine type
22177595Sweongyo#	TARGET_ARCH= may be required when a TARGET supports multiple endians
23177595Sweongyo#	BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
24177595Sweongyo
25177595Sweongyo#
26177595Sweongyo# The intended user-driven targets are:
27177595Sweongyo# buildworld  - rebuild *everything*, including glue to help do upgrades
28177595Sweongyo# installworld- install everything built by "buildworld"
29177595Sweongyo# doxygen     - build API documentation of the kernel
30177595Sweongyo# update      - convenient way to update your source tree (eg: cvsup/cvs)
31177595Sweongyo#
32177595Sweongyo# Standard targets (not defined here) are documented in the makefiles in
33177595Sweongyo# /usr/share/mk.  These include:
34177595Sweongyo#		obj depend all install clean cleandepend cleanobj
35177595Sweongyo
36177595Sweongyo# You are supposed to define both of these when calling Makefile.inc1
37177595Sweongyo# directly.  However, some old scripts don't.  Cope for the moment, but
38177595Sweongyo# issue a new warning for a transition period.
39177595Sweongyo.if defined(TARGET) && !defined(TARGET_ARCH)
40177595Sweongyo.warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1.  Setting TARGET_ARCH=${TARGET}."
41177595SweongyoTARGET_ARCH=${TARGET}
42177595Sweongyo.endif
43177595Sweongyo.if !defined(TARGET) || !defined(TARGET_ARCH)
44177595Sweongyo.error "Both TARGET and TARGET_ARCH must be defined."
45177595Sweongyo.endif
46177595Sweongyo
47177595Sweongyo.include <bsd.own.mk>
48177595Sweongyo.include <bsd.arch.inc.mk>
49177595Sweongyo.include <bsd.compiler.mk>
50177595Sweongyo
51177595Sweongyo# We must do share/info early so that installation of info `dir'
52177595Sweongyo# entries works correctly.  Do it first since it is less likely to
53177595Sweongyo# grow dependencies on include and lib than vice versa.
54177595Sweongyo#
55177595Sweongyo# We must do lib/ and libexec/ before bin/, because if installworld
56177595Sweongyo# installs a new /bin/sh, the 'make' command will *immediately*
57177595Sweongyo# use that new version.  And the new (dynamically-linked) /bin/sh
58177595Sweongyo# will expect to find appropriate libraries in /lib and /libexec.
59177595Sweongyo#
60177595SweongyoSUBDIR=	share/info lib libexec
61177595SweongyoSUBDIR+=bin
62177595Sweongyo.if ${MK_GAMES} != "no"
63177595SweongyoSUBDIR+=games
64177595Sweongyo.endif
65177595Sweongyo.if ${MK_CDDL} != "no"
66177595SweongyoSUBDIR+=cddl
67177595Sweongyo.endif
68177595SweongyoSUBDIR+=gnu include
69177595Sweongyo.if ${MK_KERBEROS} != "no"
70177595SweongyoSUBDIR+=kerberos5
71177595Sweongyo.endif
72177595Sweongyo.if ${MK_RESCUE} != "no"
73177595SweongyoSUBDIR+=rescue
74177595Sweongyo.endif
75177595SweongyoSUBDIR+=sbin
76177595Sweongyo.if ${MK_CRYPT} != "no"
77177595SweongyoSUBDIR+=secure
78177595Sweongyo.endif
79177595Sweongyo.if !defined(NO_SHARE)
80177595SweongyoSUBDIR+=share
81177595Sweongyo.endif
82177595SweongyoSUBDIR+=sys usr.bin usr.sbin
83177595Sweongyo.if ${MK_OFED} != "no"
84177595SweongyoSUBDIR+=contrib/ofed
85177595Sweongyo.endif
86177595Sweongyo#
87177595Sweongyo# We must do etc/ last for install/distribute to work.
88177595Sweongyo#
89177595SweongyoSUBDIR+=etc
90177595Sweongyo
91177595Sweongyo# These are last, since it is nice to at least get the base system
92177595Sweongyo# rebuilt before you do them.
93177595Sweongyo.for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS}
94177595Sweongyo.if exists(${.CURDIR}/${_DIR}/Makefile)
95177595SweongyoSUBDIR+= ${_DIR}
96177595Sweongyo.endif
97177595Sweongyo.endfor
98177595Sweongyo
99177595Sweongyo.if defined(SUBDIR_OVERRIDE)
100177595SweongyoSUBDIR=		${SUBDIR_OVERRIDE}
101177595Sweongyo.endif
102177595Sweongyo
103177595Sweongyo.if defined(NOCLEAN)
104177595SweongyoNO_CLEAN=	${NOCLEAN}
105177595Sweongyo.endif
106177595Sweongyo.if defined(NO_CLEANDIR)
107177595SweongyoCLEANDIR=	clean cleandepend
108177595Sweongyo.else
109177595SweongyoCLEANDIR=	cleandir
110177595Sweongyo.endif
111177595Sweongyo
112177595SweongyoLOCAL_TOOL_DIRS?=
113177595Sweongyo
114177595SweongyoBUILDENV_SHELL?=/bin/sh
115177595Sweongyo
116177595SweongyoCVS?=		cvs
117177595SweongyoCVSFLAGS?=	-A -P -d -I!
118177595SweongyoSVN?=		svn
119177595SweongyoSVNFLAGS?=	-r HEAD
120177595SweongyoSUP?=		/usr/bin/csup
121177595SweongyoSUPFLAGS?=	-g -L 2
122177595Sweongyo.if defined(SUPHOST)
123177595SweongyoSUPFLAGS+=	-h ${SUPHOST}
124177595Sweongyo.endif
125177595Sweongyo
126177595SweongyoMAKEOBJDIRPREFIX?=	/usr/obj
127177595Sweongyo.if !defined(OSRELDATE)
128177595Sweongyo.if exists(/usr/include/osreldate.h)
129177595SweongyoOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
130177595Sweongyo		/usr/include/osreldate.h
131177595Sweongyo.else
132177595SweongyoOSRELDATE=	0
133177595Sweongyo.endif
134177595Sweongyo.endif
135177595Sweongyo
136177595Sweongyo.if !defined(VERSION)
137177595SweongyoVERSION!=	uname -srp
138177595SweongyoVERSION+=	${OSRELDATE}
139177595Sweongyo.endif
140177595Sweongyo
141177595SweongyoKNOWN_ARCHES?=	amd64 arm armeb/arm armv6/arm armv6eb/arm i386 i386/pc98 ia64 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
142177595Sweongyo.if ${TARGET} == ${TARGET_ARCH}
143177595Sweongyo_t=		${TARGET}
144177595Sweongyo.else
145177595Sweongyo_t=		${TARGET_ARCH}/${TARGET}
146177595Sweongyo.endif
147177595Sweongyo.for _t in ${_t}
148177595Sweongyo.if empty(KNOWN_ARCHES:M${_t})
149177595Sweongyo.error Unknown target ${TARGET_ARCH}:${TARGET}.
150177595Sweongyo.endif
151177595Sweongyo.endfor
152177595Sweongyo
153177595Sweongyo.if ${TARGET} == ${MACHINE}
154177595SweongyoTARGET_CPUTYPE?=${CPUTYPE}
155177595Sweongyo.else
156177595SweongyoTARGET_CPUTYPE?=
157177595Sweongyo.endif
158177595Sweongyo
159177595Sweongyo.if !empty(TARGET_CPUTYPE)
160177595Sweongyo_TARGET_CPUTYPE=${TARGET_CPUTYPE}
161177595Sweongyo.else
162177595Sweongyo_TARGET_CPUTYPE=dummy
163177595Sweongyo.endif
164177595Sweongyo_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
165177595Sweongyo		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
166177595Sweongyo.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
167177595Sweongyo.error CPUTYPE global should be set with ?=.
168177595Sweongyo.endif
169177595Sweongyo.if make(buildworld)
170177595SweongyoBUILD_ARCH!=	uname -p
171177595Sweongyo.if ${MACHINE_ARCH} != ${BUILD_ARCH}
172177595Sweongyo.error To cross-build, set TARGET_ARCH.
173177595Sweongyo.endif
174177595Sweongyo.endif
175177595Sweongyo.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
176177595SweongyoOBJTREE=	${MAKEOBJDIRPREFIX}
177177595Sweongyo.else
178177595SweongyoOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
179177595Sweongyo.endif
180177595SweongyoWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
181177595Sweongyo# /usr/games added for fortune which depend on strfile
182177595SweongyoBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
183177595SweongyoXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
184177595SweongyoSTRICTTMPPATH=	${BPATH}:${XPATH}
185177595SweongyoTMPPATH=	${STRICTTMPPATH}:${PATH}
186177595Sweongyo
187177595Sweongyo#
188177595Sweongyo# Avoid running mktemp(1) unless actually needed.
189177595Sweongyo# It may not be functional, e.g., due to new ABI
190177595Sweongyo# when in the middle of installing over this system.
191177595Sweongyo#
192177595Sweongyo.if make(distributeworld) || make(installworld)
193177595SweongyoINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
194177595Sweongyo.endif
195177595Sweongyo
196177595Sweongyo#
197177595Sweongyo# Building a world goes through the following stages
198177595Sweongyo#
199177595Sweongyo# 1. legacy stage [BMAKE]
200177595Sweongyo#	This stage is responsible for creating compatibility
201177595Sweongyo#	shims that are needed by the bootstrap-tools,
202177595Sweongyo#	build-tools and cross-tools stages.
203177595Sweongyo# 1. bootstrap-tools stage [BMAKE]
204177595Sweongyo#	This stage is responsible for creating programs that
205177595Sweongyo#	are needed for backward compatibility reasons. They
206177595Sweongyo#	are not built as cross-tools.
207177595Sweongyo# 2. build-tools stage [TMAKE]
208177595Sweongyo#	This stage is responsible for creating the object
209177595Sweongyo#	tree and building any tools that are needed during
210177595Sweongyo#	the build process.
211177595Sweongyo# 3. cross-tools stage [XMAKE]
212177595Sweongyo#	This stage is responsible for creating any tools that
213177595Sweongyo#	are needed for cross-builds. A cross-compiler is one
214177595Sweongyo#	of them.
215177595Sweongyo# 4. world stage [WMAKE]
216177595Sweongyo#	This stage actually builds the world.
217177595Sweongyo# 5. install stage (optional) [IMAKE]
218177595Sweongyo#	This stage installs a previously built world.
219177595Sweongyo#
220177595Sweongyo
221177595SweongyoBOOTSTRAPPING?=	0
222177595Sweongyo
223177595Sweongyo# Common environment for world related stages
224177595SweongyoCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
225177595Sweongyo		MACHINE_ARCH=${TARGET_ARCH} \
226177595Sweongyo		MACHINE=${TARGET} \
227177595Sweongyo		CPUTYPE=${TARGET_CPUTYPE}
228177595Sweongyo.if ${MK_GROFF} != "no"
229177595SweongyoCROSSENV+=	GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
230177595Sweongyo		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
231177595Sweongyo		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
232177595Sweongyo.endif
233177595Sweongyo
234177595Sweongyo# bootstrap-tools stage
235177595SweongyoBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
236177595Sweongyo		PATH=${BPATH}:${PATH} \
237177595Sweongyo		WORLDTMP=${WORLDTMP} \
238177595Sweongyo		VERSION="${VERSION}" \
239177595Sweongyo		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
240177595Sweongyo		COMPILER_TYPE=${COMPILER_TYPE}
241177595SweongyoBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
242177595Sweongyo		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
243177595Sweongyo		DESTDIR= \
244177595Sweongyo		BOOTSTRAPPING=${OSRELDATE} \
245177595Sweongyo		SSP_CFLAGS= \
246177595Sweongyo		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
247177595Sweongyo		-DNO_PIC -DNO_PROFILE -DNO_SHARED \
248177595Sweongyo		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
249177595Sweongyo
250177595Sweongyo# build-tools stage
251177595SweongyoTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
252177595Sweongyo		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
253177595Sweongyo		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
254177595Sweongyo		DESTDIR= \
255177595Sweongyo		BOOTSTRAPPING=${OSRELDATE} \
256177595Sweongyo		SSP_CFLAGS= \
257177595Sweongyo		-DNO_LINT \
258177595Sweongyo		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
259177595Sweongyo
260177595Sweongyo# cross-tools stage
261177595SweongyoXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
262177595Sweongyo		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
263177595Sweongyo		-DWITHOUT_GDB
264177595Sweongyo
265177595Sweongyo# world stage
266177595SweongyoWMAKEENV=	${CROSSENV} \
267177595Sweongyo		_SHLIBDIRPREFIX=${WORLDTMP} \
268177595Sweongyo		_LDSCRIPTROOT= \
269177595Sweongyo		VERSION="${VERSION}" \
270177595Sweongyo		INSTALL="sh ${.CURDIR}/tools/install.sh" \
271177595Sweongyo		PATH=${TMPPATH}
272177595Sweongyo.if ${MK_CDDL} == "no"
273177595SweongyoWMAKEENV+=	NO_CTF=1
274177595Sweongyo.endif
275177595Sweongyo.if ${CC:T:Mgcc} == "gcc"
276177595SweongyoWMAKE_COMPILER_TYPE=	gcc
277177595Sweongyo.elif ${CC:T:Mclang} == "clang"
278177595SweongyoWMAKE_COMPILER_TYPE=	clang
279177595Sweongyo.elif ${MK_CLANG_IS_CC} == "no"
280177595SweongyoWMAKE_COMPILER_TYPE=	gcc
281177595Sweongyo.else
282177595SweongyoWMAKE_COMPILER_TYPE=	clang
283177595Sweongyo.endif
284177595SweongyoWMAKEENV+=	COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
285177595SweongyoWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
286177595Sweongyo
287177595Sweongyo.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
288177595Sweongyo# 32 bit world
289177595SweongyoLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
290177595Sweongyo
291177595Sweongyo.if ${TARGET_ARCH} == "amd64"
292177595Sweongyo.if empty(TARGET_CPUTYPE)
293177595SweongyoLIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
294177595Sweongyo.else
295177595SweongyoLIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
296177595Sweongyo.endif
297177595SweongyoLIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
298177595Sweongyo		MACHINE_CPU="i686 mmx sse sse2"
299177595SweongyoLIB32WMAKEFLAGS=	\
300177595Sweongyo		AS="${AS} --32" \
301177595Sweongyo		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
302177595Sweongyo
303177595Sweongyo.elif ${TARGET_ARCH} == "powerpc64"
304177595Sweongyo.if empty(TARGET_CPUTYPE)
305177595SweongyoLIB32CPUFLAGS=	-mcpu=powerpc
306177595Sweongyo.else
307177595SweongyoLIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
308177595Sweongyo.endif
309177595SweongyoLIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
310177595SweongyoLIB32WMAKEFLAGS=	\
311177595Sweongyo		LD="${LD} -m elf32ppc_fbsd"
312177595Sweongyo.endif
313177595Sweongyo
314177595Sweongyo
315177595SweongyoLIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
316177595Sweongyo		-isystem ${LIB32TMP}/usr/include/ \
317177595Sweongyo		-L${LIB32TMP}/usr/lib32 \
318177595Sweongyo		-B${LIB32TMP}/usr/lib32
319177595Sweongyo
320177595Sweongyo# Yes, the flags are redundant.
321177595SweongyoLIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
322177595Sweongyo		_SHLIBDIRPREFIX=${LIB32TMP} \
323177595Sweongyo		_LDSCRIPTROOT=${LIB32TMP} \
324177595Sweongyo		VERSION="${VERSION}" \
325177595Sweongyo		INSTALL="sh ${.CURDIR}/tools/install.sh" \
326177595Sweongyo		PATH=${TMPPATH} \
327177595Sweongyo		LIBDIR=/usr/lib32 \
328177595Sweongyo		SHLIBDIR=/usr/lib32 \
329177595Sweongyo		COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
330177595SweongyoLIB32WMAKEFLAGS+=	\
331177595Sweongyo		CC="${CC} ${LIB32FLAGS}" \
332177595Sweongyo		CXX="${CXX} ${LIB32FLAGS}" \
333177595Sweongyo		DESTDIR=${LIB32TMP} \
334177595Sweongyo		-DCOMPAT_32BIT \
335177595Sweongyo		-DNO_CPU_CFLAGS \
336177595Sweongyo		-DNO_CTF \
337177595Sweongyo		-DNO_LINT
338177595Sweongyo
339177595SweongyoLIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
340177595Sweongyo		-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
341177595SweongyoLIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS
342177595Sweongyo.endif
343177595Sweongyo
344177595Sweongyo# install stage
345177595SweongyoIMAKEENV=	${CROSSENV:N_LDSCRIPTROOT=*}
346177595SweongyoIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
347177595Sweongyo.if empty(.MAKEFLAGS:M-n)
348177595SweongyoIMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
349177595Sweongyo		LD_LIBRARY_PATH=${INSTALLTMP} \
350177595Sweongyo		PATH_LOCALE=${INSTALLTMP}/locale
351177595SweongyoIMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
352177595Sweongyo.else
353177595SweongyoIMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
354177595Sweongyo.endif
355177595Sweongyo
356177595Sweongyo# kernel stage
357177595SweongyoKMAKEENV=	${WMAKEENV}
358177595SweongyoKMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
359177595Sweongyo
360177595Sweongyo#
361177595Sweongyo# buildworld
362177595Sweongyo#
363177595Sweongyo# Attempt to rebuild the entire system, with reasonable chance of
364177595Sweongyo# success, regardless of how old your existing system is.
365177595Sweongyo#
366177595Sweongyo_worldtmp:
367177595Sweongyo.if ${.CURDIR:C/[^,]//g} != ""
368177595Sweongyo#	The m4 build of sendmail files doesn't like it if ',' is used
369177595Sweongyo#	anywhere in the path of it's files.
370177595Sweongyo	@echo
371177595Sweongyo	@echo "*** Error: path to source tree contains a comma ','"
372177595Sweongyo	@echo
373177595Sweongyo	false
374177595Sweongyo.endif
375177595Sweongyo	@echo
376177595Sweongyo	@echo "--------------------------------------------------------------"
377177595Sweongyo	@echo ">>> Rebuilding the temporary build tree"
378177595Sweongyo	@echo "--------------------------------------------------------------"
379177595Sweongyo.if !defined(NO_CLEAN)
380177595Sweongyo	rm -rf ${WORLDTMP}
381177595Sweongyo.if defined(LIB32TMP)
382177595Sweongyo	rm -rf ${LIB32TMP}
383177595Sweongyo.endif
384177595Sweongyo.else
385177595Sweongyo	rm -rf ${WORLDTMP}/legacy/usr/include
386177595Sweongyo#	XXX - These three can depend on any header file.
387177595Sweongyo	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
388177595Sweongyo	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
389177595Sweongyo	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
390177595Sweongyo.endif
391177595Sweongyo.for _dir in \
392177595Sweongyo    lib usr legacy/usr
393177595Sweongyo	mkdir -p ${WORLDTMP}/${_dir}
394177595Sweongyo.endfor
395177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
396177595Sweongyo	    -p ${WORLDTMP}/legacy/usr >/dev/null
397177595Sweongyo.if ${MK_GROFF} != "no"
398177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
399177595Sweongyo	    -p ${WORLDTMP}/legacy/usr >/dev/null
400177595Sweongyo.endif
401177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
402177595Sweongyo	    -p ${WORLDTMP}/usr >/dev/null
403177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
404177595Sweongyo	    -p ${WORLDTMP}/usr/include >/dev/null
405177595Sweongyo	ln -sf ${.CURDIR}/sys ${WORLDTMP}
406177595Sweongyo.if ${MK_BIND_LIBS} != "no"
407177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
408177595Sweongyo	    -p ${WORLDTMP}/usr/include >/dev/null
409177595Sweongyo.endif
410177595Sweongyo_legacy:
411177595Sweongyo	@echo
412177595Sweongyo	@echo "--------------------------------------------------------------"
413177595Sweongyo	@echo ">>> stage 1.1: legacy release compatibility shims"
414177595Sweongyo	@echo "--------------------------------------------------------------"
415177595Sweongyo	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
416177595Sweongyo_bootstrap-tools:
417177595Sweongyo	@echo
418177595Sweongyo	@echo "--------------------------------------------------------------"
419177595Sweongyo	@echo ">>> stage 1.2: bootstrap tools"
420177595Sweongyo	@echo "--------------------------------------------------------------"
421177595Sweongyo	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
422177595Sweongyo_cleanobj:
423177595Sweongyo.if !defined(NO_CLEAN)
424177595Sweongyo	@echo
425177595Sweongyo	@echo "--------------------------------------------------------------"
426177595Sweongyo	@echo ">>> stage 2.1: cleaning up the object tree"
427177595Sweongyo	@echo "--------------------------------------------------------------"
428177595Sweongyo	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
429177595Sweongyo.if defined(LIB32TMP)
430177595Sweongyo	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
431177595Sweongyo.endif
432177595Sweongyo.endif
433177595Sweongyo_obj:
434177595Sweongyo	@echo
435177595Sweongyo	@echo "--------------------------------------------------------------"
436177595Sweongyo	@echo ">>> stage 2.2: rebuilding the object tree"
437177595Sweongyo	@echo "--------------------------------------------------------------"
438177595Sweongyo	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
439177595Sweongyo_build-tools:
440177595Sweongyo	@echo
441177595Sweongyo	@echo "--------------------------------------------------------------"
442177595Sweongyo	@echo ">>> stage 2.3: build tools"
443177595Sweongyo	@echo "--------------------------------------------------------------"
444177595Sweongyo	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
445177595Sweongyo_cross-tools:
446177595Sweongyo	@echo
447177595Sweongyo	@echo "--------------------------------------------------------------"
448177595Sweongyo	@echo ">>> stage 3: cross tools"
449177595Sweongyo	@echo "--------------------------------------------------------------"
450177595Sweongyo	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
451177595Sweongyo_includes:
452177595Sweongyo	@echo
453177595Sweongyo	@echo "--------------------------------------------------------------"
454177595Sweongyo	@echo ">>> stage 4.1: building includes"
455177595Sweongyo	@echo "--------------------------------------------------------------"
456177595Sweongyo	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
457177595Sweongyo_libraries:
458177595Sweongyo	@echo
459177595Sweongyo	@echo "--------------------------------------------------------------"
460177595Sweongyo	@echo ">>> stage 4.2: building libraries"
461177595Sweongyo	@echo "--------------------------------------------------------------"
462177595Sweongyo	${_+_}cd ${.CURDIR}; \
463177595Sweongyo	    ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
464177595Sweongyo	    -DWITHOUT_MAN -DNO_PROFILE libraries
465177595Sweongyo_depend:
466177595Sweongyo	@echo
467177595Sweongyo	@echo "--------------------------------------------------------------"
468177595Sweongyo	@echo ">>> stage 4.3: make dependencies"
469177595Sweongyo	@echo "--------------------------------------------------------------"
470177595Sweongyo	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
471177595Sweongyoeverything:
472177595Sweongyo	@echo
473177595Sweongyo	@echo "--------------------------------------------------------------"
474177595Sweongyo	@echo ">>> stage 4.4: building everything"
475177595Sweongyo	@echo "--------------------------------------------------------------"
476177595Sweongyo	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
477177595Sweongyo.if defined(LIB32TMP)
478177595Sweongyobuild32:
479177595Sweongyo	@echo
480177595Sweongyo	@echo "--------------------------------------------------------------"
481177595Sweongyo	@echo ">>> stage 5.1: building 32 bit shim libraries"
482177595Sweongyo	@echo "--------------------------------------------------------------"
483177595Sweongyo	mkdir -p ${LIB32TMP}/usr/include
484177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
485177595Sweongyo	    -p ${LIB32TMP}/usr >/dev/null
486177595Sweongyo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
487177595Sweongyo	    -p ${LIB32TMP}/usr/include >/dev/null
488177595Sweongyo	mkdir -p ${WORLDTMP}
489177595Sweongyo	ln -sf ${.CURDIR}/sys ${WORLDTMP}
490177595Sweongyo.for _t in obj includes
491177595Sweongyo	cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
492177595Sweongyo	cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
493177595Sweongyo.if ${MK_CDDL} != "no"
494177595Sweongyo	cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
495177595Sweongyo.endif
496177595Sweongyo	cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
497177595Sweongyo.if ${MK_CRYPT} != "no"
498177595Sweongyo	cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
499177595Sweongyo.endif
500177595Sweongyo.if ${MK_KERBEROS} != "no"
501177595Sweongyo	cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
502177595Sweongyo.endif
503177595Sweongyo.endfor
504177595Sweongyo.for _dir in usr.bin/lex/lib
505177595Sweongyo	cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
506177595Sweongyo.endfor
507177595Sweongyo.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
508177595Sweongyo	cd ${.CURDIR}/${_dir}; \
509177595Sweongyo	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
510177595Sweongyo	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
511177595Sweongyo	    -DEARLY_BUILD build-tools
512177595Sweongyo.endfor
513177595Sweongyo	cd ${.CURDIR}; \
514177595Sweongyo	    ${LIB32WMAKE} -f Makefile.inc1 libraries
515178354Ssam.for _t in obj depend all
516178354Ssam	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
517178354Ssam	    DIRPRFX=libexec/rtld-elf/ ${_t}
518178354Ssam	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
519178354Ssam	    DIRPRFX=usr.bin/ldd ${_t}
520178354Ssam.endfor
521178354Ssam
522177595Sweongyodistribute32 install32:
523287197Sglebius	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
524287197Sglebius.if ${MK_CDDL} != "no"
525177595Sweongyo	cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
526177595Sweongyo.endif
527177595Sweongyo	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
528177595Sweongyo.if ${MK_CRYPT} != "no"
529177595Sweongyo	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
530177595Sweongyo.endif
531177595Sweongyo.if ${MK_KERBEROS} != "no"
532177595Sweongyo	cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
533177595Sweongyo.endif
534177595Sweongyo	cd ${.CURDIR}/libexec/rtld-elf; \
535287197Sglebius	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
536287197Sglebius	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
537287197Sglebius.endif
538287197Sglebius
539177595SweongyoWMAKE_TGTS=
540177595Sweongyo.if !defined(SUBDIR_OVERRIDE)
541177595SweongyoWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
542177595Sweongyo.endif
543177595SweongyoWMAKE_TGTS+=	_cleanobj _obj _build-tools
544177595Sweongyo.if !defined(SUBDIR_OVERRIDE)
545177595SweongyoWMAKE_TGTS+=	_cross-tools
546177595Sweongyo.endif
547177595SweongyoWMAKE_TGTS+=	_includes _libraries _depend everything
548177595Sweongyo.if defined(LIB32TMP) && ${MK_LIB32} != "no"
549177595SweongyoWMAKE_TGTS+=	build32
550177595Sweongyo.endif
551177595Sweongyo
552177595Sweongyobuildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
553177595Sweongyo.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
554177595Sweongyo
555199559Sjhbbuildworld_prologue:
556199559Sjhb	@echo "--------------------------------------------------------------"
557177595Sweongyo	@echo ">>> World build started on `LC_ALL=C date`"
558177595Sweongyo	@echo "--------------------------------------------------------------"
559177595Sweongyo
560177595Sweongyobuildworld_epilogue:
561177595Sweongyo	@echo
562177595Sweongyo	@echo "--------------------------------------------------------------"
563177595Sweongyo	@echo ">>> World build completed on `LC_ALL=C date`"
564177595Sweongyo	@echo "--------------------------------------------------------------"
565177595Sweongyo
566177595Sweongyo#
567177595Sweongyo# We need to have this as a target because the indirection between Makefile
568177595Sweongyo# and Makefile.inc1 causes the correct PATH to be used, rather than a
569177595Sweongyo# modification of the current environment's PATH.  In addition, we need
570177595Sweongyo# to quote multiword values.
571177595Sweongyo#
572177595Sweongyobuildenvvars:
573177595Sweongyo	@echo ${WMAKEENV:Q}
574177595Sweongyo
575177595Sweongyobuildenv:
576177595Sweongyo	@echo Entering world for ${TARGET_ARCH}:${TARGET}
577177595Sweongyo	@cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
578177595Sweongyo
579177595SweongyoTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
580177595Sweongyotoolchain: ${TOOLCHAIN_TGTS}
581177595Sweongyokernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
582177595Sweongyo
583177595Sweongyo#
584177595Sweongyo# installcheck
585177595Sweongyo#
586177595Sweongyo# Checks to be sure system is ready for installworld/installkernel.
587177595Sweongyo#
588177595Sweongyoinstallcheck:
589177595Sweongyo
590#
591# Require DESTDIR to be set if installing for a different architecture.
592#
593.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
594.if !make(distributeworld)
595installcheck: installcheck_DESTDIR
596installcheck_DESTDIR:
597.if !defined(DESTDIR) || empty(DESTDIR)
598	@echo "ERROR: Please set DESTDIR!"; \
599	false
600.endif
601.endif
602.endif
603
604#
605# Check for missing UIDs/GIDs.
606#
607CHECK_UIDS=
608CHECK_GIDS=	audit
609.if ${MK_SENDMAIL} != "no"
610CHECK_UIDS+=	smmsp
611CHECK_GIDS+=	smmsp
612.endif
613.if ${MK_PF} != "no"
614CHECK_UIDS+=	proxy
615CHECK_GIDS+=	proxy authpf
616.endif
617installcheck: installcheck_UGID
618installcheck_UGID:
619.for uid in ${CHECK_UIDS}
620	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
621		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
622		false; \
623	fi
624.endfor
625.for gid in ${CHECK_GIDS}
626	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
627		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
628		false; \
629	fi
630.endfor
631
632#
633# Required install tools to be saved in a scratch dir for safety.
634#
635.if ${MK_INFO} != "no"
636_install-info=	install-info
637.endif
638.if ${MK_ZONEINFO} != "no"
639_zoneinfo=	zic tzsetup
640.endif
641
642ITOOLS=	[ awk cap_mkdb cat chflags chmod chown \
643	date echo egrep find grep ${_install-info} \
644	ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
645	test true uname wc ${_zoneinfo}
646
647#
648# distributeworld
649#
650# Distributes everything compiled by a `buildworld'.
651#
652# installworld
653#
654# Installs everything compiled by a 'buildworld'.
655#
656
657# Non-base distributions produced by the base system
658EXTRA_DISTRIBUTIONS=	doc
659.if ${MK_GAMES} != "no"
660EXTRA_DISTRIBUTIONS+=	games
661.endif
662.if defined(LIB32TMP) && ${MK_LIB32} != "no"
663EXTRA_DISTRIBUTIONS+=	lib32
664.endif
665
666distributeworld installworld: installcheck
667	mkdir -p ${INSTALLTMP}
668	progs=$$(for prog in ${ITOOLS}; do \
669		if progpath=`which $$prog`; then \
670			echo $$progpath; \
671		else \
672			echo "Required tool $$prog not found in PATH." >&2; \
673			exit 1; \
674		fi; \
675	    done); \
676	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
677	    while read line; do \
678		set -- $$line; \
679		if [ "$$2 $$3" != "not found" ]; then \
680			echo $$2; \
681		else \
682			echo "Required library $$1 not found." >&2; \
683			exit 1; \
684		fi; \
685	    done); \
686	cp $$libs $$progs ${INSTALLTMP}
687	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
688.if make(distributeworld)
689.for dist in ${EXTRA_DISTRIBUTIONS}
690	-mkdir ${DESTDIR}/${DISTDIR}/${dist}
691	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
692	    -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
693	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
694	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
695	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
696	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
697.endfor
698	-mkdir ${DESTDIR}/${DISTDIR}/base
699	${_+_}cd ${.CURDIR}; ${IMAKE} distrib-dirs \
700	    DESTDIR=${DESTDIR}/${DISTDIR}/base
701.endif
702	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
703	    ${IMAKEENV} rm -rf ${INSTALLTMP}
704.if make(distributeworld)
705.for dist in ${EXTRA_DISTRIBUTIONS}
706	find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete
707.endfor
708.endif
709
710packageworld:
711.for dist in base ${EXTRA_DISTRIBUTIONS}
712	${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
713	    tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
714.endfor
715
716#
717# reinstall
718#
719# If you have a build server, you can NFS mount the source and obj directories
720# and do a 'make reinstall' on the *client* to install new binaries from the
721# most recent server build.
722#
723reinstall:
724	@echo "--------------------------------------------------------------"
725	@echo ">>> Making hierarchy"
726	@echo "--------------------------------------------------------------"
727	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
728	@echo
729	@echo "--------------------------------------------------------------"
730	@echo ">>> Installing everything"
731	@echo "--------------------------------------------------------------"
732	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
733.if defined(LIB32TMP) && ${MK_LIB32} != "no"
734	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
735.endif
736
737redistribute:
738	@echo "--------------------------------------------------------------"
739	@echo ">>> Distributing everything"
740	@echo "--------------------------------------------------------------"
741	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
742.if defined(LIB32TMP) && ${MK_LIB32} != "no"
743	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
744	    DISTRIBUTION=lib32
745.endif
746
747distrib-dirs distribution:
748	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
749
750#
751# buildkernel and installkernel
752#
753# Which kernels to build and/or install is specified by setting
754# KERNCONF. If not defined a GENERIC kernel is built/installed.
755# Only the existing (depending TARGET) config files are used
756# for building kernels and only the first of these is designated
757# as the one being installed.
758#
759# Note that we have to use TARGET instead of TARGET_ARCH when
760# we're in kernel-land. Since only TARGET_ARCH is (expected) to
761# be set to cross-build, we have to make sure TARGET is set
762# properly.
763
764.if defined(KERNFAST)
765NO_KERNELCLEAN=	t
766NO_KERNELCONFIG=	t
767NO_KERNELDEPEND=	t
768NO_KERNELOBJ=		t
769# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
770.if !defined(KERNCONF) && ${KERNFAST} != "1"
771KERNCONF=${KERNFAST}
772.endif
773.endif
774.if !defined(KERNCONF) && defined(KERNEL)
775KERNCONF=	${KERNEL}
776KERNWARN=
777.else
778.if ${TARGET_ARCH} == "powerpc64"
779KERNCONF?=	GENERIC64
780.else
781KERNCONF?=	GENERIC
782.endif
783.endif
784INSTKERNNAME?=	kernel
785
786KERNSRCDIR?=	${.CURDIR}/sys
787KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
788KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
789KERNCONFDIR?=	${KRNLCONFDIR}
790
791BUILDKERNELS=
792INSTALLKERNEL=
793.for _kernel in ${KERNCONF}
794.if exists(${KERNCONFDIR}/${_kernel})
795BUILDKERNELS+=	${_kernel}
796.if empty(INSTALLKERNEL)
797INSTALLKERNEL= ${_kernel}
798.endif
799.endif
800.endfor
801
802#
803# buildkernel
804#
805# Builds all kernels defined by BUILDKERNELS.
806#
807buildkernel:
808.if empty(BUILDKERNELS)
809	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
810	false
811.endif
812.if defined(KERNWARN)
813	@echo "--------------------------------------------------------------"
814	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
815	@echo "--------------------------------------------------------------"
816	@sleep 3
817.endif
818	@echo
819.for _kernel in ${BUILDKERNELS}
820	@echo "--------------------------------------------------------------"
821	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
822	@echo "--------------------------------------------------------------"
823	@echo "===> ${_kernel}"
824	mkdir -p ${KRNLOBJDIR}
825.if !defined(NO_KERNELCONFIG)
826	@echo
827	@echo "--------------------------------------------------------------"
828	@echo ">>> stage 1: configuring the kernel"
829	@echo "--------------------------------------------------------------"
830	cd ${KRNLCONFDIR}; \
831		PATH=${TMPPATH} \
832		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
833			${KERNCONFDIR}/${_kernel}
834.endif
835.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
836	@echo
837	@echo "--------------------------------------------------------------"
838	@echo ">>> stage 2.1: cleaning up the object tree"
839	@echo "--------------------------------------------------------------"
840	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
841.endif
842.if !defined(NO_KERNELOBJ)
843	@echo
844	@echo "--------------------------------------------------------------"
845	@echo ">>> stage 2.2: rebuilding the object tree"
846	@echo "--------------------------------------------------------------"
847	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
848.endif
849	@echo
850	@echo "--------------------------------------------------------------"
851	@echo ">>> stage 2.3: build tools"
852	@echo "--------------------------------------------------------------"
853	cd ${KRNLOBJDIR}/${_kernel}; \
854	    PATH=${BPATH}:${PATH} \
855	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
856	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
857	    -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
858# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
859.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
860.for target in obj depend all
861	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
862	    PATH=${BPATH}:${PATH} \
863	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
864	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
865.endfor
866.endif
867.if !defined(NO_KERNELDEPEND)
868	@echo
869	@echo "--------------------------------------------------------------"
870	@echo ">>> stage 3.1: making dependencies"
871	@echo "--------------------------------------------------------------"
872	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
873.endif
874	@echo
875	@echo "--------------------------------------------------------------"
876	@echo ">>> stage 3.2: building everything"
877	@echo "--------------------------------------------------------------"
878	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
879	@echo "--------------------------------------------------------------"
880	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
881	@echo "--------------------------------------------------------------"
882.endfor
883
884#
885# installkernel, etc.
886#
887# Install the kernel defined by INSTALLKERNEL
888#
889installkernel installkernel.debug \
890reinstallkernel reinstallkernel.debug: installcheck
891.if empty(INSTALLKERNEL)
892	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
893	false
894.endif
895	@echo "--------------------------------------------------------------"
896	@echo ">>> Installing kernel ${INSTALLKERNEL}"
897	@echo "--------------------------------------------------------------"
898	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
899	    ${CROSSENV} PATH=${TMPPATH} \
900	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
901
902distributekernel distributekernel.debug:
903.if empty(INSTALLKERNEL)
904	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
905	false
906.endif
907	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
908	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
909	    DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
910	    ${.TARGET:S/distributekernel/install/}
911.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
912	cd ${KRNLOBJDIR}/${_kernel}; \
913	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
914	    KERNEL=${INSTKERNNAME}.${_kernel} \
915	    DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
916	    ${.TARGET:S/distributekernel/install/}
917.endfor
918
919packagekernel:
920	cd ${DESTDIR}/${DISTDIR}/kernel; \
921	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
922.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
923	cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
924	    tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
925.endfor
926
927#
928# doxygen
929#
930# Build the API documentation with doxygen
931#
932doxygen:
933	@if [ ! -x `/usr/bin/which doxygen` ]; then \
934		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
935		exit 1; \
936	fi
937	cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
938
939#
940# update
941#
942# Update the source tree(s), by running cvsup/cvs/svn to update to the
943# latest copy.
944#
945update:
946.if defined(SUP_UPDATE)
947	@echo "--------------------------------------------------------------"
948	@echo ">>> Running ${SUP}"
949	@echo "--------------------------------------------------------------"
950.if defined(SUPFILE)
951	@${SUP} ${SUPFLAGS} ${SUPFILE}
952.endif
953.if defined(SUPFILE1)
954	@${SUP} ${SUPFLAGS} ${SUPFILE1}
955.endif
956.if defined(SUPFILE2)
957	@${SUP} ${SUPFLAGS} ${SUPFILE2}
958.endif
959.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
960	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
961.endif
962.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
963	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
964.endif
965.if defined(WWWSUPFILE) && !defined(NO_WWWUPDATE)
966	@${SUP} ${SUPFLAGS} ${WWWSUPFILE}
967.endif
968.endif
969.if defined(CVS_UPDATE)
970	@cd ${.CURDIR} ; \
971	if [ -d CVS ] ; then \
972		echo "--------------------------------------------------------------" ; \
973		echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
974		echo "--------------------------------------------------------------" ; \
975		echo ${CVS} -R -q update ${CVSFLAGS} ; \
976		${CVS} -R -q update ${CVSFLAGS} ; \
977	fi
978.endif
979.if defined(SVN_UPDATE)
980	@cd ${.CURDIR} ; \
981	if [ -d .svn ] ; then \
982		echo "--------------------------------------------------------------" ; \
983		echo ">>> Updating ${.CURDIR} using Subversion" ; \
984		echo "--------------------------------------------------------------" ; \
985		echo ${SVN} update ${SVNFLAGS} ; \
986		${SVN} update ${SVNFLAGS} ; \
987	fi
988.endif
989
990#
991# ------------------------------------------------------------------------
992#
993# From here onwards are utility targets used by the 'make world' and
994# related targets.  If your 'world' breaks, you may like to try to fix
995# the problem and manually run the following targets to attempt to
996# complete the build.  Beware, this is *not* guaranteed to work, you
997# need to have a pretty good grip on the current state of the system
998# to attempt to manually finish it.  If in doubt, 'make world' again.
999#
1000
1001#
1002# legacy: Build compatibility shims for the next three targets
1003#
1004legacy:
1005.if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
1006	@echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
1007	false
1008.endif
1009.for _tool in tools/build
1010	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1011	    cd ${.CURDIR}/${_tool}; \
1012	    ${MAKE} DIRPRFX=${_tool}/ obj; \
1013	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1014	    ${MAKE} DIRPRFX=${_tool}/ depend; \
1015	    ${MAKE} DIRPRFX=${_tool}/ all; \
1016	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1017.endfor
1018
1019#
1020# bootstrap-tools: Build tools needed for compatibility
1021#
1022.if ${MK_GAMES} != "no"
1023_strfile=	games/fortune/strfile
1024.endif
1025
1026.if ${MK_CXX} != "no"
1027_gperf=		gnu/usr.bin/gperf
1028.endif
1029
1030.if ${MK_GROFF} != "no"
1031_groff=		gnu/usr.bin/groff
1032.endif
1033
1034.if ${BOOTSTRAPPING} < 800022
1035_ar=		usr.bin/ar
1036.endif
1037
1038.if ${BOOTSTRAPPING} < 800013
1039_mklocale=	usr.bin/mklocale
1040.endif
1041
1042.if ${BOOTSTRAPPING} < 900002
1043_sed=		usr.bin/sed
1044.endif
1045
1046.if ${BOOTSTRAPPING} < 900006
1047_lex=		usr.bin/lex
1048.endif
1049
1050.if ${BOOTSTRAPPING} < 1000013
1051_yacc=		usr.bin/yacc
1052.endif
1053
1054.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1055_awk=		usr.bin/awk
1056.endif
1057
1058.if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
1059_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
1060.endif
1061
1062.if ${MK_CLANG} != "no"
1063_clang_tblgen= \
1064	lib/clang/libllvmsupport \
1065	lib/clang/libllvmtablegen \
1066	usr.bin/clang/tblgen \
1067	usr.bin/clang/clang-tblgen
1068.endif
1069
1070# dtrace tools are required for older bootstrap env and cross-build
1071.if ${MK_CDDL} != "no" && \
1072    ((${BOOTSTRAPPING} < 800038 && \
1073          !(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)) \
1074      || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1075_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1076    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1077.endif
1078
1079.if ${MK_FDT} != "no"
1080_dtc= gnu/usr.bin/dtc
1081.endif
1082
1083.if ${MK_KERBEROS} != "no"
1084_kerberos5_bootstrap_tools= \
1085	kerberos5/tools/make-roken \
1086	kerberos5/lib/libroken \
1087	kerberos5/lib/libvers \
1088	kerberos5/tools/asn1_compile \
1089	kerberos5/tools/slc
1090.endif
1091
1092#	Please document (add comment) why something is in 'bootstrap-tools'.
1093#	Try to bound the building of the bootstrap-tool to just the
1094#	FreeBSD versions that need the tool built at this stage of the build.
1095bootstrap-tools:
1096.for _tool in \
1097    ${_clang_tblgen} \
1098    ${_kerberos5_bootstrap_tools} \
1099    ${_dtrace_tools} \
1100    ${_strfile} \
1101    ${_gperf} \
1102    ${_groff} \
1103    ${_ar} \
1104    ${_dtc} \
1105    ${_awk} \
1106    usr.bin/lorder \
1107    usr.bin/makewhatis \
1108    ${_mklocale} \
1109    usr.bin/rpcgen \
1110    ${_sed} \
1111    ${_yacc} \
1112    ${_lex} \
1113    usr.bin/xinstall \
1114    ${_gensnmptree} \
1115    usr.sbin/config
1116	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1117		cd ${.CURDIR}/${_tool}; \
1118		${MAKE} DIRPRFX=${_tool}/ obj; \
1119		${MAKE} DIRPRFX=${_tool}/ depend; \
1120		${MAKE} DIRPRFX=${_tool}/ all; \
1121		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1122.endfor
1123
1124#
1125# build-tools: Build special purpose build tools
1126#
1127.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1128_aicasm= sys/modules/aic7xxx/aicasm
1129.endif
1130
1131.if !defined(NO_SHARE)
1132_share=	share/syscons/scrnmaps
1133.endif
1134
1135.if ${MK_GCC} != "no" && ${MK_CLANG_IS_CC} == "no"
1136_gcc_tools= gnu/usr.bin/cc/cc_tools
1137.endif
1138
1139.if ${MK_RESCUE} != "no"
1140_rescue= rescue/rescue
1141.endif
1142
1143build-tools:
1144.for _tool in \
1145    bin/csh \
1146    bin/sh \
1147    ${_rescue} \
1148    ${LOCAL_TOOL_DIRS} \
1149    lib/ncurses/ncurses \
1150    lib/ncurses/ncursesw \
1151    ${_share} \
1152    ${_aicasm} \
1153    usr.bin/awk \
1154    lib/libmagic \
1155    usr.bin/mkesdb_static \
1156    usr.bin/mkcsmapper_static
1157	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1158		cd ${.CURDIR}/${_tool}; \
1159		${MAKE} DIRPRFX=${_tool}/ obj; \
1160		${MAKE} DIRPRFX=${_tool}/ build-tools
1161.endfor
1162.for _tool in \
1163    ${_gcc_tools}
1164	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1165		cd ${.CURDIR}/${_tool}; \
1166		${MAKE} DIRPRFX=${_tool}/ obj; \
1167		${MAKE} DIRPRFX=${_tool}/ depend; \
1168		${MAKE} DIRPRFX=${_tool}/ all
1169.endfor
1170
1171#
1172# cross-tools: Build cross-building tools
1173#
1174.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1175.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1176_btxld=		usr.sbin/btxld
1177.endif
1178.endif
1179.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1180.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1181_crunchide=	usr.sbin/crunch/crunchide
1182.endif
1183.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1184_kgzip=		usr.sbin/kgzip
1185.endif
1186.endif
1187
1188.if ${MK_BINUTILS} != "no"
1189_binutils=	gnu/usr.bin/binutils
1190.endif
1191
1192.if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1193_clang=		usr.bin/clang
1194_clang_libs=	lib/clang
1195.endif
1196
1197.if ${MK_GCC} != "no" && ${MK_CLANG_IS_CC} == "no"
1198_cc=		gnu/usr.bin/cc
1199.endif
1200
1201cross-tools:
1202.for _tool in \
1203    ${_clang_libs} \
1204    ${_clang} \
1205    ${_binutils} \
1206    ${_cc} \
1207    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1208    ${_btxld} \
1209    ${_crunchide} \
1210    ${_kgzip}
1211	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1212		cd ${.CURDIR}/${_tool}; \
1213		${MAKE} DIRPRFX=${_tool}/ obj; \
1214		${MAKE} DIRPRFX=${_tool}/ depend; \
1215		${MAKE} DIRPRFX=${_tool}/ all; \
1216		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1217.endfor
1218
1219#
1220# hierarchy - ensure that all the needed directories are present
1221#
1222hierarchy hier:
1223	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
1224
1225#
1226# libraries - build all libraries, and install them under ${DESTDIR}.
1227#
1228# The list of libraries with dependents (${_prebuild_libs}) and their
1229# interdependencies (__L) are built automatically by the
1230# ${.CURDIR}/tools/make_libdeps.sh script.
1231#
1232libraries:
1233	cd ${.CURDIR}; \
1234	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1235	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1236	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1237	    ${MAKE} -f Makefile.inc1 _generic_libs;
1238
1239#
1240# static libgcc.a prerequisite for shared libc
1241#
1242_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1243
1244# These dependencies are not automatically generated:
1245#
1246# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1247# all shared libraries for ELF.
1248#
1249_startup_libs=	gnu/lib/csu
1250.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1251_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
1252.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1253_startup_libs+=	lib/csu/${MACHINE_ARCH}
1254.else
1255_startup_libs+=	lib/csu/${MACHINE_CPUARCH}
1256.endif
1257_startup_libs+=	gnu/lib/libgcc
1258_startup_libs+=	lib/libcompiler_rt
1259_startup_libs+=	lib/libc
1260.if ${MK_LIBCPLUSPLUS} != "no"
1261_startup_libs+=	lib/libcxxrt
1262.endif
1263
1264gnu/lib/libgcc__L: lib/libc__L
1265.if ${MK_LIBCPLUSPLUS} != "no"
1266lib/libcxxrt__L: gnu/lib/libgcc__L
1267.endif
1268
1269_prebuild_libs=	${_kerberos5_lib_libasn1} \
1270		${_kerberos5_lib_libhdb} \
1271		${_kerberos5_lib_libheimbase} \
1272		${_kerberos5_lib_libheimntlm} \
1273		${_kerberos5_lib_libheimsqlite} \
1274		${_kerberos5_lib_libheimipcc} \
1275		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1276		${_kerberos5_lib_libroken} \
1277		${_kerberos5_lib_libwind} \
1278		lib/libbz2 ${_libcom_err} lib/libcrypt \
1279		lib/libexpat \
1280		${_lib_libgssapi} ${_lib_libipx} \
1281		lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1282		lib/ncurses/ncurses lib/ncurses/ncursesw \
1283		lib/libopie lib/libpam ${_lib_libthr} \
1284		lib/libradius lib/libsbuf lib/libtacplus \
1285		${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1286		lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1287		${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1288		${_secure_lib_libssl}
1289
1290.if ${MK_LIBTHR} != "no"
1291_lib_libthr=	lib/libthr
1292.endif
1293
1294.if ${MK_OFED} != "no"
1295_ofed_lib=	contrib/ofed/usr.lib/
1296.endif
1297
1298_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1299.for _DIR in ${LOCAL_LIB_DIRS}
1300.if exists(${.CURDIR}/${_DIR}/Makefile)
1301_generic_libs+= ${_DIR}
1302.endif
1303.endfor
1304
1305lib/libopie__L lib/libtacplus__L: lib/libmd__L
1306
1307.if ${MK_CDDL} != "no"
1308_cddl_lib_libumem= cddl/lib/libumem
1309_cddl_lib_libnvpair= cddl/lib/libnvpair
1310_cddl_lib= cddl/lib
1311.endif
1312
1313.if ${MK_CRYPT} != "no"
1314.if ${MK_OPENSSL} != "no"
1315_secure_lib_libcrypto= secure/lib/libcrypto
1316_secure_lib_libssl= secure/lib/libssl
1317lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1318.if ${MK_OPENSSH} != "no"
1319_secure_lib_libssh= secure/lib/libssh
1320secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1321.if ${MK_KERBEROS_SUPPORT} != "no"
1322secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1323    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1324    lib/libmd__L kerberos5/lib/libroken__L
1325.endif
1326.endif
1327.endif
1328_secure_lib=	secure/lib
1329.endif
1330
1331.if ${MK_KERBEROS} != "no"
1332kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1333kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1334    kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1335    kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1336kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1337    kerberos5/lib/libroken__L lib/libcom_err__L
1338kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1339    secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1340kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1341    lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1342    kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1343    kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1344kerberos5/lib/libroken__L: lib/libcrypt__L
1345kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1346kerberos5/lib/libheimbase__L: lib/libthr__L
1347kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1348kerberos5/lib/libheimsqlite__L: lib/libthr__L
1349.endif
1350
1351.if ${MK_GSSAPI} != "no"
1352_lib_libgssapi=	lib/libgssapi
1353.endif
1354
1355.if ${MK_IPX} != "no"
1356_lib_libipx=	lib/libipx
1357.endif
1358
1359.if ${MK_KERBEROS} != "no"
1360_kerberos5_lib=	kerberos5/lib
1361_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1362_kerberos5_lib_libhdb= kerberos5/lib/libhdb
1363_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1364_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1365_kerberos5_lib_libhx509= kerberos5/lib/libhx509
1366_kerberos5_lib_libroken= kerberos5/lib/libroken
1367_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1368_kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1369_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1370_kerberos5_lib_libwind= kerberos5/lib/libwind
1371_libcom_err= lib/libcom_err
1372.endif
1373
1374.if ${MK_NIS} != "no"
1375_lib_libypclnt=	lib/libypclnt
1376.endif
1377
1378.if ${MK_OPENSSL} == "no"
1379lib/libradius__L: lib/libmd__L
1380.endif
1381
1382.for _lib in ${_prereq_libs}
1383${_lib}__PL: .PHONY
1384.if exists(${.CURDIR}/${_lib})
1385	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1386		cd ${.CURDIR}/${_lib}; \
1387		${MAKE} DIRPRFX=${_lib}/ obj; \
1388		${MAKE} DIRPRFX=${_lib}/ depend; \
1389		${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1390		${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1391.endif
1392.endfor
1393
1394.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1395${_lib}__L: .PHONY
1396.if exists(${.CURDIR}/${_lib})
1397	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1398		cd ${.CURDIR}/${_lib}; \
1399		${MAKE} DIRPRFX=${_lib}/ obj; \
1400		${MAKE} DIRPRFX=${_lib}/ depend; \
1401		${MAKE} DIRPRFX=${_lib}/ all; \
1402		${MAKE} DIRPRFX=${_lib}/ install
1403.endif
1404.endfor
1405
1406# libpam is special: we need to build static PAM modules before
1407# static PAM library, and dynamic PAM library before dynamic PAM
1408# modules.
1409lib/libpam__L: .PHONY
1410	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1411		cd ${.CURDIR}/lib/libpam; \
1412		${MAKE} DIRPRFX=lib/libpam/ obj; \
1413		${MAKE} DIRPRFX=lib/libpam/ depend; \
1414		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1415		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1416
1417_prereq_libs: ${_prereq_libs:S/$/__PL/}
1418_startup_libs: ${_startup_libs:S/$/__L/}
1419_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1420_generic_libs: ${_generic_libs:S/$/__L/}
1421
1422.for __target in all clean cleandepend cleandir depend includes obj
1423.for entry in ${SUBDIR}
1424${entry}.${__target}__D: .PHONY
1425	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1426		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1427		edir=${entry}.${MACHINE_ARCH}; \
1428		cd ${.CURDIR}/$${edir}; \
1429	else \
1430		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1431		edir=${entry}; \
1432		cd ${.CURDIR}/$${edir}; \
1433	fi; \
1434	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1435.endfor
1436par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1437.endfor
1438
1439.include <bsd.subdir.mk>
1440
1441.if make(check-old) || make(check-old-dirs) || \
1442    make(check-old-files) || make(check-old-libs) || \
1443    make(delete-old) || make(delete-old-dirs) || \
1444    make(delete-old-files) || make(delete-old-libs)
1445
1446#
1447# check for / delete old files section
1448#
1449
1450.include "ObsoleteFiles.inc"
1451
1452OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1453else you can not start such an application. Consult UPDATING for more \
1454information regarding how to cope with the removal/revision bump of a \
1455specific library."
1456
1457.if !defined(BATCH_DELETE_OLD_FILES)
1458RM_I=-i
1459.else
1460RM_I=-v
1461.endif
1462
1463delete-old-files:
1464	@echo ">>> Removing old files (only deletes safe to delete libs)"
1465# Ask for every old file if the user really wants to remove it.
1466# It's annoying, but better safe than sorry.
1467# NB: We cannot pass the list of OLD_FILES as a parameter because the
1468# argument list will get too long. Using .for/.endfor make "loops" will make
1469# the Makefile parser segfault.
1470	@exec 3<&0; \
1471	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1472	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1473	while read file; do \
1474		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1475			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1476			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1477		fi; \
1478	done
1479# Remove catpages without corresponding manpages.
1480	@exec 3<&0; \
1481	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1482	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1483	while read catpage; do \
1484		read manpage; \
1485		if [ ! -e "$${manpage}" ]; then \
1486			rm ${RM_I} $${catpage} <&3; \
1487	        fi; \
1488	done
1489	@echo ">>> Old files removed"
1490
1491check-old-files:
1492	@echo ">>> Checking for old files"
1493	@${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1494	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1495	while read file; do \
1496		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1497		 	echo "${DESTDIR}/$${file}"; \
1498		fi; \
1499	done
1500# Check for catpages without corresponding manpages.
1501	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1502	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1503	while read catpage; do \
1504		read manpage; \
1505		if [ ! -e "$${manpage}" ]; then \
1506			echo $${catpage}; \
1507	        fi; \
1508	done
1509
1510delete-old-libs:
1511	@echo ">>> Removing old libraries"
1512	@echo "${OLD_LIBS_MESSAGE}" | fmt
1513	@exec 3<&0; \
1514	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1515	    -V OLD_LIBS | xargs -n1 | \
1516	while read file; do \
1517		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1518			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1519			rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1520		fi; \
1521	done
1522	@echo ">>> Old libraries removed"
1523
1524check-old-libs:
1525	@echo ">>> Checking for old libraries"
1526	@${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1527	    -V OLD_LIBS | xargs -n1 | \
1528	while read file; do \
1529		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1530			echo "${DESTDIR}/$${file}"; \
1531		fi; \
1532	done
1533
1534delete-old-dirs:
1535	@echo ">>> Removing old directories"
1536	@${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1537	    -V OLD_DIRS | xargs -n1 | \
1538	while read dir; do \
1539		if [ -d "${DESTDIR}/$${dir}" ]; then \
1540			rmdir -v "${DESTDIR}/$${dir}" || true; \
1541		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1542			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1543		fi; \
1544	done
1545	@echo ">>> Old directories removed"
1546
1547check-old-dirs:
1548	@echo ">>> Checking for old directories"
1549	@${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1550	    -V OLD_DIRS | xargs -n1 | \
1551	while read dir; do \
1552		if [ -d "${DESTDIR}/$${dir}" ]; then \
1553			echo "${DESTDIR}/$${dir}"; \
1554		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1555			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1556		fi; \
1557	done
1558
1559delete-old: delete-old-files delete-old-dirs
1560	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1561
1562check-old: check-old-files check-old-libs check-old-dirs
1563	@echo "To remove old files and directories run '${MAKE} delete-old'."
1564	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1565
1566.endif
1567
1568#
1569# showconfig - show build configuration.
1570#
1571showconfig:
1572	@${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1573
1574.if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1575DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1576
1577.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1578.if exists(${KERNCONFDIR}/${KERNCONF})
1579FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1580	${KERNCONFDIR}/${KERNCONF} ; echo
1581.endif
1582.endif
1583
1584.endif
1585
1586.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1587DTBOUTPUTPATH= ${.CURDIR}
1588.endif
1589
1590#
1591# Build 'standalone' Device Tree Blob
1592#
1593builddtb:
1594	@if [ "${FDT_DTS_FILE}" = "" ]; then \
1595		echo "ERROR: FDT_DTS_FILE must be specified!"; \
1596		exit 1; \
1597	fi;	\
1598	if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1599		echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1600			exist!"; \
1601		exit 1;	\
1602	fi;	\
1603	if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then	\
1604		echo "WARNING: DTB will be placed in the current working \
1605			directory"; \
1606	fi
1607	@PATH=${TMPPATH} \
1608	dtc -O dtb -o \
1609	    ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1610	    -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1611
1612###############
1613
1614.if defined(XDEV) && defined(XDEV_ARCH)
1615
1616.if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1617XDEV_CPUTYPE?=${CPUTYPE}
1618.else
1619XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1620.endif
1621
1622NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1623	-DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1624	-DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1625	TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1626	CPUTYPE=${XDEV_CPUTYPE}
1627
1628XDDIR=${XDEV_ARCH}-freebsd
1629XDTP=/usr/${XDDIR}
1630CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR}
1631CDENV= ${CDBENV} \
1632	_SHLIBDIRPREFIX=${XDTP} \
1633	TOOLS_PREFIX=${XDTP}
1634CD2ENV=${CDENV} \
1635	MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1636
1637CDTMP=	${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1638CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1639CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1640XDDESTDIR=${DESTDIR}${XDTP}
1641.if !defined(OSREL)
1642OSREL!= uname -r | sed -e 's/[-(].*//'
1643.endif
1644
1645.ORDER: xdev-build xdev-install
1646xdev: xdev-build xdev-install
1647
1648.ORDER: _xb-build-tools _xb-cross-tools
1649xdev-build: _xb-build-tools _xb-cross-tools
1650
1651_xb-build-tools:
1652	${_+_}@cd ${.CURDIR}; \
1653	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1654
1655_xb-cross-tools:
1656.for _tool in \
1657    gnu/usr.bin/binutils \
1658    gnu/usr.bin/cc \
1659    usr.bin/ar
1660	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1661	cd ${.CURDIR}/${_tool}; \
1662	${CDMAKE} DIRPRFX=${_tool}/ obj; \
1663	${CDMAKE} DIRPRFX=${_tool}/ depend; \
1664	${CDMAKE} DIRPRFX=${_tool}/ all
1665.endfor
1666
1667_xi-mtree:
1668	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1669	mkdir -p ${XDDESTDIR}
1670	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1671	    -p ${XDDESTDIR} >/dev/null
1672	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1673	    -p ${XDDESTDIR}/usr >/dev/null
1674	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1675	    -p ${XDDESTDIR}/usr/include >/dev/null
1676
1677.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1678xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1679
1680_xi-cross-tools:
1681	@echo "_xi-cross-tools"
1682.for _tool in \
1683    gnu/usr.bin/binutils \
1684    gnu/usr.bin/cc \
1685    usr.bin/ar
1686	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1687	cd ${.CURDIR}/${_tool}; \
1688	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1689.endfor
1690
1691_xi-includes:
1692	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1693		DESTDIR=${XDDESTDIR}
1694
1695_xi-libraries:
1696	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1697		DESTDIR=${XDDESTDIR}
1698
1699_xi-links:
1700	${_+_}cd ${XDDESTDIR}/usr/bin; \
1701		for i in *; do \
1702			ln -sf ../../${XDTP}/usr/bin/$$i \
1703			    ../../../../usr/bin/${XDDIR}-$$i; \
1704			ln -sf ../../${XDTP}/usr/bin/$$i \
1705			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1706		done
1707.else
1708xdev xdev-buil xdev-install:
1709	@echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1710.endif
1711