1# 2# 3# Make command line options: 4# -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir 5# -DNO_CLEAN do not clean at all 6# -DDB_FROM_SRC use the user/group databases in src/etc instead of 7# the system database when installing. 8# -DNO_SHARE do not go into share subdir 9# -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ} 10# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel 11# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel 12# -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel 13# -DNO_ROOT install without using root privilege 14# -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects 15# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list 16# LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list 17# LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target 18# LOCAL_MTREE="list of mtree files" to process to allow local directories 19# to be created before files are installed 20# LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy 21# target 22# LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the 23# bootstrap-tools target 24# LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools 25# target 26# LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the 27# cross-tools target 28# METALOG="path to metadata log" to write permission and ownership 29# when NO_ROOT is set. (default: ${DESTDIR}/${DISTDIR}/METALOG, 30# check /etc/make.conf for DISTDIR) 31# TARGET="machine" to crossbuild world for a different machine type 32# TARGET_ARCH= may be required when a TARGET supports multiple endians 33# BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL}) 34# WORLD_FLAGS= additional flags to pass to make(1) during buildworld 35# KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel 36# SUBDIR_OVERRIDE="list of dirs" to build rather than everything. 37# All libraries and includes, and some build tools will still build. 38 39# 40# The intended user-driven targets are: 41# buildworld - rebuild *everything*, including glue to help do upgrades 42# installworld- install everything built by "buildworld" 43# checkworld - run test suite on installed world 44# doxygen - build API documentation of the kernel 45# 46# Standard targets (not defined here) are documented in the makefiles in 47# /usr/share/mk. These include: 48# obj depend all install clean cleandepend cleanobj 49 50.if !defined(TARGET) || !defined(TARGET_ARCH) 51.error Both TARGET and TARGET_ARCH must be defined. 52.endif 53 54.if make(showconfig) || make(test-system-*) 55_MKSHOWCONFIG= t 56.endif 57 58SRCDIR?= ${.CURDIR} 59LOCALBASE?= /usr/local 60TIME_ENV ?= time env 61 62.include "share/mk/src.tools.mk" 63 64# Cross toolchain changes must be in effect before bsd.compiler.mk 65# so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes. 66.if defined(CROSS_TOOLCHAIN) 67.if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk) 68.include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk" 69.elif exists(${CROSS_TOOLCHAIN}) 70.include "${CROSS_TOOLCHAIN}" 71.else 72.error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found 73.endif 74CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}" 75.elif defined(UNIVERSE_TOOLCHAIN) 76UNIVERSE_TOOLCHAIN_PATH?=${HOST_OBJTOP}/tmp/usr/bin 77XCC?="${UNIVERSE_TOOLCHAIN_PATH}/cc" 78XCXX?="${UNIVERSE_TOOLCHAIN_PATH}/c++" 79XCPP?="${UNIVERSE_TOOLCHAIN_PATH}/cpp" 80XLD?="${UNIVERSE_TOOLCHAIN_PATH}/ld" 81.endif 82.if defined(CROSS_TOOLCHAIN_PREFIX) 83CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX} 84.endif 85 86XCOMPILERS= CC CXX CPP 87.for COMPILER in ${XCOMPILERS} 88.if defined(CROSS_COMPILER_PREFIX) 89X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}} 90.else 91X${COMPILER}?= ${${COMPILER}} 92.endif 93.endfor 94# If a full path to an external cross compiler is given, don't build 95# a cross compiler. 96.if ${XCC:N${CCACHE_BIN}:M/*} 97MK_CLANG_BOOTSTRAP= no 98# Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to 99# work around incompatible headers in Clang's resource directory is enabled. 100.MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP 101.endif 102 103# Pull in compiler metadata from buildworld/toolchain if possible to avoid 104# running CC from bsd.compiler.mk. 105.if make(installworld) || make(install) || make(distributeworld) || \ 106 make(stageworld) 107.-include "${OBJTOP}/toolchain-metadata.mk" 108.if !defined(_LOADED_TOOLCHAIN_METADATA) 109.error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set. 110.endif 111.endif 112 113# Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the 114# tree to be friendlier to foreign OS builds. It's safe to do so unconditionally 115# here since we will always have the right make, unlike in src/Makefile 116# Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk) 117_NO_INCLUDE_LINKERMK= t 118# We also want the X_COMPILER* variables if we are using an external toolchain. 119_WANT_TOOLCHAIN_CROSS_VARS= t 120.include "share/mk/bsd.compiler.mk" 121.undef _NO_INCLUDE_LINKERMK 122.undef _WANT_TOOLCHAIN_CROSS_VARS 123# src.opts.mk depends on COMPILER_FEATURES 124.include "share/mk/src.opts.mk" 125 126.if ${TARGET} == ${MACHINE} 127TARGET_CPUTYPE?=${CPUTYPE} 128.else 129TARGET_CPUTYPE?= 130.endif 131.if !empty(TARGET_CPUTYPE) 132_TARGET_CPUTYPE=${TARGET_CPUTYPE} 133.else 134_TARGET_CPUTYPE=dummy 135.endif 136.if ${TARGET} == "arm" 137.if ${TARGET_CPUTYPE:M*soft*} == "" 138TARGET_TRIPLE_ABI= gnueabihf 139.else 140TARGET_TRIPLE_ABI= gnueabi 141.endif 142.endif 143MACHINE_TRIPLE_ABI?= unknown 144MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/}-${MACHINE_TRIPLE_ABI}-freebsd${OS_REVISION} 145TARGET_TRIPLE_ABI?= unknown 146TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/}-${TARGET_TRIPLE_ABI}-freebsd${OS_REVISION} 147KNOWN_ARCHES?= aarch64/arm64 \ 148 amd64 \ 149 armv7/arm \ 150 i386 \ 151 powerpc \ 152 powerpc64/powerpc \ 153 powerpc64le/powerpc \ 154 powerpcspe/powerpc \ 155 riscv64/riscv 156 157.if ${TARGET} == ${TARGET_ARCH} 158_t= ${TARGET} 159.else 160_t= ${TARGET_ARCH}/${TARGET} 161.endif 162.for _t in ${_t} 163.if empty(KNOWN_ARCHES:M${_t}) 164.error Unknown target ${TARGET_ARCH}:${TARGET}. 165.endif 166.endfor 167 168.if ${TARGET_ARCH} == "amd64" 169LIBCOMPAT_INCLUDE_DIRS+= i386 170.elif ${TARGET_ARCH} == "aarch64" 171LIBCOMPAT_INCLUDE_DIRS+= arm 172.endif 173 174.if !defined(_MKSHOWCONFIG) 175.if ((defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "gcc") || \ 176 (!defined(X_COMPILER_TYPE) && ${COMPILER_TYPE} == "gcc")) 177.if ${TARGET} == "arm" 178_GCC_BROKEN="https://reviews.freebsd.org/D36754" 179.endif 180.if ${TARGET_ARCH} == "powerpc" 181_GCC_BROKEN=Missing atomic builtins in libc++. 182.endif 183.if ${TARGET_ARCH:Mpowerpc64*} 184_GCC_BROKEN=libsys.so.7.full has a LOAD segment with RWX permissions. 185.endif 186.if ${TARGET} == "riscv" 187_GCC_BROKEN=boot code linker script issues. 188.endif 189.if defined(_GCC_BROKEN) 190.warning Target ${TARGET} is broken with GCC: ${_GCC_BROKEN} 191.if defined(TRY_GCC_BROKEN) 192.warning Trying build anyway. 193.else 194.error Avoiding broken build. Define TRY_GCC_BROKEN to try anyway. 195.endif 196.endif 197.endif 198.endif 199 200.if ${.MAKE.OS} != "FreeBSD" 201CROSSBUILD_HOST=${.MAKE.OS} 202.if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin" 203.warning Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail! 204.endif 205# We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating 206# systems since the BSD.foo.dist specs contain users and groups that do not 207# exist by default on a Linux/MacOS system. 208NO_ROOT:= 1 209DB_FROM_SRC:= 1 210.export NO_ROOT 211.endif 212 213# If all targets are disabled for system llvm then don't expect it to work 214# for cross-builds. 215.if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \ 216 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \ 217 !make(showconfig) 218MK_SYSTEM_COMPILER= no 219MK_SYSTEM_LINKER= no 220.endif 221 222# Handle external binutils. 223.if defined(CROSS_TOOLCHAIN_PREFIX) 224CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX} 225.endif 226XBINUTILS= AS AR ELFCTL LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN 227.for BINUTIL in ${XBINUTILS} 228.if defined(CROSS_BINUTILS_PREFIX) && \ 229 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}}) 230X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}} 231.else 232X${BINUTIL}?= ${${BINUTIL}} 233.endif 234.endfor 235 236# If a full path to an external linker is given, don't build lld. 237.if ${XLD:M/*} 238MK_LLD_BOOTSTRAP= no 239.endif 240 241# We also want the X_LINKER* variables if we are using an external toolchain. 242_WANT_TOOLCHAIN_CROSS_VARS= t 243.include "share/mk/bsd.linker.mk" 244.undef _WANT_TOOLCHAIN_CROSS_VARS 245 246# Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD 247 248# WITH_SYSTEM_COMPILER - Pull in needed values and make a decision. 249 250# Check if there is a local compiler that can satisfy as an external compiler. 251# Which compiler is expected to be used? 252.if ${MK_CLANG_BOOTSTRAP} == "yes" 253WANT_COMPILER_TYPE= clang 254.else 255WANT_COMPILER_TYPE= 256.endif 257 258.if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \ 259 !make(test-system-linker) 260.if ${WANT_COMPILER_TYPE} == "clang" 261WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h 262WANT_COMPILER_FREEBSD_VERSION!= \ 263 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \ 264 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown 265WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc 266WANT_COMPILER_VERSION!= \ 267 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \ 268 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown 269.endif 270.export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION 271.endif # !defined(WANT_COMPILER_FREEBSD_VERSION) 272 273# It needs to be the same revision as we would build for the bootstrap. 274# If the expected vs CC is different then we can't skip. 275# GCC cannot be used for cross-arch yet. For clang we pass -target later if 276# TARGET_ARCH!=MACHINE_ARCH. 277.if ${MK_SYSTEM_COMPILER} == "yes" && \ 278 defined(WANT_COMPILER_FREEBSD_VERSION) && \ 279 ${MK_CLANG_BOOTSTRAP} == "yes" && \ 280 !make(xdev*) && \ 281 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \ 282 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \ 283 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \ 284 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION} 285# Everything matches, disable the bootstrap compiler. 286MK_CLANG_BOOTSTRAP= no 287USING_SYSTEM_COMPILER= yes 288.endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} 289 290# WITH_SYSTEM_LD - Pull in needed values and make a decision. 291 292# Check if there is a local linker that can satisfy as an external linker. 293# Which linker is expected to be used? 294.if ${MK_LLD_BOOTSTRAP} == "yes" 295WANT_LINKER_TYPE= lld 296.else 297WANT_LINKER_TYPE= 298.endif 299 300.if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \ 301 !make(test-system-compiler) 302.if ${WANT_LINKER_TYPE} == "lld" 303WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/lld/Common/Version.inc 304WANT_LINKER_FREEBSD_VERSION!= \ 305 awk '$$2 == "LLD_FREEBSD_VERSION" {print $$3}' \ 306 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown 307WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc 308WANT_LINKER_VERSION!= \ 309 awk '$$2 == "LLD_VERSION_STRING" {gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \ 310 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown 311.else 312WANT_LINKER_FREEBSD_VERSION_FILE= 313WANT_LINKER_FREEBSD_VERSION= 314.endif 315.export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION 316.endif # !defined(WANT_LINKER_FREEBSD_VERSION) 317 318.if ${MK_SYSTEM_LINKER} == "yes" && \ 319 defined(WANT_LINKER_FREEBSD_VERSION) && \ 320 (${MK_LLD_BOOTSTRAP} == "yes") && \ 321 !make(xdev*) && \ 322 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \ 323 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \ 324 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION} 325# Everything matches, disable the bootstrap linker. 326MK_LLD_BOOTSTRAP= no 327USING_SYSTEM_LINKER= yes 328.endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE} 329 330# WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug. 331USING_SYSTEM_COMPILER?= no 332USING_SYSTEM_LINKER?= no 333 334TEST_SYSTEM_COMPILER_VARS= \ 335 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \ 336 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \ 337 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \ 338 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \ 339 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \ 340 COMPILER_FREEBSD_VERSION \ 341 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \ 342 X_COMPILER_FREEBSD_VERSION 343TEST_SYSTEM_LINKER_VARS= \ 344 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \ 345 MK_LLD_BOOTSTRAP \ 346 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \ 347 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \ 348 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \ 349 LINKER_FREEBSD_VERSION \ 350 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \ 351 X_LINKER_FREEBSD_VERSION 352 353.for _t in compiler linker 354test-system-${_t}: .PHONY 355.for v in ${TEST_SYSTEM_${_t:tu}_VARS} 356 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}" 357.endfor 358.endfor 359.if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \ 360 make(toolchain) || make(_cross-tools)) 361.if ${USING_SYSTEM_COMPILER} == "yes" 362.info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler. 363.elif ${MK_CLANG_BOOTSTRAP} == "yes" 364.info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler. 365.endif 366.if ${USING_SYSTEM_LINKER} == "yes" 367.info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker. 368.elif ${MK_LLD_BOOTSTRAP} == "yes" 369.info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker. 370.endif 371.endif 372 373# End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD 374 375# Store some compiler metadata for use in installworld where we don't 376# want to invoke CC at all. 377_TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \ 378 COMPILER_TYPE \ 379 COMPILER_FEATURES \ 380 COMPILER_FREEBSD_VERSION \ 381 COMPILER_RESOURCE_DIR \ 382 LINKER_VERSION \ 383 LINKER_FEATURES \ 384 LINKER_TYPE \ 385 LINKER_FREEBSD_VERSION 386toolchain-metadata.mk: .PHONY .META 387 @: > ${.TARGET} 388 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \ 389 > ${.TARGET} 390 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET} 391.for v in ${_TOOLCHAIN_METADATA_VARS} 392 @echo "${v}=${${v}}" >> ${.TARGET} 393 @echo "X_${v}=${X_${v}}" >> ${.TARGET} 394.endfor 395 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET} 396 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET} 397 398 399# We must do lib/ and libexec/ before bin/ in case of a mid-install error to 400# keep the users system reasonably usable. For static->dynamic root upgrades, 401# we don't want to install a dynamic binary without rtld and the needed 402# libraries. More commonly, for dynamic root, we don't want to install a 403# binary that requires a newer library version that hasn't been installed yet. 404# This ordering is not a guarantee though. The only guarantee of a working 405# system here would require fine-grained ordering of all components based 406# on their dependencies. 407.if !empty(SUBDIR_OVERRIDE) 408SUBDIR= ${SUBDIR_OVERRIDE} 409.else 410SUBDIR= lib libexec 411# Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR 412# of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and 413# LOCAL_LIB_DIRS=foo/lib to behave as expected. 414.for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|} 415_REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*} 416.endfor 417.for _DIR in ${LOCAL_LIB_DIRS} 418.if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)) 419SUBDIR+= ${_DIR} 420.endif 421.endfor 422.if !defined(NO_ROOT) && (make(installworld) || make(install)) 423# Ensure libraries are installed before progressing. 424SUBDIR+=.WAIT 425.endif 426SUBDIR+=bin 427.if ${MK_CDDL} != "no" 428SUBDIR+=cddl 429.endif 430SUBDIR+=gnu include 431.if ${MK_KERBEROS} != "no" 432SUBDIR+=kerberos5 433.endif 434.if ${MK_RESCUE} != "no" 435SUBDIR+=rescue 436.endif 437SUBDIR+=sbin 438.if ${MK_CRYPT} != "no" 439SUBDIR+=secure 440.endif 441.if !defined(NO_SHARE) 442SUBDIR+=share 443.endif 444.if ${MK_BOOT} != "no" 445SUBDIR+=stand 446.endif 447SUBDIR+=sys usr.bin usr.sbin 448.if ${MK_TESTS} != "no" 449SUBDIR+= tests 450.endif 451 452# Local directories are built in parallel with the base system directories. 453# Users may insert a .WAIT directive at the beginning or elsewhere within 454# the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed. 455.for _DIR in ${LOCAL_DIRS} 456.if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile) 457SUBDIR+= ${_DIR} 458.endif 459.endfor 460 461# We must do etc/ last as it hooks into building the man whatis file 462# by calling 'makedb' in share/man. This is only relevant for 463# install/distribute so they build the whatis file after every manpage is 464# installed. 465.if make(installworld) || make(install) 466SUBDIR+=.WAIT 467.endif 468SUBDIR+=etc 469 470.endif # !empty(SUBDIR_OVERRIDE) 471 472.if defined(NOCLEAN) 473.warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN. 474MK_CLEAN:= no 475.endif 476.if defined(NO_CLEAN) 477.info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN. 478MK_CLEAN:= no 479.endif 480.if defined(NO_CLEANDIR) 481CLEANDIR= clean cleandepend 482.else 483CLEANDIR= cleandir 484.endif 485 486.if defined(WORLDFAST) 487MK_CLEAN:= no 488NO_OBJWALK= t 489.endif 490 491.if ${MK_META_MODE} == "yes" 492# If filemon is used then we can rely on the build being incremental-safe. 493# The .meta files will also track the build command and rebuild should 494# it change. 495.if empty(.MAKE.MODE:Mnofilemon) 496MK_CLEAN:= no 497.endif 498.endif 499.if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes" 500NO_OBJWALK= t 501NO_KERNELOBJ= t 502.endif 503.if !defined(NO_OBJWALK) 504_obj= obj 505.endif 506 507LOCAL_TOOL_DIRS?= 508PACKAGEDIR?= ${DESTDIR}/${DISTDIR} 509 510.if empty(SHELL:M*csh*) 511BUILDENV_SHELL?=${SHELL} 512.else 513BUILDENV_SHELL?=/bin/sh 514.endif 515 516.if !defined(_MKSHOWCONFIG) 517.if !defined(VCS_REVISION) || empty(VCS_REVISION) 518.if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD) 519. for _D in ${PATH:S,:, ,g} 520. if exists(${_D}/svnversion) 521SVNVERSION_CMD?=${_D}/svnversion 522. endif 523. if exists(${_D}/svnliteversion) 524SVNVERSION_CMD?=${_D}/svnliteversion 525. endif 526. endfor 527.endif 528.if defined(SVNVERSION_CMD) && !empty(SVNVERSION_CMD) 529_VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR}) 530. if !empty(_VCS_REVISION) 531VCS_REVISION= $$(echo r${_VCS_REVISION}) 532.export VCS_REVISION 533. endif 534.endif 535.endif 536 537.if !defined(GIT_CMD) || empty(GIT_CMD) 538. for _P in /usr/bin /usr/local/bin 539. if exists(${_P}/git) 540GIT_CMD= ${_P}/git 541. endif 542. endfor 543.export GIT_CMD 544.endif 545 546.if !defined(OSRELDATE) 547.if exists(/usr/include/osreldate.h) 548OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ 549 /usr/include/osreldate.h 550.else 551OSRELDATE= 0 552.endif 553.export OSRELDATE 554.endif 555 556# Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION. 557.for _V in BRANCH REVISION TYPE 558.if !defined(_${_V}) 559_${_V}!= eval $$(awk '/^${_V}=/{print}' ${SRCTOP}/sys/conf/newvers.sh); echo $$${_V} 560.export _${_V} 561.endif 562.endfor 563.if !defined(SRCRELDATE) 564SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ 565 ${SRCDIR}/sys/sys/param.h 566.export SRCRELDATE 567.endif 568.if !defined(VERSION) 569VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE} 570.export VERSION 571.endif 572MAJOR_REVISION= ${_REVISION:R} 573 574_PKG_REVISION= ${_REVISION} 575_STRTIMENOW= %Y%m%d%H%M%S 576_TIMENOW= ${_STRTIMENOW:gmtime} 577BRANCH_EXT= 578.if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*} 579_PKG_REVISION:= ${MAJOR_REVISION} 580BRANCH_EXT= ${MAJOR_REVISION}.snap 581EXTRA_REVISION= .snap${_TIMENOW} 582.elif ${_BRANCH:MALPHA*} 583BRANCH_EXT= alpha 584EXTRA_REVISION= .${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW} 585.elif ${_BRANCH:MBETA*} 586BRANCH_EXT= beta 587EXTRA_REVISION= .${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW} 588.elif ${_BRANCH:MRC*} 589BRANCH_EXT= rc 590EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW} 591.elif ${_BRANCH:M*-p*} 592EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/} 593.endif 594.if !defined(PKG_VERSION) 595PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g} 596.endif 597.endif # !defined(_MKSHOWCONFIG) 598 599.if make(*package*) 600.if !defined(PKG_TIMESTAMP) 601.if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git) 602SOURCE_DATE_EPOCH!= ${GIT_CMD} -C ${SRCDIR} show -s --format=%ct HEAD 603.else 604TIMEEPOCHNOW= %s 605SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime} 606.endif 607.else 608SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP} 609.endif 610PKG_WORKERS_COUNT?= 1 611 612PKG_NAME_PREFIX?= FreeBSD 613PKG_MAINTAINER?= re@FreeBSD.org 614PKG_WWW?= https://www.FreeBSD.org 615.export PKG_NAME_PREFIX 616.export PKG_MAINTAINER 617.export PKG_WWW 618.endif 619 620.if !defined(_MKSHOWCONFIG) 621_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \ 622 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE 623.if ${_CPUTYPE} != ${_TARGET_CPUTYPE} 624.error CPUTYPE global should be set with ?=. 625.endif 626.endif 627.if make(buildworld) 628BUILD_ARCH!= uname -p 629# On some Linux systems uname -p returns "unknown" so skip this check there. 630# This check only exists to tell people to use TARGET_ARCH instead of 631# MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine. 632.if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD" 633.error To cross-build, set TARGET_ARCH. 634.endif 635.endif 636WORLDTMP?= ${OBJTOP}/tmp 637BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec 638XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin 639 640# When building we want to find the cross tools before the host tools in ${BPATH}. 641# We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared 642# toolchain files (clang, lld, etc.) during make universe/tinderbox 643STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH} 644# We should not be using tools from /usr/bin accidentally since this could cause 645# the build to break on other systems that don't have that tool. For now we 646# still allow using the old behaviour (inheriting $PATH) if 647# BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed. 648 649# Currently strict $PATH can cause build failures. Once the remaining issues 650# have been resolved it will be turned on by default. 651BUILD_WITH_STRICT_TMPPATH?=0 652.if defined(CROSSBUILD_HOST) 653# When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible 654# with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH 655# during the world build stage. We build most tools during the bootstrap-tools 656# phase but symlink host tools that are known to work instead of building them 657BUILD_WITH_STRICT_TMPPATH:=1 658.endif 659.if ${BUILD_WITH_STRICT_TMPPATH} != 0 660TMPPATH= ${STRICTTMPPATH} 661.else 662TMPPATH= ${STRICTTMPPATH}:${PATH} 663.endif 664 665# 666# Avoid running mktemp(1) unless actually needed. 667# It may not be functional, e.g., due to new ABI 668# when in the middle of installing over this system. 669# 670.if make(distributeworld) || make(installworld) || make(stageworld) 671.if ${BUILD_WITH_STRICT_TMPPATH} != 0 672MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp 673.if !exists(${MKTEMP}) 674.error mktemp binary doesn't exist in expected location: ${MKTEMP} 675.endif 676.else 677MKTEMP=mktemp 678.endif 679INSTALLTMP!= ${MKTEMP} -d -u -t install 680 681.if ${.MAKE.OS} == "FreeBSD" 682# When building on FreeBSD we always copy the host tools instead of linking 683# into INSTALLTMP to avoid issues with incompatible libraries (see r364030). 684# Note: we could create links if we don't intend to update the current machine. 685INSTALLTMP_COPY_HOST_TOOL=cp 686.else 687# However, this is not necessary on Linux/macOS. Additionally, copying the host 688# tools to another directory with cp results in AMFI Launch Constraint 689# Violations on macOS Ventura as part of its System Integrity Protection. 690INSTALLTMP_COPY_HOST_TOOL=ln -s 691.endif 692.endif 693 694.if make(stagekernel) || make(distributekernel) 695TAGS+= kernel 696PACKAGE= kernel 697.endif 698 699# 700# Building a world goes through the following stages 701# 702# 1. legacy stage [BMAKE] 703# This stage is responsible for creating compatibility 704# shims that are needed by the bootstrap-tools, 705# build-tools and cross-tools stages. These are generally 706# APIs that tools from one of those three stages need to 707# build that aren't present on the host. 708# 1. bootstrap-tools stage [BMAKE] 709# This stage is responsible for creating programs that 710# are needed for backward compatibility reasons. They 711# are not built as cross-tools. 712# 2. build-tools stage [TMAKE] 713# This stage is responsible for creating the object 714# tree and building any tools that are needed during 715# the build process. Some programs are listed during 716# this phase because they build binaries to generate 717# files needed to build these programs. This stage also 718# builds the 'build-tools' target rather than 'all'. 719# 3. cross-tools stage [XMAKE] 720# This stage is responsible for creating any tools that 721# are needed for building the system. A cross-compiler is one 722# of them. This differs from build tools in two ways: 723# 1. the 'all' target is built rather than 'build-tools' 724# 2. these tools are installed into TMPPATH for stage 4. 725# 4. world stage [WMAKE] 726# This stage actually builds the world. 727# 5. install stage (optional) [IMAKE] 728# This stage installs a previously built world. 729# 730 731BOOTSTRAPPING?= 0 732# Keep these in sync 733MINIMUM_SUPPORTED_OSREL?= 1104001 734MINIMUM_SUPPORTED_REL?= 11.4 735 736# Common environment for world related stages 737CROSSENV+= \ 738 MACHINE_ARCH=${TARGET_ARCH} \ 739 MACHINE=${TARGET} \ 740 CPUTYPE=${TARGET_CPUTYPE} 741.if ${MK_META_MODE} != "no" 742# Don't rebuild build-tools targets during normal build. 743CROSSENV+= BUILD_TOOLS_META=.NOMETA 744.endif 745.if defined(TARGET_CFLAGS) 746CROSSENV+= ${TARGET_CFLAGS} 747.endif 748.if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \ 749 defined(WITHOUT_LOCAL_MODULES) 750CROSSENV+= LOCAL_MODULES= 751.endif 752 753BOOTSTRAPPING_OSRELDATE?=${OSRELDATE} 754 755# bootstrap-tools stage 756BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ 757 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \ 758 PATH=${BPATH:Q}:${PATH:Q} \ 759 WORLDTMP=${WORLDTMP} \ 760 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" 761# need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile 762BSARGS= DESTDIR= \ 763 OBJTOP='${WORLDTMP}/obj-tools' \ 764 OBJROOT='$${OBJTOP}/' \ 765 UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \ 766 MAKEOBJDIRPREFIX= \ 767 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ 768 BWPHASE=${.TARGET:C,^_,,} \ 769 -DNO_CPU_CFLAGS \ 770 -DNO_LINT \ 771 -DNO_PIC \ 772 -DNO_SHARED \ 773 MK_ASAN=no \ 774 MK_CTF=no \ 775 MK_CLANG_EXTRAS=no \ 776 MK_CLANG_FORMAT=no \ 777 MK_CLANG_FULL=no \ 778 MK_HTML=no \ 779 MK_MAN=no \ 780 MK_RETPOLINE=no \ 781 MK_SSP=no \ 782 MK_TESTS=no \ 783 MK_UBSAN=no \ 784 MK_WERROR=no \ 785 MK_INCLUDES=yes \ 786 MK_MAN_UTILS=yes 787 788BMAKE= \ 789 ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ 790 ${BSARGS} 791.if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL) 792BMAKE+= MK_LLVM_TARGET_ALL=no 793.endif 794 795# build-tools stage 796TMAKE= \ 797 ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ 798 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 799 DESTDIR= \ 800 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ 801 BWPHASE=${.TARGET:C,^_,,} \ 802 -DNO_CPU_CFLAGS \ 803 -DNO_LINT \ 804 MK_ASAN=no \ 805 MK_CTF=no \ 806 MK_CLANG_EXTRAS=no \ 807 MK_CLANG_FORMAT=no \ 808 MK_CLANG_FULL=no \ 809 MK_LLDB=no \ 810 MK_RETPOLINE=no \ 811 MK_SSP=no \ 812 MK_TESTS=no \ 813 MK_UBSAN=no \ 814 MK_WERROR=no 815 816# cross-tools stage 817# TOOLS_PREFIX set in BMAKE 818XMAKE= ${BMAKE} \ 819 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 820 MK_CLANG=${MK_CLANG_BOOTSTRAP} \ 821 MK_LLDB=no \ 822 MK_LLVM_BINUTILS=no \ 823 MK_TESTS=no 824 825# kernel-tools stage 826KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ 827 PATH=${BPATH:Q}:${PATH:Q} \ 828 WORLDTMP=${WORLDTMP} \ 829 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" 830 831KTMAKE= ${TIME_ENV} \ 832 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \ 833 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ 834 DESTDIR= \ 835 OBJTOP='${WORLDTMP}/obj-kernel-tools' \ 836 OBJROOT='$${OBJTOP}/' \ 837 UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \ 838 MAKEOBJDIRPREFIX= \ 839 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ 840 -DNO_CPU_CFLAGS \ 841 -DNO_LINT \ 842 -DNO_PIC \ 843 -DNO_SHARED \ 844 MK_CTF=no \ 845 MK_HTML=no \ 846 MK_MAN=no \ 847 MK_SSP=no \ 848 MK_RETPOLINE=no \ 849 MK_WERROR=no 850 851# world stage 852WMAKEENV= ${CROSSENV} \ 853 INSTALL="${INSTALL_CMD} -U" \ 854 PATH=${TMPPATH:Q} \ 855 SYSROOT=${WORLDTMP} 856 857# make hierarchy 858HMAKE= PATH=${TMPPATH:Q} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q} 859.if defined(NO_ROOT) 860HMAKE+= PATH=${TMPPATH:Q} METALOG=${METALOG} -DNO_ROOT 861.endif 862 863CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \ 864 CPP="${XCPP} ${XCFLAGS}" \ 865 AS="${XAS}" AR="${XAR}" ELFCTL="${XELFCTL}" LD="${XLD}" \ 866 LLVM_LINK="${XLLVM_LINK}" NM=${XNM} OBJCOPY="${XOBJCOPY}" \ 867 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \ 868 SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}" 869 870.if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX}) 871# In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a 872# directory, but the compiler will look in the right place for its 873# tools so we don't need to tell it where to look. 874BFLAGS+= -B${CROSS_BINUTILS_PREFIX} 875.endif 876 877 878# The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX 879# and target set by TARGET/TARGET_ARCH. However, there are several needs to 880# always pass an explicit --sysroot and -target. 881# - External compiler needs sysroot and target flags. 882# - External ld needs sysroot. 883# - To be clear about the use of a sysroot when using the internal compiler. 884# - Easier debugging. 885# - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to 886# the flip-flopping build command when sometimes using external and 887# sometimes using internal. 888# - Allow using lld which has no support for default paths. 889.if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX}) 890BFLAGS+= -B${WORLDTMP}/usr/bin 891.endif 892.if ${WANT_COMPILER_TYPE} == gcc || \ 893 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 894.elif ${WANT_COMPILER_TYPE} == clang || \ 895 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang) 896XCFLAGS+= -target ${TARGET_TRIPLE} 897.endif 898XCFLAGS+= --sysroot=${WORLDTMP} 899 900.if !empty(BFLAGS) 901XCFLAGS+= ${BFLAGS} 902.endif 903 904.include "share/mk/bsd.compat.pre.mk" 905.for LIBCOMPAT in ${_ALL_LIBCOMPATS} 906.if ${MK_LIB${LIBCOMPAT}} == "yes" 907_LIBCOMPATS+= ${LIBCOMPAT} 908.endif 909.endfor 910.include "Makefile.libcompat" 911 912# META_MODE normally ignores host file changes since every build updates 913# timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times 914# when the ABI breaks though that we want to force rebuilding WORLDTMP 915# to get updated host tools. 916.if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \ 917 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \ 918 !defined(_MKSHOWCONFIG) 919# r318736 - ino64 major ABI breakage 920META_MODE_BAD_ABI_VERS+= 1200031 921 922.if !defined(OBJDIR_HOST_OSRELDATE) 923.if exists(${OBJTOP}/host-osreldate.h) 924OBJDIR_HOST_OSRELDATE!= \ 925 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ 926 ${OBJTOP}/host-osreldate.h 927.elif exists(${WORLDTMP}/usr/include/osreldate.h) 928OBJDIR_HOST_OSRELDATE= 0 929.endif 930.export OBJDIR_HOST_OSRELDATE 931.endif 932 933# Note that this logic is the opposite of normal BOOTSTRAP handling. We want 934# to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP 935# is older than the ABI-breakage OSRELDATE of the HOST then we rebuild. 936.if defined(OBJDIR_HOST_OSRELDATE) 937.for _ver in ${META_MODE_BAD_ABI_VERS} 938.if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver} 939_meta_mode_need_rebuild= ${_ver} 940.endif 941.endfor 942.if defined(_meta_mode_need_rebuild) 943.info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}. 944NO_META_IGNORE_HOST_HEADERS= 1 945.export NO_META_IGNORE_HOST_HEADERS 946.endif # defined(_meta_mode_need_rebuild) 947.endif # defined(OBJDIR_HOST_OSRELDATE) 948.endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ... 949# This is only used for META_MODE+filemon to track what the oldest 950# __FreeBSD_version is in WORLDTMP. This purposely does NOT have 951# a make dependency on /usr/include/osreldate.h as the file should 952# only be copied when it is missing or meta mode determines it has changed. 953# Since host files are normally ignored without NO_META_IGNORE_HOST 954# the file will never be updated unless that flag is specified. This 955# allows tracking the oldest osreldate to force rebuilds via 956# META_MODE_BADABI_REVS above. 957host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here 958.if !defined(CROSSBUILD_HOST) 959 @cp -f /usr/include/osreldate.h ${.TARGET} 960.else 961 @echo "#ifndef __FreeBSD_version" > ${.TARGET} 962 @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET} 963 @echo "#endif" >> ${.TARGET} 964.endif 965 966WMAKE= ${TIME_ENV} ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ 967 BWPHASE=${.TARGET:C,^_,,} \ 968 DESTDIR=${WORLDTMP} 969 970IMAKEENV= ${CROSSENV} 971IMAKE= ${TIME_ENV} ${IMAKEENV} ${MAKE} -f Makefile.inc1 \ 972 ${IMAKE_INSTALL} ${IMAKE_MTREE} 973.if empty(.MAKEFLAGS:M-n) 974IMAKEENV+= PATH=${STRICTTMPPATH:Q}:${INSTALLTMP:Q} \ 975 LD_LIBRARY_PATH=${INSTALLTMP:Q} \ 976 PATH_LOCALE=${INSTALLTMP}/locale 977IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh 978.else 979IMAKEENV+= PATH=${TMPPATH:Q}:${INSTALLTMP:Q} 980.endif 981 982# When generating install media, do not allow user and group information from 983# the build host to affect the contents of the distribution. 984.if make(distributeworld) || make(distrib-dirs) || make(distribution) || \ 985 make(stageworld) 986DB_FROM_SRC= yes 987.endif 988 989.if defined(DB_FROM_SRC) 990INSTALLFLAGS+= -N ${.CURDIR}/etc 991MTREEFLAGS+= -N ${.CURDIR}/etc 992.endif 993_INSTALL_DDIR= ${DESTDIR}/${DISTDIR} 994INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::} 995.if defined(NO_ROOT) 996METALOG?= ${DESTDIR}/${DISTDIR}/METALOG 997METALOG:= ${METALOG:C,//+,/,g} 998IMAKE+= -DNO_ROOT METALOG=${METALOG} 999METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR} 1000INSTALLFLAGS+= ${METALOG_INSTALLFLAGS} 1001CERTCTLFLAGS= ${METALOG_INSTALLFLAGS} 1002MTREEFLAGS+= -W 1003.endif 1004.if defined(BUILD_PKGS) 1005INSTALLFLAGS+= -h sha256 1006.endif 1007.if defined(DB_FROM_SRC) || defined(NO_ROOT) 1008IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" 1009IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" 1010.endif 1011 1012.if make(distributeworld) || make(packageworld) || make(distributekernel) || \ 1013 make(packagekernel) 1014.if ${DISTDIR:U/} == / 1015.error DISTDIR must be set for make distribute* and make package*, and may not be the root directory. 1016.endif 1017.if !defined(NO_ROOT) || !defined(METALOG) 1018.error NO_ROOT and METALOG must be set for make distribute* and make package*. 1019.endif 1020.endif 1021 1022.if make(distributeworld) 1023CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR} 1024CERTCTLFLAGS+= -d /base 1025.else 1026CERTCTLDESTDIR= ${DESTDIR} 1027.endif 1028CERTCTLFLAGS+= -D "${CERTCTLDESTDIR}" 1029 1030DESTDIR_MTREEFLAGS= -deU 1031# When creating worldtmp we don't need to set the directories as owned by root 1032# so we also pass -W 1033WORLDTMP_MTREEFLAGS= -deUW 1034.if defined(NO_ROOT) 1035# When building with -DNO_ROOT we shouldn't be changing the directories 1036# that are created by mtree to be owned by root/wheel. 1037DESTDIR_MTREEFLAGS+= -W 1038.endif 1039.if defined(DB_FROM_SRC) 1040DISTR_MTREEFLAGS= -N ${.CURDIR}/etc 1041.endif 1042DISTR_MTREECMD= ${MTREE_CMD} 1043.if ${BUILD_WITH_STRICT_TMPPATH} != 0 1044DISTR_MTREECMD= ${WORLDTMP}/legacy/usr/sbin/mtree 1045.endif 1046DISTR_MTREE= ${DISTR_MTREECMD} ${DISTR_MTREEFLAGS} 1047WORLDTMP_MTREE= ${DISTR_MTREECMD} ${WORLDTMP_MTREEFLAGS} 1048DESTDIR_MTREE= ${DISTR_MTREECMD} ${DESTDIR_MTREEFLAGS} 1049 1050METALOG_SORT_CMD= env -i LC_COLLATE=C sort 1051 1052# kernel stage 1053KMAKEENV= ${WMAKEENV:NSYSROOT=*} 1054KMAKE= ${TIME_ENV} ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} 1055 1056# 1057# buildworld 1058# 1059# Attempt to rebuild the entire system, with reasonable chance of 1060# success, regardless of how old your existing system is. 1061# 1062_sanity_check: .PHONY .MAKE 1063.if ${.CURDIR:C/[^,]//g} != "" 1064# The m4 build of sendmail files doesn't like it if ',' is used 1065# anywhere in the path of it's files. 1066 @echo 1067 @echo "*** Error: path to source tree contains a comma ','" 1068 @echo 1069 @false 1070.elif ${.CURDIR:M*\:*} != "" 1071# Using ':' leaks into PATH and breaks finding cross-tools. 1072 @echo 1073 @echo "*** Error: path to source tree contains a colon ':'" 1074 @echo 1075 @false 1076.endif 1077 1078# Our current approach to dependency tracking cannot cope with certain source 1079# tree changes, particularly with respect to removing source files and 1080# replacing generated files. Handle these cases here in an ad-hoc fashion. 1081_cleanobj_fast_depend_hack: .PHONY 1082 @echo ">>> Deleting stale dependencies..."; 1083 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \ 1084 ALL_libcompats=${_ALL_libcompats:Q} \ 1085 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP} 1086 1087_cleanworldtmp: .PHONY 1088.if ${MK_CLEAN} == "yes" 1089 @echo 1090 @echo "--------------------------------------------------------------" 1091 @echo ">>> Cleaning up the temporary build tree" 1092 @echo "--------------------------------------------------------------" 1093 rm -rf ${WORLDTMP} 1094.else 1095# Note: for delete-old we need to set $PATH to also include the host $PATH 1096# since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/ 1097# will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH} 1098# so we remove that assignment from $WMAKE and prepend the new $PATH 1099 ${_+_}@if [ -e "${WORLDTMP}" ]; then \ 1100 echo ">>> Deleting stale files in build tree..."; \ 1101 cd ${.CURDIR}; env PATH=${TMPPATH:Q}:${PATH:Q} ${WMAKE:NPATH=*} \ 1102 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \ 1103 delete-old-libs >/dev/null; \ 1104 fi 1105 rm -rf ${WORLDTMP}/legacy/usr/include 1106.if ${USING_SYSTEM_COMPILER} == "yes" 1107.for cc in cc c++ 1108 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \ 1109 inum=$$(ls -i ${WORLDTMP}/usr/bin/${cc}); \ 1110 find ${WORLDTMP}/usr/bin -inum $${inum%% *} -delete; \ 1111 fi 1112.endfor 1113.endif # ${USING_SYSTEM_COMPILER} == "yes" 1114.if ${USING_SYSTEM_LINKER} == "yes" 1115 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld 1116.endif # ${USING_SYSTEM_LINKER} == "yes" 1117.endif # ${MK_CLEAN} == "yes" 1118_worldtmp: .PHONY 1119 @echo 1120 @echo "--------------------------------------------------------------" 1121 @echo ">>> Rebuilding the temporary build tree" 1122 @echo "--------------------------------------------------------------" 1123 @mkdir -p ${WORLDTMP} 1124 @touch ${WORLDTMP}/${.TARGET} 1125# We can't use mtree to create the worldtmp directories since it may not be 1126# available on the target system (this happens e.g. when building on non-FreeBSD) 1127 ${_+_}cd ${.CURDIR}/tools/build; \ 1128 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs 1129# In order to build without inheriting $PATH we need to add symlinks to the host 1130# tools in $WORLDTMP for the tools that we don't build during bootstrap-tools 1131 ${_+_}cd ${.CURDIR}/tools/build; \ 1132 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks 1133 1134_legacy: 1135 @echo 1136 @echo "--------------------------------------------------------------" 1137 @echo ">>> stage 1.1: legacy release compatibility shims" 1138 @echo "--------------------------------------------------------------" 1139 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy 1140_bootstrap-tools: 1141 @echo 1142 @echo "--------------------------------------------------------------" 1143 @echo ">>> stage 1.2: bootstrap tools" 1144 @echo "--------------------------------------------------------------" 1145.if ${MK_CLEAN} != "yes" 1146 ${_+_}cd ${.CURDIR}; ${BMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack 1147.endif 1148 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools 1149 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/geom ${WORLDTMP}/bin 1150 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 1151 -p ${WORLDTMP}/usr >/dev/null 1152 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 1153 -p ${WORLDTMP}/usr/include >/dev/null 1154.for d in ${LIBCOMPAT_INCLUDE_DIRS} 1155 mkdir -p ${WORLDTMP}/usr/include/${d} 1156.endfor 1157 ln -sf ${.CURDIR}/sys ${WORLDTMP} 1158.if ${MK_DEBUG_FILES} != "no" 1159 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 1160 -p ${WORLDTMP}/usr/lib >/dev/null 1161.endif 1162.for _mtree in ${LOCAL_MTREE} 1163 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null 1164.endfor 1165_cleanobj: 1166.if ${MK_CLEAN} == "yes" 1167 @echo 1168 @echo "--------------------------------------------------------------" 1169 @echo ">>> stage 2.1: cleaning up the object tree" 1170 @echo "--------------------------------------------------------------" 1171 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK 1172 # since the restricted $PATH might not contain a valid cc binary 1173 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR} 1174.for LIBCOMPAT in ${_LIBCOMPATS} 1175 ${_+_}cd ${.CURDIR}; ${LIB${LIBCOMPAT}WMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR} 1176.endfor 1177.else 1178 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack 1179.endif # ${MK_CLEAN} == "yes" 1180_obj: 1181 @echo 1182 @echo "--------------------------------------------------------------" 1183 @echo ">>> stage 2.2: rebuilding the object tree" 1184 @echo "--------------------------------------------------------------" 1185 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj 1186_build-tools: 1187 @echo 1188 @echo "--------------------------------------------------------------" 1189 @echo ">>> stage 2.3: build tools" 1190 @echo "--------------------------------------------------------------" 1191 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools 1192_cross-tools: 1193 @echo 1194 @echo "--------------------------------------------------------------" 1195 @echo ">>> stage 3: cross tools" 1196 @echo "--------------------------------------------------------------" 1197 @rm -f ${OBJTOP}/toolchain-metadata.mk 1198 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools 1199 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools 1200_build-metadata: 1201 @echo 1202 @echo "--------------------------------------------------------------" 1203 @echo ">>> stage 3.1: recording build metadata" 1204 @echo "--------------------------------------------------------------" 1205 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk 1206 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h 1207_includes: 1208 @echo 1209 @echo "--------------------------------------------------------------" 1210 @echo ">>> stage 4.1: building includes" 1211 @echo "--------------------------------------------------------------" 1212# Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need 1213# headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last. 1214 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ 1215 MK_INCLUDES=yes includes 1216.if !empty(SUBDIR_OVERRIDE) && make(buildworld) 1217 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes 1218.endif 1219 ${_+_}cd ${.CURDIR}; ${WMAKE} test-includes 1220_libraries: 1221 @echo 1222 @echo "--------------------------------------------------------------" 1223 @echo ">>> stage 4.2: building libraries" 1224 @echo "--------------------------------------------------------------" 1225 ${_+_}cd ${.CURDIR}; \ 1226 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \ 1227 MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \ 1228 libraries 1229everything: .PHONY 1230 @echo 1231 @echo "--------------------------------------------------------------" 1232 @echo ">>> stage 4.4: building everything" 1233 @echo "--------------------------------------------------------------" 1234 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all 1235 1236WMAKE_TGTS= 1237.if !defined(WORLDFAST) 1238WMAKE_TGTS+= _sanity_check _cleanworldtmp _worldtmp _legacy 1239.if empty(SUBDIR_OVERRIDE) 1240WMAKE_TGTS+= _bootstrap-tools 1241.endif 1242WMAKE_TGTS+= _cleanobj 1243.if !defined(NO_OBJWALK) 1244WMAKE_TGTS+= _obj 1245.endif 1246WMAKE_TGTS+= _build-tools _cross-tools 1247WMAKE_TGTS+= _build-metadata 1248WMAKE_TGTS+= _includes 1249.endif 1250.if !defined(NO_LIBS) 1251WMAKE_TGTS+= _libraries 1252.endif 1253.if empty(SUBDIR_OVERRIDE) 1254.for libcompat in ${libcompats} 1255WMAKE_TGTS+= build${libcompat} 1256.endfor 1257.endif 1258WMAKE_TGTS+= everything 1259 1260# record buildworld / install time in seconds 1261.if make(buildworld) 1262_BUILDWORLD_START!= date '+%s' 1263.export _BUILDWORLD_START 1264.endif 1265.if make(reinstall) || make(restage) 1266_INSTALLWORLD_START!= date '+%s' 1267.export _INSTALLWORLD_START 1268.endif 1269.if make(*installkernel*) 1270_INSTALLKERNEL_START!= date '+%s' 1271.export _INSTALLKERNEL_START 1272.endif 1273 1274buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY 1275.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue 1276 1277_ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown 1278 1279buildworld_prologue: .PHONY 1280 @echo "--------------------------------------------------------------" 1281 @echo ">>> World build started on `LC_ALL=C date`" 1282 @echo "--------------------------------------------------------------" 1283 1284buildworld_epilogue: .PHONY 1285 @echo 1286 @echo "--------------------------------------------------------------" 1287 @echo ">>> World build completed on `LC_ALL=C date`" 1288 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \ 1289 echo ">>> World built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}" 1290 @echo "--------------------------------------------------------------" 1291 1292# 1293# We need to have this as a target because the indirection between Makefile 1294# and Makefile.inc1 causes the correct PATH to be used, rather than a 1295# modification of the current environment's PATH. In addition, we need 1296# to quote multiword values. 1297# 1298buildenvvars: .PHONY 1299 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@} 1300 1301.if ${.TARGETS:Mbuildenv} 1302.if ${.MAKEFLAGS:M-j} 1303.error The buildenv target is incompatible with -j 1304.endif 1305.endif 1306BUILDENV_DIR?= ${.CURDIR} 1307# 1308# Note: make will report any errors the shell reports. This can 1309# be odd if the last command in an interactive shell generates an 1310# error or is terminated by SIGINT. These reported errors look bad, 1311# but are harmless. Allowing them also allows BUILDENV_SHELL to 1312# be a complex command whose status will be returned to the caller. 1313# Some scripts in tools rely on this behavior to report build errors. 1314# 1315buildenv: .PHONY 1316 @echo Entering world for ${TARGET_ARCH}:${TARGET} 1317.if ${BUILDENV_SHELL:M*zsh*} 1318 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE} 1319.endif 1320 @cd ${BUILDENV_DIR} && env ${WMAKEENV} \ 1321 INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \ 1322 MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL} 1323 1324TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:${libcompats:@v@Nbuild${v}@:ts:}} 1325toolchain: ${TOOLCHAIN_TGTS} .PHONY 1326KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries} 1327.if make(kernel-toolchain) 1328.ORDER: ${KERNEL_TOOLCHAIN_TGTS} 1329.endif 1330kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY 1331 1332# 1333# installcheck 1334# 1335# Checks to be sure system is ready for installworld/installkernel. 1336# 1337installcheck: _installcheck_world _installcheck_kernel .PHONY 1338_installcheck_world: .PHONY 1339 @echo "--------------------------------------------------------------" 1340 @echo ">>> Install check world started on `LC_ALL=C date`" 1341 @echo "--------------------------------------------------------------" 1342_installcheck_kernel: .PHONY 1343 @echo "--------------------------------------------------------------" 1344 @echo ">>> Install check kernel started on `LC_ALL=C date`" 1345 @echo "--------------------------------------------------------------" 1346 1347# 1348# Require DESTDIR to be set if installing for a different architecture or 1349# using the user/group database in the source tree. 1350# 1351.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \ 1352 defined(DB_FROM_SRC) 1353.if !make(distributeworld) 1354_installcheck_world: __installcheck_DESTDIR 1355_installcheck_kernel: __installcheck_DESTDIR 1356__installcheck_DESTDIR: .PHONY 1357.if !defined(DESTDIR) || empty(DESTDIR) 1358 @echo "ERROR: Please set DESTDIR!"; \ 1359 false 1360.endif 1361.endif 1362.endif 1363 1364.if !defined(DB_FROM_SRC) 1365# 1366# Check for missing UIDs/GIDs. 1367# 1368CHECK_UIDS= auditdistd 1369CHECK_GIDS= audit 1370CHECK_UIDS+= ntpd 1371CHECK_GIDS+= ntpd 1372CHECK_UIDS+= proxy 1373CHECK_GIDS+= proxy authpf 1374CHECK_UIDS+= smmsp 1375CHECK_GIDS+= smmsp 1376CHECK_UIDS+= unbound 1377CHECK_GIDS+= unbound 1378_installcheck_world: __installcheck_UGID 1379__installcheck_UGID: .PHONY 1380.for uid in ${CHECK_UIDS} 1381 @if ! `id -u ${uid} >/dev/null 2>&1`; then \ 1382 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \ 1383 false; \ 1384 fi 1385.endfor 1386.for gid in ${CHECK_GIDS} 1387 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \ 1388 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \ 1389 false; \ 1390 fi 1391.endfor 1392.endif 1393# 1394# If installing over the running system (DESTDIR is / or unset) and the install 1395# includes rescue, try running rescue from the objdir as a sanity check. If 1396# rescue is not functional (e.g., because it depends on a system call not 1397# supported by the currently running kernel), abort the installation. 1398# 1399.if !make(distributeworld) && ${MK_RESCUE} != "no" && \ 1400 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH) 1401_installcheck_world: __installcheck_sh_check 1402__installcheck_sh_check: .PHONY 1403 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \ 1404 OK ]; then \ 1405 echo "rescue/sh check failed, installation aborted" >&2; \ 1406 false; \ 1407 fi 1408.endif 1409 1410# 1411# Required install tools to be saved in a scratch dir for safety. 1412# 1413.if !defined(CROSSBUILD_HOST) 1414_sysctl=sysctl 1415.endif 1416 1417ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \ 1418 date echo egrep find grep id install ${_install-info} \ 1419 ln make mkdir mtree mv pwd_mkdb \ 1420 rm sed services_mkdb sh sort strip ${_sysctl} test time true uname wc 1421 1422.if ${MK_ZONEINFO} != "no" 1423ITOOLS+=tzsetup 1424.endif 1425 1426# Needed for share/man 1427.if ${MK_MAN_UTILS} != "no" 1428ITOOLS+=makewhatis 1429.endif 1430 1431ITOOLS+=${LOCAL_ITOOLS} 1432 1433# 1434# distributeworld 1435# 1436# Distributes everything compiled by a `buildworld'. 1437# 1438# installworld 1439# 1440# Installs everything compiled by a 'buildworld'. 1441# 1442 1443# Non-base distributions produced by the base system 1444EXTRA_DISTRIBUTIONS= 1445.for libcompat in ${libcompats} 1446EXTRA_DISTRIBUTIONS+= lib${libcompat} 1447.endfor 1448.if ${MK_TESTS} != "no" 1449EXTRA_DISTRIBUTIONS+= tests 1450.endif 1451 1452DEBUG_DISTRIBUTIONS= 1453.if ${MK_DEBUG_FILES} != "no" 1454DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,} 1455.endif 1456 1457MTREE_MAGIC?= mtree 2.0 1458 1459distributeworld installworld stageworld: _installcheck_world .PHONY 1460 mkdir -p ${INSTALLTMP} 1461 progs=$$(for prog in ${ITOOLS}; do \ 1462 if progpath=`env PATH=${TMPPATH:Q} which $$prog`; then \ 1463 echo $$progpath; \ 1464 else \ 1465 echo "Required tool $$prog not found in PATH ("${TMPPATH:Q}")." >&2; \ 1466 exit 1; \ 1467 fi; \ 1468 done); \ 1469 if [ -z "${CROSSBUILD_HOST}" ] ; then \ 1470 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | grep -Ev '\[.*]' | \ 1471 while read line; do \ 1472 set -- $$line; \ 1473 if [ "$$2 $$3" != "not found" ]; then \ 1474 echo $$2; \ 1475 else \ 1476 echo "Required library $$1 not found." >&2; \ 1477 exit 1; \ 1478 fi; \ 1479 done); \ 1480 fi; \ 1481 ${INSTALLTMP_COPY_HOST_TOOL} $$libs $$progs ${INSTALLTMP} 1482 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale 1483.if defined(NO_ROOT) 1484 -mkdir -p ${METALOG:H} 1485 echo "#${MTREE_MAGIC}" > ${METALOG} 1486.endif 1487.if make(distributeworld) 1488.for dist in ${EXTRA_DISTRIBUTIONS} 1489 -mkdir ${DESTDIR}/${DISTDIR}/${dist} 1490 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \ 1491 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null 1492 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 1493 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null 1494 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 1495 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null 1496.for d in ${LIBCOMPAT_INCLUDE_DIRS} 1497 -mkdir ${DESTDIR}/${DISTDIR}/${dist}/usr/include/${d} 1498.endfor 1499.if ${MK_DEBUG_FILES} != "no" 1500 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 1501 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null 1502.endif 1503.for libcompat in ${libcompats} 1504 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 1505 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null 1506.if ${MK_DEBUG_FILES} != "no" 1507 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 1508 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null 1509.endif 1510.endfor 1511.if ${MK_TESTS} != "no" && ${dist} == "tests" 1512 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} 1513 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 1514 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null 1515.if ${MK_DEBUG_FILES} != "no" 1516 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 1517 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug${TESTSBASE} >/dev/null 1518.endif 1519.endif 1520 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ 1521 sed -e 's#^\./#./${dist}/#' >> ${METALOG} 1522 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \ 1523 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} 1524 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \ 1525 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG} 1526.for d in ${LIBCOMPAT_INCLUDE_DIRS} 1527 echo "./${dist}/usr/include/${d} type=dir uname=root gname=wheel mode=0755" >> ${METALOG} 1528.endfor 1529.for libcompat in ${libcompats} 1530 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \ 1531 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} 1532.endfor 1533.endfor 1534 -mkdir ${DESTDIR}/${DISTDIR}/base 1535 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \ 1536 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \ 1537 DISTBASE=/base DESTDIR=${INSTALL_DDIR}/base \ 1538 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs 1539 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys 1540.endif # make(distributeworld) 1541 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \ 1542 ${IMAKEENV} rm -rf ${INSTALLTMP} 1543.if !make(packageworld) && ${MK_CAROOT} != "no" 1544 @if which openssl>/dev/null; then \ 1545 PATH=${TMPPATH:Q}:${PATH:Q} \ 1546 LOCALBASE=${LOCALBASE:Q} \ 1547 sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash; \ 1548 else \ 1549 echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \ 1550 fi 1551.endif 1552.if make(distributeworld) 1553.for dist in ${EXTRA_DISTRIBUTIONS} 1554 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete 1555.endfor 1556.for dist in base ${EXTRA_DISTRIBUTIONS} 1557.for path suffix in "" .meta /usr/lib/debug .debug.meta 1558 @# For each file that exists in this dist, print the corresponding 1559 @# line from the METALOG. This relies on the fact that 1560 @# a line containing only the filename will sort immediately before 1561 @# the relevant mtree line. 1562 cd ${DESTDIR}/${DISTDIR}; \ 1563 find ./${dist}${path} | ${METALOG_SORT_CMD} -u ${METALOG} - | \ 1564 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}/, "."); print } }' > \ 1565 ${DESTDIR}/${DISTDIR}/${dist}${suffix} 1566.endfor 1567.endfor 1568.endif # make(distributeworld) 1569 1570packageworld: .PHONY 1571.for dist in base ${EXTRA_DISTRIBUTIONS} 1572 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1573 ${TAR_CMD} cvf - --exclude usr/lib/debug \ 1574 @${DESTDIR}/${DISTDIR}/${dist}.meta | \ 1575 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz 1576.endfor 1577 1578.for dist in ${DEBUG_DISTRIBUTIONS} 1579 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1580 ${TAR_CMD} cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \ 1581 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz 1582.endfor 1583 1584makeman: .PHONY 1585 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \ 1586 ${.CURDIR}/share/man/man5/src.conf.5 1587 1588# Ensure no regressions in self-includeability of sys/*.h and net*/*.h 1589test-includes: .PHONY 1590 ${_+_}cd ${.CURDIR}/tools/build/test-includes; \ 1591 ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} DESTDIR=${WORLDTMP} test-includes 1592 1593# We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec 1594# because we may be building with a STRICTTMPPATH, so we explicitly include 1595# /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else 1596# we may need to function. 1597_sysent_PATH= ${TMPPATH}:/usr/libexec 1598_sysent_dirs= sys/kern 1599_sysent_dirs+= sys/compat/freebsd32 1600_sysent_dirs+= sys/amd64/linux \ 1601 sys/amd64/linux32 \ 1602 sys/arm64/linux \ 1603 sys/i386/linux \ 1604 sys/tools/syscalls/examples/cpp 1605 1606sysent: .PHONY 1607.for _dir in ${_sysent_dirs} 1608sysent-${_dir}: .PHONY 1609 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent" 1610 ${_+_}@env PATH=${_sysent_PATH:Q} ${MAKE} -C ${.CURDIR}/${_dir} sysent 1611 1612sysent: sysent-${_dir} 1613.endfor 1614 1615# 1616# reinstall 1617# 1618# If you have a build server, you can NFS mount the source and obj directories 1619# and do a 'make reinstall' on the *client* to install new binaries from the 1620# most recent server build. 1621# 1622restage reinstall: .MAKE .PHONY 1623 @echo "--------------------------------------------------------------" 1624 @echo ">>> Making hierarchy" 1625 @echo "--------------------------------------------------------------" 1626 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ 1627 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy 1628.if make(restage) 1629 @echo "--------------------------------------------------------------" 1630 @echo ">>> Making distribution" 1631 @echo "--------------------------------------------------------------" 1632 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ 1633 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution 1634.endif 1635 @echo 1636 @echo "--------------------------------------------------------------" 1637 @echo ">>> Installing everything started on `LC_ALL=C date`" 1638 @echo "--------------------------------------------------------------" 1639 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install 1640.for libcompat in ${libcompats} 1641 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat} 1642.endfor 1643 @echo "--------------------------------------------------------------" 1644 @echo ">>> Installing everything completed on `LC_ALL=C date`" 1645 @seconds=$$(($$(date '+%s') - ${_INSTALLWORLD_START})); \ 1646 echo ">>> Install world completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}" 1647 @echo "--------------------------------------------------------------" 1648 1649redistribute: .MAKE .PHONY 1650 @echo "--------------------------------------------------------------" 1651 @echo ">>> Distributing everything" 1652 @echo "--------------------------------------------------------------" 1653 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute 1654.for libcompat in ${libcompats} 1655 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \ 1656 DISTRIBUTION=lib${libcompat} 1657.endfor 1658 1659distrib-dirs distribution: .MAKE .PHONY 1660 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \ 1661 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} 1662.if make(distribution) 1663 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH:Q} \ 1664 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \ 1665 METALOG=${METALOG} MK_TESTS=no \ 1666 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig 1667.endif 1668 1669# 1670# buildetc and installetc 1671# 1672buildetc: .MAKE .PHONY 1673 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _worldtmp 1674 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _legacy 1675 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _bootstrap-tools \ 1676 MK_CROSS_COMPILER=no MK_TOOLCHAIN=no 1677 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _obj \ 1678 SUBDIR_OVERRIDE=etc 1679 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 everything \ 1680 SUBDIR_OVERRIDE=etc 1681 1682installetc: .MAKE .PHONY 1683 @echo "--------------------------------------------------------------" 1684 @echo ">>> Making hierarchy" 1685 @echo "--------------------------------------------------------------" 1686 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distrib-dirs 1687 @echo "--------------------------------------------------------------" 1688 @echo ">>> Making distribution" 1689 @echo "--------------------------------------------------------------" 1690 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribution 1691 1692# 1693# buildkernel and installkernel 1694# 1695# Which kernels to build and/or install is specified by setting 1696# KERNCONF. If not defined a GENERIC kernel is built/installed. 1697# Only the existing (depending TARGET) config files are used 1698# for building kernels and only the first of these is designated 1699# as the one being installed. 1700# 1701# Note that we have to use TARGET instead of TARGET_ARCH when 1702# we're in kernel-land. Since only TARGET_ARCH is (expected) to 1703# be set to cross-build, we have to make sure TARGET is set 1704# properly. 1705 1706.if defined(KERNFAST) 1707NO_KERNELCLEAN= t 1708NO_KERNELCONFIG= t 1709NO_KERNELOBJ= t 1710# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah 1711.if !defined(KERNCONF) && ${KERNFAST} != "1" 1712KERNCONF=${KERNFAST} 1713.endif 1714.endif 1715GENERIC_KERNCONF_SUFX_powerpc64= 64 1716GENERIC_KERNCONF_SUFX_powerpc64le= 64LE 1717GENERIC_KERNCONF_powerpcspe= MPC85XXSPE 1718GENERIC_KERNCONF?= ${GENERIC_KERNCONF_${TARGET_ARCH}:UGENERIC${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}}} 1719INSTKERNNAME?= kernel 1720 1721KERNSRCDIR?= ${.CURDIR}/sys 1722KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf 1723KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,} 1724KERNCONFDIR?= ${KRNLCONFDIR} 1725 1726.for _k in ${GENERIC_KERNCONF} MINIMAL${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}} ${GENERIC_KERNCONF}-MMCCAM 1727.if exists(${KERNCONFDIR}/${_k}) 1728PKG_KERNCONF+= ${_k} 1729.for _dbg in NODEBUG DEBUG 1730.if exists(${KERNCONFDIR}/${_k}-${_dbg}) 1731PKG_KERNCONF+= ${_k}-${_dbg} 1732.endif 1733.endfor 1734.endif 1735.endfor 1736 1737.if defined(PACKAGE_BUILDING) 1738KERNCONF?= ${PKG_KERNCONF} 1739.else 1740KERNCONF?= ${GENERIC_KERNCONF} 1741.endif 1742 1743BUILDKERNELS= 1744INSTALLKERNEL= 1745.if defined(NO_INSTALLKERNEL) 1746# All of the BUILDKERNELS loops start at index 1. 1747BUILDKERNELS+= dummy 1748.endif 1749.for _kernel in ${KERNCONF} 1750.if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel}) 1751BUILDKERNELS+= ${_kernel} 1752.if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL) 1753INSTALLKERNEL= ${_kernel} 1754.endif 1755.else 1756.if make(buildkernel) 1757.error Missing KERNCONF ${KERNCONFDIR}/${_kernel} 1758.endif 1759.endif 1760.endfor 1761 1762_cleankernobj_fast_depend_hack: .PHONY 1763# 20191009 r353340 removal of opensolaris_atomic.S (also r353381) 1764.if ${MACHINE} != i386 1765.for f in opensolaris_atomic 1766.for m in opensolaris zfs 1767 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \ 1768 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \ 1769 echo "Removing stale dependencies for opensolaris_atomic"; \ 1770 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \ 1771 fi 1772.endfor 1773.endfor 1774.endif 1775 1776${WMAKE_TGTS:N_cleanworldtmp:N_worldtmp:${libcompats:@v@Nbuild${v}@:ts:}}: .MAKE .PHONY 1777${.ALLTARGETS:M_*:N_cleanworldtmp:N_worldtmp}: .MAKE .PHONY 1778 1779# record kernel(s) build time in seconds 1780.if make(buildkernel) 1781_BUILDKERNEL_START!= date '+%s' 1782.endif 1783 1784# 1785# buildkernel 1786# 1787# Builds all kernels defined by BUILDKERNELS. 1788# 1789buildkernel: .MAKE .PHONY 1790.if empty(BUILDKERNELS:Ndummy) 1791 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ 1792 false 1793.endif 1794 @echo 1795.for _kernel in ${BUILDKERNELS:Ndummy} 1796 @echo "--------------------------------------------------------------" 1797 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" 1798 @echo "--------------------------------------------------------------" 1799 @echo "===> ${_kernel}" 1800 mkdir -p ${KRNLOBJDIR} 1801.if !defined(NO_KERNELCONFIG) 1802 @echo 1803 @echo "--------------------------------------------------------------" 1804 @echo ">>> stage 1: configuring the kernel" 1805 @echo "--------------------------------------------------------------" 1806 cd ${KRNLCONFDIR}; \ 1807 PATH=${TMPPATH:Q} \ 1808 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ 1809 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \ 1810 '${KERNCONFDIR}/${_kernel}' 1811.endif 1812.if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN) 1813 @echo 1814 @echo "--------------------------------------------------------------" 1815 @echo ">>> stage 2.1: cleaning up the object tree" 1816 @echo "--------------------------------------------------------------" 1817 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} 1818.else 1819 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack 1820.endif 1821.if !defined(NO_KERNELOBJ) 1822 @echo 1823 @echo "--------------------------------------------------------------" 1824 @echo ">>> stage 2.2: rebuilding the object tree" 1825 @echo "--------------------------------------------------------------" 1826 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj 1827.endif 1828 @echo 1829 @echo "--------------------------------------------------------------" 1830 @echo ">>> stage 2.3: build tools" 1831 @echo "--------------------------------------------------------------" 1832 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools 1833 @echo 1834 @echo "--------------------------------------------------------------" 1835 @echo ">>> stage 3.1: building everything" 1836 @echo "--------------------------------------------------------------" 1837 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ 1838 @echo "--------------------------------------------------------------" 1839 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" 1840 @echo "--------------------------------------------------------------" 1841 1842.endfor 1843 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \ 1844 echo ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}" 1845 @echo "--------------------------------------------------------------" 1846 1847.if !make(packages) && !make(update-packages) 1848NO_INSTALLEXTRAKERNELS?= yes 1849.else 1850# packages/update-packages installs kernels to a staging directory then builds 1851# packages from the result to be installed, typically to other systems. It is 1852# less surprising for these targets to honor KERNCONF if multiple kernels are 1853# specified. 1854NO_INSTALLEXTRAKERNELS?= no 1855.endif 1856 1857# 1858# installkernel, etc. 1859# 1860# Install the kernel defined by INSTALLKERNEL 1861# 1862installkernel installkernel.debug \ 1863reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY 1864.if !defined(NO_INSTALLKERNEL) 1865.if empty(INSTALLKERNEL) 1866 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 1867 false 1868.endif 1869 @echo "--------------------------------------------------------------" 1870 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)" 1871 @echo "--------------------------------------------------------------" 1872 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 1873 ${CROSSENV} PATH=${TMPPATH:Q} \ 1874 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} METALOG=${METALOG} \ 1875 ${.TARGET:S/kernel//} 1876 @echo "--------------------------------------------------------------" 1877 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)" 1878 @echo "--------------------------------------------------------------" 1879 @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \ 1880 echo ">>> Install kernel(s) ${INSTALLKERNEL} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}" 1881 @echo "--------------------------------------------------------------" 1882.endif 1883.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1884.for _kernel in ${BUILDKERNELS:[2..-1]} 1885 @echo "--------------------------------------------------------------" 1886 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)" 1887 @echo "--------------------------------------------------------------" 1888 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \ 1889 ${CROSSENV} PATH=${TMPPATH:Q} \ 1890 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} METALOG=${METALOG} \ 1891 ${.TARGET:S/kernel//} 1892 @echo "--------------------------------------------------------------" 1893 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)" 1894 @echo "--------------------------------------------------------------" 1895.endfor 1896 @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \ 1897 echo ">>> Install kernel(s) ${BUILDKERNELS} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}" 1898 @echo "--------------------------------------------------------------" 1899.endif 1900 1901distributekernel distributekernel.debug: .PHONY 1902.if !defined(NO_INSTALLKERNEL) 1903.if empty(INSTALLKERNEL) 1904 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 1905 false 1906.endif 1907 mkdir -p ${DESTDIR}/${DISTDIR} 1908 rm -f ${DESTDIR}/${DISTDIR}/kernel.premeta 1909 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 1910 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \ 1911 ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} KERNEL=${INSTKERNNAME} \ 1912 DISTBASE=/kernel DESTDIR=${INSTALL_DDIR}/kernel \ 1913 METALOG=${METALOG:S/METALOG/kernel.premeta/} \ 1914 ${.TARGET:S/distributekernel/install/} 1915.if defined(NO_ROOT) 1916 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.meta 1917 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta | \ 1918 ${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.meta 1919.endif 1920.endif 1921.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1922.for _kernel in ${BUILDKERNELS:[2..-1]} 1923 rm -f ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta 1924 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \ 1925 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \ 1926 ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} \ 1927 KERNEL=${INSTKERNNAME}.${_kernel} \ 1928 DISTBASE=/kernel.${_kernel} DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \ 1929 METALOG=${METALOG:S/METALOG/kernel.${_kernel}.premeta/} \ 1930 ${.TARGET:S/distributekernel/install/} 1931.if defined(NO_ROOT) 1932 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta 1933 sed -e "s|^./kernel.${_kernel}|.|" \ 1934 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta | \ 1935 ${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta 1936.endif 1937.endfor 1938.endif 1939 1940packagekernel: .PHONY 1941.if defined(NO_ROOT) 1942.if !defined(NO_INSTALLKERNEL) 1943 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1944 ${TAR_CMD} cvf - --exclude '*.debug' \ 1945 @${DESTDIR}/${DISTDIR}/kernel.meta | \ 1946 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz 1947.endif 1948.if ${MK_DEBUG_FILES} != "no" 1949 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1950 ${TAR_CMD} cvf - --include '*/*/*.debug' \ 1951 @${DESTDIR}/${DISTDIR}/kernel.meta | \ 1952 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz 1953.endif 1954.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1955.for _kernel in ${BUILDKERNELS:[2..-1]} 1956 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1957 ${TAR_CMD} cvf - --exclude '*.debug' \ 1958 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ 1959 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz 1960.if ${MK_DEBUG_FILES} != "no" 1961 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1962 ${TAR_CMD} cvf - --include '*/*/*.debug' \ 1963 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ 1964 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz 1965.endif 1966.endfor 1967.endif 1968.else 1969.if !defined(NO_INSTALLKERNEL) 1970 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1971 ${TAR_CMD} cvf - --exclude '*.debug' . | \ 1972 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz 1973.endif 1974.if ${MK_DEBUG_FILES} != "no" 1975 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1976 ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \ 1977 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz 1978.endif 1979.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1980.for _kernel in ${BUILDKERNELS:[2..-1]} 1981 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1982 ${TAR_CMD} cvf - --exclude '*.debug' . | \ 1983 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz 1984.if ${MK_DEBUG_FILES} != "no" 1985 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1986 ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \ 1987 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz 1988.endif 1989.endfor 1990.endif 1991.endif 1992 1993stagekernel: .PHONY 1994 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} DISTDIR=. distributekernel 1995 1996PORTSDIR?= /usr/ports 1997WSTAGEDIR?= ${OBJTOP}/worldstage 1998KSTAGEDIR?= ${OBJTOP}/kernelstage 1999SSTAGEDIR?= ${OBJTOP}/sourcestage 2000REPODIR?= ${OBJROOT}repo 2001PKG_FORMAT?= tzst 2002PKG_LEVEL?= -1 2003PKG_CLEVEL?= ${"${PKG_FORMAT:Mtar}" != "":?:-l ${PKG_LEVEL}} 2004PKG_REPO_SIGNING_KEY?= # empty 2005PKG_OUTPUT_DIR?= ${PKG_VERSION} 2006PKG_ABI_FILE?= ${WSTAGEDIR}/usr/bin/uname 2007.if make(create-*-packages*) || make(real-update-packages) || make(real-sign-packages) 2008PKG_ABI!= ${PKG_CMD} -o ABI_FILE=${PKG_ABI_FILE} config ABI 2009.endif 2010 2011.ORDER: stage-packages create-packages 2012.ORDER: create-packages create-world-packages 2013.ORDER: create-packages create-source-packages 2014.ORDER: create-packages create-kernel-packages 2015.ORDER: create-packages sign-packages 2016 2017_pkgbootstrap: .PHONY 2018.if make(*package*) && !exists(${LOCALBASE}/sbin/pkg) 2019 @env ASSUME_ALWAYS_YES=YES pkg bootstrap 2020.endif 2021 2022PKG_BIN_VERSION!=${PKG_CMD} --version </dev/null 2>/dev/null |\ 2023 awk -F. '/^[0-9.]+$$/ {print $$1 * 10000 + $$2 * 100 + $$3}' 2024.if ${PKG_BIN_VERSION} < 11700 2025PKG_EXT= ${PKG_FORMAT} 2026.else 2027PKG_EXT= pkg 2028.endif 2029 2030.if !defined(PKG_VERSION_FROM) && make(real-update-packages) 2031.if exists(${PKG_ABI_FILE}) && exists(${REPODIR}/${PKG_ABI}) 2032PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest 2033PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM} 2034# Determine the name of the branch base on the version 2035# X.bY => beta 2036# X.aY => alpha 2037# X.rcY => rc 2038# X.snap => snap 2039# all others mean release 2040# 2041# This will be used when comparing to the branch that we are building 2042# to decide if we keep old packages or new packages when only their 2043# version differs 2044BRANCH_EXT_FROM= 2045.if ${PKG_VERSION_FROM:M*.snap*} 2046BRANCH_EXT_FROM= ${PKG_VERSION_FROM:C/.snap.*$//}.snap 2047.elif ${PKG_VERSION_FROM:M*.b*} 2048BRANCH_EXT_FROM= beta 2049.elif ${PKG_VERSION_FROM:M*.rc*} 2050BRANCH_EXT_FROM= rc 2051.elif ${PKG_VERSION_FROM:M*.a*} 2052BRANCH_EXT_FROM= alpha 2053.endif 2054.else 2055PKG_VERSION_FROM= 2056PKG_VERSION_FROM_DIR= 2057BRANCH_EXT_FROM= 2058.endif 2059.endif 2060 2061PKGMAKEARGS+= PKG_VERSION=${PKG_VERSION} \ 2062 NO_INSTALLEXTRAKERNELS=${NO_INSTALLEXTRAKERNELS} 2063 2064packages: .PHONY 2065 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-packages 2066 2067update-packages: .PHONY 2068 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages 2069 2070package-pkg: .PHONY 2071 rm -rf /tmp/ports.${TARGET} || : 2072 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \ 2073 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \ 2074 WSTAGEDIR=${WSTAGEDIR} \ 2075 OSVERSION="${SRCRELDATE}" \ 2076 sh ${.CURDIR}/release/scripts/make-pkg-package.sh 2077 2078real-packages: stage-packages create-packages sign-packages .PHONY 2079 2080real-update-packages: stage-packages .PHONY 2081 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages 2082.if empty(PKG_VERSION_FROM_DIR) 2083 @echo "==> Bootstrapping repository, not checking for new packages" 2084.else 2085 @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})" 2086 @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \ 2087 pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \ 2088 newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_EXT} ; \ 2089 oldsum=$$(pkg query -F $${pkg} '%X') ; \ 2090 if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \ 2091 continue; \ 2092 fi ; \ 2093 newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \ 2094 if [ "${BRANCH_EXT_FROM}" = "${BRANCH_EXT}" -a "$${oldsum}" = "$${newsum}" ]; then \ 2095 echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_EXT}" ; \ 2096 rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \ 2097 cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \ 2098 else \ 2099 echo "==> New package $${newpkgname}" ; \ 2100 fi ; \ 2101 done 2102.endif 2103 ${_+_}@cd ${.CURDIR}; \ 2104 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages 2105 2106stage-packages-world: .PHONY 2107 @mkdir -p ${WSTAGEDIR} 2108 ${_+_}@cd ${.CURDIR}; \ 2109 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld 2110 2111stage-packages-kernel: .PHONY 2112 @mkdir -p ${KSTAGEDIR} 2113 ${_+_}@cd ${.CURDIR}; \ 2114 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel 2115 2116stage-packages-source: .PHONY 2117 @mkdir -p ${SSTAGEDIR}; 2118 2119stage-packages: .PHONY stage-packages-world stage-packages-kernel stage-packages-source 2120 2121_repodir: .PHONY 2122 @mkdir -p ${REPODIR} 2123 2124create-packages-world: _pkgbootstrap _repodir .PHONY 2125 ${_+_}@cd ${.CURDIR}; \ 2126 ${MAKE} -f Makefile.inc1 \ 2127 DESTDIR=${WSTAGEDIR} \ 2128 PKG_VERSION=${PKG_VERSION} create-world-packages 2129 2130create-packages-kernel: _pkgbootstrap _repodir .PHONY 2131 ${_+_}@cd ${.CURDIR}; \ 2132 ${MAKE} -f Makefile.inc1 \ 2133 DESTDIR=${KSTAGEDIR} \ 2134 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \ 2135 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 2136 create-kernel-packages 2137 2138create-packages-kernel-repo: .PHONY create-packages-kernel sign-packages 2139 2140create-packages-world-repo: .PHONY create-packages-world sign-packages 2141 2142create-packages-source: _pkgbootstrap _repodir .PHONY 2143 ${_+_}@cd ${.CURDIR}; \ 2144 ${MAKE} -f Makefile.inc1 \ 2145 DESTDIR=${SSTAGEDIR} \ 2146 PKG_VERSION=${PKG_VERSION} create-source-packages 2147 2148create-packages: .PHONY create-packages-world create-packages-kernel create-packages-source 2149 2150create-source-src-package: _pkgbootstrap .PHONY 2151 rm -f ${SSTAGEDIR}/src.plist 2>/dev/null || : 2152.if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git) 2153 @cd ${SRCDIR}; \ 2154 ( echo "@override_prefix /usr/src" ; \ 2155 ${GIT_CMD} ls-files --recurse-submodules ":!:sys/" ) \ 2156 > ${SSTAGEDIR}/src.plist 2157 ${SRCDIR}/release/packages/generate-ucl.lua \ 2158 PKGNAME "src" \ 2159 PKGGENNAME "src" \ 2160 VERSION "${PKG_VERSION}" \ 2161 DESC "FreeBSD Kernel Sources" \ 2162 COMMENT "FreeBSD Userland Sources" \ 2163 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 2164 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 2165 PKG_WWW "${PKG_WWW}" \ 2166 ${SRCDIR}/release/packages/template.ucl \ 2167 ${SSTAGEDIR}/src.ucl 2168 ${PKG_CMD} -o ABI=${PKG_ABI} \ 2169 -o OSVERSION="${SRCRELDATE}" \ 2170 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2171 -M ${SSTAGEDIR}/src.ucl \ 2172 -p ${SSTAGEDIR}/src.plist \ 2173 -r ${SRCDIR} \ 2174 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} 2175.endif 2176 2177create-source-src-sys-package: _pkgbootstrap .PHONY 2178 rm -f ${SSTAGEDIR}/src-sys.plist 2>/dev/null || : 2179.if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git) 2180 @cd ${SRCDIR}; \ 2181 ( echo "@override_prefix /usr/src" ; \ 2182 ${GIT_CMD} ls-files --recurse-submodules "sys/" ) \ 2183 > ${SSTAGEDIR}/src-sys.plist 2184 ${SRCDIR}/release/packages/generate-ucl.lua \ 2185 PKGNAME "src-sys" \ 2186 PKGGENNAME "src" \ 2187 VERSION "${PKG_VERSION}" \ 2188 DESC "FreeBSD Kernel Sources" \ 2189 COMMENT "FreeBSD Kernel Sources" \ 2190 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 2191 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 2192 PKG_WWW "${PKG_WWW}" \ 2193 ${SRCDIR}/release/packages/template.ucl \ 2194 ${SSTAGEDIR}/src-sys.ucl 2195 ${PKG_CMD} -o ABI=${PKG_ABI} \ 2196 -o OSVERSION="${SRCRELDATE}" \ 2197 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2198 -M ${SSTAGEDIR}/src-sys.ucl \ 2199 -p ${SSTAGEDIR}/src-sys.plist \ 2200 -r ${SRCDIR} \ 2201 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} 2202.endif 2203 2204create-source-packages: .PHONY _pkgbootstrap create-source-src-package create-source-src-sys-package 2205 2206create-world-packages: _pkgbootstrap .PHONY 2207 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || : 2208 @cd ${WSTAGEDIR} ; \ 2209 ${METALOG_SORT_CMD} ${WSTAGEDIR}/${DISTDIR}/METALOG | \ 2210 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk 2211 @for plist in ${WSTAGEDIR}/*.plist; do \ 2212 plist=$${plist##*/} ; \ 2213 pkgname=$${plist%.plist} ; \ 2214 echo "_PKGS+= $${pkgname}" ; \ 2215 done > ${WSTAGEDIR}/packages.mk 2216 ${_+_}@cd ${.CURDIR}; \ 2217 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \ 2218 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 2219 .MAKE.JOB.PREFIX= 2220 2221.if make(create-world-packages-jobs) 2222.include "${WSTAGEDIR}/packages.mk" 2223.endif 2224 2225create-world-packages-jobs: .PHONY 2226.for pkgname in ${_PKGS} 2227create-world-packages-jobs: create-world-package-${pkgname} 2228create-world-package-${pkgname}: .PHONY 2229 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \ 2230 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl 2231 @awk -F\" ' \ 2232 /^name/ { printf("===> Creating %s-", $$2); next } \ 2233 /^version/ { print $$2; next } \ 2234 ' ${WSTAGEDIR}/${pkgname}.ucl 2235 @if [ "${pkgname}" == "runtime" ]; then \ 2236 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \ 2237 fi 2238 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ 2239 -o OSVERSION="${SRCRELDATE}" \ 2240 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2241 -M ${WSTAGEDIR}/${pkgname}.ucl \ 2242 -p ${WSTAGEDIR}/${pkgname}.plist \ 2243 -r ${WSTAGEDIR} \ 2244 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} 2245.endfor 2246 2247_default_flavor= -default 2248.if make(*package*) && exists(${KSTAGEDIR}/kernel.meta) 2249. if ${MK_DEBUG_FILES} != "no" 2250_debug=-dbg 2251. endif 2252 2253create-dtb-package: 2254 @if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \ 2255 ${SRCDIR}/release/packages/generate-ucl.lua \ 2256 PKGNAME "dtb" \ 2257 VERSION "${PKG_VERSION}" \ 2258 COMMENT "FreeBSD Devicetree Blobs" \ 2259 DESC "FreeBSD Devicetree Blobs" \ 2260 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 2261 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 2262 PKG_WWW "${PKG_WWW}" \ 2263 ${SRCDIR}/release/packages/template.ucl \ 2264 ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \ 2265 awk -F\" ' \ 2266 /name/ { printf("===> Creating %s-", $$2); next } \ 2267 /version/ {print $$2; next } ' \ 2268 ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \ 2269 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ 2270 -o OSVERSION="${SRCRELDATE}" \ 2271 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2272 -M ${KSTAGEDIR}/${DISTDIR}/dtb.ucl \ 2273 -p ${KSTAGEDIR}/${DISTDIR}/dtb.plist \ 2274 -r ${KSTAGEDIR}/${DISTDIR} \ 2275 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \ 2276 fi 2277 2278create-kernel-packages: .PHONY 2279. for flavor in "" ${_debug} 2280create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-dtb-package 2281create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY 2282 @cd ${KSTAGEDIR}/${DISTDIR} ; \ 2283 ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \ 2284 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ 2285 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \ 2286 ${SRCDIR}/release/packages/generate-ucl.lua \ 2287 PKGNAME "kernel-${INSTALLKERNEL:tl}${flavor}" \ 2288 VERSION "${PKG_VERSION}" \ 2289 KERNELDIR "kernel" \ 2290 COMMENT "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \ 2291 DESC "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \ 2292 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 2293 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 2294 PKG_WWW "${PKG_WWW}" \ 2295 ${SRCDIR}/release/packages/template.ucl \ 2296 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ 2297 awk -F\" ' \ 2298 /name/ { printf("===> Creating %s-", $$2); next } \ 2299 /version/ {print $$2; next } ' \ 2300 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ 2301 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ 2302 -o OSVERSION="${SRCRELDATE}" \ 2303 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2304 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \ 2305 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \ 2306 -r ${KSTAGEDIR}/${DISTDIR} \ 2307 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} 2308. endfor 2309.endif 2310.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 2311. for _kernel in ${BUILDKERNELS:[2..-1]} 2312. if exists(${KSTAGEDIR}/kernel.${_kernel}.meta) 2313. if ${MK_DEBUG_FILES} != "no" 2314_debug=-dbg 2315. endif 2316. for flavor in "" ${_debug} 2317create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel} 2318create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY 2319 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \ 2320 ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.${_kernel}.meta | \ 2321 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ 2322 -v kernel=yes -v _kernconf=${_kernel} ; \ 2323 ${SRCDIR}/release/packages/generate-ucl.lua \ 2324 PKGNAME "kernel-${_kernel:tl}${flavor}" \ 2325 PKGGENNAME "kernel" \ 2326 FORCEINCLUDE "kernel${flavor}" \ 2327 UCLFILES "${SRCDIR}/release/packages/" \ 2328 VERSION "${PKG_VERSION}" \ 2329 KERNELDIR "kernel.${_kernel}" \ 2330 DESC "FreeBSD ${_kernel} kernel ${flavor}" \ 2331 COMMENT "FreeBSD ${_kernel} kernel ${flavor}" \ 2332 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 2333 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 2334 PKG_WWW "${PKG_WWW}" \ 2335 ${SRCDIR}/release/packages/template.ucl \ 2336 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ 2337 awk -F\" ' \ 2338 /name/ { printf("===> Creating %s-", $$2); next } \ 2339 /version/ {print $$2; next } ' \ 2340 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ 2341 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ 2342 -o OSVERSION="${SRCRELDATE}" \ 2343 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \ 2344 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \ 2345 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \ 2346 -r ${KSTAGEDIR}/kernel.${_kernel} \ 2347 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} 2348. endfor 2349. endif 2350. endfor 2351.endif 2352 2353sign-packages: .PHONY 2354 ${_+_}@cd ${.CURDIR}; \ 2355 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} real-sign-packages 2356 2357real-sign-packages: _pkgbootstrap .PHONY 2358 printf "version = 2;\n" > ${WSTAGEDIR}/meta 2359.if ${PKG_BIN_VERSION} < 11700 2360 printf "packing_format = \"${PKG_FORMAT}\";\n" >> ${WSTAGEDIR}/meta 2361.endif 2362 @${PKG_CMD} -o ABI=${PKG_ABI} -o OSVERSION="${SRCRELDATE}" \ 2363 -o WORKERS_COUNT=${PKG_WORKERS_COUNT} repo \ 2364 -m ${WSTAGEDIR}/meta \ 2365 -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \ 2366 ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \ 2367 ${PKG_REPO_SIGNING_KEY} ; \ 2368 cd ${REPODIR}/${PKG_ABI}; \ 2369 ln -hfs ${PKG_OUTPUT_DIR} latest 2370 2371# 2372# 2373# checkworld 2374# 2375# Run test suite on installed world. 2376# 2377checkworld: .PHONY 2378 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \ 2379 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \ 2380 exit 1; \ 2381 fi 2382 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile 2383 2384# 2385# 2386# doxygen 2387# 2388# Build the API documentation with doxygen 2389# 2390doxygen: .PHONY 2391 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \ 2392 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ 2393 exit 1; \ 2394 fi 2395 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all 2396 2397# 2398# ------------------------------------------------------------------------ 2399# 2400# From here onwards are utility targets used by the 'make world' and 2401# related targets. If your 'world' breaks, you may like to try to fix 2402# the problem and manually run the following targets to attempt to 2403# complete the build. Beware, this is *not* guaranteed to work, you 2404# need to have a pretty good grip on the current state of the system 2405# to attempt to manually finish it. If in doubt, 'make world' again. 2406# 2407 2408# 2409# legacy: Build compatibility shims for the next three targets. This is a 2410# minimal set of tools and shims necessary to compensate for older systems 2411# which don't have the APIs required by the targets built in bootstrap-tools, 2412# build-tools or cross-tools. 2413# 2414legacy: .PHONY 2415.if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0 2416 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \ 2417 false 2418.endif 2419 2420.for _tool in \ 2421 tools/build \ 2422 ${LOCAL_LEGACY_DIRS} 2423 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \ 2424 cd ${.CURDIR}/${_tool}; \ 2425 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2426 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \ 2427 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \ 2428 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \ 2429 DESTDIR=${WORLDTMP}/legacy install 2430.endfor 2431 2432# 2433# bootstrap-tools: Build tools needed for compatibility. These are binaries that 2434# are built to build other binaries in the system. However, the focus of these 2435# binaries is usually quite narrow. Bootstrap tools use the host's compiler and 2436# libraries, augmented by -legacy, in addition to the libraries built during 2437# bootstrap-tools. 2438# 2439_bt= _bootstrap-tools 2440 2441# We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't 2442# accidentally run tools that are incompatible but happen to be in $PATH. 2443# This is especially important when building on Linux/MacOS where many of the 2444# programs used during the build accept different flags or generate different 2445# output. On those platforms we only symlink the tools known to be compatible 2446# (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others 2447# from the FreeBSD sources during the bootstrap-tools stage. 2448# We want to build without the user's $PATH starting in the bootstrap-tools 2449# phase so the tools used in that phase (ln, cp, etc) must have already been 2450# linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink 2451# variable in tools/build/Makefile and are linked during the legacy phase. 2452# Since they could be Linux or MacOS binaries, too we must only use flags that 2453# are portable across operating systems. 2454 2455# If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the 2456# current source tree. Otherwise we create a symlink to the version found in 2457# $PATH during the bootstrap-tools stage. 2458# When building on non-FreeBSD systems we can't assume that the host binaries 2459# accept compatible flags or produce compatible output. Therefore we force 2460# BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary. 2461.if defined(CROSSBUILD_HOST) 2462BOOTSTRAP_ALL_TOOLS:= 1 2463.endif 2464.if defined(BOOTSTRAP_ALL_TOOLS) 2465# BOOTSTRAPPING will be set on the command line so we can't override it here. 2466# Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS} 2467BOOTSTRAPPING_OSRELDATE:= 0 2468.endif 2469 2470.if ${MK_GAMES} != "no" 2471_strfile= usr.bin/fortune/strfile 2472.endif 2473 2474# vtfontcvt is used to build font files for loader and to generate 2475# C source for loader built in font (8x16.c). 2476_vtfontcvt= usr.bin/vtfontcvt 2477 2478# zic is used to compile timezone data 2479.if ${MK_ZONEINFO} != "no" 2480_zic= usr.sbin/zic 2481.endif 2482 2483# If we are not building the bootstrap because BOOTSTRAPPING is sufficient 2484# we symlink the host version to $WORLDTMP instead. By doing this we can also 2485# detect when a bootstrap tool is being used without the required MK_FOO. 2486# If you add a new bootstrap tool where we could also use the host version, 2487# please ensure that you also add a .else case where you add the tool to the 2488# _bootstrap_tools_links variable. 2489.if ${BOOTSTRAPPING} < 1000033 2490# Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to 2491# generate any files). To fix this cyclic dependency we can build a bootstrap 2492# version of m4 (with pre-generated files) then use that to build the real m4. 2493# We can't simply use the host m4 since e.g. the macOS version does not accept 2494# the flags that are passed by lex. 2495# For lex we also use the pre-gerated files since we would otherwise need to 2496# build awk and sed first (which need lex to build) 2497# TODO: add a _bootstrap_lex and then build the real lex afterwards 2498_lex= usr.bin/lex 2499_m4= tools/build/bootstrap-m4 usr.bin/m4 2500${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc 2501${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4 2502_bt_m4_depend=${_bt}-usr.bin/m4 2503_bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend} 2504.else 2505_bootstrap_tools_links+=m4 lex 2506.endif 2507 2508# ELF Tool Chain libraries are needed for ELF tools and dtrace tools. 2509# r296685 fix cross-endian objcopy 2510# r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2. 2511# r334881 added libdwarf constants used by ctfconvert. 2512# r338478 fixed a crash in objcopy for mips64el objects 2513# r339083 libelf: correct mips64el test to use ELF header 2514# r348347 Add missing powerpc64 relocation support to libdwarf 2515.if ${BOOTSTRAPPING} < 1300030 2516_elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd 2517${_bt}-lib/libelf: ${_bt_m4_depend} 2518${_bt}-lib/libdwarf: ${_bt_m4_depend} 2519_bt_libelf_depend=${_bt}-lib/libelf 2520.endif 2521 2522_libkldelf= lib/libkldelf 2523${_bt}-lib/libkldelf: ${_bt_libelf_depend} 2524_bt_libkldelf_depend=${_bt}-lib/libkldelf 2525 2526_kldxref= usr.sbin/kldxref 2527${_bt}-usr.sbin/kldxref: ${_bt_libelf_depend} ${_bt_libkldelf_depend} 2528 2529# flua is required to regenerate syscall files. It first appeared during the 2530# 13.0-CURRENT cycle, thus needs to be built on -older releases and stable 2531# branches. 2532.if ${BOOTSTRAPPING} < 1300059 2533${_bt}-libexec/flua: ${_bt}-lib/liblua 2534_flua= lib/liblua libexec/flua 2535.endif 2536 2537# r245440 mtree -N support added 2538# r313404 requires sha384.h for libnetbsd, added to libmd in r292782 2539.if ${BOOTSTRAPPING} < 1100093 2540_libnetbsd= lib/libnetbsd 2541_nmtree= lib/libmd \ 2542 usr.sbin/nmtree 2543 2544${_bt}-lib/libnetbsd: ${_bt}-lib/libmd 2545${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd 2546.else 2547_bootstrap_tools_links+=mtree 2548.endif 2549 2550# r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l 2551.if ${BOOTSTRAPPING} < 1000027 2552_cat= bin/cat 2553.else 2554_bootstrap_tools_links+=cat 2555.endif 2556 2557# r277259 crunchide: Correct 64-bit section header offset 2558# r281674 crunchide: always include both 32- and 64-bit ELF support 2559.if ${BOOTSTRAPPING} < 1100078 2560_crunchide= usr.sbin/crunch/crunchide 2561.else 2562_bootstrap_tools_links+=crunchide 2563.endif 2564 2565# 1400052, 1300526, 1203507: Removed -dc from linker invocation 2566.if ${BOOTSTRAPPING} < 1203507 || \ 2567 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300526) || \ 2568 (${BOOTSTRAPPING} > 1400000 && ${BOOTSTRAPPING} < 1400052) 2569_crunchgen= usr.sbin/crunch/crunchgen 2570.else 2571_bootstrap_tools_links+=crunchgen 2572.endif 2573 2574# The ATKBD_DFLT_KEYMAP, UKBD_DFLT_KEYMAP and KBDMUX_DFLT_KEYMAP kernel options 2575# require kbdcontrol. Note that, even on FreeBSD, the host will lack kbdcontrol 2576# if built with WITHOUT_LEGACY_CONSOLE. 2577.if defined(BOOTSTRAP_ALL_TOOLS) || !exists(/usr/sbin/kbdcontrol) 2578_kbdcontrol= usr.sbin/kbdcontrol 2579.else 2580_bootstrap_tools_links+=kbdcontrol 2581.endif 2582 2583.if ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no" 2584_etdump= usr.bin/etdump 2585_makefs= usr.sbin/makefs 2586 2587_libnetbsd= lib/libnetbsd 2588${_bt}-usr.sbin/makefs: ${_bt}-lib/libnetbsd 2589 2590.if defined(BOOTSTRAP_ALL_TOOLS) 2591_libsbuf= lib/libsbuf 2592${_bt}-usr.sbin/makefs: ${_bt}-lib/libsbuf 2593.endif 2594.endif 2595 2596# 1300102: VHDX support 2597.if ${BOOTSTRAPPING} < 1201520 || \ 2598 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102) || \ 2599 ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no" 2600_mkimg= usr.bin/mkimg 2601.else 2602_bootstrap_tools_links+=mkimg 2603.endif 2604 2605_yacc= usr.bin/yacc 2606 2607.if ${MK_BSNMP} != "no" 2608_gensnmptree= usr.sbin/bsnmpd/gensnmptree 2609.endif 2610 2611 2612# We need to build tblgen when we're building clang or lld, either as 2613# bootstrap tools, or as the part of the normal build. 2614# llvm-tblgen is also needed for various llvm binutils (e.g. objcopy). 2615.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \ 2616 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \ 2617 ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no" 2618_clang_tblgen= \ 2619 lib/clang/libllvmminimal \ 2620 usr.bin/clang/llvm-min-tblgen \ 2621 usr.bin/clang/llvm-tblgen 2622.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \ 2623 ${MK_LLDB} != "no" 2624_clang_tblgen+= lib/clang/libclangminimal 2625_clang_tblgen+= usr.bin/clang/clang-tblgen 2626.endif 2627.if ${MK_LLDB} != "no" 2628_clang_tblgen+= usr.bin/clang/lldb-tblgen 2629.endif 2630${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal 2631${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal 2632${_bt}-usr.bin/clang/llvm-min-tblgen: ${_bt}-lib/clang/libllvmminimal 2633${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal 2634${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-usr.bin/clang/llvm-min-tblgen 2635.endif 2636 2637# C.UTF-8 is always built in share/ctypes and we need localedef for that. 2638_localedef= usr.bin/localedef 2639${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend} 2640 2641.if ${MK_ICONV} != "no" 2642_mkesdb= usr.bin/mkesdb 2643_mkcsmapper= usr.bin/mkcsmapper 2644${_bt}-usr.bin/mkesdb: ${_bt}-usr.bin/yacc ${_bt_lex_depend} 2645${_bt}-usr.bin/mkcsmapper: ${_bt}-usr.bin/yacc ${_bt_lex_depend} 2646.endif 2647 2648.if ${MK_KERBEROS} != "no" 2649_kerberos5_bootstrap_tools= \ 2650 kerberos5/tools/make-roken \ 2651 kerberos5/lib/libroken \ 2652 kerberos5/lib/libvers \ 2653 kerberos5/tools/asn1_compile \ 2654 kerberos5/tools/slc \ 2655 usr.bin/compile_et 2656 2657.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g} 2658.for _tool in ${_kerberos5_bootstrap_tools} 2659${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend} 2660.endfor 2661.endif 2662 2663${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd 2664 2665# The tools listed in _basic_bootstrap_tools will generally not be 2666# bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a 2667# Linux or MacOS host the host versions are incompatible so we need to build 2668# them from the source tree. Usually the link name will be the same as the subdir, 2669# but some directories such as grep or test install multiple binaries. In that 2670# case we use the _basic_bootstrap_tools_multilink variable which is a list of 2671# subdirectory and comma-separated list of files. 2672_basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep 2673_basic_bootstrap_tools_multilink+=bin/test test,[ 2674# bootstrap tools needed by buildworld: 2675_basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \ 2676 usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \ 2677 usr.bin/truncate usr.bin/tsort 2678# Some build scripts use nawk instead of awk (this happens at least in 2679# cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk 2680# and nawk in ${WORLDTMP}/legacy/bin. 2681_basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk 2682# file2c is required for building usr.sbin/config: 2683_basic_bootstrap_tools+=usr.bin/file2c 2684# uuencode/uudecode required for share/tabset 2685_basic_bootstrap_tools_multilink+=usr.bin/bintrans uuencode,uudecode 2686# xargs is required by mkioctls 2687_basic_bootstrap_tools+=usr.bin/xargs 2688# cap_mkdb is required for share/termcap: 2689_basic_bootstrap_tools+=usr.bin/cap_mkdb 2690# services_mkdb/pwd_mkdb are required for installworld: 2691_basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb 2692# ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?) 2693.if !defined(CROSSBUILD_HOST) 2694# ldd is only needed for updating the running system so we don't need to 2695# bootstrap ldd on non-FreeBSD systems 2696_basic_bootstrap_tools+=usr.bin/ldd 2697.endif 2698# sysctl/chflags are required for installkernel: 2699.if !defined(CROSSBUILD_HOST) 2700_basic_bootstrap_tools+=bin/chflags 2701# Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't 2702# matter since we don't need any of the new features for the build. 2703_bootstrap_tools_links+=sysctl 2704.else 2705# When building on non-FreeBSD, install a fake chflags instead since the 2706# version from the source tree cannot work. We also don't need sysctl since we 2707# are install with -DNO_ROOT. 2708_other_bootstrap_tools+=tools/build/cross-build/fake_chflags 2709.endif 2710# mkfifo is used by sys/conf/newvers.sh 2711_basic_bootstrap_tools+=usr.bin/mkfifo 2712# jot is needed for the mkimg tests 2713_basic_bootstrap_tools+=usr.bin/jot 2714 2715.if defined(BOOTSTRAP_ALL_TOOLS) 2716# sha256 and sha512 are used by release/ (and possibly others) 2717_basic_bootstrap_tools+=sbin/md5 2718.endif 2719 2720# tzsetup is needed as an install tool 2721.if ${MK_ZONEINFO} != "no" 2722_basic_bootstrap_tools+=usr.sbin/tzsetup 2723.endif 2724 2725.if defined(BOOTSTRAP_ALL_TOOLS) 2726_other_bootstrap_tools+=${_basic_bootstrap_tools} 2727.for _subdir _links in ${_basic_bootstrap_tools_multilink} 2728_other_bootstrap_tools+=${_subdir} 2729.endfor 2730${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc 2731${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc 2732# If we are bootstrapping file2c, we have to build it before config: 2733${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend} 2734# Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since 2735# the links to make/bmake make links will have already have been created in the 2736# `make legacy` step. Not adding a link to make is important on non-FreeBSD 2737# since "make" will usually point to GNU make there. 2738_other_bootstrap_tools+=usr.bin/bmake 2739 2740# Avoid dependency on host bz2 headers: 2741_other_bootstrap_tools+=lib/libbz2 2742${_bt}-usr.bin/grep: ${_bt}-lib/libbz2 2743 2744# libdwarf depends on libz 2745_other_bootstrap_tools+=lib/libz 2746${_bt}-lib/libdwarf: ${_bt}-lib/libz 2747 2748# libroken depends on libcrypt 2749_other_bootstrap_tools+=lib/libcrypt 2750${_bt}-lib/libroken: ${_bt}-lib/libcrypt 2751.else 2752# All tools in _basic_bootstrap_tools have the same name as the subdirectory 2753# so we can use :T to get the name of the symlinks that we need to create. 2754_bootstrap_tools_links+=${_basic_bootstrap_tools:T} 2755.for _subdir _links in ${_basic_bootstrap_tools_multilink} 2756_bootstrap_tools_links+=${_links:S/,/ /g} 2757.endfor 2758.endif # defined(BOOTSTRAP_ALL_TOOLS) 2759 2760# Link the tools that we need for building but don't need to bootstrap because 2761# the host version is known to be compatible into ${WORLDTMP}/legacy 2762# We do this before building any of the bootstrap tools in case they depend on 2763# the presence of any of the links (e.g. as m4/lex/awk) 2764${_bt}-links: .PHONY 2765 2766.for _tool in ${_bootstrap_tools_links} 2767${_bt}-link-${_tool}: .PHONY 2768 @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \ 2769 source_path=`which ${_tool}`; \ 2770 if [ ! -e "$${source_path}" ] ; then \ 2771 echo "Cannot find host tool '${_tool}'"; false; \ 2772 fi; \ 2773 cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}" 2774${_bt}-links: ${_bt}-link-${_tool} 2775.endfor 2776 2777bootstrap-tools: ${_bt}-links .PHONY 2778 2779# Please document (add comment) why something is in 'bootstrap-tools'. 2780# Try to bound the building of the bootstrap-tool to just the 2781# FreeBSD versions that need the tool built at this stage of the build. 2782.for _tool in \ 2783 ${_clang_tblgen} \ 2784 ${_kerberos5_bootstrap_tools} \ 2785 ${_strfile} \ 2786 usr.bin/dtc \ 2787 ${_cat} \ 2788 ${_kbdcontrol} \ 2789 ${_elftoolchain_libs} \ 2790 ${_libkldelf} \ 2791 ${_kldxref} \ 2792 lib/libopenbsd \ 2793 usr.bin/mandoc \ 2794 usr.bin/rpcgen \ 2795 ${_yacc} \ 2796 ${_m4} \ 2797 ${_lex} \ 2798 ${_other_bootstrap_tools} \ 2799 usr.bin/xinstall \ 2800 ${_gensnmptree} \ 2801 usr.sbin/config \ 2802 ${_flua} \ 2803 ${_crunchide} \ 2804 ${_crunchgen} \ 2805 ${_etdump} \ 2806 ${_libnetbsd} \ 2807 ${_libsbuf} \ 2808 ${_makefs} \ 2809 ${_mkimg} \ 2810 ${_nmtree} \ 2811 ${_vtfontcvt} \ 2812 ${_localedef} \ 2813 ${_mkcsmapper} \ 2814 ${_mkesdb} \ 2815 ${_zic} \ 2816 ${LOCAL_BSTOOL_DIRS} 2817${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE 2818 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 2819 cd ${.CURDIR}/${_tool}; \ 2820 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2821 if [ "${_tool}" = "usr.bin/lex" ]; then \ 2822 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \ 2823 fi; \ 2824 ${MAKE} DIRPRFX=${_tool}/ all; \ 2825 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install 2826 2827bootstrap-tools: ${_bt}-${_tool} 2828.endfor 2829.if target(${_bt}-lib/libmd) 2830# If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the 2831# necessary dependencies: 2832${_bt}-usr.bin/sort: ${_bt}-lib/libmd 2833${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd 2834${_bt}-sbin/md5: ${_bt}-lib/libmd 2835.endif 2836 2837 2838# 2839# build-tools: Build special purpose build tools 2840# 2841.if !defined(NO_SHARE) && ${MK_SYSCONS} != "no" 2842_share= share/syscons/scrnmaps 2843.endif 2844 2845.if ${MK_RESCUE} != "no" 2846# rescue includes programs that have build-tools targets 2847_rescue=rescue/rescue 2848.endif 2849 2850.if ${MK_TCSH} != "no" 2851_tcsh=bin/csh 2852.endif 2853.if ${MK_FILE} != "no" 2854_libmagic=lib/libmagic 2855.endif 2856 2857.if ${MK_PMC} != "no" 2858_jevents=lib/libpmc/pmu-events 2859.endif 2860 2861# kernel-toolchain skips _cleanobj, so handle cleaning up previous 2862# build-tools directories if needed. 2863.if ${MK_CLEAN} == "yes" && make(kernel-toolchain) 2864_bt_clean= ${CLEANDIR} 2865.endif 2866 2867.for _tool in \ 2868 ${_tcsh} \ 2869 bin/sh \ 2870 ${LOCAL_TOOL_DIRS} \ 2871 ${_jevents} \ 2872 lib/ncurses/tinfo \ 2873 ${_rescue} \ 2874 ${_share} \ 2875 usr.bin/awk \ 2876 ${_libmagic} \ 2877 usr.bin/vi/catalog 2878build-tools_${_tool}: .PHONY 2879 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \ 2880 cd ${.CURDIR}/${_tool}; \ 2881 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \ 2882 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2883 ${MAKE} DIRPRFX=${_tool}/ build-tools 2884build-tools: build-tools_${_tool} 2885.endfor 2886 2887# 2888# kernel-tools: Build kernel-building tools 2889# 2890kernel-tools: .PHONY 2891 mkdir -p ${WORLDTMP}/usr 2892 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 2893 -p ${WORLDTMP}/usr >/dev/null 2894 2895# 2896# cross-tools: All the tools needed to build the rest of the system after 2897# we get done with the earlier stages. It is the last set of tools needed 2898# to begin building the target binaries. 2899# 2900.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0 2901.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" 2902_btxld= usr.sbin/btxld 2903.endif 2904.endif 2905 2906# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures 2907# resulting from missing bug fixes or ELF Toolchain updates. 2908.if ${MK_CDDL} != "no" 2909_dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \ 2910 cddl/usr.bin/ctfmerge 2911.endif 2912 2913.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no" 2914# Some bespoke tools from or based on ELF Tool Chain. elfcopy is included 2915# because llvm-objcopy is currently not capable of translating ELF to PE32+, 2916# which is required for EFI boot programs. 2917_elftctools= lib/libelftc \ 2918 lib/libpe \ 2919 usr.bin/elfcopy \ 2920 usr.bin/elfctl \ 2921 usr.bin/elfdump 2922# If we're given an XNM we don't need to build standard binary utilities. 2923.if ${XNM:M/*} == "" 2924_elftctools+= usr.bin/nm \ 2925 usr.bin/size \ 2926 usr.bin/strings 2927# These are not required by the build, but can be useful for developers who 2928# cross-build on a FreeBSD 10 host: 2929_elftctools+= usr.bin/addr2line 2930.endif 2931.endif 2932 2933.if ${MK_CLANG_BOOTSTRAP} != "no" 2934_clang= usr.bin/clang/clang 2935.endif 2936.if ${MK_LLD_BOOTSTRAP} != "no" 2937_lld= usr.bin/clang/lld 2938.endif 2939.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no" 2940_clang_libs= lib/clang 2941.endif 2942.if ${MK_USB} != "no" 2943_usb_tools= stand/usb/tools 2944.endif 2945 2946.if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS) 2947_ar=usr.bin/ar 2948.endif 2949 2950cross-tools: .MAKE .PHONY 2951.for _tool in \ 2952 ${LOCAL_XTOOL_DIRS} \ 2953 ${_ar} \ 2954 ${_clang_libs} \ 2955 ${_clang} \ 2956 ${_lld} \ 2957 ${_elftctools} \ 2958 ${_dtrace_tools} \ 2959 ${_btxld} \ 2960 ${_usb_tools} 2961 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 2962 cd ${.CURDIR}/${_tool}; \ 2963 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2964 ${MAKE} DIRPRFX=${_tool}/ all; \ 2965 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install 2966.endfor 2967 2968# 2969# native-xtools is the current target for qemu-user cross builds of ports 2970# via poudriere and the imgact_binmisc kernel module. 2971# This target merely builds a toolchan/sysroot, then builds the tools it wants 2972# with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain 2973# already built. It then installs the static tools to NXBDESTDIR for Poudriere 2974# to pickup. 2975# 2976NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/ 2977NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH} 2978NXTP?= /nxb-bin 2979.if ${NXTP:N/*} 2980.error NXTP variable should be an absolute path 2981.endif 2982NXBDESTDIR?= ${DESTDIR}${NXTP} 2983 2984# This is the list of tools to be built/installed as static and where 2985# appropriate to build for the given TARGET.TARGET_ARCH. 2986NXBDIRS+= \ 2987 bin/cat \ 2988 bin/chmod \ 2989 bin/cp \ 2990 ${_tcsh} \ 2991 bin/echo \ 2992 bin/expr \ 2993 bin/hostname \ 2994 bin/ln \ 2995 bin/ls \ 2996 bin/mkdir \ 2997 bin/mv \ 2998 bin/ps \ 2999 bin/realpath \ 3000 bin/rm \ 3001 bin/rmdir \ 3002 bin/sh \ 3003 bin/sleep \ 3004 sbin/md5 \ 3005 sbin/sysctl \ 3006 usr.bin/addr2line \ 3007 usr.bin/ar \ 3008 usr.bin/awk \ 3009 usr.bin/basename \ 3010 usr.bin/bmake \ 3011 usr.bin/bzip2 \ 3012 usr.bin/cmp \ 3013 usr.bin/diff \ 3014 usr.bin/dirname \ 3015 usr.bin/elfcopy \ 3016 usr.bin/env \ 3017 usr.bin/fetch \ 3018 usr.bin/find \ 3019 usr.bin/grep \ 3020 usr.bin/gzip \ 3021 usr.bin/head \ 3022 usr.bin/id \ 3023 usr.bin/lex \ 3024 usr.bin/limits \ 3025 usr.bin/mandoc \ 3026 usr.bin/mktemp \ 3027 usr.bin/mt \ 3028 usr.bin/nm \ 3029 usr.bin/patch \ 3030 usr.bin/readelf \ 3031 usr.bin/sed \ 3032 usr.bin/size \ 3033 usr.bin/sort \ 3034 usr.bin/strings \ 3035 usr.bin/tar \ 3036 usr.bin/touch \ 3037 usr.bin/tr \ 3038 usr.bin/true \ 3039 usr.bin/uniq \ 3040 usr.bin/unzip \ 3041 usr.bin/wc \ 3042 usr.bin/xargs \ 3043 usr.bin/xinstall \ 3044 usr.bin/xz \ 3045 usr.bin/yacc \ 3046 usr.sbin/chown 3047 3048SUBDIR_DEPEND_usr.bin/clang= lib/clang 3049.if ${MK_CLANG} != "no" 3050NXBDIRS+= lib/clang 3051NXBDIRS+= usr.bin/clang 3052.endif 3053# XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs 3054# to be evaluated after NXBDIRS is set. 3055.if make(install) && !empty(SUBDIR_OVERRIDE) 3056SUBDIR= ${SUBDIR_OVERRIDE} 3057.endif 3058 3059NXBMAKEARGS+= \ 3060 OBJTOP=${NXBOBJTOP:Q} \ 3061 OBJROOT=${NXBOBJROOT:Q} \ 3062 -DNO_SHARED \ 3063 -DNO_CPU_CFLAGS \ 3064 -DNO_PIC \ 3065 MK_CASPER=no \ 3066 MK_CLANG_EXTRAS=no \ 3067 MK_CLANG_FORMAT=no \ 3068 MK_CLANG_FULL=no \ 3069 MK_CTF=no \ 3070 MK_DEBUG_FILES=no \ 3071 MK_HTML=no \ 3072 MK_LLDB=no \ 3073 MK_MAN=no \ 3074 MK_MAN_UTILS=yes \ 3075 MK_OFED=no \ 3076 MK_OPENSSH=no \ 3077 MK_RETPOLINE=no \ 3078 MK_SENDMAIL=no \ 3079 MK_SSP=no \ 3080 MK_TESTS=no \ 3081 MK_WERROR=no \ 3082 MK_ZFS=no 3083 3084NXBMAKEENV+= \ 3085 MAKEOBJDIRPREFIX= 3086 3087# This should match all of the knobs in lib/Makefile that it takes to avoid 3088# descending into lib/clang! 3089NXBTNOTOOLS= MK_CLANG=no MK_LLD=no MK_LLDB=no MK_LLVM_BINUTILS=no 3090 3091.if make(native-xtools*) && \ 3092 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH)) 3093.error Missing NXB_TARGET / NXB_TARGET_ARCH 3094.endif 3095# For 'toolchain' we want to produce native binaries that themselves generate 3096# native binaries. 3097NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \ 3098 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} 3099# For 'everything' we want to produce native binaries (hence -target to 3100# be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries. 3101# TARGET/TARGET_ARCH are still passed along from user. 3102# 3103# Use the toolchain we create as an external toolchain. 3104.if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*} 3105NXBMAKE+= XCC="${XCC}" \ 3106 XCXX="${XCXX}" \ 3107 XCPP="${XCPP}" 3108.else 3109NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \ 3110 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \ 3111 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp" 3112.endif 3113NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \ 3114 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \ 3115 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \ 3116 TARGET_TRIPLE=${MACHINE_TRIPLE:Q} 3117# NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to 3118# invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS. 3119NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}' 3120# Need to avoid the -isystem logic when using clang as an external toolchain 3121# even if the TARGET being built for wants GCC. 3122NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}' 3123native-xtools: .PHONY 3124 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj 3125 # Build the bootstrap/host/cross tools that produce native binaries 3126 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain 3127 # Populate includes/libraries sysroot that produce native binaries. 3128 # This is split out from 'toolchain' above mostly so that target LLVM 3129 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without 3130 # polluting the cross-compiler build. The LLVM libs are skipped 3131 # here to avoid the problem but are kept in 'toolchain' so that 3132 # needed build tools are built. 3133 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes ${NXBTNOTOOLS} 3134 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries ${NXBTNOTOOLS} 3135.if !defined(NO_OBJWALK) 3136 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj 3137.endif 3138 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything 3139 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR" 3140 3141native-xtools-install: .PHONY 3142 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr 3143 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 3144 -p ${NXBDESTDIR}/usr >/dev/null 3145 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 3146 -p ${NXBDESTDIR}/usr/include >/dev/null 3147.for d in ${LIBCOMPAT_INCLUDE_DIRS} 3148 mkdir -p ${NXBDESTDIR}/usr/include/${d} 3149.endfor 3150 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \ 3151 DESTDIR=${NXBDESTDIR} \ 3152 -DNO_ROOT \ 3153 install 3154 3155# 3156# hierarchy - ensure that all the needed directories are present 3157# 3158hierarchy hier: .MAKE .PHONY 3159 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs 3160 3161# 3162# libraries - build all libraries, and install them under ${DESTDIR}. 3163# 3164# The list of libraries with dependents (${_prebuild_libs}) and their 3165# interdependencies (__L) are built automatically by the 3166# ${.CURDIR}/tools/make_libdeps.sh script. 3167# 3168libraries: .MAKE .PHONY 3169 ${_+_}cd ${.CURDIR}; \ 3170 ${MAKE} -f Makefile.inc1 _prereq_libs; \ 3171 ${MAKE} -f Makefile.inc1 _startup_libs; \ 3172 ${MAKE} -f Makefile.inc1 _prebuild_libs -DLIBCRYPTO_WITHOUT_SUBDIRS; \ 3173 ${MAKE} -f Makefile.inc1 _generic_libs 3174 3175# 3176# static libgcc.a prerequisite for shared libc 3177# 3178_prereq_libs= lib/libcompiler_rt 3179.if ${MK_SSP} != "no" 3180_prereq_libs+= lib/libssp_nonshared 3181.endif 3182.if ${MK_ASAN} != "no" 3183_prereq_libs+= lib/libclang_rt/asan 3184_prereq_libs+= lib/libclang_rt/asan-preinit 3185_prereq_libs+= lib/libclang_rt/asan_cxx 3186_prereq_libs+= lib/libclang_rt/asan_static 3187.endif 3188.if ${MK_UBSAN} != "no" 3189_prereq_libs+= lib/libclang_rt/ubsan_minimal 3190_prereq_libs+= lib/libclang_rt/ubsan_standalone 3191_prereq_libs+= lib/libclang_rt/ubsan_standalone_cxx 3192.endif 3193 3194# These dependencies are not automatically generated: 3195# 3196# lib/csu and lib/libc must be built before 3197# all shared libraries for ELF. 3198# 3199_startup_libs= lib/csu 3200_startup_libs+= lib/libc 3201_startup_libs+= lib/libc_nonshared 3202_startup_libs+= lib/libcxxrt 3203_startup_libs+= lib/libsys 3204 3205_prereq_libs+= lib/libgcc_eh lib/libgcc_s 3206_startup_libs+= lib/libgcc_eh lib/libgcc_s 3207 3208lib/libc__L: lib/libsys__L 3209lib/libgcc_s__L: lib/libc__L 3210lib/libgcc_s__L: lib/libc_nonshared__L 3211lib/libcxxrt__L: lib/libgcc_s__L 3212lib/libcrypt__L: lib/libmd__L 3213 3214_prebuild_libs= ${_kerberos5_lib_libasn1} \ 3215 ${_kerberos5_lib_libhdb} \ 3216 ${_kerberos5_lib_libheimbase} \ 3217 ${_kerberos5_lib_libheimntlm} \ 3218 ${_libsqlite3} \ 3219 ${_kerberos5_lib_libheimipcc} \ 3220 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ 3221 ${_kerberos5_lib_libroken} \ 3222 ${_kerberos5_lib_libwind} \ 3223 lib/libbz2 ${_libcom_err} lib/libcrypt \ 3224 lib/libc++ \ 3225 lib/libelf lib/libexpat \ 3226 lib/libfigpar \ 3227 ${_lib_libgssapi} \ 3228 lib/libjail \ 3229 lib/libkiconv lib/libkldelf lib/libkvm \ 3230 lib/liblzma lib/libmd lib/libnv \ 3231 lib/libzstd \ 3232 ${_lib_casper} \ 3233 lib/ncurses/tinfo \ 3234 lib/ncurses/ncurses \ 3235 lib/libpam/libpam lib/libthr \ 3236 ${_lib_libradius} lib/libsbuf lib/libtacplus \ 3237 lib/libgeom \ 3238 ${_lib_librt} \ 3239 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ 3240 ${_cddl_lib_libuutil} \ 3241 ${_cddl_lib_libavl} \ 3242 ${_cddl_lib_libicp} \ 3243 ${_cddl_lib_libicp_rescue} \ 3244 ${_cddl_lib_libspl} \ 3245 ${_cddl_lib_libtpool} \ 3246 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \ 3247 ${_cddl_lib_libzutil} \ 3248 ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \ 3249 lib/libufs \ 3250 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \ 3251 lib/libxo \ 3252 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \ 3253 ${_lib_libldns} ${_secure_lib_libssh} 3254 3255.if ${MK_DIALOG} != "no" 3256_prebuild_libs+= gnu/lib/libdialog 3257gnu/lib/libdialog__L: lib/msun__L lib/ncurses/tinfo__L lib/ncurses/ncurses__L 3258.endif 3259 3260.if ${MK_GOOGLETEST} != "no" 3261_prebuild_libs+= lib/libregex 3262.endif 3263 3264lib/libgeom__L: lib/libexpat__L lib/libsbuf__L 3265lib/libkldelf__L: lib/libelf__L 3266lib/libkvm__L: lib/libelf__L 3267 3268.if ${MK_RADIUS_SUPPORT} != "no" 3269_lib_libradius= lib/libradius 3270.endif 3271 3272lib/ncurses/ncurses__L: lib/ncurses/tinfo__L 3273 3274.if ${MK_OFED} != "no" 3275_prebuild_libs+= \ 3276 lib/ofed/libibverbs \ 3277 lib/ofed/libibmad \ 3278 lib/ofed/libibumad \ 3279 lib/ofed/complib \ 3280 lib/ofed/libmlx5 3281 3282lib/ofed/libibmad__L: lib/ofed/libibumad__L 3283lib/ofed/complib__L: lib/libthr__L 3284lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L 3285.endif 3286 3287.if ${MK_CASPER} != "no" 3288_lib_casper= lib/libcasper 3289.endif 3290 3291lib/libpjdlog__L: lib/libutil__L 3292lib/libcasper__L: lib/libnv__L 3293lib/liblzma__L: lib/libmd__L lib/libthr__L 3294lib/libzstd__L: lib/libthr__L 3295lib/librt__L: lib/libthr__L 3296 3297_generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} 3298.if ${MK_IPFILTER} != "no" 3299_generic_libs+= sbin/ipf/libipf 3300.endif 3301.for _DIR in ${LOCAL_LIB_DIRS} 3302.if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)) 3303_generic_libs+= ${_DIR} 3304.endif 3305.endfor 3306 3307lib/libtacplus__L: lib/libmd__L lib/libpam/libpam__L 3308lib/libxo__L: lib/libutil__L 3309 3310.if ${MK_CDDL} != "no" 3311_cddl_lib_libumem= cddl/lib/libumem 3312_cddl_lib_libnvpair= cddl/lib/libnvpair 3313_cddl_lib_libavl= cddl/lib/libavl 3314_cddl_lib_libuutil= cddl/lib/libuutil 3315_cddl_lib_libspl= cddl/lib/libspl 3316 3317cddl/lib/libavl__L: cddl/lib/libspl__L 3318cddl/lib/libnvpair__L: cddl/lib/libspl__L 3319cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L 3320 3321.if ${MK_ZFS} != "no" 3322_lib_librt= lib/librt 3323_cddl_lib_libicp= cddl/lib/libicp 3324_cddl_lib_libicp_rescue= cddl/lib/libicp_rescue 3325_cddl_lib_libtpool= cddl/lib/libtpool 3326_cddl_lib_libzutil= cddl/lib/libzutil 3327_cddl_lib_libzfs_core= cddl/lib/libzfs_core 3328_cddl_lib_libzfs= cddl/lib/libzfs 3329_cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv 3330 3331cddl/lib/libtpool__L: cddl/lib/libspl__L 3332 3333cddl/lib/libzutil__L: cddl/lib/libavl__L lib/libgeom__L lib/msun__L cddl/lib/libtpool__L 3334 3335cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L cddl/lib/libspl__L cddl/lib/libzutil__L 3336 3337cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L lib/librt__L 3338cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L 3339cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L 3340cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L 3341cddl/lib/libzfs__L: secure/lib/libcrypto__L 3342 3343cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L 3344lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L 3345.endif 3346_cddl_lib_libctf= cddl/lib/libctf 3347_cddl_lib= cddl/lib 3348cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L 3349cddl/lib/libdtrace__L: lib/libxo__L 3350.endif 3351# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db 3352_prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db 3353lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L 3354lib/libproc__L: lib/libprocstat__L 3355lib/librtld_db__L: lib/libprocstat__L 3356 3357.if ${MK_CRYPT} != "no" 3358.if ${MK_OPENSSL} != "no" 3359_secure_lib_libcrypto= secure/lib/libcrypto 3360_secure_lib_libssl= secure/lib/libssl 3361lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L 3362secure/lib/libcrypto__L: lib/libthr__L 3363.if ${MK_LDNS} != "no" 3364_lib_libldns= lib/libldns 3365lib/libldns__L: secure/lib/libssl__L 3366.endif 3367.if ${MK_OPENSSH} != "no" 3368_secure_lib_libssh= secure/lib/libssh 3369secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L 3370.if ${MK_LDNS} != "no" 3371secure/lib/libssh__L: lib/libldns__L 3372.endif 3373.if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no" 3374secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \ 3375 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \ 3376 lib/libmd__L kerberos5/lib/libroken__L 3377.endif 3378.endif 3379.endif 3380_secure_lib= secure/lib 3381.endif 3382 3383.if ${MK_KERBEROS} != "no" 3384kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L 3385kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 3386 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \ 3387 kerberos5/lib/libwind__L lib/libsqlite3__L 3388kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \ 3389 kerberos5/lib/libroken__L lib/libcom_err__L 3390kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 3391 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L 3392kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 3393 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \ 3394 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \ 3395 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L 3396kerberos5/lib/libroken__L: lib/libcrypt__L 3397kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L 3398kerberos5/lib/libheimbase__L: lib/libthr__L 3399kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L 3400.endif 3401 3402lib/libsqlite3__L: lib/libthr__L 3403 3404.if ${MK_GSSAPI} != "no" 3405_lib_libgssapi= lib/libgssapi 3406.endif 3407 3408.if ${MK_KERBEROS} != "no" 3409_kerberos5_lib= kerberos5/lib 3410_kerberos5_lib_libasn1= kerberos5/lib/libasn1 3411_kerberos5_lib_libhdb= kerberos5/lib/libhdb 3412_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase 3413_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5 3414_kerberos5_lib_libhx509= kerberos5/lib/libhx509 3415_kerberos5_lib_libroken= kerberos5/lib/libroken 3416_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm 3417_libsqlite3= lib/libsqlite3 3418_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc 3419_kerberos5_lib_libwind= kerberos5/lib/libwind 3420_libcom_err= lib/libcom_err 3421.endif 3422 3423.if ${MK_NIS} != "no" 3424_lib_libypclnt= lib/libypclnt 3425.endif 3426 3427.if ${MK_OPENSSL} == "no" 3428lib/libradius__L: lib/libmd__L 3429.endif 3430 3431lib/libproc__L: \ 3432 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} \ 3433 lib/libelf__L lib/librtld_db__L lib/libutil__L lib/libcxxrt__L 3434 3435.for _lib in ${_prereq_libs} 3436${_lib}__PL: .PHONY .MAKE 3437.if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib}) 3438 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ 3439 cd ${.CURDIR}/${_lib}; \ 3440 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ 3441 ${MAKE} MK_TESTS=no -DNO_PIC \ 3442 DIRPRFX=${_lib}/ all; \ 3443 ${MAKE} MK_TESTS=no -DNO_PIC \ 3444 DIRPRFX=${_lib}/ install 3445.endif 3446.endfor 3447 3448.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs} 3449${_lib}__L: .PHONY .MAKE 3450.if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib}) 3451 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ 3452 cd ${.CURDIR}/${_lib}; \ 3453 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ 3454 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \ 3455 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install 3456.endif 3457.endfor 3458 3459_prereq_libs: ${_prereq_libs:S/$/__PL/} 3460_startup_libs: ${_startup_libs:S/$/__L/} 3461_prebuild_libs: ${_prebuild_libs:S/$/__L/} 3462_generic_libs: ${_generic_libs:S/$/__L/} 3463 3464# Enable SUBDIR_PARALLEL when not calling 'make all', unless called from 3465# 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely 3466# that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE 3467# or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in 3468# parallel. This is safe for the world stage of buildworld though since it has 3469# already built libraries in a proper order and installed includes into 3470# WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to 3471# avoid trashing a system if it crashes mid-install. 3472.if !make(all) || defined(_PARALLEL_SUBDIR_OK) 3473SUBDIR_PARALLEL= 3474.endif 3475 3476.include <bsd.subdir.mk> 3477 3478.if make(check-old) || make(check-old-dirs) || \ 3479 make(check-old-files) || make(check-old-libs) || \ 3480 make(delete-old) || make(delete-old-dirs) || \ 3481 make(delete-old-files) || make(delete-old-libs) || \ 3482 make(list-old-dirs) || make(list-old-files) || make(list-old-libs) 3483 3484# 3485# check for / delete old files section 3486# 3487 3488.include "ObsoleteFiles.inc" 3489 3490OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \ 3491else you can not start such an application. Consult UPDATING for more \ 3492information regarding how to cope with the removal/revision bump of a \ 3493specific library." 3494 3495.if !defined(BATCH_DELETE_OLD_FILES) 3496RM_I=-i 3497.else 3498RM_I=-fv 3499.endif 3500 3501list-old-files: .PHONY 3502 @cd ${.CURDIR}; \ 3503 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 3504 -V "OLD_FILES:ts\n" -V "OLD_FILES:Musr/share/*.gz:R:ts\n" \ 3505 -V "MOVED_LIBS:ts\n" \ 3506 ${_ALL_libcompats:@v@-V "OLD_FILES:Mlib/*.so.*:S,^lib,usr/lib$v,:ts\n"@} \ 3507 ${_ALL_libcompats:@v@-V "OLD_FILES:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} | \ 3508 sort 3509 3510delete-old-files: .PHONY 3511 @echo ">>> Removing old files (only deletes safe to delete libs)" 3512# Ask for every old file if the user really wants to remove it. 3513# It's annoying, but better safe than sorry. 3514# NB: We cannot pass the list of OLD_FILES as a parameter because the 3515# argument list will get too long. Using .for/.endfor make "loops" will make 3516# the Makefile parser segfault. 3517 @exec 3<&0; \ 3518 cd ${.CURDIR}; \ 3519 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \ 3520 while read file; do \ 3521 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 3522 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 3523 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ 3524 fi; \ 3525 for ext in debug symbols; do \ 3526 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \ 3527 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 3528 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \ 3529 <&3; \ 3530 fi; \ 3531 done; \ 3532 done 3533# Remove catpages without corresponding manpages. 3534 @exec 3<&0; \ 3535 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \ 3536 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 3537 while read catpage; do \ 3538 read manpage; \ 3539 if [ ! -e "$${manpage}" ]; then \ 3540 rm ${RM_I} $${catpage} <&3; \ 3541 fi; \ 3542 done 3543 @echo ">>> Old files removed" 3544 3545check-old-files: .PHONY 3546 @echo ">>> Checking for old files" 3547 @cd ${.CURDIR}; \ 3548 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \ 3549 while read file; do \ 3550 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 3551 echo "${DESTDIR}/$${file}"; \ 3552 fi; \ 3553 for ext in debug symbols; do \ 3554 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 3555 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ 3556 fi; \ 3557 done; \ 3558 done 3559# Check for catpages without corresponding manpages. 3560 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ 3561 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 3562 while read catpage; do \ 3563 read manpage; \ 3564 if [ ! -e "$${manpage}" ]; then \ 3565 echo $${catpage}; \ 3566 fi; \ 3567 done | sort 3568 3569list-old-libs: .PHONY 3570 @cd ${.CURDIR}; \ 3571 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 3572 -V "OLD_LIBS:ts\n" \ 3573 ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/*:S,^lib,usr/lib$v,:ts\n"@} \ 3574 ${_ALL_libcompats:@v@-V "OLD_LIBS:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} \ 3575 ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/casper/*:S,^lib/casper,usr/lib$v,:ts\n"@} | \ 3576 sort 3577 3578delete-old-libs: .PHONY 3579 @echo ">>> Removing old libraries" 3580 @echo "${OLD_LIBS_MESSAGE}" | fmt 3581 @exec 3<&0; \ 3582 cd ${.CURDIR}; \ 3583 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \ 3584 while read file; do \ 3585 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 3586 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 3587 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ 3588 fi; \ 3589 for ext in debug symbols; do \ 3590 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \ 3591 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 3592 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \ 3593 <&3; \ 3594 fi; \ 3595 done; \ 3596 done 3597 @echo ">>> Old libraries removed" 3598 3599check-old-libs: .PHONY 3600 @echo ">>> Checking for old libraries" 3601 @cd ${.CURDIR}; \ 3602 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \ 3603 while read file; do \ 3604 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 3605 echo "${DESTDIR}/$${file}"; \ 3606 fi; \ 3607 for ext in debug symbols; do \ 3608 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 3609 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ 3610 fi; \ 3611 done; \ 3612 done 3613 3614list-old-dirs: .PHONY 3615 @cd ${.CURDIR}; \ 3616 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 3617 -V OLD_DIRS | sed -E 's/[[:space:]]+/\n/g' | sort -r 3618 3619delete-old-dirs: .PHONY 3620 @echo ">>> Removing old directories" 3621 @cd ${.CURDIR}; \ 3622 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \ 3623 while read dir; do \ 3624 if [ -d "${DESTDIR}/$${dir}" ]; then \ 3625 rmdir -v "${DESTDIR}/$${dir}" || true; \ 3626 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 3627 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 3628 fi; \ 3629 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 3630 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \ 3631 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 3632 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \ 3633 fi; \ 3634 done 3635 @echo ">>> Old directories removed" 3636 3637check-old-dirs: .PHONY 3638 @echo ">>> Checking for old directories" 3639 @cd ${.CURDIR}; \ 3640 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \ 3641 while read dir; do \ 3642 if [ -d "${DESTDIR}/$${dir}" ]; then \ 3643 echo "${DESTDIR}/$${dir}"; \ 3644 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 3645 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 3646 fi; \ 3647 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 3648 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \ 3649 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 3650 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \ 3651 fi; \ 3652 done 3653 3654delete-old: delete-old-files delete-old-dirs .PHONY 3655 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'." 3656 3657check-old: check-old-files check-old-libs check-old-dirs .PHONY 3658 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'." 3659 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'." 3660 3661.endif 3662 3663# 3664# showconfig - show build configuration. 3665# 3666# ignore lower case knobs (not for use with WITH*) 3667# 3668showconfig: .PHONY 3669 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}; \ 3670 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}) 2>&1 | \ 3671 grep -E '^(MK|OPT)_[A-Z]' | sort -u 3672 3673.if !empty(KRNLOBJDIR) && !empty(KERNCONF) 3674DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ 3675 3676.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE) 3677.if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF}) 3678FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \ 3679 '${KERNCONFDIR}/${KERNCONF}' ; echo 3680.endif 3681.endif 3682 3683.endif 3684 3685.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH}) 3686DTBOUTPUTPATH= ${.CURDIR} 3687.endif 3688 3689# 3690# Build 'standalone' Device Tree Blob 3691# 3692builddtb: .PHONY 3693 @PATH=${TMPPATH:Q} MACHINE=${TARGET} \ 3694 sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \ 3695 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH} 3696 3697############### 3698 3699# cleanworld 3700# In the following, the first 'rm' in a series will usually remove all 3701# files and directories. If it does not, then there are probably some 3702# files with file flags set, so this unsets them and tries the 'rm' a 3703# second time. There are situations where this target will be cleaning 3704# some directories via more than one method, but that duplication is 3705# needed to correctly handle all the possible situations. Removing all 3706# files without file flags set in the first 'rm' instance saves time, 3707# because 'chflags' will need to operate on fewer files afterwards. 3708# 3709# It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 3710# created by bsd.obj.mk, except that we don't want to .include that file 3711# in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes 3712# since it is not possible for files to land in the wrong place. 3713# 3714.if make(cleanworld) 3715BW_CANONICALOBJDIR:=${OBJTOP}/ 3716.elif make(cleankernel) 3717BW_CANONICALOBJDIR:=${KRNLOBJDIR}/${KERNCONF}/ 3718.elif make(cleanuniverse) 3719BW_CANONICALOBJDIR:=${OBJROOT} 3720.if ${MK_UNIFIED_OBJDIR} == "no" 3721.error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled. 3722.endif 3723.endif 3724cleanworld cleanuniverse cleankernel: .PHONY 3725.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \ 3726 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA} 3727 -(cd ${BW_CANONICALOBJDIR} && rm -rf *) 3728 -chflags -R 0 ${BW_CANONICALOBJDIR} 3729 -(cd ${BW_CANONICALOBJDIR} && rm -rf *) 3730.endif 3731.if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \ 3732 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA}) 3733.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 3734 # To be safe in this case, fall back to a 'make cleandir' 3735 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir 3736.endif 3737.endif 3738 3739.if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH} 3740XDEV_CPUTYPE?=${CPUTYPE} 3741.else 3742XDEV_CPUTYPE?=${TARGET_CPUTYPE} 3743.endif 3744 3745NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \ 3746 MK_MAN=no MK_NLS=no \ 3747 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \ 3748 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 3749 CPUTYPE=${XDEV_CPUTYPE} 3750 3751XDDIR=${TARGET_ARCH}-freebsd 3752XDTP?=/usr/${XDDIR} 3753.if ${XDTP:N/*} 3754.error XDTP variable should be an absolute path 3755.endif 3756 3757CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/ 3758CDBOBJTOP= ${CDBOBJROOT}${XDDIR} 3759CDBENV= \ 3760 INSTALL="sh ${.CURDIR}/tools/install.sh" 3761CDENV= ${CDBENV} \ 3762 TOOLS_PREFIX=${XDTP} 3763CDMAKEARGS= \ 3764 OBJTOP=${CDBOBJTOP:Q} \ 3765 OBJROOT=${CDBOBJROOT:Q} 3766CD2MAKEARGS= ${CDMAKEARGS} 3767 3768.if ${WANT_COMPILER_TYPE} == gcc || \ 3769 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 3770# GCC requires -isystem and -L when using a cross-compiler. --sysroot 3771# won't set header path and -L is used to ensure the base library path 3772# is added before the port PREFIX library path. 3773CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib 3774# GCC requires -B to find /usr/lib/crti.o when using a cross-compiler 3775# combined with --sysroot. 3776CD2CFLAGS+= -B${XDDESTDIR}/usr/lib 3777# Force using libc++ for external GCC. 3778.if defined(X_COMPILER_TYPE) && \ 3779 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 3780CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \ 3781 -nostdinc++ 3782.endif 3783.endif 3784CD2CFLAGS+= --sysroot=${XDDESTDIR}/ 3785CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \ 3786 CPP="${CPP} ${CD2CFLAGS}" \ 3787 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} 3788 3789CDTMP= ${OBJTOP}/${XDDIR}/tmp 3790CDMAKE=${CDENV} PATH=${CDTMP:Q}/usr/bin:${PATH:Q} ${MAKE} ${CDMAKEARGS} ${NOFUN} 3791CD2MAKE=${CD2ENV} PATH=${CDTMP:Q}/usr/bin:${XDDESTDIR:Q}/usr/bin:${PATH:Q} \ 3792 ${MAKE} ${CD2MAKEARGS} ${NOFUN} 3793.if ${MK_META_MODE} != "no" 3794# Don't rebuild build-tools targets during normal build. 3795CD2MAKE+= BUILD_TOOLS_META=.NOMETA 3796.endif 3797XDDESTDIR=${DESTDIR}${XDTP} 3798 3799.ORDER: xdev-build xdev-install xdev-links 3800xdev: xdev-build xdev-install .PHONY 3801 3802.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools 3803xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY 3804 3805_xb-worldtmp: .PHONY 3806 mkdir -p ${CDTMP}/usr 3807 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 3808 -p ${CDTMP}/usr >/dev/null 3809 3810_xb-bootstrap-tools: .PHONY 3811.for _tool in \ 3812 ${_clang_tblgen} \ 3813 ${_yacc} 3814 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 3815 cd ${.CURDIR}/${_tool}; \ 3816 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ 3817 ${CDMAKE} DIRPRFX=${_tool}/ all; \ 3818 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install 3819.endfor 3820 3821_xb-build-tools: .PHONY 3822 ${_+_}@cd ${.CURDIR}; \ 3823 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools 3824 3825XDEVDIRS= \ 3826 ${_clang_libs} \ 3827 ${_lld} \ 3828 ${_elftctools} \ 3829 usr.bin/ar \ 3830 ${_clang} 3831 3832_xb-cross-tools: .PHONY 3833.for _tool in ${XDEVDIRS} 3834 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \ 3835 cd ${.CURDIR}/${_tool}; \ 3836 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ 3837 ${CDMAKE} DIRPRFX=${_tool}/ all 3838.endfor 3839 3840_xi-mtree: .PHONY 3841 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}" 3842 mkdir -p ${XDDESTDIR} 3843 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \ 3844 -p ${XDDESTDIR} >/dev/null 3845 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 3846 -p ${XDDESTDIR}/usr >/dev/null 3847 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 3848 -p ${XDDESTDIR}/usr/include >/dev/null 3849.for d in ${LIBCOMPAT_INCLUDE_DIRS} 3850 mkdir -p ${XDDESTDIR}/usr/include/${d} 3851.endfor 3852.for libcompat in ${libcompats} 3853 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 3854 -p ${XDDESTDIR}/usr >/dev/null 3855.endfor 3856.if ${MK_TESTS} != "no" 3857 mkdir -p ${XDDESTDIR}${TESTSBASE} 3858 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 3859 -p ${XDDESTDIR}${TESTSBASE} >/dev/null 3860.endif 3861 3862.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries 3863xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY 3864 3865_xi-cross-tools: .PHONY 3866 @echo "_xi-cross-tools" 3867.for _tool in ${XDEVDIRS} 3868 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ 3869 cd ${.CURDIR}/${_tool}; \ 3870 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} 3871.endfor 3872 3873_xi-includes: .PHONY 3874.if !defined(NO_OBJWALK) 3875 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \ 3876 DESTDIR=${XDDESTDIR} 3877.endif 3878 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \ 3879 DESTDIR=${XDDESTDIR} 3880 3881_xi-libraries: .PHONY 3882 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \ 3883 DESTDIR=${XDDESTDIR} 3884 3885xdev-links: .PHONY 3886 ${_+_}cd ${XDDESTDIR}/usr/bin; \ 3887 mkdir -p ../../../../usr/bin; \ 3888 for i in *; do \ 3889 ln -sf ../../${XDTP}/usr/bin/$$i \ 3890 ../../../../usr/bin/${XDDIR}-$$i; \ 3891 ln -sf ../../${XDTP}/usr/bin/$$i \ 3892 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \ 3893 done 3894