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