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