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