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