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