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