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