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