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