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