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