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