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