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