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