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