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