]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Fix a typo.
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
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 #
62 SRCDIR?=        ${.CURDIR}
63 .if defined(SUBDIR_OVERRIDE)
64 SUBDIR= ${SUBDIR_OVERRIDE}
65 .else
66 SUBDIR= share/info lib libexec
67 SUBDIR+=bin
68 .if ${MK_GAMES} != "no"
69 SUBDIR+=games
70 .endif
71 .if ${MK_CDDL} != "no"
72 SUBDIR+=cddl
73 .endif
74 SUBDIR+=gnu include
75 .if ${MK_KERBEROS} != "no"
76 SUBDIR+=kerberos5
77 .endif
78 .if ${MK_RESCUE} != "no"
79 SUBDIR+=rescue
80 .endif
81 SUBDIR+=sbin
82 .if ${MK_CRYPT} != "no"
83 SUBDIR+=secure
84 .endif
85 .if !defined(NO_SHARE)
86 SUBDIR+=share
87 .endif
88 SUBDIR+=sys usr.bin usr.sbin
89 .if ${MK_TESTS} != "no"
90 SUBDIR+=        tests
91 .endif
92 .if ${MK_OFED} != "no"
93 SUBDIR+=contrib/ofed
94 .endif
95 #
96 # We must do etc/ last for install/distribute to work.
97 #
98 SUBDIR+=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)
104 SUBDIR+= ${_DIR}
105 .endif
106 .endfor
107 .endif
108
109 .if defined(NOCLEAN)
110 NO_CLEAN=       ${NOCLEAN}
111 .endif
112 .if defined(NO_CLEANDIR)
113 CLEANDIR=       clean cleandepend
114 .else
115 CLEANDIR=       cleandir
116 .endif
117
118 LOCAL_TOOL_DIRS?=
119
120 BUILDENV_SHELL?=/bin/sh
121
122 SVN?=           /usr/local/bin/svn
123 SVNFLAGS?=      -r HEAD
124
125 MAKEOBJDIRPREFIX?=      /usr/obj
126 .if !defined(OSRELDATE)
127 .if exists(/usr/include/osreldate.h)
128 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
129                 /usr/include/osreldate.h
130 .else
131 OSRELDATE=      0
132 .endif
133 .endif
134
135 .if !defined(VERSION)
136 REVISION!=      ${MAKE} -C ${SRCDIR}/release -V REVISION
137 BRANCH!=        ${MAKE} -C ${SRCDIR}/release -V BRANCH
138 SRCRELDATE!=    awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
139                 ${SRCDIR}/sys/sys/param.h
140 VERSION=        FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
141 .endif
142
143 KNOWN_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}
156 TARGET_CPUTYPE?=${CPUTYPE}
157 .else
158 TARGET_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)
172 BUILD_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)
178 OBJTREE=        ${MAKEOBJDIRPREFIX}
179 .else
180 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
181 .endif
182 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
183 # /usr/games added for fortune which depend on strfile
184 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
185 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
186 STRICTTMPPATH=  ${BPATH}:${XPATH}
187 TMPPATH=        ${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)
195 INSTALLTMP!=    /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
223 BOOTSTRAPPING?= 0
224
225 # Common environment for world related stages
226 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
227                 MACHINE_ARCH=${TARGET_ARCH} \
228                 MACHINE=${TARGET} \
229                 CPUTYPE=${TARGET_CPUTYPE}
230 .if ${MK_GROFF} != "no"
231 CROSSENV+=      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)
236 CROSSENV+=      ${TARGET_CFLAGS}
237 .endif
238
239 # bootstrap-tools stage
240 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
241                 PATH=${BPATH}:${PATH} \
242                 WORLDTMP=${WORLDTMP} \
243                 VERSION="${VERSION}" \
244                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
245 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
246                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
247                 DESTDIR= \
248                 BOOTSTRAPPING=${OSRELDATE} \
249                 SSP_CFLAGS= \
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
256 TMAKE=          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= \
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
266 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
267                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
268                 MK_GDB=no MK_TESTS=no
269
270 # kernel-tools stage
271 KTMAKEENV=      INSTALL="sh ${.CURDIR}/tools/install.sh" \
272                 PATH=${BPATH}:${PATH} \
273                 WORLDTMP=${WORLDTMP} \
274                 VERSION="${VERSION}"
275 KTMAKE=         TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
276                 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
277                 DESTDIR= \
278                 BOOTSTRAPPING=${OSRELDATE} \
279                 SSP_CFLAGS= \
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
285 WMAKEENV=       ${CROSSENV} \
286                 _SHLIBDIRPREFIX=${WORLDTMP} \
287                 _LDSCRIPTROOT= \
288                 VERSION="${VERSION}" \
289                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
290                 PATH=${TMPPATH}
291
292 # make hierarchy
293 HMAKE=          PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
294 .if defined(NO_ROOT)
295 HMAKE+=         PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
296 .endif
297
298 .if ${MK_CDDL} == "no"
299 WMAKEENV+=      MK_CTF=no
300 .endif
301
302 .if defined(CROSS_TOOLCHAIN_PREFIX)
303 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
304 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
305 .endif
306 XCOMPILERS=     CC CXX CPP
307 .for COMPILER in ${XCOMPILERS}
308 .if defined(CROSS_COMPILER_PREFIX)
309 X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
310 .else
311 X${COMPILER}?=  ${${COMPILER}}
312 .endif
313 .endfor
314 XBINUTILS=      AS AR LD NM OBJDUMP RANLIB STRINGS
315 .for BINUTIL in ${XBINUTILS}
316 .if defined(CROSS_BINUTILS_PREFIX)
317 X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
318 .else
319 X${BINUTIL}?=   ${${BINUTIL}}
320 .endif
321 .endfor
322 WMAKEENV+=      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/*}
328 XFLAGS=         --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})
334 XFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
335 .endif
336 .else
337 XFLAGS+=        -B${WORLDTMP}/usr/bin
338 .endif
339 .if ${TARGET} == "arm" && ${MK_ARM_EABI} != "no"
340 .if ${TARGET_ARCH:M*eb*} == ""
341 TARGET_ABI=     gnueabi
342 .elif ${TARGET_ARCH} == "armv6hf"
343 TARGET_ABI=     gnueabihf
344 .endif
345 .endif
346 TARGET_ABI?=    unknown
347 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
348 XFLAGS+=        -target ${TARGET_TRIPLE}
349 .endif
350
351 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
352
353 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
354 # 32 bit world
355 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
356
357 .if ${TARGET_ARCH} == "amd64"
358 .if empty(TARGET_CPUTYPE)
359 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
360 .else
361 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
362 .endif
363 LIB32WMAKEENV=  MACHINE=i386 MACHINE_ARCH=i386 \
364                 MACHINE_CPU="i686 mmx sse sse2"
365 LIB32WMAKEFLAGS=        \
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)
371 LIB32CPUFLAGS=  -mcpu=powerpc
372 .else
373 LIB32CPUFLAGS=  -mcpu=${TARGET_CPUTYPE}
374 .endif
375 LIB32WMAKEENV=  MACHINE=powerpc MACHINE_ARCH=powerpc
376 LIB32WMAKEFLAGS=        \
377                 LD="${LD} -m elf32ppc_fbsd"
378 .endif
379
380
381 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
382                 -isystem ${LIB32TMP}/usr/include/ \
383                 -L${LIB32TMP}/usr/lib32 \
384                 -B${LIB32TMP}/usr/lib32
385 .if ${XCC:M/*}
386 LIB32FLAGS+=            --sysroot=${WORLDTMP}
387 .endif
388
389 # Yes, the flags are redundant.
390 LIB32WMAKEENV+= 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"
400 LIB32WMAKEFLAGS+= 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
410 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
411                 MK_MAN=no MK_INFO=no MK_HTML=no
412 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
413                 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
414 .endif
415
416 IMAKEENV=       ${CROSSENV:N_LDSCRIPTROOT=*}
417 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
418                 ${IMAKE_INSTALL} ${IMAKE_MTREE}
419 .if empty(.MAKEFLAGS:M-n)
420 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
421                 LD_LIBRARY_PATH=${INSTALLTMP} \
422                 PATH_LOCALE=${INSTALLTMP}/locale
423 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
424 .else
425 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
426 .endif
427 .if defined(DB_FROM_SRC)
428 INSTALLFLAGS+=  -N ${.CURDIR}/etc
429 MTREEFLAGS+=    -N ${.CURDIR}/etc
430 .endif
431 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
432 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
433 .if defined(NO_ROOT)
434 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
435 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
436 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
437 MTREEFLAGS+=    -W
438 .endif
439 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
440 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
441 IMAKE_MTREE=    MTREE_CMD="mtree ${MTREEFLAGS}"
442 .endif
443
444 # kernel stage
445 KMAKEENV=       ${WMAKEENV}
446 KMAKE=          ${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
570 everything:
571         @echo
572         @echo "--------------------------------------------------------------"
573         @echo ">>> stage 4.4: building everything"
574         @echo "--------------------------------------------------------------"
575         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
576 .if defined(LIB32TMP)
577 build32:
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
627 distribute32 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
644 WMAKE_TGTS=
645 .if !defined(SUBDIR_OVERRIDE)
646 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
647 .endif
648 WMAKE_TGTS+=    _cleanobj _obj _build-tools
649 .if !defined(SUBDIR_OVERRIDE)
650 WMAKE_TGTS+=    _cross-tools
651 .endif
652 WMAKE_TGTS+=    _includes _libraries _depend everything
653 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
654 WMAKE_TGTS+=    build32
655 .endif
656
657 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
658 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
659
660 buildworld_prologue:
661         @echo "--------------------------------------------------------------"
662         @echo ">>> World build started on `LC_ALL=C date`"
663         @echo "--------------------------------------------------------------"
664
665 buildworld_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 #
677 buildenvvars:
678         @echo ${WMAKEENV:Q}
679
680 buildenv:
681         @echo Entering world for ${TARGET_ARCH}:${TARGET}
682         @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
683
684 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
685 toolchain: ${TOOLCHAIN_TGTS}
686 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
687
688 #
689 # installcheck
690 #
691 # Checks to be sure system is ready for installworld/installkernel.
692 #
693 installcheck: _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 #
718 CHECK_UIDS=     auditdistd
719 CHECK_GIDS=     audit
720 .if ${MK_SENDMAIL} != "no"
721 CHECK_UIDS+=    smmsp
722 CHECK_GIDS+=    smmsp
723 .endif
724 .if ${MK_PF} != "no"
725 CHECK_UIDS+=    proxy
726 CHECK_GIDS+=    proxy authpf
727 .endif
728 .if ${MK_UNBOUND} != "no"
729 CHECK_UIDS+=    unbound
730 CHECK_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
758 ITOOLS= [ 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
775 EXTRA_DISTRIBUTIONS=    doc
776 .if ${MK_GAMES} != "no"
777 EXTRA_DISTRIBUTIONS+=   games
778 .endif
779 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
780 EXTRA_DISTRIBUTIONS+=   lib32
781 .endif
782 .if ${MK_TESTS} != "no"
783 EXTRA_DISTRIBUTIONS+=   tests
784 .endif
785
786 DEBUG_DISTRIBUTIONS=
787 .if ${MK_DEBUG_FILES} != "no"
788 DEBUG_DISTRIBUTIONS+=   base ${EXTRA_DISTRIBUTIONS:S,doc,,}
789 .endif
790
791 MTREE_MAGIC?=   mtree 2.0
792
793 distributeworld 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
880 packageworld:
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 #
913 reinstall:
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
928 redistribute:
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
938 distrib-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)
957 NO_KERNELCLEAN= t
958 NO_KERNELCONFIG=        t
959 NO_KERNELDEPEND=        t
960 NO_KERNELOBJ=           t
961 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
962 .if !defined(KERNCONF) && ${KERNFAST} != "1"
963 KERNCONF=${KERNFAST}
964 .endif
965 .endif
966 .if ${TARGET_ARCH} == "powerpc64"
967 KERNCONF?=      GENERIC64
968 .else
969 KERNCONF?=      GENERIC
970 .endif
971 INSTKERNNAME?=  kernel
972
973 KERNSRCDIR?=    ${.CURDIR}/sys
974 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
975 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
976 KERNCONFDIR?=   ${KRNLCONFDIR}
977
978 BUILDKERNELS=
979 INSTALLKERNEL=
980 .for _kernel in ${KERNCONF}
981 .if exists(${KERNCONFDIR}/${_kernel})
982 BUILDKERNELS+=  ${_kernel}
983 .if empty(INSTALLKERNEL)
984 INSTALLKERNEL= ${_kernel}
985 .endif
986 .endif
987 .endfor
988
989 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
990
991 #
992 # buildkernel
993 #
994 # Builds all kernels defined by BUILDKERNELS.
995 #
996 buildkernel:
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 #
1059 installkernel installkernel.debug \
1060 reinstallkernel 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
1072 distributekernel 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
1107 packagekernel:
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 #
1131 doxygen:
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 #
1144 update:
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 #
1173 legacy:
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"
1243 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1244 .endif
1245
1246 # We need to build tblgen 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.
1284 bootstrap-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
1332 build-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 #
1363 kernel-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
1402 cross-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 NXBENV=         MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1422                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1423                 VERSION="${VERSION}"
1424 NXBMAKE=        ${NXBENV} ${MAKE} \
1425                 TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1426                 CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1427                 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1428                 MK_GDB=no MK_TESTS=no \
1429                 SSP_CFLAGS= \
1430                 MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
1431                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1432                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1433                 MK_CLANG_FULL=no MK_LLDB=no
1434
1435 native-xtools: .MAKE
1436         mkdir -p ${OBJTREE}/nxb-bin/usr
1437         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1438             -p ${OBJTREE}/nxb-bin/usr >/dev/null
1439         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1440             -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1441 .for _tool in \
1442     ${_clang_tblgen} \
1443     usr.bin/ar \
1444     ${_binutils} \
1445     ${_cc} \
1446     ${_gcc_tools} \
1447     ${_clang_libs} \
1448     ${_clang} \
1449     usr.bin/awk \
1450     usr.bin/bmake \
1451     usr.bin/lex \
1452     usr.bin/lorder \
1453     usr.bin/sed \
1454     usr.bin/yacc
1455         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1456                 cd ${.CURDIR}/${_tool} && \
1457                 ${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1458                 ${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1459                 ${NXBMAKE} DIRPRFX=${_tool}/ all && \
1460                 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1461 .endfor
1462
1463 #
1464 # hierarchy - ensure that all the needed directories are present
1465 #
1466 hierarchy hier:
1467         cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1468
1469 #
1470 # libraries - build all libraries, and install them under ${DESTDIR}.
1471 #
1472 # The list of libraries with dependents (${_prebuild_libs}) and their
1473 # interdependencies (__L) are built automatically by the
1474 # ${.CURDIR}/tools/make_libdeps.sh script.
1475 #
1476 libraries: .MAKE
1477         cd ${.CURDIR} && \
1478             ${MAKE} -f Makefile.inc1 _prereq_libs && \
1479             ${MAKE} -f Makefile.inc1 _startup_libs && \
1480             ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1481             ${MAKE} -f Makefile.inc1 _generic_libs
1482
1483 #
1484 # static libgcc.a prerequisite for shared libc
1485 #
1486 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1487
1488 # These dependencies are not automatically generated:
1489 #
1490 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1491 # all shared libraries for ELF.
1492 #
1493 _startup_libs=  gnu/lib/csu
1494 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1495 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1496 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1497 _startup_libs+= lib/csu/${MACHINE_ARCH}
1498 .else
1499 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1500 .endif
1501 _startup_libs+= gnu/lib/libgcc
1502 _startup_libs+= lib/libcompiler_rt
1503 _startup_libs+= lib/libc
1504 _startup_libs+= lib/libc_nonshared
1505 .if ${MK_LIBCPLUSPLUS} != "no"
1506 _startup_libs+= lib/libcxxrt
1507 .endif
1508
1509 gnu/lib/libgcc__L: lib/libc__L
1510 gnu/lib/libgcc__L: lib/libc_nonshared__L
1511 .if ${MK_LIBCPLUSPLUS} != "no"
1512 lib/libcxxrt__L: gnu/lib/libgcc__L
1513 .endif
1514
1515 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1516                 ${_kerberos5_lib_libhdb} \
1517                 ${_kerberos5_lib_libheimbase} \
1518                 ${_kerberos5_lib_libheimntlm} \
1519                 ${_kerberos5_lib_libheimsqlite} \
1520                 ${_kerberos5_lib_libheimipcc} \
1521                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1522                 ${_kerberos5_lib_libroken} \
1523                 ${_kerberos5_lib_libwind} \
1524                 ${_lib_atf} \
1525                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1526                 lib/libelf lib/libexpat \
1527                 ${_lib_libgssapi} \
1528                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1529                 ${_lib_libcapsicum} \
1530                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1531                 lib/libopie lib/libpam ${_lib_libthr} \
1532                 lib/libradius lib/libsbuf lib/libtacplus \
1533                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1534                 ${_cddl_lib_libavl} \
1535                 ${_cddl_lib_libzfs_core} \
1536                 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1537                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1538                 ${_secure_lib_libssh} ${_secure_lib_libssl}
1539 .if ${MK_GNUCXX} != "no"
1540 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1541 gnu/lib/libstdc++__L: lib/msun__L
1542 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1543 .endif
1544
1545 .if defined(WITH_ATF) || ${MK_TESTS} != "no"
1546 .if !defined(WITH_ATF)
1547 # Ensure that the ATF libraries will be built during make libraries, even
1548 # though they will have WITHOUT_TESTS
1549 MAKE+=          -DWITH_ATF
1550 .endif
1551 _lib_atf=       lib/atf
1552 .endif
1553
1554 .if ${MK_LIBTHR} != "no"
1555 _lib_libthr=    lib/libthr
1556 .endif
1557
1558 .if ${MK_OFED} != "no"
1559 _ofed_lib=      contrib/ofed/usr.lib/
1560 .endif
1561
1562 .if ${MK_CASPER} != "no"
1563 _lib_libcapsicum=lib/libcapsicum
1564 .endif
1565
1566 lib/libcapsicum__L: lib/libnv__L
1567 lib/libpjdlog__L: lib/libutil__L
1568
1569 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1570 .for _DIR in ${LOCAL_LIB_DIRS}
1571 .if exists(${.CURDIR}/${_DIR}/Makefile)
1572 _generic_libs+= ${_DIR}
1573 .endif
1574 .endfor
1575
1576 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1577
1578 .if ${MK_CDDL} != "no"
1579 _cddl_lib_libumem= cddl/lib/libumem
1580 _cddl_lib_libnvpair= cddl/lib/libnvpair
1581 _cddl_lib_libavl= cddl/lib/libavl
1582 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1583 _cddl_lib= cddl/lib
1584 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1585 .endif
1586
1587 .if ${MK_CRYPT} != "no"
1588 .if ${MK_OPENSSL} != "no"
1589 _secure_lib_libcrypto= secure/lib/libcrypto
1590 _secure_lib_libssl= secure/lib/libssl
1591 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1592 .if ${MK_LDNS} != "no"
1593 _lib_libldns= lib/libldns
1594 lib/libldns__L: secure/lib/libcrypto__L
1595 .endif
1596 .if ${MK_OPENSSH} != "no"
1597 _secure_lib_libssh= secure/lib/libssh
1598 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1599 .if ${MK_LDNS} != "no"
1600 secure/lib/libssh__L: lib/libldns__L
1601 .endif
1602 .if ${MK_KERBEROS_SUPPORT} != "no"
1603 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1604     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1605     lib/libmd__L kerberos5/lib/libroken__L
1606 .endif
1607 .endif
1608 .endif
1609 _secure_lib=    secure/lib
1610 .endif
1611
1612 .if ${MK_KERBEROS} != "no"
1613 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1614 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1615     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1616     kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1617 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1618     kerberos5/lib/libroken__L lib/libcom_err__L
1619 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1620     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1621 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1622     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1623     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1624     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1625 kerberos5/lib/libroken__L: lib/libcrypt__L
1626 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1627 kerberos5/lib/libheimbase__L: lib/libthr__L
1628 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1629 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1630 .endif
1631
1632 .if ${MK_GSSAPI} != "no"
1633 _lib_libgssapi= lib/libgssapi
1634 .endif
1635
1636 .if ${MK_KERBEROS} != "no"
1637 _kerberos5_lib= kerberos5/lib
1638 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1639 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1640 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1641 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1642 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1643 _kerberos5_lib_libroken= kerberos5/lib/libroken
1644 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1645 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1646 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1647 _kerberos5_lib_libwind= kerberos5/lib/libwind
1648 _libcom_err= lib/libcom_err
1649 .endif
1650
1651 .if ${MK_NIS} != "no"
1652 _lib_libypclnt= lib/libypclnt
1653 .endif
1654
1655 .if ${MK_OPENSSL} == "no"
1656 lib/libradius__L: lib/libmd__L
1657 .endif
1658
1659 .for _lib in ${_prereq_libs}
1660 ${_lib}__PL: .PHONY .MAKE
1661 .if exists(${.CURDIR}/${_lib})
1662         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1663                 cd ${.CURDIR}/${_lib} && \
1664                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1665                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1666                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1667                     DIRPRFX=${_lib}/ all && \
1668                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1669                     DIRPRFX=${_lib}/ install
1670 .endif
1671 .endfor
1672
1673 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1674 ${_lib}__L: .PHONY .MAKE
1675 .if exists(${.CURDIR}/${_lib})
1676         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1677                 cd ${.CURDIR}/${_lib} && \
1678                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1679                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1680                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1681                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1682 .endif
1683 .endfor
1684
1685 # libpam is special: we need to build static PAM modules before
1686 # static PAM library, and dynamic PAM library before dynamic PAM
1687 # modules.
1688 lib/libpam__L: .PHONY .MAKE
1689         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1690                 cd ${.CURDIR}/lib/libpam && \
1691                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1692                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1693                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1694                     -D_NO_LIBPAM_SO_YET all && \
1695                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1696                     -D_NO_LIBPAM_SO_YET install
1697
1698 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1699 _startup_libs: ${_startup_libs:S/$/__L/}
1700 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1701 _generic_libs: ${_generic_libs:S/$/__L/}
1702
1703 .for __target in all clean cleandepend cleandir depend includes obj
1704 .for entry in ${SUBDIR}
1705 ${entry}.${__target}__D: .PHONY .MAKE
1706         ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1707                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1708                 edir=${entry}.${MACHINE_ARCH}; \
1709                 cd ${.CURDIR}/$${edir}; \
1710         else \
1711                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1712                 edir=${entry}; \
1713                 cd ${.CURDIR}/$${edir}; \
1714         fi; \
1715         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1716 .endfor
1717 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1718 .endfor
1719
1720 .include <bsd.subdir.mk>
1721
1722 .if make(check-old) || make(check-old-dirs) || \
1723     make(check-old-files) || make(check-old-libs) || \
1724     make(delete-old) || make(delete-old-dirs) || \
1725     make(delete-old-files) || make(delete-old-libs)
1726
1727 #
1728 # check for / delete old files section
1729 #
1730
1731 .include "ObsoleteFiles.inc"
1732
1733 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1734 else you can not start such an application. Consult UPDATING for more \
1735 information regarding how to cope with the removal/revision bump of a \
1736 specific library."
1737
1738 .if !defined(BATCH_DELETE_OLD_FILES)
1739 RM_I=-i
1740 .else
1741 RM_I=-v
1742 .endif
1743
1744 delete-old-files:
1745         @echo ">>> Removing old files (only deletes safe to delete libs)"
1746 # Ask for every old file if the user really wants to remove it.
1747 # It's annoying, but better safe than sorry.
1748 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1749 # argument list will get too long. Using .for/.endfor make "loops" will make
1750 # the Makefile parser segfault.
1751         @exec 3<&0; \
1752         cd ${.CURDIR}; \
1753         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1754             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1755         while read file; do \
1756                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1757                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1758                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1759                 fi; \
1760         done
1761 # Remove catpages without corresponding manpages.
1762         @exec 3<&0; \
1763         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1764         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1765         while read catpage; do \
1766                 read manpage; \
1767                 if [ ! -e "$${manpage}" ]; then \
1768                         rm ${RM_I} $${catpage} <&3; \
1769                 fi; \
1770         done
1771         @echo ">>> Old files removed"
1772
1773 check-old-files:
1774         @echo ">>> Checking for old files"
1775         @cd ${.CURDIR}; \
1776         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1777             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1778         while read file; do \
1779                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1780                         echo "${DESTDIR}/$${file}"; \
1781                 fi; \
1782         done
1783 # Check for catpages without corresponding manpages.
1784         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1785         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1786         while read catpage; do \
1787                 read manpage; \
1788                 if [ ! -e "$${manpage}" ]; then \
1789                         echo $${catpage}; \
1790                 fi; \
1791         done
1792
1793 delete-old-libs:
1794         @echo ">>> Removing old libraries"
1795         @echo "${OLD_LIBS_MESSAGE}" | fmt
1796         @exec 3<&0; \
1797         cd ${.CURDIR}; \
1798         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1799             -V OLD_LIBS | xargs -n1 | \
1800         while read file; do \
1801                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1802                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1803                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1804                 fi; \
1805                 for ext in debug symbols; do \
1806                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1807                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1808                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1809                               <&3; \
1810                   fi; \
1811                 done; \
1812         done
1813         @echo ">>> Old libraries removed"
1814
1815 check-old-libs:
1816         @echo ">>> Checking for old libraries"
1817         @cd ${.CURDIR}; \
1818         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1819             -V OLD_LIBS | xargs -n1 | \
1820         while read file; do \
1821                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1822                         echo "${DESTDIR}/$${file}"; \
1823                 fi; \
1824                 for ext in debug symbols; do \
1825                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1826                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1827                   fi; \
1828                 done; \
1829         done
1830
1831 delete-old-dirs:
1832         @echo ">>> Removing old directories"
1833         @cd ${.CURDIR}; \
1834         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1835             -V OLD_DIRS | xargs -n1 | sort -r | \
1836         while read dir; do \
1837                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1838                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1839                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1840                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1841                 fi; \
1842         done
1843         @echo ">>> Old directories removed"
1844
1845 check-old-dirs:
1846         @echo ">>> Checking for old directories"
1847         @cd ${.CURDIR}; \
1848         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1849             -V OLD_DIRS | xargs -n1 | \
1850         while read dir; do \
1851                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1852                         echo "${DESTDIR}/$${dir}"; \
1853                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1854                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1855                 fi; \
1856         done
1857
1858 delete-old: delete-old-files delete-old-dirs
1859         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1860
1861 check-old: check-old-files check-old-libs check-old-dirs
1862         @echo "To remove old files and directories run '${MAKE} delete-old'."
1863         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1864
1865 .endif
1866
1867 #
1868 # showconfig - show build configuration.
1869 #
1870 showconfig:
1871         @${MAKE} -n -f src.opts.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1872
1873 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1874 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1875
1876 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1877 .if exists(${KERNCONFDIR}/${KERNCONF})
1878 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1879         '${KERNCONFDIR}/${KERNCONF}' ; echo
1880 .endif
1881 .endif
1882
1883 .endif
1884
1885 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1886 DTBOUTPUTPATH= ${.CURDIR}
1887 .endif
1888
1889 #
1890 # Build 'standalone' Device Tree Blob
1891 #
1892 builddtb:
1893         @PATH=${TMPPATH} MACHINE=${TARGET} \
1894         ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
1895             "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
1896
1897 ###############
1898
1899 .if defined(TARGET) && defined(TARGET_ARCH)
1900
1901 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
1902 XDEV_CPUTYPE?=${CPUTYPE}
1903 .else
1904 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1905 .endif
1906
1907 NOFUN=-DNO_FSCHG MK_HTML=no MK_INFO=no -DNO_LINT \
1908         MK_MAN=no MK_NLS=no MK_PROFILE=no \
1909         MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
1910         TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
1911         CPUTYPE=${XDEV_CPUTYPE}
1912
1913 XDDIR=${TARGET_ARCH}-freebsd
1914 XDTP?=/usr/${XDDIR}
1915 .if ${XDTP:N/*}
1916 .error XDTP variable should be an absolute path
1917 .endif
1918
1919 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1920         INSTALL="sh ${.CURDIR}/tools/install.sh"
1921 CDENV= ${CDBENV} \
1922         _SHLIBDIRPREFIX=${XDDESTDIR} \
1923         TOOLS_PREFIX=${XDTP}
1924 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1925         --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
1926         -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
1927 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
1928         CPP="${CPP} ${CD2CFLAGS}" \
1929         MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
1930
1931 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1932 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1933 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1934 XDDESTDIR=${DESTDIR}/${XDTP}
1935 .if !defined(OSREL)
1936 OSREL!= uname -r | sed -e 's/[-(].*//'
1937 .endif
1938
1939 .ORDER: xdev-build xdev-install xdev-links
1940 xdev: xdev-build xdev-install
1941
1942 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1943 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1944
1945 _xb-worldtmp:
1946         mkdir -p ${CDTMP}/usr
1947         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1948             -p ${CDTMP}/usr >/dev/null
1949
1950 _xb-bootstrap-tools:
1951 .for _tool in \
1952     ${_clang_tblgen}
1953         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1954         cd ${.CURDIR}/${_tool} && \
1955         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1956         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1957         ${CDMAKE} DIRPRFX=${_tool}/ all && \
1958         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1959 .endfor
1960
1961 _xb-build-tools:
1962         ${_+_}@cd ${.CURDIR}; \
1963         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1964
1965 _xb-cross-tools:
1966 .for _tool in \
1967     ${_binutils} \
1968     usr.bin/ar \
1969     ${_clang_libs} \
1970     ${_clang} \
1971     ${_cc}
1972         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1973         cd ${.CURDIR}/${_tool} && \
1974         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1975         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1976         ${CDMAKE} DIRPRFX=${_tool}/ all
1977 .endfor
1978
1979 _xi-mtree:
1980         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1981         mkdir -p ${XDDESTDIR}
1982         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1983             -p ${XDDESTDIR} >/dev/null
1984         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1985             -p ${XDDESTDIR}/usr >/dev/null
1986         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1987             -p ${XDDESTDIR}/usr/include >/dev/null
1988 .if ${MK_TESTS} != "no"
1989         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1990             -p ${XDDESTDIR}/usr >/dev/null
1991 .endif
1992
1993 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
1994 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
1995
1996 _xi-cross-tools:
1997         @echo "_xi-cross-tools"
1998 .for _tool in \
1999     ${_binutils} \
2000     usr.bin/ar \
2001     ${_clang_libs} \
2002     ${_clang} \
2003     ${_cc}
2004         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2005         cd ${.CURDIR}/${_tool}; \
2006         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2007 .endfor
2008
2009 _xi-includes:
2010         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2011                 DESTDIR=${XDDESTDIR}
2012
2013 _xi-libraries:
2014         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2015                 DESTDIR=${XDDESTDIR}
2016
2017 xdev-links:
2018         ${_+_}cd ${XDDESTDIR}/usr/bin; \
2019         mkdir -p ../../../../usr/bin; \
2020                 for i in *; do \
2021                         ln -sf ../../${XDTP}/usr/bin/$$i \
2022                             ../../../../usr/bin/${XDDIR}-$$i; \
2023                         ln -sf ../../${XDTP}/usr/bin/$$i \
2024                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2025                 done
2026 .else
2027 xdev xdev-build xdev-install xdev-links:
2028         @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2029 .endif