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