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