Merge OpenSSL 1.0.2f.
[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:${SHELL})
31 #       WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 #       KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 #       SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 #           All libraries and includes, and some build tools will still build.
35
36 #
37 # The intended user-driven targets are:
38 # buildworld  - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # doxygen     - build API documentation of the kernel
41 # update      - convenient way to update your source tree (eg: svn/svnup)
42 #
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk.  These include:
45 #               obj depend all install clean cleandepend cleanobj
46
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
49 .endif
50
51 LOCALBASE?=     /usr/local
52
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
58 .endif
59 .include <bsd.compiler.mk>              # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk" 
61
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable.  For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries.  More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though.  The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
70 SRCDIR?=        ${.CURDIR}
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
73 .else
74 SUBDIR= lib libexec
75 .if make(install*)
76 # Ensure libraries are installed before progressing.
77 SUBDIR+=.WAIT
78 .endif
79 SUBDIR+=bin
80 .if ${MK_CDDL} != "no"
81 SUBDIR+=cddl
82 .endif
83 SUBDIR+=gnu include
84 .if ${MK_KERBEROS} != "no"
85 SUBDIR+=kerberos5
86 .endif
87 .if ${MK_RESCUE} != "no"
88 SUBDIR+=rescue
89 .endif
90 SUBDIR+=sbin
91 .if ${MK_CRYPT} != "no"
92 SUBDIR+=secure
93 .endif
94 .if !defined(NO_SHARE)
95 SUBDIR+=share
96 .endif
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
99 SUBDIR+=        tests
100 .endif
101 .if ${MK_OFED} != "no"
102 SUBDIR+=contrib/ofed
103 .endif
104
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
109 SUBDIR+=        ${_DIR}
110 .endif
111 .endfor
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory.  This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+=    ${LOCAL_LIB_DIRS:M${_DIR}*}
117 .endfor
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
120 SUBDIR+=        ${_DIR}
121 .else
122 .warning ${_DIR} not added to SUBDIR list.  See UPDATING 20141121.
123 .endif
124 .endfor
125
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man.  This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
129 # installed.
130 .if make(install*)
131 SUBDIR+=.WAIT
132 .endif
133 SUBDIR+=etc
134
135 .endif  # !empty(SUBDIR_OVERRIDE)
136
137 .if defined(NOCLEAN)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
139 NO_CLEAN=       ${NOCLEAN}
140 .endif
141 .if defined(NO_CLEANDIR)
142 CLEANDIR=       clean cleandepend
143 .else
144 CLEANDIR=       cleandir
145 .endif
146
147 LOCAL_TOOL_DIRS?=
148 PACKAGEDIR?=    ${DESTDIR}/${DISTDIR}
149
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
152 .else
153 BUILDENV_SHELL?=/bin/sh
154 .endif
155
156 SVN?=           /usr/local/bin/svn
157 SVNFLAGS?=      -r HEAD
158
159 MAKEOBJDIRPREFIX?=      /usr/obj
160 .if !defined(OSRELDATE)
161 .if exists(/usr/include/osreldate.h)
162 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
163                 /usr/include/osreldate.h
164 .else
165 OSRELDATE=      0
166 .endif
167 .export OSRELDATE
168 .endif
169
170 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
171 .if !defined(VERSION) && !make(showconfig)
172 REVISION!=      ${MAKE} -C ${SRCDIR}/release -V REVISION
173 BRANCH!=        ${MAKE} -C ${SRCDIR}/release -V BRANCH
174 SRCRELDATE!=    awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
175                 ${SRCDIR}/sys/sys/param.h
176 VERSION=        FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
177 .export VERSION
178 .endif
179
180 KNOWN_ARCHES?=  aarch64/arm64 \
181                 amd64 \
182                 arm \
183                 armeb/arm \
184                 armv6/arm \
185                 armv6hf/arm \
186                 i386 \
187                 i386/pc98 \
188                 mips \
189                 mipsel/mips \
190                 mips64el/mips \
191                 mips64/mips \
192                 mipsn32el/mips \
193                 mipsn32/mips \
194                 powerpc \
195                 powerpc64/powerpc \
196                 riscv64/riscv \
197                 sparc64
198
199 .if ${TARGET} == ${TARGET_ARCH}
200 _t=             ${TARGET}
201 .else
202 _t=             ${TARGET_ARCH}/${TARGET}
203 .endif
204 .for _t in ${_t}
205 .if empty(KNOWN_ARCHES:M${_t})
206 .error Unknown target ${TARGET_ARCH}:${TARGET}.
207 .endif
208 .endfor
209
210 .if ${TARGET} == ${MACHINE}
211 TARGET_CPUTYPE?=${CPUTYPE}
212 .else
213 TARGET_CPUTYPE?=
214 .endif
215
216 .if !empty(TARGET_CPUTYPE)
217 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
218 .else
219 _TARGET_CPUTYPE=dummy
220 .endif
221 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
222 .if !make(showconfig)
223 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
224                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
225 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
226 .error CPUTYPE global should be set with ?=.
227 .endif
228 .endif
229 .if make(buildworld)
230 BUILD_ARCH!=    uname -p
231 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
232 .error To cross-build, set TARGET_ARCH.
233 .endif
234 .endif
235 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
236 OBJTREE=        ${MAKEOBJDIRPREFIX}
237 .else
238 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
239 .endif
240 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
241 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
242 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
243 STRICTTMPPATH=  ${BPATH}:${XPATH}
244 TMPPATH=        ${STRICTTMPPATH}:${PATH}
245
246 #
247 # Avoid running mktemp(1) unless actually needed.
248 # It may not be functional, e.g., due to new ABI
249 # when in the middle of installing over this system.
250 #
251 .if make(distributeworld) || make(installworld)
252 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
253 .endif
254
255 #
256 # Building a world goes through the following stages
257 #
258 # 1. legacy stage [BMAKE]
259 #       This stage is responsible for creating compatibility
260 #       shims that are needed by the bootstrap-tools,
261 #       build-tools and cross-tools stages. These are generally
262 #       APIs that tools from one of those three stages need to
263 #       build that aren't present on the host.
264 # 1. bootstrap-tools stage [BMAKE]
265 #       This stage is responsible for creating programs that
266 #       are needed for backward compatibility reasons. They
267 #       are not built as cross-tools.
268 # 2. build-tools stage [TMAKE]
269 #       This stage is responsible for creating the object
270 #       tree and building any tools that are needed during
271 #       the build process. Some programs are listed during
272 #       this phase because they build binaries to generate
273 #       files needed to build these programs. This stage also
274 #       builds the 'build-tools' target rather than 'all'.
275 # 3. cross-tools stage [XMAKE]
276 #       This stage is responsible for creating any tools that
277 #       are needed for building the system. A cross-compiler is one
278 #       of them. This differs from build tools in two ways:
279 #       1. the 'all' target is built rather than 'build-tools'
280 #       2. these tools are installed into TMPPATH for stage 4.
281 # 4. world stage [WMAKE]
282 #       This stage actually builds the world.
283 # 5. install stage (optional) [IMAKE]
284 #       This stage installs a previously built world.
285 #
286
287 BOOTSTRAPPING?= 0
288
289 # Common environment for world related stages
290 CROSSENV+=      MAKEOBJDIRPREFIX=${OBJTREE} \
291                 MACHINE_ARCH=${TARGET_ARCH} \
292                 MACHINE=${TARGET} \
293                 CPUTYPE=${TARGET_CPUTYPE}
294 .if ${MK_GROFF} != "no"
295 CROSSENV+=      GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
296                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
297                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
298 .endif
299 .if defined(TARGET_CFLAGS)
300 CROSSENV+=      ${TARGET_CFLAGS}
301 .endif
302
303 # bootstrap-tools stage
304 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
305                 PATH=${BPATH}:${PATH} \
306                 WORLDTMP=${WORLDTMP} \
307                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
308 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
309 BSARGS=         DESTDIR= \
310                 BOOTSTRAPPING=${OSRELDATE} \
311                 SSP_CFLAGS= \
312                 MK_HTML=no NO_LINT=yes MK_MAN=no \
313                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
314                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
315                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
316                 MK_LLDB=no MK_TESTS=no \
317                 MK_INCLUDES=yes
318
319 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
320                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
321                 ${BSARGS}
322
323 # build-tools stage
324 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
325                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
326                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
327                 DESTDIR= \
328                 BOOTSTRAPPING=${OSRELDATE} \
329                 SSP_CFLAGS= \
330                 -DNO_LINT \
331                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
332                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
333                 MK_LLDB=no MK_TESTS=no
334
335 # cross-tools stage
336 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
337                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
338                 MK_GDB=no MK_TESTS=no
339
340 # kernel-tools stage
341 KTMAKEENV=      INSTALL="sh ${.CURDIR}/tools/install.sh" \
342                 PATH=${BPATH}:${PATH} \
343                 WORLDTMP=${WORLDTMP}
344 KTMAKE=         TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
345                 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
346                 DESTDIR= \
347                 BOOTSTRAPPING=${OSRELDATE} \
348                 SSP_CFLAGS= \
349                 MK_HTML=no -DNO_LINT MK_MAN=no \
350                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
351                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
352
353 # world stage
354 WMAKEENV=       ${CROSSENV} \
355                 _LDSCRIPTROOT= \
356                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
357                 PATH=${TMPPATH}
358
359 # make hierarchy
360 HMAKE=          PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
361 .if defined(NO_ROOT)
362 HMAKE+=         PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
363 .endif
364
365 .if defined(CROSS_TOOLCHAIN_PREFIX)
366 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
367 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
368 .endif
369
370 # If we do not have a bootstrap binutils (because the in-tree one does not
371 # support the target architecture), provide a default cross-binutils prefix.
372 # This allows aarch64 builds, for example, to automatically use the
373 # aarch64-binutils port or package.
374 .if !make(showconfig)
375 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
376     !defined(CROSS_BINUTILS_PREFIX)
377 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
378 .if !exists(${CROSS_BINUTILS_PREFIX})
379 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
380 .endif
381 .endif
382 .endif
383
384 XCOMPILERS=     CC CXX CPP
385 .for COMPILER in ${XCOMPILERS}
386 .if defined(CROSS_COMPILER_PREFIX)
387 X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
388 .else
389 X${COMPILER}?=  ${${COMPILER}}
390 .endif
391 .endfor
392 XBINUTILS=      AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
393 .for BINUTIL in ${XBINUTILS}
394 .if defined(CROSS_BINUTILS_PREFIX) && \
395     exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
396 X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
397 .else
398 X${BINUTIL}?=   ${${BINUTIL}}
399 .endif
400 .endfor
401 CROSSENV+=      CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
402                 DEPFLAGS="${DEPFLAGS}" \
403                 CPP="${XCPP} ${XCFLAGS}" \
404                 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
405                 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
406                 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
407                 SIZE="${XSIZE}"
408
409 .if ${XCC:N${CCACHE_BIN}:M/*}
410 .if defined(CROSS_BINUTILS_PREFIX)
411 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
412 # directory, but the compiler will look in the right place for it's
413 # tools so we don't need to tell it where to look.
414 .if exists(${CROSS_BINUTILS_PREFIX})
415 BFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
416 .endif
417 .else
418 BFLAGS+=        -B${WORLDTMP}/usr/bin
419 .endif
420 .if ${TARGET} == "arm"
421 .if ${TARGET_ARCH:M*hf*} != ""
422 TARGET_ABI=     gnueabihf
423 .else
424 TARGET_ABI=     gnueabi
425 .endif
426 .endif
427 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
428 XCFLAGS+=       -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
429 XCXXFLAGS+=     -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
430 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
431 # due to CXX="${XCXX} ${XCXXFLAGS}".  bsd.dep.mk does use CXXFLAGS when
432 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
433 DEPFLAGS+=      -I${WORLDTMP}/usr/include/c++/v1
434 .else
435 TARGET_ABI?=    unknown
436 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
437 XCFLAGS+=       -target ${TARGET_TRIPLE}
438 .endif
439 XCFLAGS+=       --sysroot=${WORLDTMP} ${BFLAGS}
440 XCXXFLAGS+=     --sysroot=${WORLDTMP} ${BFLAGS}
441 .else
442 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
443 BFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
444 XCFLAGS+=       ${BFLAGS}
445 XCXXFLAGS+=     ${BFLAGS}
446 .endif
447 .endif # ${XCC:M/*}
448
449 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
450
451 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
452 # 32 bit world
453 LIB32_OBJTREE=  ${OBJTREE}${.CURDIR}/world32
454 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
455
456 .if ${TARGET_ARCH} == "amd64"
457 .if empty(TARGET_CPUTYPE)
458 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
459 .else
460 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
461 .endif
462 LIB32WMAKEENV=  MACHINE=i386 MACHINE_ARCH=i386 \
463                 MACHINE_CPU="i686 mmx sse sse2"
464 LIB32WMAKEFLAGS=        \
465                 AS="${XAS} --32" \
466                 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
467                 OBJCOPY="${XOBJCOPY}"
468
469 .elif ${TARGET_ARCH} == "powerpc64"
470 .if empty(TARGET_CPUTYPE)
471 LIB32CPUFLAGS=  -mcpu=powerpc
472 .else
473 LIB32CPUFLAGS=  -mcpu=${TARGET_CPUTYPE}
474 .endif
475 LIB32WMAKEENV=  MACHINE=powerpc MACHINE_ARCH=powerpc
476 LIB32WMAKEFLAGS=        \
477                 LD="${XLD} -m elf32ppc_fbsd" \
478                 OBJCOPY="${XOBJCOPY}"
479 .endif
480
481
482 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
483                 -isystem ${LIB32TMP}/usr/include/ \
484                 -L${LIB32TMP}/usr/lib32 \
485                 -B${LIB32TMP}/usr/lib32
486 .if ${XCC:N${CCACHE_BIN}:M/*}
487 LIB32FLAGS+=            --sysroot=${WORLDTMP}
488 .endif
489
490 # Yes, the flags are redundant.
491 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
492                 _LDSCRIPTROOT=${LIB32TMP} \
493                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
494                 PATH=${TMPPATH} \
495                 LIBDIR=/usr/lib32 \
496                 SHLIBDIR=/usr/lib32 \
497                 DTRACE="${DTRACE} -32"
498 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
499                 CXX="${XCXX} ${LIB32FLAGS}" \
500                 DESTDIR=${LIB32TMP} \
501                 -DCOMPAT_32BIT \
502                 -DLIBRARIES_ONLY \
503                 -DNO_CPU_CFLAGS \
504                 MK_CTF=no \
505                 -DNO_LINT \
506                 MK_TESTS=no
507
508 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
509                 MK_MAN=no MK_HTML=no
510 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
511                 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
512 .endif
513
514 IMAKEENV=       ${CROSSENV:N_LDSCRIPTROOT=*}
515 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
516                 ${IMAKE_INSTALL} ${IMAKE_MTREE}
517 .if empty(.MAKEFLAGS:M-n)
518 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
519                 LD_LIBRARY_PATH=${INSTALLTMP} \
520                 PATH_LOCALE=${INSTALLTMP}/locale
521 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
522 .else
523 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
524 .endif
525 .if defined(DB_FROM_SRC)
526 INSTALLFLAGS+=  -N ${.CURDIR}/etc
527 MTREEFLAGS+=    -N ${.CURDIR}/etc
528 .endif
529 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
530 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
531 .if defined(NO_ROOT)
532 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
533 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
534 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
535 MTREEFLAGS+=    -W
536 .endif
537 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
538 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
539 IMAKE_MTREE=    MTREE_CMD="mtree ${MTREEFLAGS}"
540 .endif
541
542 # kernel stage
543 KMAKEENV=       ${WMAKEENV}
544 KMAKE=          ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
545
546 #
547 # buildworld
548 #
549 # Attempt to rebuild the entire system, with reasonable chance of
550 # success, regardless of how old your existing system is.
551 #
552 _worldtmp: .PHONY
553 .if ${.CURDIR:C/[^,]//g} != ""
554 #       The m4 build of sendmail files doesn't like it if ',' is used
555 #       anywhere in the path of it's files.
556         @echo
557         @echo "*** Error: path to source tree contains a comma ','"
558         @echo
559         false
560 .endif
561         @echo
562         @echo "--------------------------------------------------------------"
563         @echo ">>> Rebuilding the temporary build tree"
564         @echo "--------------------------------------------------------------"
565 .if !defined(NO_CLEAN)
566         rm -rf ${WORLDTMP}
567 .if defined(LIB32TMP)
568         rm -rf ${LIB32TMP}
569 .endif
570 .else
571         rm -rf ${WORLDTMP}/legacy/usr/include
572 #       XXX - These can depend on any header file.
573         rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
574         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
575 .endif
576 .for _dir in \
577     lib usr legacy/bin legacy/usr
578         mkdir -p ${WORLDTMP}/${_dir}
579 .endfor
580         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
581             -p ${WORLDTMP}/legacy/usr >/dev/null
582 .if ${MK_GROFF} != "no"
583         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
584             -p ${WORLDTMP}/legacy/usr >/dev/null
585 .endif
586         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
587             -p ${WORLDTMP}/usr >/dev/null
588         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
589             -p ${WORLDTMP}/usr/include >/dev/null
590         ln -sf ${.CURDIR}/sys ${WORLDTMP}
591 .if ${MK_DEBUG_FILES} != "no"
592         # We could instead disable debug files for these build stages
593         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
594             -p ${WORLDTMP}/legacy/usr/lib >/dev/null
595         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
596             -p ${WORLDTMP}/usr/lib >/dev/null
597 .endif
598 .if ${MK_LIB32} != "no"
599         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
600             -p ${WORLDTMP}/usr >/dev/null
601 .if ${MK_DEBUG_FILES} != "no"
602         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
603             -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
604         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
605             -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
606 .endif
607 .endif
608 .if ${MK_TESTS} != "no"
609         mkdir -p ${WORLDTMP}${TESTSBASE}
610         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
611             -p ${WORLDTMP}${TESTSBASE} >/dev/null
612 .if ${MK_DEBUG_FILES} != "no"
613         mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
614         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
615             -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
616 .endif
617 .endif
618 .for _mtree in ${LOCAL_MTREE}
619         mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
620 .endfor
621 _legacy:
622         @echo
623         @echo "--------------------------------------------------------------"
624         @echo ">>> stage 1.1: legacy release compatibility shims"
625         @echo "--------------------------------------------------------------"
626         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
627 _bootstrap-tools:
628         @echo
629         @echo "--------------------------------------------------------------"
630         @echo ">>> stage 1.2: bootstrap tools"
631         @echo "--------------------------------------------------------------"
632         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
633 _cleanobj:
634 .if !defined(NO_CLEAN)
635         @echo
636         @echo "--------------------------------------------------------------"
637         @echo ">>> stage 2.1: cleaning up the object tree"
638         @echo "--------------------------------------------------------------"
639         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
640 .if defined(LIB32TMP)
641         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
642 .endif
643 .endif
644 _obj:
645         @echo
646         @echo "--------------------------------------------------------------"
647         @echo ">>> stage 2.2: rebuilding the object tree"
648         @echo "--------------------------------------------------------------"
649         ${_+_}cd ${.CURDIR}; ${WMAKE} obj
650 _build-tools:
651         @echo
652         @echo "--------------------------------------------------------------"
653         @echo ">>> stage 2.3: build tools"
654         @echo "--------------------------------------------------------------"
655         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
656 _cross-tools:
657         @echo
658         @echo "--------------------------------------------------------------"
659         @echo ">>> stage 3: cross tools"
660         @echo "--------------------------------------------------------------"
661         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
662         ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
663 _includes:
664         @echo
665         @echo "--------------------------------------------------------------"
666         @echo ">>> stage 4.1: building includes"
667         @echo "--------------------------------------------------------------"
668 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
669 # headers from default SUBDIR.  Do SUBDIR_OVERRIDE includes last.
670         ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
671             includes
672 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
673         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
674 .endif
675 _libraries:
676         @echo
677         @echo "--------------------------------------------------------------"
678         @echo ">>> stage 4.2: building libraries"
679         @echo "--------------------------------------------------------------"
680         ${_+_}cd ${.CURDIR}; \
681             ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
682             MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
683 _depend:
684         @echo
685         @echo "--------------------------------------------------------------"
686         @echo ">>> stage 4.3: make dependencies"
687         @echo "--------------------------------------------------------------"
688         ${_+_}cd ${.CURDIR}; ${WMAKE} depend
689 everything:
690         @echo
691         @echo "--------------------------------------------------------------"
692         @echo ">>> stage 4.4: building everything"
693         @echo "--------------------------------------------------------------"
694         ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
695 .if defined(LIB32TMP)
696 build32: .PHONY
697         @echo
698         @echo "--------------------------------------------------------------"
699         @echo ">>> stage 5.1: building 32 bit shim libraries"
700         @echo "--------------------------------------------------------------"
701         mkdir -p ${LIB32TMP}/usr/include
702         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
703             -p ${LIB32TMP}/usr >/dev/null
704         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
705             -p ${LIB32TMP}/usr/include >/dev/null
706         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
707             -p ${LIB32TMP}/usr >/dev/null
708 .if ${MK_DEBUG_FILES} != "no"
709         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
710             -p ${LIB32TMP}/usr/lib >/dev/null
711         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
712             -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
713 .endif
714         mkdir -p ${WORLDTMP}
715         ln -sf ${.CURDIR}/sys ${WORLDTMP}
716 .for _t in obj includes
717         ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
718         ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
719 .if ${MK_CDDL} != "no"
720         ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
721 .endif
722         ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
723 .if ${MK_CRYPT} != "no"
724         ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
725 .endif
726 .if ${MK_KERBEROS} != "no"
727         ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
728 .endif
729 .endfor
730 .for _dir in usr.bin/lex/lib
731         ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
732 .endfor
733 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
734         ${_+_}cd ${.CURDIR}/${_dir}; \
735             WORLDTMP=${WORLDTMP} \
736             MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
737             MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
738             DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
739             build-tools
740 .endfor
741         ${_+_}cd ${.CURDIR}; \
742             ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
743 .for _t in obj depend all
744         ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
745             -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
746         ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
747             DIRPRFX=usr.bin/ldd ${_t}
748 .endfor
749
750 distribute32 install32: .MAKE .PHONY
751         ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
752 .if ${MK_CDDL} != "no"
753         ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
754 .endif
755         ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
756 .if ${MK_CRYPT} != "no"
757         ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
758 .endif
759 .if ${MK_KERBEROS} != "no"
760         ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
761 .endif
762         ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
763             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
764         ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
765             ${.TARGET:S/32$//}
766 .endif
767
768 WMAKE_TGTS=
769 WMAKE_TGTS+=    _worldtmp _legacy
770 .if empty(SUBDIR_OVERRIDE)
771 WMAKE_TGTS+=    _bootstrap-tools
772 .endif
773 WMAKE_TGTS+=    _cleanobj _obj _build-tools _cross-tools
774 WMAKE_TGTS+=    _includes _libraries _depend everything
775 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
776 WMAKE_TGTS+=    build32
777 .endif
778
779 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
780 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
781
782 buildworld_prologue:
783         @echo "--------------------------------------------------------------"
784         @echo ">>> World build started on `LC_ALL=C date`"
785         @echo "--------------------------------------------------------------"
786
787 buildworld_epilogue:
788         @echo
789         @echo "--------------------------------------------------------------"
790         @echo ">>> World build completed on `LC_ALL=C date`"
791         @echo "--------------------------------------------------------------"
792
793 #
794 # We need to have this as a target because the indirection between Makefile
795 # and Makefile.inc1 causes the correct PATH to be used, rather than a
796 # modification of the current environment's PATH.  In addition, we need
797 # to quote multiword values.
798 #
799 buildenvvars: .PHONY
800         @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
801
802 .if ${.TARGETS:Mbuildenv}
803 .if ${.MAKEFLAGS:M-j}
804 .error The buildenv target is incompatible with -j
805 .endif
806 .endif
807 BUILDENV_DIR?=  ${.CURDIR}
808 buildenv: .PHONY
809         @echo Entering world for ${TARGET_ARCH}:${TARGET}
810 .if ${BUILDENV_SHELL:M*zsh*}
811         @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
812 .endif
813         @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
814             || true
815
816 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
817 toolchain: ${TOOLCHAIN_TGTS}
818 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
819
820 #
821 # installcheck
822 #
823 # Checks to be sure system is ready for installworld/installkernel.
824 #
825 installcheck: _installcheck_world _installcheck_kernel
826 _installcheck_world:
827 _installcheck_kernel:
828
829 #
830 # Require DESTDIR to be set if installing for a different architecture or
831 # using the user/group database in the source tree.
832 #
833 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
834     defined(DB_FROM_SRC)
835 .if !make(distributeworld)
836 _installcheck_world: __installcheck_DESTDIR
837 _installcheck_kernel: __installcheck_DESTDIR
838 __installcheck_DESTDIR:
839 .if !defined(DESTDIR) || empty(DESTDIR)
840         @echo "ERROR: Please set DESTDIR!"; \
841         false
842 .endif
843 .endif
844 .endif
845
846 .if !defined(DB_FROM_SRC)
847 #
848 # Check for missing UIDs/GIDs.
849 #
850 CHECK_UIDS=     auditdistd
851 CHECK_GIDS=     audit
852 .if ${MK_SENDMAIL} != "no"
853 CHECK_UIDS+=    smmsp
854 CHECK_GIDS+=    smmsp
855 .endif
856 .if ${MK_PF} != "no"
857 CHECK_UIDS+=    proxy
858 CHECK_GIDS+=    proxy authpf
859 .endif
860 .if ${MK_UNBOUND} != "no"
861 CHECK_UIDS+=    unbound
862 CHECK_GIDS+=    unbound
863 .endif
864 _installcheck_world: __installcheck_UGID
865 __installcheck_UGID:
866 .for uid in ${CHECK_UIDS}
867         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
868                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
869                 false; \
870         fi
871 .endfor
872 .for gid in ${CHECK_GIDS}
873         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
874                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
875                 false; \
876         fi
877 .endfor
878 .endif
879
880 #
881 # Required install tools to be saved in a scratch dir for safety.
882 #
883 .if ${MK_ZONEINFO} != "no"
884 _zoneinfo=      zic tzsetup
885 .endif
886
887 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
888         date echo egrep find grep id install ${_install-info} \
889         ln make mkdir mtree mv pwd_mkdb \
890         rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
891         ${LOCAL_ITOOLS}
892
893 # Needed for share/man
894 .if ${MK_MAN} != "no"
895 ITOOLS+=makewhatis
896 .endif
897
898 #
899 # distributeworld
900 #
901 # Distributes everything compiled by a `buildworld'.
902 #
903 # installworld
904 #
905 # Installs everything compiled by a 'buildworld'.
906 #
907
908 # Non-base distributions produced by the base system
909 EXTRA_DISTRIBUTIONS=    doc
910 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
911 EXTRA_DISTRIBUTIONS+=   lib32
912 .endif
913 .if ${MK_TESTS} != "no"
914 EXTRA_DISTRIBUTIONS+=   tests
915 .endif
916
917 DEBUG_DISTRIBUTIONS=
918 .if ${MK_DEBUG_FILES} != "no"
919 DEBUG_DISTRIBUTIONS+=   base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
920 .endif
921
922 MTREE_MAGIC?=   mtree 2.0
923
924 distributeworld installworld: _installcheck_world
925         mkdir -p ${INSTALLTMP}
926         progs=$$(for prog in ${ITOOLS}; do \
927                 if progpath=`which $$prog`; then \
928                         echo $$progpath; \
929                 else \
930                         echo "Required tool $$prog not found in PATH." >&2; \
931                         exit 1; \
932                 fi; \
933             done); \
934         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
935             while read line; do \
936                 set -- $$line; \
937                 if [ "$$2 $$3" != "not found" ]; then \
938                         echo $$2; \
939                 else \
940                         echo "Required library $$1 not found." >&2; \
941                         exit 1; \
942                 fi; \
943             done); \
944         cp $$libs $$progs ${INSTALLTMP}
945         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
946 .if defined(NO_ROOT)
947         echo "#${MTREE_MAGIC}" > ${METALOG}
948 .endif
949 .if make(distributeworld)
950 .for dist in ${EXTRA_DISTRIBUTIONS}
951         -mkdir ${DESTDIR}/${DISTDIR}/${dist}
952         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
953             -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
954         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
955             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
956         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
957             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
958 .if ${MK_DEBUG_FILES} != "no"
959         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
960             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
961 .endif
962 .if ${MK_LIB32} != "no"
963         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
964             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
965 .if ${MK_DEBUG_FILES} != "no"
966         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
967             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
968 .endif
969 .endif
970 .if ${MK_TESTS} != "no" && ${dist} == "tests"
971         -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
972         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
973             -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
974 .if ${MK_DEBUG_FILES} != "no"
975         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
976             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
977 .endif
978 .endif
979 .if defined(NO_ROOT)
980         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
981             sed -e 's#^\./#./${dist}/#' >> ${METALOG}
982         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
983             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
984         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
985             sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
986 .if ${MK_LIB32} != "no"
987         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
988             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
989 .endif
990 .endif
991 .endfor
992         -mkdir ${DESTDIR}/${DISTDIR}/base
993         ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
994             METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
995             DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
996             LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
997 .endif
998         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
999             ${IMAKEENV} rm -rf ${INSTALLTMP}
1000 .if make(distributeworld)
1001 .for dist in ${EXTRA_DISTRIBUTIONS}
1002         find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1003 .endfor
1004 .if defined(NO_ROOT)
1005 .for dist in base ${EXTRA_DISTRIBUTIONS}
1006         @# For each file that exists in this dist, print the corresponding
1007         @# line from the METALOG.  This relies on the fact that
1008         @# a line containing only the filename will sort immediatly before
1009         @# the relevant mtree line.
1010         cd ${DESTDIR}/${DISTDIR}; \
1011         find ./${dist} | sort -u ${METALOG} - | \
1012         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1013         ${DESTDIR}/${DISTDIR}/${dist}.meta
1014 .endfor
1015 .for dist in ${DEBUG_DISTRIBUTIONS}
1016         @# For each file that exists in this dist, print the corresponding
1017         @# line from the METALOG.  This relies on the fact that
1018         @# a line containing only the filename will sort immediatly before
1019         @# the relevant mtree line.
1020         cd ${DESTDIR}/${DISTDIR}; \
1021         find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1022         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1023         ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1024 .endfor
1025 .endif
1026 .endif
1027
1028 packageworld:
1029 .for dist in base ${EXTRA_DISTRIBUTIONS}
1030 .if defined(NO_ROOT)
1031         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1032             tar cvf - --exclude usr/lib/debug \
1033             @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1034             ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1035 .else
1036         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1037             tar cvf - --exclude usr/lib/debug . | \
1038             ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1039 .endif
1040 .endfor
1041
1042 .for dist in ${DEBUG_DISTRIBUTIONS}
1043 . if defined(NO_ROOT)
1044         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1045             tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1046             ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1047 . else
1048         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1049             tar cvLf - usr/lib/debug | \
1050             ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1051 . endif
1052 .endfor
1053
1054 #
1055 # reinstall
1056 #
1057 # If you have a build server, you can NFS mount the source and obj directories
1058 # and do a 'make reinstall' on the *client* to install new binaries from the
1059 # most recent server build.
1060 #
1061 reinstall: .MAKE .PHONY
1062         @echo "--------------------------------------------------------------"
1063         @echo ">>> Making hierarchy"
1064         @echo "--------------------------------------------------------------"
1065         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1066             LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1067         @echo
1068         @echo "--------------------------------------------------------------"
1069         @echo ">>> Installing everything"
1070         @echo "--------------------------------------------------------------"
1071         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1072 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1073         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1074 .endif
1075
1076 redistribute: .MAKE .PHONY
1077         @echo "--------------------------------------------------------------"
1078         @echo ">>> Distributing everything"
1079         @echo "--------------------------------------------------------------"
1080         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1081 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1082         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1083             DISTRIBUTION=lib32
1084 .endif
1085
1086 distrib-dirs: .MAKE .PHONY
1087         ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1088             ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1089
1090 distribution: .MAKE .PHONY
1091         ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1092             ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1093         ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1094                 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1095                 METALOG=${METALOG} installconfig
1096
1097 #
1098 # buildkernel and installkernel
1099 #
1100 # Which kernels to build and/or install is specified by setting
1101 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1102 # Only the existing (depending TARGET) config files are used
1103 # for building kernels and only the first of these is designated
1104 # as the one being installed.
1105 #
1106 # Note that we have to use TARGET instead of TARGET_ARCH when
1107 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1108 # be set to cross-build, we have to make sure TARGET is set
1109 # properly.
1110
1111 .if defined(KERNFAST)
1112 NO_KERNELCLEAN= t
1113 NO_KERNELCONFIG=        t
1114 NO_KERNELDEPEND=        t
1115 NO_KERNELOBJ=           t
1116 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1117 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1118 KERNCONF=${KERNFAST}
1119 .endif
1120 .endif
1121 .if ${TARGET_ARCH} == "powerpc64"
1122 KERNCONF?=      GENERIC64
1123 .else
1124 KERNCONF?=      GENERIC
1125 .endif
1126 INSTKERNNAME?=  kernel
1127
1128 KERNSRCDIR?=    ${.CURDIR}/sys
1129 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
1130 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
1131 KERNCONFDIR?=   ${KRNLCONFDIR}
1132
1133 BUILDKERNELS=
1134 INSTALLKERNEL=
1135 .if defined(NO_INSTALLKERNEL)
1136 # All of the BUILDKERNELS loops start at index 1.
1137 BUILDKERNELS+= dummy
1138 .endif
1139 .for _kernel in ${KERNCONF}
1140 .if exists(${KERNCONFDIR}/${_kernel})
1141 BUILDKERNELS+=  ${_kernel}
1142 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1143 INSTALLKERNEL= ${_kernel}
1144 .endif
1145 .endif
1146 .endfor
1147
1148 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1149
1150 #
1151 # buildkernel
1152 #
1153 # Builds all kernels defined by BUILDKERNELS.
1154 #
1155 buildkernel: .MAKE .PHONY
1156 .if empty(BUILDKERNELS:Ndummy)
1157         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1158         false
1159 .endif
1160         @echo
1161 .for _kernel in ${BUILDKERNELS:Ndummy}
1162         @echo "--------------------------------------------------------------"
1163         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1164         @echo "--------------------------------------------------------------"
1165         @echo "===> ${_kernel}"
1166         mkdir -p ${KRNLOBJDIR}
1167 .if !defined(NO_KERNELCONFIG)
1168         @echo
1169         @echo "--------------------------------------------------------------"
1170         @echo ">>> stage 1: configuring the kernel"
1171         @echo "--------------------------------------------------------------"
1172         cd ${KRNLCONFDIR}; \
1173                 PATH=${TMPPATH} \
1174                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1175                         -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1176 .endif
1177 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1178         @echo
1179         @echo "--------------------------------------------------------------"
1180         @echo ">>> stage 2.1: cleaning up the object tree"
1181         @echo "--------------------------------------------------------------"
1182         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1183 .endif
1184 .if !defined(NO_KERNELOBJ)
1185         @echo
1186         @echo "--------------------------------------------------------------"
1187         @echo ">>> stage 2.2: rebuilding the object tree"
1188         @echo "--------------------------------------------------------------"
1189         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1190 .endif
1191         @echo
1192         @echo "--------------------------------------------------------------"
1193         @echo ">>> stage 2.3: build tools"
1194         @echo "--------------------------------------------------------------"
1195         ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1196 .if !defined(NO_KERNELDEPEND)
1197         @echo
1198         @echo "--------------------------------------------------------------"
1199         @echo ">>> stage 3.1: making dependencies"
1200         @echo "--------------------------------------------------------------"
1201         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1202 .endif
1203         @echo
1204         @echo "--------------------------------------------------------------"
1205         @echo ">>> stage 3.2: building everything"
1206         @echo "--------------------------------------------------------------"
1207         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1208         @echo "--------------------------------------------------------------"
1209         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1210         @echo "--------------------------------------------------------------"
1211 .endfor
1212
1213 #
1214 # installkernel, etc.
1215 #
1216 # Install the kernel defined by INSTALLKERNEL
1217 #
1218 installkernel installkernel.debug \
1219 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1220 .if !defined(NO_INSTALLKERNEL)
1221 .if empty(INSTALLKERNEL)
1222         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1223         false
1224 .endif
1225         @echo "--------------------------------------------------------------"
1226         @echo ">>> Installing kernel ${INSTALLKERNEL}"
1227         @echo "--------------------------------------------------------------"
1228         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1229             ${CROSSENV} PATH=${TMPPATH} \
1230             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1231 .endif
1232 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1233 .for _kernel in ${BUILDKERNELS:[2..-1]}
1234         @echo "--------------------------------------------------------------"
1235         @echo ">>> Installing kernel ${_kernel}"
1236         @echo "--------------------------------------------------------------"
1237         cd ${KRNLOBJDIR}/${_kernel}; \
1238             ${CROSSENV} PATH=${TMPPATH} \
1239             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1240 .endfor
1241 .endif
1242
1243 distributekernel distributekernel.debug:
1244 .if !defined(NO_INSTALLKERNEL)
1245 .if empty(INSTALLKERNEL)
1246         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1247         false
1248 .endif
1249         mkdir -p ${DESTDIR}/${DISTDIR}
1250 .if defined(NO_ROOT)
1251         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1252 .endif
1253         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1254             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1255             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1256             DESTDIR=${INSTALL_DDIR}/kernel \
1257             ${.TARGET:S/distributekernel/install/}
1258 .if defined(NO_ROOT)
1259         sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1260             ${DESTDIR}/${DISTDIR}/kernel.meta
1261 .endif
1262 .endif
1263 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1264 .for _kernel in ${BUILDKERNELS:[2..-1]}
1265 .if defined(NO_ROOT)
1266         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1267 .endif
1268         cd ${KRNLOBJDIR}/${_kernel}; \
1269             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1270             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1271             KERNEL=${INSTKERNNAME}.${_kernel} \
1272             DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1273             ${.TARGET:S/distributekernel/install/}
1274 .if defined(NO_ROOT)
1275         sed -e 's|^./kernel|.|' \
1276             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1277             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1278 .endif
1279 .endfor
1280 .endif
1281
1282 packagekernel:
1283 .if defined(NO_ROOT)
1284 .if !defined(NO_INSTALLKERNEL)
1285         cd ${DESTDIR}/${DISTDIR}/kernel; \
1286             tar cvf - --exclude '*.debug' \
1287             @${DESTDIR}/${DISTDIR}/kernel.meta | \
1288             ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1289 .endif
1290         cd ${DESTDIR}/${DISTDIR}/kernel; \
1291             tar cvf - --include '*/*/*.debug' \
1292             @${DESTDIR}/${DISTDIR}/kernel.meta | \
1293             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1294 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1295 .for _kernel in ${BUILDKERNELS:[2..-1]}
1296         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1297             tar cvf - --exclude '*.debug' \
1298             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1299             ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1300         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1301             tar cvf - --include '*/*/*.debug' \
1302             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1303             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1304 .endfor
1305 .endif
1306 .else
1307 .if !defined(NO_INSTALLKERNEL)
1308         cd ${DESTDIR}/${DISTDIR}/kernel; \
1309             tar cvf - --exclude '*.debug' . | \
1310             ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1311 .endif
1312         cd ${DESTDIR}/${DISTDIR}/kernel; \
1313             tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1314             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1315 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1316 .for _kernel in ${BUILDKERNELS:[2..-1]}
1317         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1318             tar cvf - --exclude '*.debug' . | \
1319             ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1320         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1321             tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1322             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1323 .endfor
1324 .endif
1325 .endif
1326
1327 #
1328 # doxygen
1329 #
1330 # Build the API documentation with doxygen
1331 #
1332 doxygen: .PHONY
1333         @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1334                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1335                 exit 1; \
1336         fi
1337         ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1338
1339 #
1340 # update
1341 #
1342 # Update the source tree(s), by running svn/svnup to update to the
1343 # latest copy.
1344 #
1345 update:
1346 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1347         @echo "--------------------------------------------------------------"
1348         @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1349         @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1350         @echo "--------------------------------------------------------------"
1351         @exit 1
1352 .endif
1353 .if defined(SVN_UPDATE)
1354         @echo "--------------------------------------------------------------"
1355         @echo ">>> Updating ${.CURDIR} using Subversion"
1356         @echo "--------------------------------------------------------------"
1357         @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1358 .endif
1359
1360 #
1361 # ------------------------------------------------------------------------
1362 #
1363 # From here onwards are utility targets used by the 'make world' and
1364 # related targets.  If your 'world' breaks, you may like to try to fix
1365 # the problem and manually run the following targets to attempt to
1366 # complete the build.  Beware, this is *not* guaranteed to work, you
1367 # need to have a pretty good grip on the current state of the system
1368 # to attempt to manually finish it.  If in doubt, 'make world' again.
1369 #
1370
1371 #
1372 # legacy: Build compatibility shims for the next three targets. This is a
1373 # minimal set of tools and shims necessary to compensate for older systems
1374 # which don't have the APIs required by the targets built in bootstrap-tools,
1375 # build-tools or cross-tools.
1376 #
1377
1378 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1379 .if ${BOOTSTRAPPING} < 1100006
1380 _elftoolchain_libs= lib/libelf lib/libdwarf
1381 .endif
1382
1383 legacy:
1384 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1385         @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1386         false
1387 .endif
1388 .for _tool in tools/build ${_elftoolchain_libs}
1389         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1390             cd ${.CURDIR}/${_tool}; \
1391             ${MAKE} DIRPRFX=${_tool}/ obj; \
1392             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1393             ${MAKE} DIRPRFX=${_tool}/ depend; \
1394             ${MAKE} DIRPRFX=${_tool}/ all; \
1395             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1396 .endfor
1397
1398 #
1399 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1400 # are built to build other binaries in the system. However, the focus of these
1401 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1402 # libraries, augmented by -legacy.
1403 #
1404 _bt=            _bootstrap-tools
1405
1406 .if ${MK_GAMES} != "no"
1407 _strfile=       usr.bin/fortune/strfile
1408 .endif
1409
1410 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1411 _gperf=         gnu/usr.bin/gperf
1412 .endif
1413
1414 .if ${MK_GROFF} != "no"
1415 _groff=         gnu/usr.bin/groff \
1416                 usr.bin/soelim
1417 .endif
1418
1419 .if ${MK_VT} != "no"
1420 _vtfontcvt=     usr.bin/vtfontcvt
1421 .endif
1422
1423 .if ${BOOTSTRAPPING} < 900002
1424 _sed=           usr.bin/sed
1425 .endif
1426
1427 .if ${BOOTSTRAPPING} < 1000033
1428 _libopenbsd=    lib/libopenbsd
1429 _m4=            usr.bin/m4
1430 _lex=           usr.bin/lex
1431
1432 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1433 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1434 .endif
1435
1436 .if ${BOOTSTRAPPING} < 1000026
1437 _nmtree=        lib/libnetbsd \
1438                 usr.sbin/nmtree
1439
1440 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1441 .endif
1442
1443 .if ${BOOTSTRAPPING} < 1000027
1444 _cat=           bin/cat
1445 .endif
1446
1447 # r277259 crunchide: Correct 64-bit section header offset
1448 # r281674 crunchide: always include both 32- and 64-bit ELF support
1449 # r285986 crunchen: use STRIPBIN rather than STRIP
1450 .if ${BOOTSTRAPPING} < 1100078
1451 _crunch=        usr.sbin/crunch
1452 .endif
1453
1454 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1455 _awk=           usr.bin/awk
1456 .endif
1457
1458 _yacc=          lib/liby \
1459                 usr.bin/yacc
1460
1461 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1462
1463 .if ${MK_BSNMP} != "no"
1464 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1465 .endif
1466
1467 # We need to build tblgen when we're building clang either as
1468 # the bootstrap compiler, or as the part of the normal build.
1469 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1470 _clang_tblgen= \
1471         lib/clang/libllvmsupport \
1472         lib/clang/libllvmtablegen \
1473         usr.bin/clang/tblgen \
1474         usr.bin/clang/clang-tblgen
1475
1476 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1477 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1478 .endif
1479
1480 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1481 # request it.
1482 _dtc= usr.bin/dtc
1483 .if ${MK_GPL_DTC} != "no"
1484 _dtc= gnu/usr.bin/dtc
1485 .endif
1486
1487 .if ${MK_KERBEROS} != "no"
1488 _kerberos5_bootstrap_tools= \
1489         kerberos5/tools/make-roken \
1490         kerberos5/lib/libroken \
1491         kerberos5/lib/libvers \
1492         kerberos5/tools/asn1_compile \
1493         kerberos5/tools/slc \
1494         usr.bin/compile_et
1495
1496 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1497 .endif
1498
1499 .if ${MK_MANDOCDB} != "no"
1500 _libopenbsd?=   lib/libopenbsd
1501 _makewhatis=    lib/libsqlite3 \
1502                 usr.bin/mandoc
1503 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1504 .else
1505 _makewhatis=usr.bin/makewhatis
1506 .endif
1507
1508 bootstrap-tools: .PHONY
1509
1510 #       Please document (add comment) why something is in 'bootstrap-tools'.
1511 #       Try to bound the building of the bootstrap-tool to just the
1512 #       FreeBSD versions that need the tool built at this stage of the build.
1513 .for _tool in \
1514     ${_clang_tblgen} \
1515     ${_kerberos5_bootstrap_tools} \
1516     ${_strfile} \
1517     ${_gperf} \
1518     ${_groff} \
1519     ${_dtc} \
1520     ${_awk} \
1521     ${_cat} \
1522     usr.bin/lorder \
1523     ${_libopenbsd} \
1524     ${_makewhatis} \
1525     usr.bin/rpcgen \
1526     ${_sed} \
1527     ${_yacc} \
1528     ${_m4} \
1529     ${_lex} \
1530     usr.bin/xinstall \
1531     ${_gensnmptree} \
1532     usr.sbin/config \
1533     ${_crunch} \
1534     ${_nmtree} \
1535     ${_vtfontcvt} \
1536     usr.bin/localedef
1537 ${_bt}-${_tool}: .PHONY .MAKE
1538         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1539                 cd ${.CURDIR}/${_tool}; \
1540                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1541                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1542                 ${MAKE} DIRPRFX=${_tool}/ all; \
1543                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1544
1545 bootstrap-tools: ${_bt}-${_tool}
1546 .endfor
1547
1548 #
1549 # build-tools: Build special purpose build tools
1550 #
1551 .if !defined(NO_SHARE)
1552 _share= share/syscons/scrnmaps
1553 .endif
1554
1555 .if ${MK_GCC} != "no"
1556 _gcc_tools= gnu/usr.bin/cc/cc_tools
1557 .endif
1558
1559 .if ${MK_RESCUE} != "no"
1560 # rescue includes programs that have build-tools targets
1561 _rescue=rescue/rescue
1562 .endif
1563
1564 .for _tool in \
1565     bin/csh \
1566     bin/sh \
1567     ${LOCAL_TOOL_DIRS} \
1568     lib/ncurses/ncurses \
1569     lib/ncurses/ncursesw \
1570     ${_rescue} \
1571     ${_share} \
1572     usr.bin/awk \
1573     lib/libmagic \
1574     usr.bin/mkesdb_static \
1575     usr.bin/mkcsmapper_static \
1576     usr.bin/vi/catalog
1577 build-tools_${_tool}: .PHONY
1578         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1579                 cd ${.CURDIR}/${_tool}; \
1580                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1581                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1582 build-tools: build-tools_${_tool}
1583 .endfor
1584 .for _tool in \
1585     ${_gcc_tools}
1586 build-tools_${_tool}: .PHONY
1587         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1588                 cd ${.CURDIR}/${_tool}; \
1589                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1590                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1591                 ${MAKE} DIRPRFX=${_tool}/ all
1592 build-tools: build-tools_${_tool}
1593 .endfor
1594
1595 #
1596 # kernel-tools: Build kernel-building tools
1597 #
1598 kernel-tools:
1599         mkdir -p ${MAKEOBJDIRPREFIX}/usr
1600         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1601             -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1602
1603 #
1604 # cross-tools: All the tools needed to build the rest of the system after
1605 # we get done with the earlier stages. It is the last set of tools needed
1606 # to begin building the target binaries.
1607 #
1608 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1609 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1610 _btxld=         usr.sbin/btxld
1611 .endif
1612 .endif
1613
1614 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1615 # resulting from missing bug fixes or ELF Toolchain updates.
1616 .if ${MK_CDDL} != "no"
1617 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1618     cddl/usr.bin/ctfmerge
1619 .endif
1620
1621 # If we're given an XAS, don't build binutils.
1622 .if ${XAS:M/*} == ""
1623 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1624 _binutils=      gnu/usr.bin/binutils
1625 .endif
1626 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1627 _elftctools=    lib/libelftc \
1628                 usr.bin/elfcopy \
1629                 usr.bin/nm \
1630                 usr.bin/size \
1631                 usr.bin/strings
1632 # These are not required by the build, but can be useful for developers who
1633 # cross-build on a FreeBSD 10 host:
1634 _elftctools+=   usr.bin/addr2line
1635 .endif
1636 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1637 # If cross-building with an external binutils we still need to build strip for
1638 # the target (for at least crunchide).
1639 _elftctools=    lib/libelftc \
1640                 usr.bin/elfcopy
1641 .endif
1642
1643 # If an full path to an external cross compiler is given, don't build
1644 # a cross compiler.
1645 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1646 .if ${MK_CLANG_BOOTSTRAP} != "no"
1647 _clang=         usr.bin/clang
1648 _clang_libs=    lib/clang
1649 .endif
1650 .if ${MK_GCC_BOOTSTRAP} != "no"
1651 _cc=            gnu/usr.bin/cc
1652 .endif
1653 .endif
1654 .if ${MK_USB} != "no"
1655 _usb_tools=     sys/boot/usb/tools
1656 .endif
1657
1658 cross-tools: .MAKE .PHONY
1659 .for _tool in \
1660     ${_clang_libs} \
1661     ${_clang} \
1662     ${_binutils} \
1663     ${_elftctools} \
1664     ${_dtrace_tools} \
1665     ${_cc} \
1666     ${_btxld} \
1667     ${_crunchide} \
1668     ${_usb_tools}
1669         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1670                 cd ${.CURDIR}/${_tool}; \
1671                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1672                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1673                 ${MAKE} DIRPRFX=${_tool}/ all; \
1674                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1675 .endfor
1676
1677 NXBDESTDIR=     ${OBJTREE}/nxb-bin
1678 NXBENV=         MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1679                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1680                 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1681 NXBMAKE=        ${NXBENV} ${MAKE} \
1682                 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1683                 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1684                 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1685                 MK_GDB=no MK_TESTS=no \
1686                 SSP_CFLAGS= \
1687                 MK_HTML=no NO_LINT=yes MK_MAN=no \
1688                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1689                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1690                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1691                 MK_LLDB=no MK_DEBUG_FILES=no
1692
1693 # native-xtools is the current target for qemu-user cross builds of ports
1694 # via poudriere and the imgact_binmisc kernel module.
1695 # For non-clang enabled targets that are still using the in tree gcc
1696 # we must build a gperf binary for one instance of its Makefiles.  On
1697 # clang-enabled systems, the gperf binary is obsolete.
1698 native-xtools: .PHONY
1699 .if ${MK_GCC_BOOTSTRAP} != "no"
1700         mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1701         ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1702         cd ${.CURDIR}/${_gperf}; \
1703         ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1704         ${NXBMAKE} DIRPRFX=${_gperf}/ depend; \
1705         ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1706         ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1707 .endif
1708         mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1709         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1710             -p ${NXBDESTDIR}/usr >/dev/null
1711         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1712             -p ${NXBDESTDIR}/usr/include >/dev/null
1713 .if ${MK_DEBUG_FILES} != "no"
1714         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1715             -p ${NXBDESTDIR}/usr/lib >/dev/null
1716 .endif
1717 .for _tool in \
1718     bin/cat \
1719     bin/chmod \
1720     bin/cp \
1721     bin/csh \
1722     bin/echo \
1723     bin/expr \
1724     bin/hostname \
1725     bin/ln \
1726     bin/ls \
1727     bin/mkdir \
1728     bin/mv \
1729     bin/ps \
1730     bin/realpath \
1731     bin/rm \
1732     bin/rmdir \
1733     bin/sh \
1734     bin/sleep \
1735     ${_clang_tblgen} \
1736     usr.bin/ar \
1737     ${_binutils} \
1738     ${_elftctools} \
1739     ${_cc} \
1740     ${_gcc_tools} \
1741     ${_clang_libs} \
1742     ${_clang} \
1743     sbin/md5 \
1744     sbin/sysctl \
1745     gnu/usr.bin/diff \
1746     usr.bin/awk \
1747     usr.bin/basename \
1748     usr.bin/bmake \
1749     usr.bin/bzip2 \
1750     usr.bin/cmp \
1751     usr.bin/dirname \
1752     usr.bin/env \
1753     usr.bin/fetch \
1754     usr.bin/find \
1755     usr.bin/grep \
1756     usr.bin/gzip \
1757     usr.bin/id \
1758     usr.bin/lex \
1759     usr.bin/lorder \
1760     usr.bin/mktemp \
1761     usr.bin/mt \
1762     usr.bin/patch \
1763     usr.bin/sed \
1764     usr.bin/sort \
1765     usr.bin/tar \
1766     usr.bin/touch \
1767     usr.bin/tr \
1768     usr.bin/true \
1769     usr.bin/uniq \
1770     usr.bin/unzip \
1771     usr.bin/xargs \
1772     usr.bin/xinstall \
1773     usr.bin/xz \
1774     usr.bin/yacc \
1775     usr.sbin/chown
1776         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1777                 cd ${.CURDIR}/${_tool}; \
1778                 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1779                 ${NXBMAKE} DIRPRFX=${_tool}/ depend; \
1780                 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1781                 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1782 .endfor
1783
1784 #
1785 # hierarchy - ensure that all the needed directories are present
1786 #
1787 hierarchy hier: .MAKE .PHONY
1788         ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1789
1790 #
1791 # libraries - build all libraries, and install them under ${DESTDIR}.
1792 #
1793 # The list of libraries with dependents (${_prebuild_libs}) and their
1794 # interdependencies (__L) are built automatically by the
1795 # ${.CURDIR}/tools/make_libdeps.sh script.
1796 #
1797 libraries: .MAKE .PHONY
1798         ${_+_}cd ${.CURDIR}; \
1799             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1800             ${MAKE} -f Makefile.inc1 _startup_libs; \
1801             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1802             ${MAKE} -f Makefile.inc1 _generic_libs
1803
1804 #
1805 # static libgcc.a prerequisite for shared libc
1806 #
1807 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1808
1809 # These dependencies are not automatically generated:
1810 #
1811 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1812 # all shared libraries for ELF.
1813 #
1814 _startup_libs=  gnu/lib/csu
1815 _startup_libs+= lib/csu
1816 _startup_libs+= gnu/lib/libgcc
1817 _startup_libs+= lib/libcompiler_rt
1818 _startup_libs+= lib/libc
1819 _startup_libs+= lib/libc_nonshared
1820 .if ${MK_LIBCPLUSPLUS} != "no"
1821 _startup_libs+= lib/libcxxrt
1822 .endif
1823
1824 gnu/lib/libgcc__L: lib/libc__L
1825 gnu/lib/libgcc__L: lib/libc_nonshared__L
1826 .if ${MK_LIBCPLUSPLUS} != "no"
1827 lib/libcxxrt__L: gnu/lib/libgcc__L
1828 .endif
1829
1830 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1831                 ${_kerberos5_lib_libhdb} \
1832                 ${_kerberos5_lib_libheimbase} \
1833                 ${_kerberos5_lib_libheimntlm} \
1834                 ${_libsqlite3} \
1835                 ${_kerberos5_lib_libheimipcc} \
1836                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1837                 ${_kerberos5_lib_libroken} \
1838                 ${_kerberos5_lib_libwind} \
1839                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1840                 lib/libelf lib/libexpat \
1841                 lib/libfigpar \
1842                 ${_lib_libgssapi} \
1843                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1844                 ${_lib_libcapsicum} \
1845                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1846                 lib/libopie lib/libpam ${_lib_libthr} \
1847                 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1848                 lib/libgeom \
1849                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1850                 ${_cddl_lib_libuutil} \
1851                 ${_cddl_lib_libavl} \
1852                 ${_cddl_lib_libzfs_core} \
1853                 ${_cddl_lib_libctf} \
1854                 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1855                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1856                 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1857                 gnu/lib/libdialog
1858 .if ${MK_GNUCXX} != "no"
1859 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1860 gnu/lib/libstdc++__L: lib/msun__L
1861 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1862 .endif
1863
1864 .if ${MK_LIBCPLUSPLUS} != "no"
1865 _prebuild_libs+= lib/libc++
1866 .endif
1867
1868 lib/libgeom__L: lib/libexpat__L
1869 lib/libkvm__L: lib/libelf__L
1870
1871 .if ${MK_LIBTHR} != "no"
1872 _lib_libthr=    lib/libthr
1873 .endif
1874
1875 .if ${MK_RADIUS_SUPPORT} != "no"
1876 _lib_libradius= lib/libradius
1877 .endif
1878
1879 .if ${MK_OFED} != "no"
1880 _ofed_lib=      contrib/ofed/usr.lib/
1881 .endif
1882
1883 .if ${MK_CASPER} != "no"
1884 _lib_libcapsicum=lib/libcapsicum
1885 .endif
1886
1887 lib/libcapsicum__L: lib/libnv__L
1888 lib/libpjdlog__L: lib/libutil__L
1889 lib/liblzma__L: lib/libthr__L
1890
1891 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1892 .for _DIR in ${LOCAL_LIB_DIRS}
1893 .if exists(${.CURDIR}/${_DIR}/Makefile)
1894 _generic_libs+= ${_DIR}
1895 .endif
1896 .endfor
1897
1898 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1899
1900 .if ${MK_CDDL} != "no"
1901 _cddl_lib_libumem= cddl/lib/libumem
1902 _cddl_lib_libnvpair= cddl/lib/libnvpair
1903 _cddl_lib_libavl= cddl/lib/libavl
1904 _cddl_lib_libuutil= cddl/lib/libuutil
1905 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1906 _cddl_lib_libctf= cddl/lib/libctf
1907 _cddl_lib= cddl/lib
1908 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1909 cddl/lib/libzfs__L: lib/libgeom__L
1910 cddl/lib/libctf__L: lib/libz__L
1911 .endif
1912 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1913 # on select architectures though (see cddl/lib/Makefile)
1914 .if ${MACHINE_CPUARCH} != "sparc64"
1915 _prebuild_libs+=        lib/libproc lib/librtld_db
1916 .endif
1917
1918 .if ${MK_CRYPT} != "no"
1919 .if ${MK_OPENSSL} != "no"
1920 _secure_lib_libcrypto= secure/lib/libcrypto
1921 _secure_lib_libssl= secure/lib/libssl
1922 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1923 .if ${MK_LDNS} != "no"
1924 _lib_libldns= lib/libldns
1925 lib/libldns__L: secure/lib/libcrypto__L
1926 .endif
1927 .if ${MK_OPENSSH} != "no"
1928 _secure_lib_libssh= secure/lib/libssh
1929 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1930 .if ${MK_LDNS} != "no"
1931 secure/lib/libssh__L: lib/libldns__L
1932 .endif
1933 .if ${MK_KERBEROS_SUPPORT} != "no"
1934 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1935     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1936     lib/libmd__L kerberos5/lib/libroken__L
1937 .endif
1938 .endif
1939 .endif
1940 _secure_lib=    secure/lib
1941 .endif
1942
1943 .if ${MK_KERBEROS} != "no"
1944 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1945 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1946     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1947     kerberos5/lib/libwind__L lib/libsqlite3__L
1948 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1949     kerberos5/lib/libroken__L lib/libcom_err__L
1950 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1951     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1952 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1953     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1954     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1955     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1956 kerberos5/lib/libroken__L: lib/libcrypt__L
1957 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1958 kerberos5/lib/libheimbase__L: lib/libthr__L
1959 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1960 .endif
1961
1962 lib/libsqlite3__L: lib/libthr__L
1963
1964 .if ${MK_GSSAPI} != "no"
1965 _lib_libgssapi= lib/libgssapi
1966 .endif
1967
1968 .if ${MK_KERBEROS} != "no"
1969 _kerberos5_lib= kerberos5/lib
1970 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1971 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1972 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1973 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1974 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1975 _kerberos5_lib_libroken= kerberos5/lib/libroken
1976 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1977 _libsqlite3= lib/libsqlite3
1978 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1979 _kerberos5_lib_libwind= kerberos5/lib/libwind
1980 _libcom_err= lib/libcom_err
1981 .endif
1982
1983 .if ${MK_NIS} != "no"
1984 _lib_libypclnt= lib/libypclnt
1985 .endif
1986
1987 .if ${MK_OPENSSL} == "no"
1988 lib/libradius__L: lib/libmd__L
1989 .endif
1990
1991 lib/libproc__L: \
1992     ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
1993 .if ${MK_CXX} != "no"
1994 .if ${MK_LIBCPLUSPLUS} != "no"
1995 lib/libproc__L: lib/libcxxrt__L
1996 .else # This implies MK_GNUCXX != "no"; see lib/libproc
1997 lib/libproc__L: gnu/lib/libsupc++__L
1998 .endif
1999 .endif
2000
2001 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2002
2003 .for _lib in ${_prereq_libs}
2004 ${_lib}__PL: .PHONY .MAKE
2005 .if exists(${.CURDIR}/${_lib})
2006         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2007                 cd ${.CURDIR}/${_lib}; \
2008                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2009                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2010                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2011                     DIRPRFX=${_lib}/ all; \
2012                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2013                     DIRPRFX=${_lib}/ install
2014 .endif
2015 .endfor
2016
2017 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2018 ${_lib}__L: .PHONY .MAKE
2019 .if exists(${.CURDIR}/${_lib})
2020         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2021                 cd ${.CURDIR}/${_lib}; \
2022                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2023                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2024                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2025                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2026 .endif
2027 .endfor
2028
2029 # libpam is special: we need to build static PAM modules before
2030 # static PAM library, and dynamic PAM library before dynamic PAM
2031 # modules.
2032 lib/libpam__L: .PHONY .MAKE
2033         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2034                 cd ${.CURDIR}/lib/libpam; \
2035                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2036                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; \
2037                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2038                     -D_NO_LIBPAM_SO_YET all; \
2039                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2040                     -D_NO_LIBPAM_SO_YET install
2041
2042 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2043 _startup_libs: ${_startup_libs:S/$/__L/}
2044 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2045 _generic_libs: ${_generic_libs:S/$/__L/}
2046
2047 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2048 # 'everything' with _PARALLEL_SUBDIR_OK set.  This is because it is unlikely
2049 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2050 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2051 # parallel.  This is safe for the world stage of buildworld though since it has
2052 # already built libraries in a proper order and installed includes into
2053 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2054 # avoid trashing a system if it crashes mid-install.
2055 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2056 SUBDIR_PARALLEL=
2057 .endif
2058
2059 .include <bsd.subdir.mk>
2060
2061 .if make(check-old) || make(check-old-dirs) || \
2062     make(check-old-files) || make(check-old-libs) || \
2063     make(delete-old) || make(delete-old-dirs) || \
2064     make(delete-old-files) || make(delete-old-libs)
2065
2066 #
2067 # check for / delete old files section
2068 #
2069
2070 .include "ObsoleteFiles.inc"
2071
2072 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2073 else you can not start such an application. Consult UPDATING for more \
2074 information regarding how to cope with the removal/revision bump of a \
2075 specific library."
2076
2077 .if !defined(BATCH_DELETE_OLD_FILES)
2078 RM_I=-i
2079 .else
2080 RM_I=-v
2081 .endif
2082
2083 delete-old-files:
2084         @echo ">>> Removing old files (only deletes safe to delete libs)"
2085 # Ask for every old file if the user really wants to remove it.
2086 # It's annoying, but better safe than sorry.
2087 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2088 # argument list will get too long. Using .for/.endfor make "loops" will make
2089 # the Makefile parser segfault.
2090         @exec 3<&0; \
2091         cd ${.CURDIR}; \
2092         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2093             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2094         while read file; do \
2095                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2096                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2097                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2098                 fi; \
2099                 for ext in debug symbols; do \
2100                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2101                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2102                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2103                               <&3; \
2104                   fi; \
2105                 done; \
2106         done
2107 # Remove catpages without corresponding manpages.
2108         @exec 3<&0; \
2109         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2110         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2111         while read catpage; do \
2112                 read manpage; \
2113                 if [ ! -e "$${manpage}" ]; then \
2114                         rm ${RM_I} $${catpage} <&3; \
2115                 fi; \
2116         done
2117         @echo ">>> Old files removed"
2118
2119 check-old-files:
2120         @echo ">>> Checking for old files"
2121         @cd ${.CURDIR}; \
2122         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2123             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2124         while read file; do \
2125                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2126                         echo "${DESTDIR}/$${file}"; \
2127                 fi; \
2128                 for ext in debug symbols; do \
2129                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2130                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2131                   fi; \
2132                 done; \
2133         done
2134 # Check for catpages without corresponding manpages.
2135         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2136         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2137         while read catpage; do \
2138                 read manpage; \
2139                 if [ ! -e "$${manpage}" ]; then \
2140                         echo $${catpage}; \
2141                 fi; \
2142         done
2143
2144 delete-old-libs:
2145         @echo ">>> Removing old libraries"
2146         @echo "${OLD_LIBS_MESSAGE}" | fmt
2147         @exec 3<&0; \
2148         cd ${.CURDIR}; \
2149         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2150             -V OLD_LIBS | xargs -n1 | \
2151         while read file; do \
2152                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2153                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2154                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2155                 fi; \
2156                 for ext in debug symbols; do \
2157                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2158                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2159                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2160                               <&3; \
2161                   fi; \
2162                 done; \
2163         done
2164         @echo ">>> Old libraries removed"
2165
2166 check-old-libs:
2167         @echo ">>> Checking for old libraries"
2168         @cd ${.CURDIR}; \
2169         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2170             -V OLD_LIBS | xargs -n1 | \
2171         while read file; do \
2172                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2173                         echo "${DESTDIR}/$${file}"; \
2174                 fi; \
2175                 for ext in debug symbols; do \
2176                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2177                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2178                   fi; \
2179                 done; \
2180         done
2181
2182 delete-old-dirs:
2183         @echo ">>> Removing old directories"
2184         @cd ${.CURDIR}; \
2185         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2186             -V OLD_DIRS | xargs -n1 | sort -r | \
2187         while read dir; do \
2188                 if [ -d "${DESTDIR}/$${dir}" ]; then \
2189                         rmdir -v "${DESTDIR}/$${dir}" || true; \
2190                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2191                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2192                 fi; \
2193         done
2194         @echo ">>> Old directories removed"
2195
2196 check-old-dirs:
2197         @echo ">>> Checking for old directories"
2198         @cd ${.CURDIR}; \
2199         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2200             -V OLD_DIRS | xargs -n1 | \
2201         while read dir; do \
2202                 if [ -d "${DESTDIR}/$${dir}" ]; then \
2203                         echo "${DESTDIR}/$${dir}"; \
2204                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2205                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2206                 fi; \
2207         done
2208
2209 delete-old: delete-old-files delete-old-dirs
2210         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2211
2212 check-old: check-old-files check-old-libs check-old-dirs
2213         @echo "To remove old files and directories run '${MAKE} delete-old'."
2214         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2215
2216 .endif
2217
2218 #
2219 # showconfig - show build configuration.
2220 #
2221 showconfig:
2222         @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2223           ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2224
2225 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2226 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2227
2228 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2229 .if exists(${KERNCONFDIR}/${KERNCONF})
2230 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2231         '${KERNCONFDIR}/${KERNCONF}' ; echo
2232 .endif
2233 .endif
2234
2235 .endif
2236
2237 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2238 DTBOUTPUTPATH= ${.CURDIR}
2239 .endif
2240
2241 #
2242 # Build 'standalone' Device Tree Blob
2243 #
2244 builddtb:
2245         @PATH=${TMPPATH} MACHINE=${TARGET} \
2246         ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2247             "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2248
2249 ###############
2250
2251 # cleanworld
2252 # In the following, the first 'rm' in a series will usually remove all
2253 # files and directories.  If it does not, then there are probably some
2254 # files with file flags set, so this unsets them and tries the 'rm' a
2255 # second time.  There are situations where this target will be cleaning
2256 # some directories via more than one method, but that duplication is
2257 # needed to correctly handle all the possible situations.  Removing all
2258 # files without file flags set in the first 'rm' instance saves time,
2259 # because 'chflags' will need to operate on fewer files afterwards.
2260 #
2261 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2262 # created by bsd.obj.mk, except that we don't want to .include that file
2263 # in this makefile.
2264 #
2265 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2266 cleanworld: .PHONY
2267 .if exists(${BW_CANONICALOBJDIR}/)
2268         -rm -rf ${BW_CANONICALOBJDIR}/*
2269         -chflags -R 0 ${BW_CANONICALOBJDIR}
2270         rm -rf ${BW_CANONICALOBJDIR}/*
2271 .endif
2272 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2273         #   To be safe in this case, fall back to a 'make cleandir'
2274         ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2275 .endif
2276
2277 .if defined(TARGET) && defined(TARGET_ARCH)
2278
2279 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2280 XDEV_CPUTYPE?=${CPUTYPE}
2281 .else
2282 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2283 .endif
2284
2285 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2286         MK_MAN=no MK_NLS=no MK_PROFILE=no \
2287         MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2288         TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2289         CPUTYPE=${XDEV_CPUTYPE}
2290
2291 XDDIR=${TARGET_ARCH}-freebsd
2292 XDTP?=/usr/${XDDIR}
2293 .if ${XDTP:N/*}
2294 .error XDTP variable should be an absolute path
2295 .endif
2296
2297 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2298         INSTALL="sh ${.CURDIR}/tools/install.sh"
2299 CDENV= ${CDBENV} \
2300         TOOLS_PREFIX=${XDTP}
2301 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2302         --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2303         -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2304 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2305         CPP="${CPP} ${CD2CFLAGS}" \
2306         MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2307
2308 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2309 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2310 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2311 XDDESTDIR=${DESTDIR}/${XDTP}
2312 .if !defined(OSREL)
2313 OSREL!= uname -r | sed -e 's/[-(].*//'
2314 .endif
2315
2316 .ORDER: xdev-build xdev-install xdev-links
2317 xdev: xdev-build xdev-install
2318
2319 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2320 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2321
2322 _xb-worldtmp: .PHONY
2323         mkdir -p ${CDTMP}/usr
2324         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2325             -p ${CDTMP}/usr >/dev/null
2326
2327 _xb-bootstrap-tools: .PHONY
2328 .for _tool in \
2329     ${_clang_tblgen} \
2330     ${_gperf}
2331         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2332         cd ${.CURDIR}/${_tool}; \
2333         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2334         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2335         ${CDMAKE} DIRPRFX=${_tool}/ all; \
2336         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2337 .endfor
2338
2339 _xb-build-tools: .PHONY
2340         ${_+_}@cd ${.CURDIR}; \
2341         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2342
2343 _xb-cross-tools: .PHONY
2344 .for _tool in \
2345     ${_binutils} \
2346     ${_elftctools} \
2347     usr.bin/ar \
2348     ${_clang_libs} \
2349     ${_clang} \
2350     ${_cc}
2351         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2352         cd ${.CURDIR}/${_tool}; \
2353         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2354         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2355         ${CDMAKE} DIRPRFX=${_tool}/ all
2356 .endfor
2357
2358 _xi-mtree: .PHONY
2359         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2360         mkdir -p ${XDDESTDIR}
2361         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2362             -p ${XDDESTDIR} >/dev/null
2363         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2364             -p ${XDDESTDIR}/usr >/dev/null
2365         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2366             -p ${XDDESTDIR}/usr/include >/dev/null
2367 .if ${MK_LIB32} != "no"
2368         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2369             -p ${XDDESTDIR}/usr >/dev/null
2370 .endif
2371 .if ${MK_TESTS} != "no"
2372         mkdir -p ${XDDESTDIR}${TESTSBASE}
2373         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2374             -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2375 .endif
2376
2377 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2378 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2379
2380 _xi-cross-tools: .PHONY
2381         @echo "_xi-cross-tools"
2382 .for _tool in \
2383     ${_binutils} \
2384     ${_elftctools} \
2385     usr.bin/ar \
2386     ${_clang_libs} \
2387     ${_clang} \
2388     ${_cc}
2389         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2390         cd ${.CURDIR}/${_tool}; \
2391         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2392 .endfor
2393
2394 _xi-includes: .PHONY
2395         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2396                 DESTDIR=${XDDESTDIR}
2397
2398 _xi-libraries: .PHONY
2399         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2400                 DESTDIR=${XDDESTDIR}
2401
2402 xdev-links: .PHONY
2403         ${_+_}cd ${XDDESTDIR}/usr/bin; \
2404         mkdir -p ../../../../usr/bin; \
2405                 for i in *; do \
2406                         ln -sf ../../${XDTP}/usr/bin/$$i \
2407                             ../../../../usr/bin/${XDDIR}-$$i; \
2408                         ln -sf ../../${XDTP}/usr/bin/$$i \
2409                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2410                 done
2411 .else
2412 xdev xdev-build xdev-install xdev-links:
2413         @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2414 .endif