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