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# 20170411 r332443 exect 812.for f in exect fstat fstatat fstatfs getdirentries getfsstat setlogin shmat sigreturn statfs 813.if exists(${OBJTOP}/lib/libc/.depend.${f}.o) 814 @if egrep -qw '${f}\.[sS]' \ 815 ${OBJTOP}/lib/libc/.depend.${f}.o; then \ 816 echo Removing stale dependencies for ${f} syscall wrappers; \ 817 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \ 818 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ 819 fi 820.endif 821.endfor 822# 20170607 remove stale dependencies for utimens* wrappers removed in r319663 823.for f in futimens utimensat 824.if exists(${OBJTOP}/lib/libc/.depend.${f}.o) 825 @if egrep -q '/${f}.c' \ 826 ${OBJTOP}/lib/libc/.depend.${f}.o; then \ 827 echo Removing stale dependencies for ${f} syscall wrappers; \ 828 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \ 829 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ 830 fi 831.endif 832.endfor 833# 20170523 remove stale generated asm files for functions which are no longer 834# syscalls after r302092 (pipe) and r318736 (others) 835.for f in getdents lstat mknod pipe stat 836.if exists(${OBJTOP}/lib/libc/${f}.s) || \ 837 exists(${OBJTOP}/lib/libc/${f}.S) 838 @echo Removing stale generated ${f} syscall files 839 @rm -f ${OBJTOP}/lib/libc/${f}.* \ 840 ${OBJTOP}/lib/libc/.depend.${f}.* \ 841 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \ 842 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*} 843.endif 844.endfor 845 846_worldtmp: .PHONY 847 @echo 848 @echo "--------------------------------------------------------------" 849 @echo ">>> Rebuilding the temporary build tree" 850 @echo "--------------------------------------------------------------" 851.if !defined(NO_CLEAN) 852 rm -rf ${WORLDTMP} 853.else 854.if exists(${WORLDTMP}) 855 @echo ">>> Deleting stale files in build tree..." 856 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ 857 delete-old delete-old-libs >/dev/null 858.endif 859 rm -rf ${WORLDTMP}/legacy/usr/include 860.if ${USING_SYSTEM_COMPILER} == "yes" 861.for cc in cc c++ 862 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \ 863 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \ 864 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \ 865 fi 866.endfor 867.endif # ${USING_SYSTEM_COMPILER} == "yes" 868.endif # !defined(NO_CLEAN) 869 @mkdir -p ${WORLDTMP} 870 @touch ${WORLDTMP}/${.TARGET} 871 872.for _dir in \ 873 lib lib/casper usr legacy/bin legacy/usr 874 mkdir -p ${WORLDTMP}/${_dir} 875.endfor 876 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 877 -p ${WORLDTMP}/legacy/usr >/dev/null 878 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 879 -p ${WORLDTMP}/legacy/usr/include >/dev/null 880 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 881 -p ${WORLDTMP}/usr >/dev/null 882 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 883 -p ${WORLDTMP}/usr/include >/dev/null 884 ln -sf ${.CURDIR}/sys ${WORLDTMP} 885.if ${MK_DEBUG_FILES} != "no" 886 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 887 -p ${WORLDTMP}/legacy/usr/lib >/dev/null 888 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 889 -p ${WORLDTMP}/usr/lib >/dev/null 890.endif 891.for _mtree in ${LOCAL_MTREE} 892 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null 893.endfor 894_legacy: 895 @echo 896 @echo "--------------------------------------------------------------" 897 @echo ">>> stage 1.1: legacy release compatibility shims" 898 @echo "--------------------------------------------------------------" 899 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy 900_bootstrap-tools: 901 @echo 902 @echo "--------------------------------------------------------------" 903 @echo ">>> stage 1.2: bootstrap tools" 904 @echo "--------------------------------------------------------------" 905 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools 906_cleanobj: 907.if !defined(NO_CLEAN) 908 @echo 909 @echo "--------------------------------------------------------------" 910 @echo ">>> stage 2.1: cleaning up the object tree" 911 @echo "--------------------------------------------------------------" 912 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR} 913.if defined(LIBCOMPAT) 914 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR} 915.endif 916.else 917 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack 918.endif # !defined(NO_CLEAN) 919_obj: 920 @echo 921 @echo "--------------------------------------------------------------" 922 @echo ">>> stage 2.2: rebuilding the object tree" 923 @echo "--------------------------------------------------------------" 924 ${_+_}cd ${.CURDIR}; ${WMAKE} obj 925_build-tools: 926 @echo 927 @echo "--------------------------------------------------------------" 928 @echo ">>> stage 2.3: build tools" 929 @echo "--------------------------------------------------------------" 930 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools 931_cross-tools: 932 @echo 933 @echo "--------------------------------------------------------------" 934 @echo ">>> stage 3: cross tools" 935 @echo "--------------------------------------------------------------" 936 @rm -f ${OBJTOP}/compiler-metadata.mk 937 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools 938 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools 939_build-metadata: 940 @echo 941 @echo "--------------------------------------------------------------" 942 @echo ">>> stage 3.1: recording build metadata" 943 @echo "--------------------------------------------------------------" 944 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk 945 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h 946_includes: 947 @echo 948 @echo "--------------------------------------------------------------" 949 @echo ">>> stage 4.1: building includes" 950 @echo "--------------------------------------------------------------" 951# Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need 952# headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last. 953 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ 954 MK_INCLUDES=yes includes 955.if !empty(SUBDIR_OVERRIDE) && make(buildworld) 956 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes 957.endif 958_libraries: 959 @echo 960 @echo "--------------------------------------------------------------" 961 @echo ">>> stage 4.2: building libraries" 962 @echo "--------------------------------------------------------------" 963 ${_+_}cd ${.CURDIR}; \ 964 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \ 965 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries 966everything: .PHONY 967 @echo 968 @echo "--------------------------------------------------------------" 969 @echo ">>> stage 4.3: building everything" 970 @echo "--------------------------------------------------------------" 971 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all 972 973WMAKE_TGTS= 974.if !defined(WORLDFAST) 975WMAKE_TGTS+= _sanity_check _worldtmp _legacy 976.if empty(SUBDIR_OVERRIDE) 977WMAKE_TGTS+= _bootstrap-tools 978.endif 979WMAKE_TGTS+= _cleanobj 980.if !defined(NO_OBJWALK) 981WMAKE_TGTS+= _obj 982.endif 983WMAKE_TGTS+= _build-tools _cross-tools 984WMAKE_TGTS+= _build-metadata 985WMAKE_TGTS+= _includes 986.endif 987.if !defined(NO_LIBS) 988WMAKE_TGTS+= _libraries 989.endif 990WMAKE_TGTS+= everything 991.if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE) 992WMAKE_TGTS+= build${libcompat} 993.endif 994 995buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY 996.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue 997 998buildworld_prologue: .PHONY 999 @echo "--------------------------------------------------------------" 1000 @echo ">>> World build started on `LC_ALL=C date`" 1001 @echo "--------------------------------------------------------------" 1002 1003buildworld_epilogue: .PHONY 1004 @echo 1005 @echo "--------------------------------------------------------------" 1006 @echo ">>> World build completed on `LC_ALL=C date`" 1007 @echo "--------------------------------------------------------------" 1008 1009# 1010# We need to have this as a target because the indirection between Makefile 1011# and Makefile.inc1 causes the correct PATH to be used, rather than a 1012# modification of the current environment's PATH. In addition, we need 1013# to quote multiword values. 1014# 1015buildenvvars: .PHONY 1016 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@} 1017 1018.if ${.TARGETS:Mbuildenv} 1019.if ${.MAKEFLAGS:M-j} 1020.error The buildenv target is incompatible with -j 1021.endif 1022.endif 1023BUILDENV_DIR?= ${.CURDIR} 1024# 1025# Note: make will report any errors the shell reports. This can 1026# be odd if the last command in an interactive shell generates an 1027# error or is terminated by SIGINT. These reported errors look bad, 1028# but are harmless. Allowing them also allows BUIDLENV_SHELL to 1029# be a complex command whose status will be returned to the caller. 1030# Some scripts in tools rely on this behavior to report build errors. 1031# 1032buildenv: .PHONY 1033 @echo Entering world for ${TARGET_ARCH}:${TARGET} 1034.if ${BUILDENV_SHELL:M*zsh*} 1035 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE} 1036.endif 1037 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} 1038 1039TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}} 1040toolchain: ${TOOLCHAIN_TGTS} .PHONY 1041KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries} 1042.if make(kernel-toolchain) 1043.ORDER: ${KERNEL_TOOLCHAIN_TGTS} 1044.endif 1045kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY 1046 1047# 1048# installcheck 1049# 1050# Checks to be sure system is ready for installworld/installkernel. 1051# 1052installcheck: _installcheck_world _installcheck_kernel .PHONY 1053_installcheck_world: .PHONY 1054_installcheck_kernel: .PHONY 1055 1056# 1057# Require DESTDIR to be set if installing for a different architecture or 1058# using the user/group database in the source tree. 1059# 1060.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \ 1061 defined(DB_FROM_SRC) 1062.if !make(distributeworld) 1063_installcheck_world: __installcheck_DESTDIR 1064_installcheck_kernel: __installcheck_DESTDIR 1065__installcheck_DESTDIR: .PHONY 1066.if !defined(DESTDIR) || empty(DESTDIR) 1067 @echo "ERROR: Please set DESTDIR!"; \ 1068 false 1069.endif 1070.endif 1071.endif 1072 1073.if !defined(DB_FROM_SRC) 1074# 1075# Check for missing UIDs/GIDs. 1076# 1077CHECK_UIDS= auditdistd 1078CHECK_GIDS= audit 1079.if ${MK_SENDMAIL} != "no" 1080CHECK_UIDS+= smmsp 1081CHECK_GIDS+= smmsp 1082.endif 1083.if ${MK_PF} != "no" 1084CHECK_UIDS+= proxy 1085CHECK_GIDS+= proxy authpf 1086.endif 1087.if ${MK_UNBOUND} != "no" 1088CHECK_UIDS+= unbound 1089CHECK_GIDS+= unbound 1090.endif 1091_installcheck_world: __installcheck_UGID 1092__installcheck_UGID: .PHONY 1093.for uid in ${CHECK_UIDS} 1094 @if ! `id -u ${uid} >/dev/null 2>&1`; then \ 1095 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \ 1096 false; \ 1097 fi 1098.endfor 1099.for gid in ${CHECK_GIDS} 1100 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \ 1101 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \ 1102 false; \ 1103 fi 1104.endfor 1105.endif 1106# 1107# If installing over the running system (DESTDIR is / or unset) and the install 1108# includes rescue, try running rescue from the objdir as a sanity check. If 1109# rescue is not functional (e.g., because it depends on a system call not 1110# supported by the currently running kernel), abort the installation. 1111# 1112.if !make(distributeworld) && ${MK_RESCUE} != "no" && \ 1113 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH) 1114_installcheck_world: __installcheck_sh_check 1115__installcheck_sh_check: .PHONY 1116 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \ 1117 OK ]; then \ 1118 echo "rescue/sh check failed, installation aborted" >&2; \ 1119 false; \ 1120 fi 1121.endif 1122 1123# 1124# Required install tools to be saved in a scratch dir for safety. 1125# 1126.if ${MK_ZONEINFO} != "no" 1127_zoneinfo= zic tzsetup 1128.endif 1129 1130ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \ 1131 date echo egrep find grep id install ${_install-info} \ 1132 ln make mkdir mtree mv pwd_mkdb \ 1133 rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \ 1134 ${LOCAL_ITOOLS} 1135 1136# Needed for share/man 1137.if ${MK_MAN_UTILS} != "no" 1138ITOOLS+=makewhatis 1139.endif 1140 1141# 1142# distributeworld 1143# 1144# Distributes everything compiled by a `buildworld'. 1145# 1146# installworld 1147# 1148# Installs everything compiled by a 'buildworld'. 1149# 1150 1151# Non-base distributions produced by the base system 1152EXTRA_DISTRIBUTIONS= doc 1153.if defined(LIBCOMPAT) 1154EXTRA_DISTRIBUTIONS+= lib${libcompat} 1155.endif 1156.if ${MK_TESTS} != "no" 1157EXTRA_DISTRIBUTIONS+= tests 1158.endif 1159 1160DEBUG_DISTRIBUTIONS= 1161.if ${MK_DEBUG_FILES} != "no" 1162DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,} 1163.endif 1164 1165MTREE_MAGIC?= mtree 2.0 1166 1167distributeworld installworld stageworld: _installcheck_world .PHONY 1168 mkdir -p ${INSTALLTMP} 1169 progs=$$(for prog in ${ITOOLS}; do \ 1170 if progpath=`which $$prog`; then \ 1171 echo $$progpath; \ 1172 else \ 1173 echo "Required tool $$prog not found in PATH." >&2; \ 1174 exit 1; \ 1175 fi; \ 1176 done); \ 1177 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \ 1178 while read line; do \ 1179 set -- $$line; \ 1180 if [ "$$2 $$3" != "not found" ]; then \ 1181 echo $$2; \ 1182 else \ 1183 echo "Required library $$1 not found." >&2; \ 1184 exit 1; \ 1185 fi; \ 1186 done); \ 1187 cp $$libs $$progs ${INSTALLTMP} 1188 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale 1189.if defined(NO_ROOT) 1190 -mkdir -p ${METALOG:H} 1191 echo "#${MTREE_MAGIC}" > ${METALOG} 1192.endif 1193.if make(distributeworld) 1194.for dist in ${EXTRA_DISTRIBUTIONS} 1195 -mkdir ${DESTDIR}/${DISTDIR}/${dist} 1196 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ 1197 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null 1198 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 1199 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null 1200 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 1201 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null 1202.if ${MK_DEBUG_FILES} != "no" 1203 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 1204 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null 1205.endif 1206.if defined(LIBCOMPAT) 1207 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 1208 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null 1209.if ${MK_DEBUG_FILES} != "no" 1210 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 1211 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null 1212.endif 1213.endif 1214.if ${MK_TESTS} != "no" && ${dist} == "tests" 1215 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} 1216 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 1217 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null 1218.if ${MK_DEBUG_FILES} != "no" 1219 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 1220 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null 1221.endif 1222.endif 1223.if defined(NO_ROOT) 1224 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ 1225 sed -e 's#^\./#./${dist}/#' >> ${METALOG} 1226 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \ 1227 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} 1228 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \ 1229 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG} 1230.if defined(LIBCOMPAT) 1231 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \ 1232 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} 1233.endif 1234.endif 1235.endfor 1236 -mkdir ${DESTDIR}/${DISTDIR}/base 1237 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ 1238 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \ 1239 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \ 1240 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs 1241.endif 1242 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \ 1243 ${IMAKEENV} rm -rf ${INSTALLTMP} 1244.if make(distributeworld) 1245.for dist in ${EXTRA_DISTRIBUTIONS} 1246 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete 1247.endfor 1248.if defined(NO_ROOT) 1249.for dist in base ${EXTRA_DISTRIBUTIONS} 1250 @# For each file that exists in this dist, print the corresponding 1251 @# line from the METALOG. This relies on the fact that 1252 @# a line containing only the filename will sort immediately before 1253 @# the relevant mtree line. 1254 cd ${DESTDIR}/${DISTDIR}; \ 1255 find ./${dist} | sort -u ${METALOG} - | \ 1256 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \ 1257 ${DESTDIR}/${DISTDIR}/${dist}.meta 1258.endfor 1259.for dist in ${DEBUG_DISTRIBUTIONS} 1260 @# For each file that exists in this dist, print the corresponding 1261 @# line from the METALOG. This relies on the fact that 1262 @# a line containing only the filename will sort immediately before 1263 @# the relevant mtree line. 1264 cd ${DESTDIR}/${DISTDIR}; \ 1265 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \ 1266 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \ 1267 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta 1268.endfor 1269.endif 1270.endif 1271 1272packageworld: .PHONY 1273.for dist in base ${EXTRA_DISTRIBUTIONS} 1274.if defined(NO_ROOT) 1275 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1276 tar cvf - --exclude usr/lib/debug \ 1277 @${DESTDIR}/${DISTDIR}/${dist}.meta | \ 1278 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz 1279.else 1280 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1281 tar cvf - --exclude usr/lib/debug . | \ 1282 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz 1283.endif 1284.endfor 1285 1286.for dist in ${DEBUG_DISTRIBUTIONS} 1287. if defined(NO_ROOT) 1288 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1289 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \ 1290 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz 1291. else 1292 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ 1293 tar cvLf - usr/lib/debug | \ 1294 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz 1295. endif 1296.endfor 1297 1298# 1299# reinstall 1300# 1301# If you have a build server, you can NFS mount the source and obj directories 1302# and do a 'make reinstall' on the *client* to install new binaries from the 1303# most recent server build. 1304# 1305restage reinstall: .MAKE .PHONY 1306 @echo "--------------------------------------------------------------" 1307 @echo ">>> Making hierarchy" 1308 @echo "--------------------------------------------------------------" 1309 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ 1310 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy 1311.if make(restage) 1312 @echo "--------------------------------------------------------------" 1313 @echo ">>> Making distribution" 1314 @echo "--------------------------------------------------------------" 1315 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ 1316 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution 1317.endif 1318 @echo 1319 @echo "--------------------------------------------------------------" 1320 @echo ">>> Installing everything" 1321 @echo "--------------------------------------------------------------" 1322 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install 1323.if defined(LIBCOMPAT) 1324 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat} 1325.endif 1326 1327redistribute: .MAKE .PHONY 1328 @echo "--------------------------------------------------------------" 1329 @echo ">>> Distributing everything" 1330 @echo "--------------------------------------------------------------" 1331 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute 1332.if defined(LIBCOMPAT) 1333 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \ 1334 DISTRIBUTION=lib${libcompat} 1335.endif 1336 1337distrib-dirs distribution: .MAKE .PHONY 1338 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ 1339 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} 1340.if make(distribution) 1341 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \ 1342 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \ 1343 METALOG=${METALOG} MK_TESTS=no installconfig 1344.endif 1345 1346# 1347# buildkernel and installkernel 1348# 1349# Which kernels to build and/or install is specified by setting 1350# KERNCONF. If not defined a GENERIC kernel is built/installed. 1351# Only the existing (depending TARGET) config files are used 1352# for building kernels and only the first of these is designated 1353# as the one being installed. 1354# 1355# Note that we have to use TARGET instead of TARGET_ARCH when 1356# we're in kernel-land. Since only TARGET_ARCH is (expected) to 1357# be set to cross-build, we have to make sure TARGET is set 1358# properly. 1359 1360.if defined(KERNFAST) 1361NO_KERNELCLEAN= t 1362NO_KERNELCONFIG= t 1363NO_KERNELOBJ= t 1364# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah 1365.if !defined(KERNCONF) && ${KERNFAST} != "1" 1366KERNCONF=${KERNFAST} 1367.endif 1368.endif 1369.if ${TARGET_ARCH} == "powerpc64" 1370KERNCONF?= GENERIC64 1371.else 1372KERNCONF?= GENERIC 1373.endif 1374INSTKERNNAME?= kernel 1375 1376KERNSRCDIR?= ${.CURDIR}/sys 1377KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf 1378KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,} 1379KERNCONFDIR?= ${KRNLCONFDIR} 1380 1381BUILDKERNELS= 1382INSTALLKERNEL= 1383.if defined(NO_INSTALLKERNEL) 1384# All of the BUILDKERNELS loops start at index 1. 1385BUILDKERNELS+= dummy 1386.endif 1387.for _kernel in ${KERNCONF} 1388.if exists(${KERNCONFDIR}/${_kernel}) 1389BUILDKERNELS+= ${_kernel} 1390.if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL) 1391INSTALLKERNEL= ${_kernel} 1392.endif 1393.else 1394.if make(buildkernel) 1395.error Missing KERNCONF ${KERNCONFDIR}/${_kernel} 1396.endif 1397.endif 1398.endfor 1399 1400_cleankernobj_fast_depend_hack: .PHONY 1401# 20180320 remove stale generated assym.s after renaming to .inc in r331254 1402.if exists(${OBJTOP}/sys/${KERNCONF}/assym.s) 1403 @echo Removing stale generated assym files 1404 @rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \ 1405 ${OBJTOP}/sys/${KERNCONF}/.depend.assym.* 1406.endif 1407 1408${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY 1409 1410# 1411# buildkernel 1412# 1413# Builds all kernels defined by BUILDKERNELS. 1414# 1415buildkernel: .MAKE .PHONY 1416.if empty(BUILDKERNELS:Ndummy) 1417 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ 1418 false 1419.endif 1420 @echo 1421.for _kernel in ${BUILDKERNELS:Ndummy} 1422 @echo "--------------------------------------------------------------" 1423 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" 1424 @echo "--------------------------------------------------------------" 1425 @echo "===> ${_kernel}" 1426 mkdir -p ${KRNLOBJDIR} 1427.if !defined(NO_KERNELCONFIG) 1428 @echo 1429 @echo "--------------------------------------------------------------" 1430 @echo ">>> stage 1: configuring the kernel" 1431 @echo "--------------------------------------------------------------" 1432 cd ${KRNLCONFDIR}; \ 1433 PATH=${TMPPATH} \ 1434 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ 1435 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}' 1436.endif 1437.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) 1438 @echo 1439 @echo "--------------------------------------------------------------" 1440 @echo ">>> stage 2.1: cleaning up the object tree" 1441 @echo "--------------------------------------------------------------" 1442 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} 1443.else 1444 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack 1445.endif 1446.if !defined(NO_KERNELOBJ) 1447 @echo 1448 @echo "--------------------------------------------------------------" 1449 @echo ">>> stage 2.2: rebuilding the object tree" 1450 @echo "--------------------------------------------------------------" 1451 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj 1452.endif 1453 @echo 1454 @echo "--------------------------------------------------------------" 1455 @echo ">>> stage 2.3: build tools" 1456 @echo "--------------------------------------------------------------" 1457 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools 1458 @echo 1459 @echo "--------------------------------------------------------------" 1460 @echo ">>> stage 3.1: building everything" 1461 @echo "--------------------------------------------------------------" 1462 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ 1463 @echo "--------------------------------------------------------------" 1464 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" 1465 @echo "--------------------------------------------------------------" 1466.endfor 1467 1468NO_INSTALLEXTRAKERNELS?= yes 1469 1470# 1471# installkernel, etc. 1472# 1473# Install the kernel defined by INSTALLKERNEL 1474# 1475installkernel installkernel.debug \ 1476reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY 1477.if !defined(NO_INSTALLKERNEL) 1478.if empty(INSTALLKERNEL) 1479 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 1480 false 1481.endif 1482 @echo "--------------------------------------------------------------" 1483 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)" 1484 @echo "--------------------------------------------------------------" 1485 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 1486 ${CROSSENV} PATH=${TMPPATH} \ 1487 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//} 1488 @echo "--------------------------------------------------------------" 1489 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)" 1490 @echo "--------------------------------------------------------------" 1491.endif 1492.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1493.for _kernel in ${BUILDKERNELS:[2..-1]} 1494 @echo "--------------------------------------------------------------" 1495 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)" 1496 @echo "--------------------------------------------------------------" 1497 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \ 1498 ${CROSSENV} PATH=${TMPPATH} \ 1499 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//} 1500 @echo "--------------------------------------------------------------" 1501 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)" 1502 @echo "--------------------------------------------------------------" 1503.endfor 1504.endif 1505 1506distributekernel distributekernel.debug: .PHONY 1507.if !defined(NO_INSTALLKERNEL) 1508.if empty(INSTALLKERNEL) 1509 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 1510 false 1511.endif 1512 mkdir -p ${DESTDIR}/${DISTDIR} 1513.if defined(NO_ROOT) 1514 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta 1515.endif 1516 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 1517 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \ 1518 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \ 1519 DESTDIR=${INSTALL_DDIR}/kernel \ 1520 ${.TARGET:S/distributekernel/install/} 1521.if defined(NO_ROOT) 1522 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \ 1523 ${DESTDIR}/${DISTDIR}/kernel.meta 1524.endif 1525.endif 1526.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1527.for _kernel in ${BUILDKERNELS:[2..-1]} 1528.if defined(NO_ROOT) 1529 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta 1530.endif 1531 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \ 1532 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \ 1533 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \ 1534 KERNEL=${INSTKERNNAME}.${_kernel} \ 1535 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \ 1536 ${.TARGET:S/distributekernel/install/} 1537.if defined(NO_ROOT) 1538 @sed -e "s|^./kernel.${_kernel}|.|" \ 1539 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \ 1540 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta 1541.endif 1542.endfor 1543.endif 1544 1545packagekernel: .PHONY 1546.if defined(NO_ROOT) 1547.if !defined(NO_INSTALLKERNEL) 1548 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1549 tar cvf - --exclude '*.debug' \ 1550 @${DESTDIR}/${DISTDIR}/kernel.meta | \ 1551 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz 1552.endif 1553.if ${MK_DEBUG_FILES} != "no" 1554 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1555 tar cvf - --include '*/*/*.debug' \ 1556 @${DESTDIR}/${DISTDIR}/kernel.meta | \ 1557 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz 1558.endif 1559.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1560.for _kernel in ${BUILDKERNELS:[2..-1]} 1561 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1562 tar cvf - --exclude '*.debug' \ 1563 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ 1564 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz 1565.if ${MK_DEBUG_FILES} != "no" 1566 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1567 tar cvf - --include '*/*/*.debug' \ 1568 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ 1569 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz 1570.endif 1571.endfor 1572.endif 1573.else 1574.if !defined(NO_INSTALLKERNEL) 1575 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1576 tar cvf - --exclude '*.debug' . | \ 1577 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz 1578.endif 1579.if ${MK_DEBUG_FILES} != "no" 1580 cd ${DESTDIR}/${DISTDIR}/kernel; \ 1581 tar cvf - --include '*/*/*.debug' $$(eval find .) | \ 1582 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz 1583.endif 1584.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1585.for _kernel in ${BUILDKERNELS:[2..-1]} 1586 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1587 tar cvf - --exclude '*.debug' . | \ 1588 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz 1589.if ${MK_DEBUG_FILES} != "no" 1590 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ 1591 tar cvf - --include '*/*/*.debug' $$(eval find .) | \ 1592 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz 1593.endif 1594.endfor 1595.endif 1596.endif 1597 1598stagekernel: .PHONY 1599 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel 1600 1601PORTSDIR?= /usr/ports 1602WSTAGEDIR?= ${OBJTOP}/worldstage 1603KSTAGEDIR?= ${OBJTOP}/kernelstage 1604REPODIR?= ${OBJROOT}repo 1605PKGSIGNKEY?= # empty 1606 1607.ORDER: stage-packages create-packages 1608.ORDER: create-packages create-world-packages 1609.ORDER: create-packages create-kernel-packages 1610.ORDER: create-packages sign-packages 1611 1612_pkgbootstrap: .PHONY 1613.if !exists(${LOCALBASE}/sbin/pkg) 1614 @env ASSUME_ALWAYS_YES=YES pkg bootstrap 1615.endif 1616 1617packages: .PHONY 1618 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages 1619 1620package-pkg: .PHONY 1621 rm -rf /tmp/ports.${TARGET} || : 1622 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \ 1623 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \ 1624 WSTAGEDIR=${WSTAGEDIR} \ 1625 sh ${.CURDIR}/release/scripts/make-pkg-package.sh 1626 1627real-packages: stage-packages create-packages sign-packages .PHONY 1628 1629stage-packages-world: .PHONY 1630 @mkdir -p ${WSTAGEDIR} 1631 ${_+_}@cd ${.CURDIR}; \ 1632 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld 1633 1634stage-packages-kernel: .PHONY 1635 @mkdir -p ${KSTAGEDIR} 1636 ${_+_}@cd ${.CURDIR}; \ 1637 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel 1638 1639stage-packages: .PHONY stage-packages-world stage-packages-kernel 1640 1641_repodir: .PHONY 1642 @mkdir -p ${REPODIR} 1643 1644create-packages-world: _pkgbootstrap _repodir .PHONY 1645 ${_+_}@cd ${.CURDIR}; \ 1646 ${MAKE} -f Makefile.inc1 \ 1647 DESTDIR=${WSTAGEDIR} \ 1648 PKG_VERSION=${PKG_VERSION} create-world-packages 1649 1650create-packages-kernel: _pkgbootstrap _repodir .PHONY 1651 ${_+_}@cd ${.CURDIR}; \ 1652 ${MAKE} -f Makefile.inc1 \ 1653 DESTDIR=${KSTAGEDIR} \ 1654 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \ 1655 create-kernel-packages 1656 1657create-packages: .PHONY create-packages-world create-packages-kernel 1658 1659create-world-packages: _pkgbootstrap .PHONY 1660 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || : 1661 @cd ${WSTAGEDIR} ; \ 1662 env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \ 1663 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk 1664 @for plist in ${WSTAGEDIR}/*.plist; do \ 1665 plist=$${plist##*/} ; \ 1666 pkgname=$${plist%.plist} ; \ 1667 echo "_PKGS+= $${pkgname}" ; \ 1668 done > ${WSTAGEDIR}/packages.mk 1669 ${_+_}@cd ${.CURDIR}; \ 1670 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \ 1671 .MAKE.JOB.PREFIX= 1672 1673.if make(create-world-packages-jobs) 1674.include "${WSTAGEDIR}/packages.mk" 1675.endif 1676 1677create-world-packages-jobs: .PHONY 1678.for pkgname in ${_PKGS} 1679create-world-packages-jobs: create-world-package-${pkgname} 1680create-world-package-${pkgname}: .PHONY 1681 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \ 1682 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl 1683 @awk -F\" ' \ 1684 /^name/ { printf("===> Creating %s-", $$2); next } \ 1685 /^version/ { print $$2; next } \ 1686 ' ${WSTAGEDIR}/${pkgname}.ucl 1687 @if [ "${pkgname}" == "runtime" ]; then \ 1688 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \ 1689 fi 1690 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ 1691 create -M ${WSTAGEDIR}/${pkgname}.ucl \ 1692 -p ${WSTAGEDIR}/${pkgname}.plist \ 1693 -r ${WSTAGEDIR} \ 1694 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} 1695.endfor 1696 1697create-kernel-packages: .PHONY 1698_default_flavor= -default 1699.if exists(${KSTAGEDIR}/kernel.meta) 1700. if ${MK_DEBUG_FILES} != "no" 1701_debug=-debug 1702. endif 1703. for flavor in "" ${_debug} 1704create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} 1705create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY 1706 @cd ${KSTAGEDIR}/${DISTDIR} ; \ 1707 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \ 1708 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ 1709 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \ 1710 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ 1711 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ 1712 sed -e "s/%VERSION%/${PKG_VERSION}/" \ 1713 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \ 1714 -e "s/%KERNELDIR%/kernel/" \ 1715 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \ 1716 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \ 1717 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \ 1718 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \ 1719 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \ 1720 ${SRCDIR}/release/packages/kernel.ucl \ 1721 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ 1722 awk -F\" ' \ 1723 /name/ { printf("===> Creating %s-", $$2); next } \ 1724 /version/ {print $$2; next } ' \ 1725 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ 1726 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ 1727 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \ 1728 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \ 1729 -r ${KSTAGEDIR}/${DISTDIR} \ 1730 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} 1731. endfor 1732.endif 1733.if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" 1734. for _kernel in ${BUILDKERNELS:[2..-1]} 1735. if exists(${KSTAGEDIR}/kernel.${_kernel}.meta) 1736. if ${MK_DEBUG_FILES} != "no" 1737_debug=-debug 1738. endif 1739. for flavor in "" ${_debug} 1740create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel} 1741create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY 1742 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \ 1743 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \ 1744 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ 1745 -v kernel=yes -v _kernconf=${_kernel} ; \ 1746 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ 1747 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ 1748 sed -e "s/%VERSION%/${PKG_VERSION}/" \ 1749 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \ 1750 -e "s/%KERNELDIR%/kernel.${_kernel}/" \ 1751 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \ 1752 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \ 1753 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \ 1754 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \ 1755 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \ 1756 ${SRCDIR}/release/packages/kernel.ucl \ 1757 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ 1758 awk -F\" ' \ 1759 /name/ { printf("===> Creating %s-", $$2); next } \ 1760 /version/ {print $$2; next } ' \ 1761 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ 1762 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ 1763 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \ 1764 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \ 1765 -r ${KSTAGEDIR}/kernel.${_kernel} \ 1766 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} 1767. endfor 1768. endif 1769. endfor 1770.endif 1771 1772sign-packages: _pkgbootstrap .PHONY 1773 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \ 1774 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \ 1775 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \ 1776 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \ 1777 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \ 1778 ${PKGSIGNKEY} ; \ 1779 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \ 1780 ln -s ${PKG_VERSION} latest 1781 1782# 1783# 1784# checkworld 1785# 1786# Run test suite on installed world. 1787# 1788checkworld: .PHONY 1789 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \ 1790 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \ 1791 exit 1; \ 1792 fi 1793 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile 1794 1795# 1796# 1797# doxygen 1798# 1799# Build the API documentation with doxygen 1800# 1801doxygen: .PHONY 1802 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \ 1803 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ 1804 exit 1; \ 1805 fi 1806 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all 1807 1808# 1809# update 1810# 1811# Update the source tree(s), by running svn/svnup to update to the 1812# latest copy. 1813# 1814update: .PHONY 1815.if defined(SVN_UPDATE) 1816 @echo "--------------------------------------------------------------" 1817 @echo ">>> Updating ${.CURDIR} using Subversion" 1818 @echo "--------------------------------------------------------------" 1819 @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS}) 1820.endif 1821 1822# 1823# ------------------------------------------------------------------------ 1824# 1825# From here onwards are utility targets used by the 'make world' and 1826# related targets. If your 'world' breaks, you may like to try to fix 1827# the problem and manually run the following targets to attempt to 1828# complete the build. Beware, this is *not* guaranteed to work, you 1829# need to have a pretty good grip on the current state of the system 1830# to attempt to manually finish it. If in doubt, 'make world' again. 1831# 1832 1833# 1834# legacy: Build compatibility shims for the next three targets. This is a 1835# minimal set of tools and shims necessary to compensate for older systems 1836# which don't have the APIs required by the targets built in bootstrap-tools, 1837# build-tools or cross-tools. 1838# 1839 1840# ELF Tool Chain libraries are needed for ELF tools and dtrace tools. 1841# r296685 fix cross-endian objcopy 1842# r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2. 1843.if ${BOOTSTRAPPING} < 1200020 1844_elftoolchain_libs= lib/libelf lib/libdwarf 1845.endif 1846 1847legacy: .PHONY 1848.if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0 1849 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \ 1850 false 1851.endif 1852 1853.for _tool in tools/build ${_elftoolchain_libs} 1854 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \ 1855 cd ${.CURDIR}/${_tool}; \ 1856 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 1857 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \ 1858 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \ 1859 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \ 1860 DESTDIR=${WORLDTMP}/legacy install 1861.endfor 1862 1863# 1864# bootstrap-tools: Build tools needed for compatibility. These are binaries that 1865# are built to build other binaries in the system. However, the focus of these 1866# binaries is usually quite narrow. Bootstrap tools use the host's compiler and 1867# libraries, augmented by -legacy. 1868# 1869_bt= _bootstrap-tools 1870 1871.if ${MK_GAMES} != "no" 1872_strfile= usr.bin/fortune/strfile 1873.endif 1874 1875.if ${MK_GCC} != "no" && ${MK_CXX} != "no" 1876_gperf= gnu/usr.bin/gperf 1877.endif 1878 1879.if ${MK_VT} != "no" 1880_vtfontcvt= usr.bin/vtfontcvt 1881.endif 1882 1883.if ${BOOTSTRAPPING} < 1000033 1884_m4= usr.bin/m4 1885_lex= usr.bin/lex 1886 1887${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd 1888${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4 1889.endif 1890 1891# r245440 mtree -N support added 1892# r313404 requires sha384.h for libnetbsd, added to libmd in r292782 1893.if ${BOOTSTRAPPING} < 1100093 1894_nmtree= lib/libmd \ 1895 lib/libnetbsd \ 1896 usr.sbin/nmtree 1897 1898${_bt}-lib/libnetbsd: ${_bt}-lib/libmd 1899${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd 1900.endif 1901 1902# r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l 1903.if ${BOOTSTRAPPING} < 1000027 1904_cat= bin/cat 1905.endif 1906 1907# r277259 crunchide: Correct 64-bit section header offset 1908# r281674 crunchide: always include both 32- and 64-bit ELF support 1909.if ${BOOTSTRAPPING} < 1100078 1910_crunchide= usr.sbin/crunch/crunchide 1911.endif 1912 1913# r285986 crunchen: use STRIPBIN rather than STRIP 1914# 1100113: Support MK_AUTO_OBJ 1915# 1200006: META_MODE fixes 1916.if ${BOOTSTRAPPING} < 1100078 || \ 1917 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \ 1918 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006) 1919_crunchgen= usr.sbin/crunch/crunchgen 1920.endif 1921 1922# r296926 -P keymap search path, MFC to stable/10 in r298297 1923.if ${BOOTSTRAPPING} < 1003501 || \ 1924 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103) 1925_kbdcontrol= usr.sbin/kbdcontrol 1926.endif 1927 1928_yacc= lib/liby \ 1929 usr.bin/yacc 1930 1931${_bt}-usr.bin/yacc: ${_bt}-lib/liby 1932 1933.if ${MK_BSNMP} != "no" 1934_gensnmptree= usr.sbin/bsnmpd/gensnmptree 1935.endif 1936 1937# We need to build tblgen when we're building clang or lld, either as 1938# bootstrap tools, or as the part of the normal build. 1939.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \ 1940 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" 1941_clang_tblgen= \ 1942 lib/clang/libllvmminimal \ 1943 usr.bin/clang/llvm-tblgen \ 1944 usr.bin/clang/clang-tblgen 1945 1946${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal 1947${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal 1948.endif 1949 1950# Default to building the GPL DTC, but build the BSDL one if users explicitly 1951# request it. 1952_dtc= usr.bin/dtc 1953.if ${MK_GPL_DTC} != "no" 1954_dtc= gnu/usr.bin/dtc 1955.endif 1956 1957.if ${MK_KERBEROS} != "no" 1958_kerberos5_bootstrap_tools= \ 1959 kerberos5/tools/make-roken \ 1960 kerberos5/lib/libroken \ 1961 kerberos5/lib/libvers \ 1962 kerberos5/tools/asn1_compile \ 1963 kerberos5/tools/slc \ 1964 usr.bin/compile_et 1965 1966.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g} 1967.endif 1968 1969${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd 1970 1971bootstrap-tools: .PHONY 1972 1973# Please document (add comment) why something is in 'bootstrap-tools'. 1974# Try to bound the building of the bootstrap-tool to just the 1975# FreeBSD versions that need the tool built at this stage of the build. 1976.for _tool in \ 1977 ${_clang_tblgen} \ 1978 ${_kerberos5_bootstrap_tools} \ 1979 ${_strfile} \ 1980 ${_gperf} \ 1981 ${_dtc} \ 1982 ${_cat} \ 1983 ${_kbdcontrol} \ 1984 usr.bin/lorder \ 1985 lib/libopenbsd \ 1986 usr.bin/mandoc \ 1987 usr.bin/rpcgen \ 1988 ${_yacc} \ 1989 ${_m4} \ 1990 ${_lex} \ 1991 usr.bin/xinstall \ 1992 ${_gensnmptree} \ 1993 usr.sbin/config \ 1994 ${_crunchide} \ 1995 ${_crunchgen} \ 1996 ${_nmtree} \ 1997 ${_vtfontcvt} \ 1998 usr.bin/localedef 1999${_bt}-${_tool}: .PHONY .MAKE 2000 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 2001 cd ${.CURDIR}/${_tool}; \ 2002 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2003 ${MAKE} DIRPRFX=${_tool}/ all; \ 2004 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install 2005 2006bootstrap-tools: ${_bt}-${_tool} 2007.endfor 2008 2009# 2010# build-tools: Build special purpose build tools 2011# 2012.if !defined(NO_SHARE) && ${MK_SYSCONS} != "no" 2013_share= share/syscons/scrnmaps 2014.endif 2015 2016.if ${MK_GCC} != "no" 2017_gcc_tools= gnu/usr.bin/cc/cc_tools 2018.endif 2019 2020.if ${MK_RESCUE} != "no" 2021# rescue includes programs that have build-tools targets 2022_rescue=rescue/rescue 2023.endif 2024 2025.if ${MK_TCSH} != "no" 2026_tcsh=bin/csh 2027.endif 2028.if ${MK_FILE} != "no" 2029_libmagic=lib/libmagic 2030.endif 2031 2032# kernel-toolchain skips _cleanobj, so handle cleaning up previous 2033# build-tools directories if needed. 2034.if !defined(NO_CLEAN) && make(kernel-toolchain) 2035_bt_clean= ${CLEANDIR} 2036.endif 2037 2038.for _tool in \ 2039 ${_tcsh} \ 2040 bin/sh \ 2041 ${LOCAL_TOOL_DIRS} \ 2042 lib/ncurses/ncurses \ 2043 lib/ncurses/ncursesw \ 2044 ${_rescue} \ 2045 ${_share} \ 2046 usr.bin/awk \ 2047 ${_libmagic} \ 2048 usr.bin/mkesdb_static \ 2049 usr.bin/mkcsmapper_static \ 2050 usr.bin/vi/catalog \ 2051 ${_gcc_tools} 2052build-tools_${_tool}: .PHONY 2053 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \ 2054 cd ${.CURDIR}/${_tool}; \ 2055 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \ 2056 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2057 ${MAKE} DIRPRFX=${_tool}/ build-tools 2058build-tools: build-tools_${_tool} 2059.endfor 2060 2061# 2062# kernel-tools: Build kernel-building tools 2063# 2064kernel-tools: .PHONY 2065 mkdir -p ${WORLDTMP}/usr 2066 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 2067 -p ${WORLDTMP}/usr >/dev/null 2068 2069# 2070# cross-tools: All the tools needed to build the rest of the system after 2071# we get done with the earlier stages. It is the last set of tools needed 2072# to begin building the target binaries. 2073# 2074.if ${TARGET_ARCH} != ${MACHINE_ARCH} 2075.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" 2076_btxld= usr.sbin/btxld 2077.endif 2078.endif 2079 2080# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures 2081# resulting from missing bug fixes or ELF Toolchain updates. 2082.if ${MK_CDDL} != "no" 2083_dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \ 2084 cddl/usr.bin/ctfmerge 2085.endif 2086 2087# If we're given an XAS, don't build binutils. 2088.if ${XAS:M/*} == "" 2089.if ${MK_BINUTILS_BOOTSTRAP} != "no" 2090_binutils= gnu/usr.bin/binutils 2091.endif 2092.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no" 2093_elftctools= lib/libelftc \ 2094 lib/libpe \ 2095 usr.bin/elfcopy \ 2096 usr.bin/nm \ 2097 usr.bin/size \ 2098 usr.bin/strings 2099# These are not required by the build, but can be useful for developers who 2100# cross-build on a FreeBSD 10 host: 2101_elftctools+= usr.bin/addr2line 2102.endif 2103.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no" 2104# If cross-building with an external binutils we still need to build strip for 2105# the target (for at least crunchide). 2106_elftctools= lib/libelftc \ 2107 lib/libpe \ 2108 usr.bin/elfcopy 2109.endif 2110 2111.if ${MK_CLANG_BOOTSTRAP} != "no" 2112_clang= usr.bin/clang 2113.endif 2114.if ${MK_LLD_BOOTSTRAP} != "no" 2115_lld= usr.bin/clang/lld 2116.endif 2117.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no" 2118_clang_libs= lib/clang 2119.endif 2120.if ${MK_GCC_BOOTSTRAP} != "no" 2121_gcc= gnu/usr.bin/cc 2122.endif 2123.if ${MK_USB} != "no" 2124_usb_tools= stand/usb/tools 2125.endif 2126 2127cross-tools: .MAKE .PHONY 2128.for _tool in \ 2129 ${LOCAL_XTOOL_DIRS} \ 2130 ${_clang_libs} \ 2131 ${_clang} \ 2132 ${_lld} \ 2133 ${_binutils} \ 2134 ${_elftctools} \ 2135 ${_dtrace_tools} \ 2136 ${_gcc} \ 2137 ${_btxld} \ 2138 ${_usb_tools} 2139 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 2140 cd ${.CURDIR}/${_tool}; \ 2141 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ 2142 ${MAKE} DIRPRFX=${_tool}/ all; \ 2143 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install 2144.endfor 2145 2146# 2147# native-xtools is the current target for qemu-user cross builds of ports 2148# via poudriere and the imgact_binmisc kernel module. 2149# This target merely builds a toolchan/sysroot, then builds the tools it wants 2150# with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain 2151# already built. It then installs the static tools to NXBDESTDIR for Poudriere 2152# to pickup. 2153# 2154NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/ 2155NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH} 2156NXTP?= /nxb-bin 2157.if ${NXTP:N/*} 2158.error NXTP variable should be an absolute path 2159.endif 2160NXBDESTDIR?= ${DESTDIR}${NXTP} 2161 2162# This is the list of tools to be built/installed as static and where 2163# appropriate to build for the given TARGET.TARGET_ARCH. 2164NXBDIRS+= \ 2165 bin/cat \ 2166 bin/chmod \ 2167 bin/cp \ 2168 ${_tcsh} \ 2169 bin/echo \ 2170 bin/expr \ 2171 bin/hostname \ 2172 bin/ln \ 2173 bin/ls \ 2174 bin/mkdir \ 2175 bin/mv \ 2176 bin/ps \ 2177 bin/realpath \ 2178 bin/rm \ 2179 bin/rmdir \ 2180 bin/sh \ 2181 bin/sleep \ 2182 sbin/md5 \ 2183 sbin/sysctl \ 2184 usr.bin/addr2line \ 2185 usr.bin/ar \ 2186 usr.bin/awk \ 2187 usr.bin/basename \ 2188 usr.bin/bmake \ 2189 usr.bin/bzip2 \ 2190 usr.bin/cmp \ 2191 usr.bin/diff \ 2192 usr.bin/dirname \ 2193 usr.bin/elfcopy \ 2194 usr.bin/env \ 2195 usr.bin/fetch \ 2196 usr.bin/find \ 2197 usr.bin/grep \ 2198 usr.bin/gzip \ 2199 usr.bin/id \ 2200 usr.bin/lex \ 2201 usr.bin/limits \ 2202 usr.bin/lorder \ 2203 usr.bin/mandoc \ 2204 usr.bin/mktemp \ 2205 usr.bin/mt \ 2206 usr.bin/nm \ 2207 usr.bin/patch \ 2208 usr.bin/readelf \ 2209 usr.bin/sed \ 2210 usr.bin/size \ 2211 usr.bin/sort \ 2212 usr.bin/strings \ 2213 usr.bin/tar \ 2214 usr.bin/touch \ 2215 usr.bin/tr \ 2216 usr.bin/true \ 2217 usr.bin/uniq \ 2218 usr.bin/unzip \ 2219 usr.bin/xargs \ 2220 usr.bin/xinstall \ 2221 usr.bin/xz \ 2222 usr.bin/yacc \ 2223 usr.sbin/chown 2224 2225SUBDIR_DEPEND_usr.bin/clang= lib/clang 2226.if ${MK_CLANG} != "no" 2227NXBDIRS+= lib/clang 2228NXBDIRS+= usr.bin/clang 2229.endif 2230.if ${MK_GCC} != "no" 2231NXBDIRS+= gnu/usr.bin/cc 2232.endif 2233.if ${MK_BINUTILS} != "no" 2234NXBDIRS+= gnu/usr.bin/binutils 2235.endif 2236# XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs 2237# to be evaluated after NXBDIRS is set. 2238.if make(install) && !empty(SUBDIR_OVERRIDE) 2239SUBDIR= ${SUBDIR_OVERRIDE} 2240.endif 2241 2242NXBMAKEARGS+= \ 2243 OBJTOP=${NXBOBJTOP:Q} \ 2244 OBJROOT=${NXBOBJROOT:Q} \ 2245 MAKEOBJDIRPREFIX= \ 2246 -DNO_SHARED \ 2247 -DNO_CPU_CFLAGS \ 2248 -DNO_PIC \ 2249 SSP_CFLAGS= \ 2250 MK_CLANG_EXTRAS=no \ 2251 MK_CLANG_FULL=no \ 2252 MK_CTF=no \ 2253 MK_DEBUG_FILES=no \ 2254 MK_GDB=no \ 2255 MK_HTML=no \ 2256 MK_LLDB=no \ 2257 MK_MAN=no \ 2258 MK_MAN_UTILS=yes \ 2259 MK_OFED=no \ 2260 MK_OPENSSH=no \ 2261 MK_PROFILE=no \ 2262 MK_SENDMAIL=no \ 2263 MK_SVNLITE=no \ 2264 MK_TESTS=no \ 2265 MK_WARNS=no \ 2266 MK_ZFS=no 2267 2268.if make(native-xtools*) && \ 2269 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH)) 2270.error Missing NXB_TARGET / NXB_TARGET_ARCH 2271.endif 2272# For 'toolchain' we want to produce native binaries that themselves generate 2273# native binaries. 2274NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \ 2275 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} 2276# For 'everything' we want to produce native binaries (hence -target to 2277# be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries. 2278# TARGET/TARGET_ARCH are still passed along from user. 2279# 2280# Use the toolchain we create as an external toolchain. 2281.if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*} 2282NXBMAKE+= XCC="${XCC}" \ 2283 XCXX="${XCXX}" \ 2284 XCPP="${XCPP}" 2285.else 2286NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \ 2287 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \ 2288 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp" 2289.endif 2290NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \ 2291 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \ 2292 TARGET_TRIPLE=${MACHINE_TRIPLE:Q} 2293# NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to 2294# invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS. 2295NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}' 2296# Need to avoid the -isystem logic when using clang as an external toolchain 2297# even if the TARGET being built for wants GCC. 2298NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}' 2299native-xtools: .PHONY 2300 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes 2301 # Build the bootstrap/host/cross tools that produce native binaries 2302 # Pass along MK_GCC=yes to ensure GCC-needed build tools are built. 2303 # We don't quite know what the NXB_TARGET wants so just build it. 2304 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes 2305 # Populate includes/libraries sysroot that produce native binaries. 2306 # This is split out from 'toolchain' above mostly so that target LLVM 2307 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without 2308 # polluting the cross-compiler build. The LLVM/GCC libs are skipped 2309 # here to avoid the problem but are kept in 'toolchain' so that 2310 # needed build tools are built. 2311 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no 2312 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no 2313 # Clean out improper TARGET=MACHINE files 2314 ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir 2315.if !defined(NO_OBJWALK) 2316 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj 2317.endif 2318 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything 2319 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR" 2320 2321native-xtools-install: .PHONY 2322 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr 2323 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 2324 -p ${NXBDESTDIR}/usr >/dev/null 2325 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 2326 -p ${NXBDESTDIR}/usr/include >/dev/null 2327 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \ 2328 DESTDIR=${NXBDESTDIR} \ 2329 -DNO_ROOT \ 2330 install 2331 2332# 2333# hierarchy - ensure that all the needed directories are present 2334# 2335hierarchy hier: .MAKE .PHONY 2336 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs 2337 2338# 2339# libraries - build all libraries, and install them under ${DESTDIR}. 2340# 2341# The list of libraries with dependents (${_prebuild_libs}) and their 2342# interdependencies (__L) are built automatically by the 2343# ${.CURDIR}/tools/make_libdeps.sh script. 2344# 2345libraries: .MAKE .PHONY 2346 ${_+_}cd ${.CURDIR}; \ 2347 ${MAKE} -f Makefile.inc1 _prereq_libs; \ 2348 ${MAKE} -f Makefile.inc1 _startup_libs; \ 2349 ${MAKE} -f Makefile.inc1 _prebuild_libs; \ 2350 ${MAKE} -f Makefile.inc1 _generic_libs 2351 2352# 2353# static libgcc.a prerequisite for shared libc 2354# 2355_prereq_libs= lib/libcompiler_rt 2356.if ${MK_SSP} != "no" 2357_prereq_libs+= gnu/lib/libssp/libssp_nonshared 2358.endif 2359 2360# These dependencies are not automatically generated: 2361# 2362# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before 2363# all shared libraries for ELF. 2364# 2365_startup_libs= gnu/lib/csu 2366_startup_libs+= lib/csu 2367_startup_libs+= lib/libcompiler_rt 2368_startup_libs+= lib/libc 2369_startup_libs+= lib/libc_nonshared 2370.if ${MK_LIBCPLUSPLUS} != "no" 2371_startup_libs+= lib/libcxxrt 2372.endif 2373 2374.if ${MK_LLVM_LIBUNWIND} != "no" 2375_prereq_libs+= lib/libgcc_eh lib/libgcc_s 2376_startup_libs+= lib/libgcc_eh lib/libgcc_s 2377 2378lib/libgcc_s__L: lib/libc__L 2379lib/libgcc_s__L: lib/libc_nonshared__L 2380.if ${MK_LIBCPLUSPLUS} != "no" 2381lib/libcxxrt__L: lib/libgcc_s__L 2382.endif 2383 2384.else # MK_LLVM_LIBUNWIND == no 2385 2386_prereq_libs+= gnu/lib/libgcc 2387_startup_libs+= gnu/lib/libgcc 2388 2389gnu/lib/libgcc__L: lib/libc__L 2390gnu/lib/libgcc__L: lib/libc_nonshared__L 2391.if ${MK_LIBCPLUSPLUS} != "no" 2392lib/libcxxrt__L: gnu/lib/libgcc__L 2393.endif 2394.endif 2395 2396_prebuild_libs= ${_kerberos5_lib_libasn1} \ 2397 ${_kerberos5_lib_libhdb} \ 2398 ${_kerberos5_lib_libheimbase} \ 2399 ${_kerberos5_lib_libheimntlm} \ 2400 ${_libsqlite3} \ 2401 ${_kerberos5_lib_libheimipcc} \ 2402 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ 2403 ${_kerberos5_lib_libroken} \ 2404 ${_kerberos5_lib_libwind} \ 2405 lib/libbz2 ${_libcom_err} lib/libcrypt \ 2406 lib/libelf lib/libexpat \ 2407 lib/libfigpar \ 2408 ${_lib_libgssapi} \ 2409 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \ 2410 ${_lib_casper} \ 2411 lib/ncurses/ncurses lib/ncurses/ncursesw \ 2412 lib/libopie lib/libpam/libpam ${_lib_libthr} \ 2413 ${_lib_libradius} lib/libsbuf lib/libtacplus \ 2414 lib/libgeom \ 2415 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ 2416 ${_cddl_lib_libuutil} \ 2417 ${_cddl_lib_libavl} \ 2418 ${_cddl_lib_libzfs_core} \ 2419 ${_cddl_lib_libctf} \ 2420 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \ 2421 ${_secure_lib_libcrypto} ${_lib_libldns} \ 2422 ${_secure_lib_libssh} ${_secure_lib_libssl} 2423 2424.if ${MK_GNUCXX} != "no" 2425_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++ 2426gnu/lib/libstdc++__L: lib/msun__L 2427gnu/lib/libsupc++__L: gnu/lib/libstdc++__L 2428.endif 2429 2430.if ${MK_DIALOG} != "no" 2431_prebuild_libs+= gnu/lib/libdialog 2432gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L 2433.endif 2434 2435.if ${MK_LIBCPLUSPLUS} != "no" 2436_prebuild_libs+= lib/libc++ 2437.endif 2438 2439lib/libgeom__L: lib/libexpat__L 2440lib/libkvm__L: lib/libelf__L 2441 2442.if ${MK_LIBTHR} != "no" 2443_lib_libthr= lib/libthr 2444.endif 2445 2446.if ${MK_RADIUS_SUPPORT} != "no" 2447_lib_libradius= lib/libradius 2448.endif 2449 2450.if ${MK_OFED} != "no" 2451# 2452# The OFED libraries are built in four steps 2453# as reflected below, due to interdependencies. 2454# 2455# NOTE: Depending on contrib/ofed/include is only needed for 2456# the lib32 compat build. 2457# 2458_ofed_lib= \ 2459contrib/ofed/include \ 2460contrib/ofed/usr.lib/0 \ 2461contrib/ofed/usr.lib/1 \ 2462contrib/ofed/usr.lib/2 \ 2463contrib/ofed/usr.lib/3 2464 2465contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L 2466contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L 2467contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L 2468contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L 2469.endif 2470 2471.if ${MK_CASPER} != "no" 2472_lib_casper= lib/libcasper 2473.endif 2474 2475lib/libpjdlog__L: lib/libutil__L 2476lib/libcasper__L: lib/libnv__L 2477lib/liblzma__L: lib/libthr__L 2478 2479_generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib} 2480.if ${MK_IPFILTER} != "no" 2481_generic_libs+= sbin/ipf/libipf 2482.endif 2483.for _DIR in ${LOCAL_LIB_DIRS} 2484.if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)) 2485_generic_libs+= ${_DIR} 2486.endif 2487.endfor 2488 2489lib/libopie__L lib/libtacplus__L: lib/libmd__L 2490 2491.if ${MK_CDDL} != "no" 2492_cddl_lib_libumem= cddl/lib/libumem 2493_cddl_lib_libnvpair= cddl/lib/libnvpair 2494_cddl_lib_libavl= cddl/lib/libavl 2495_cddl_lib_libuutil= cddl/lib/libuutil 2496.if ${MK_ZFS} != "no" 2497_cddl_lib_libzfs_core= cddl/lib/libzfs_core 2498cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L 2499.endif 2500_cddl_lib_libctf= cddl/lib/libctf 2501_cddl_lib= cddl/lib 2502cddl/lib/libctf__L: lib/libz__L 2503.endif 2504# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built 2505# on select architectures though (see cddl/lib/Makefile) 2506.if ${MACHINE_CPUARCH} != "sparc64" 2507_prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db 2508lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L 2509lib/libproc__L: lib/libprocstat__L 2510lib/librtld_db__L: lib/libprocstat__L 2511.endif 2512 2513.if ${MK_CRYPT} != "no" 2514.if ${MK_OPENSSL} != "no" 2515_secure_lib_libcrypto= secure/lib/libcrypto 2516_secure_lib_libssl= secure/lib/libssl 2517lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L 2518.if ${MK_LDNS} != "no" 2519_lib_libldns= lib/libldns 2520lib/libldns__L: secure/lib/libcrypto__L 2521.endif 2522.if ${MK_OPENSSH} != "no" 2523_secure_lib_libssh= secure/lib/libssh 2524secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L 2525.if ${MK_LDNS} != "no" 2526secure/lib/libssh__L: lib/libldns__L 2527.endif 2528.if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no" 2529secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \ 2530 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \ 2531 lib/libmd__L kerberos5/lib/libroken__L 2532.endif 2533.endif 2534.endif 2535_secure_lib= secure/lib 2536.endif 2537 2538.if ${MK_KERBEROS} != "no" 2539kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L 2540kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 2541 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \ 2542 kerberos5/lib/libwind__L lib/libsqlite3__L 2543kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \ 2544 kerberos5/lib/libroken__L lib/libcom_err__L 2545kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 2546 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L 2547kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ 2548 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \ 2549 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \ 2550 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L 2551kerberos5/lib/libroken__L: lib/libcrypt__L 2552kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L 2553kerberos5/lib/libheimbase__L: lib/libthr__L 2554kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L 2555.endif 2556 2557lib/libsqlite3__L: lib/libthr__L 2558 2559.if ${MK_GSSAPI} != "no" 2560_lib_libgssapi= lib/libgssapi 2561.endif 2562 2563.if ${MK_KERBEROS} != "no" 2564_kerberos5_lib= kerberos5/lib 2565_kerberos5_lib_libasn1= kerberos5/lib/libasn1 2566_kerberos5_lib_libhdb= kerberos5/lib/libhdb 2567_kerberos5_lib_libheimbase= kerberos5/lib/libheimbase 2568_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5 2569_kerberos5_lib_libhx509= kerberos5/lib/libhx509 2570_kerberos5_lib_libroken= kerberos5/lib/libroken 2571_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm 2572_libsqlite3= lib/libsqlite3 2573_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc 2574_kerberos5_lib_libwind= kerberos5/lib/libwind 2575_libcom_err= lib/libcom_err 2576.endif 2577 2578.if ${MK_NIS} != "no" 2579_lib_libypclnt= lib/libypclnt 2580.endif 2581 2582.if ${MK_OPENSSL} == "no" 2583lib/libradius__L: lib/libmd__L 2584.endif 2585 2586lib/libproc__L: \ 2587 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L 2588.if ${MK_CXX} != "no" 2589.if ${MK_LIBCPLUSPLUS} != "no" 2590lib/libproc__L: lib/libcxxrt__L 2591.else # This implies MK_GNUCXX != "no"; see lib/libproc 2592lib/libproc__L: gnu/lib/libsupc++__L 2593.endif 2594.endif 2595 2596.for _lib in ${_prereq_libs} 2597${_lib}__PL: .PHONY .MAKE 2598.if exists(${.CURDIR}/${_lib}) 2599 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ 2600 cd ${.CURDIR}/${_lib}; \ 2601 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ 2602 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ 2603 DIRPRFX=${_lib}/ all; \ 2604 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ 2605 DIRPRFX=${_lib}/ install 2606.endif 2607.endfor 2608 2609.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs} 2610${_lib}__L: .PHONY .MAKE 2611.if exists(${.CURDIR}/${_lib}) 2612 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ 2613 cd ${.CURDIR}/${_lib}; \ 2614 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ 2615 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \ 2616 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install 2617.endif 2618.endfor 2619 2620_prereq_libs: ${_prereq_libs:S/$/__PL/} 2621_startup_libs: ${_startup_libs:S/$/__L/} 2622_prebuild_libs: ${_prebuild_libs:S/$/__L/} 2623_generic_libs: ${_generic_libs:S/$/__L/} 2624 2625# Enable SUBDIR_PARALLEL when not calling 'make all', unless called from 2626# 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely 2627# that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE 2628# or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in 2629# parallel. This is safe for the world stage of buildworld though since it has 2630# already built libraries in a proper order and installed includes into 2631# WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to 2632# avoid trashing a system if it crashes mid-install. 2633.if !make(all) || defined(_PARALLEL_SUBDIR_OK) 2634SUBDIR_PARALLEL= 2635.endif 2636 2637.include <bsd.subdir.mk> 2638 2639.if make(check-old) || make(check-old-dirs) || \ 2640 make(check-old-files) || make(check-old-libs) || \ 2641 make(delete-old) || make(delete-old-dirs) || \ 2642 make(delete-old-files) || make(delete-old-libs) 2643 2644# 2645# check for / delete old files section 2646# 2647 2648.include "ObsoleteFiles.inc" 2649 2650OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \ 2651else you can not start such an application. Consult UPDATING for more \ 2652information regarding how to cope with the removal/revision bump of a \ 2653specific library." 2654 2655.if !defined(BATCH_DELETE_OLD_FILES) 2656RM_I=-i 2657.else 2658RM_I=-v 2659.endif 2660 2661delete-old-files: .PHONY 2662 @echo ">>> Removing old files (only deletes safe to delete libs)" 2663# Ask for every old file if the user really wants to remove it. 2664# It's annoying, but better safe than sorry. 2665# NB: We cannot pass the list of OLD_FILES as a parameter because the 2666# argument list will get too long. Using .for/.endfor make "loops" will make 2667# the Makefile parser segfault. 2668 @exec 3<&0; \ 2669 cd ${.CURDIR}; \ 2670 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2671 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ 2672 while read file; do \ 2673 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 2674 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 2675 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ 2676 fi; \ 2677 for ext in debug symbols; do \ 2678 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \ 2679 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 2680 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \ 2681 <&3; \ 2682 fi; \ 2683 done; \ 2684 done 2685# Remove catpages without corresponding manpages. 2686 @exec 3<&0; \ 2687 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ 2688 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 2689 while read catpage; do \ 2690 read manpage; \ 2691 if [ ! -e "$${manpage}" ]; then \ 2692 rm ${RM_I} $${catpage} <&3; \ 2693 fi; \ 2694 done 2695 @echo ">>> Old files removed" 2696 2697check-old-files: .PHONY 2698 @echo ">>> Checking for old files" 2699 @cd ${.CURDIR}; \ 2700 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2701 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ 2702 while read file; do \ 2703 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 2704 echo "${DESTDIR}/$${file}"; \ 2705 fi; \ 2706 for ext in debug symbols; do \ 2707 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 2708 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ 2709 fi; \ 2710 done; \ 2711 done 2712# Check for catpages without corresponding manpages. 2713 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ 2714 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 2715 while read catpage; do \ 2716 read manpage; \ 2717 if [ ! -e "$${manpage}" ]; then \ 2718 echo $${catpage}; \ 2719 fi; \ 2720 done 2721 2722delete-old-libs: .PHONY 2723 @echo ">>> Removing old libraries" 2724 @echo "${OLD_LIBS_MESSAGE}" | fmt 2725 @exec 3<&0; \ 2726 cd ${.CURDIR}; \ 2727 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2728 -V OLD_LIBS | xargs -n1 | \ 2729 while read file; do \ 2730 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 2731 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 2732 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ 2733 fi; \ 2734 for ext in debug symbols; do \ 2735 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \ 2736 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 2737 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \ 2738 <&3; \ 2739 fi; \ 2740 done; \ 2741 done 2742 @echo ">>> Old libraries removed" 2743 2744check-old-libs: .PHONY 2745 @echo ">>> Checking for old libraries" 2746 @cd ${.CURDIR}; \ 2747 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2748 -V OLD_LIBS | xargs -n1 | \ 2749 while read file; do \ 2750 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 2751 echo "${DESTDIR}/$${file}"; \ 2752 fi; \ 2753 for ext in debug symbols; do \ 2754 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \ 2755 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ 2756 fi; \ 2757 done; \ 2758 done 2759 2760delete-old-dirs: .PHONY 2761 @echo ">>> Removing old directories" 2762 @cd ${.CURDIR}; \ 2763 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2764 -V OLD_DIRS | xargs -n1 | sort -r | \ 2765 while read dir; do \ 2766 if [ -d "${DESTDIR}/$${dir}" ]; then \ 2767 rmdir -v "${DESTDIR}/$${dir}" || true; \ 2768 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 2769 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 2770 fi; \ 2771 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 2772 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \ 2773 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 2774 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \ 2775 fi; \ 2776 done 2777 @echo ">>> Old directories removed" 2778 2779check-old-dirs: .PHONY 2780 @echo ">>> Checking for old directories" 2781 @cd ${.CURDIR}; \ 2782 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ 2783 -V OLD_DIRS | xargs -n1 | \ 2784 while read dir; do \ 2785 if [ -d "${DESTDIR}/$${dir}" ]; then \ 2786 echo "${DESTDIR}/$${dir}"; \ 2787 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 2788 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 2789 fi; \ 2790 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 2791 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \ 2792 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \ 2793 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \ 2794 fi; \ 2795 done 2796 2797delete-old: delete-old-files delete-old-dirs .PHONY 2798 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'." 2799 2800check-old: check-old-files check-old-libs check-old-dirs .PHONY 2801 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'." 2802 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'." 2803 2804.endif 2805 2806# 2807# showconfig - show build configuration. 2808# 2809showconfig: .PHONY 2810 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \ 2811 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u 2812 2813.if !empty(KRNLOBJDIR) && !empty(KERNCONF) 2814DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ 2815 2816.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE) 2817.if exists(${KERNCONFDIR}/${KERNCONF}) 2818FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \ 2819 '${KERNCONFDIR}/${KERNCONF}' ; echo 2820.endif 2821.endif 2822 2823.endif 2824 2825.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH}) 2826DTBOUTPUTPATH= ${.CURDIR} 2827.endif 2828 2829# 2830# Build 'standalone' Device Tree Blob 2831# 2832builddtb: .PHONY 2833 @PATH=${TMPPATH} MACHINE=${TARGET} \ 2834 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \ 2835 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH} 2836 2837############### 2838 2839# cleanworld 2840# In the following, the first 'rm' in a series will usually remove all 2841# files and directories. If it does not, then there are probably some 2842# files with file flags set, so this unsets them and tries the 'rm' a 2843# second time. There are situations where this target will be cleaning 2844# some directories via more than one method, but that duplication is 2845# needed to correctly handle all the possible situations. Removing all 2846# files without file flags set in the first 'rm' instance saves time, 2847# because 'chflags' will need to operate on fewer files afterwards. 2848# 2849# It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 2850# created by bsd.obj.mk, except that we don't want to .include that file 2851# in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes 2852# since it is not possible for files to land in the wrong place. 2853# 2854.if make(cleanworld) 2855BW_CANONICALOBJDIR:=${OBJTOP}/ 2856.elif make(cleanuniverse) 2857BW_CANONICALOBJDIR:=${OBJROOT} 2858.if ${MK_UNIFIED_OBJDIR} == "no" 2859.error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled. 2860.endif 2861.endif 2862cleanworld cleanuniverse: .PHONY 2863.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \ 2864 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA} 2865 -rm -rf ${BW_CANONICALOBJDIR}* 2866 -chflags -R 0 ${BW_CANONICALOBJDIR} 2867 rm -rf ${BW_CANONICALOBJDIR}* 2868.endif 2869.if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \ 2870 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA}) 2871.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 2872 # To be safe in this case, fall back to a 'make cleandir' 2873 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir 2874.endif 2875.endif 2876 2877.if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH} 2878XDEV_CPUTYPE?=${CPUTYPE} 2879.else 2880XDEV_CPUTYPE?=${TARGET_CPUTYPE} 2881.endif 2882 2883NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \ 2884 MK_MAN=no MK_NLS=no MK_PROFILE=no \ 2885 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \ 2886 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 2887 CPUTYPE=${XDEV_CPUTYPE} 2888 2889XDDIR=${TARGET_ARCH}-freebsd 2890XDTP?=/usr/${XDDIR} 2891.if ${XDTP:N/*} 2892.error XDTP variable should be an absolute path 2893.endif 2894 2895CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/ 2896CDBOBJTOP= ${CDBOBJROOT}${XDDIR} 2897CDBENV= \ 2898 INSTALL="sh ${.CURDIR}/tools/install.sh" 2899CDENV= ${CDBENV} \ 2900 TOOLS_PREFIX=${XDTP} 2901CDMAKEARGS= \ 2902 OBJTOP=${CDBOBJTOP:Q} \ 2903 OBJROOT=${CDBOBJROOT:Q} 2904CD2MAKEARGS= ${CDMAKEARGS} 2905 2906.if ${WANT_COMPILER_TYPE} == gcc || \ 2907 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 2908# GCC requires -isystem and -L when using a cross-compiler. --sysroot 2909# won't set header path and -L is used to ensure the base library path 2910# is added before the port PREFIX library path. 2911CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib 2912# GCC requires -B to find /usr/lib/crti.o when using a cross-compiler 2913# combined with --sysroot. 2914CD2CFLAGS+= -B${XDDESTDIR}/usr/lib 2915# Force using libc++ for external GCC. 2916.if defined(X_COMPILER_TYPE) && \ 2917 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 2918CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \ 2919 -nostdinc++ 2920.endif 2921.endif 2922CD2CFLAGS+= --sysroot=${XDDESTDIR}/ 2923CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \ 2924 CPP="${CPP} ${CD2CFLAGS}" \ 2925 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} 2926 2927CDTMP= ${OBJTOP}/${XDDIR}/tmp 2928CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN} 2929CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \ 2930 ${MAKE} ${CD2MAKEARGS} ${NOFUN} 2931.if ${MK_META_MODE} != "no" 2932# Don't rebuild build-tools targets during normal build. 2933CD2MAKE+= BUILD_TOOLS_META=.NOMETA 2934.endif 2935XDDESTDIR=${DESTDIR}${XDTP} 2936 2937.ORDER: xdev-build xdev-install xdev-links 2938xdev: xdev-build xdev-install .PHONY 2939 2940.ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools 2941xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY 2942 2943_xb-worldtmp: .PHONY 2944 mkdir -p ${CDTMP}/usr 2945 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 2946 -p ${CDTMP}/usr >/dev/null 2947 2948_xb-bootstrap-tools: .PHONY 2949.for _tool in \ 2950 ${_clang_tblgen} \ 2951 ${_gperf} \ 2952 ${_yacc} 2953 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ 2954 cd ${.CURDIR}/${_tool}; \ 2955 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ 2956 ${CDMAKE} DIRPRFX=${_tool}/ all; \ 2957 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install 2958.endfor 2959 2960_xb-build-tools: .PHONY 2961 ${_+_}@cd ${.CURDIR}; \ 2962 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools 2963 2964XDEVDIRS= \ 2965 ${_clang_libs} \ 2966 ${_lld} \ 2967 ${_binutils} \ 2968 ${_elftctools} \ 2969 usr.bin/ar \ 2970 ${_clang} \ 2971 ${_gcc} 2972 2973_xb-cross-tools: .PHONY 2974.for _tool in ${XDEVDIRS} 2975 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \ 2976 cd ${.CURDIR}/${_tool}; \ 2977 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ 2978 ${CDMAKE} DIRPRFX=${_tool}/ all 2979.endfor 2980 2981_xi-mtree: .PHONY 2982 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}" 2983 mkdir -p ${XDDESTDIR} 2984 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ 2985 -p ${XDDESTDIR} >/dev/null 2986 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 2987 -p ${XDDESTDIR}/usr >/dev/null 2988 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 2989 -p ${XDDESTDIR}/usr/include >/dev/null 2990.if defined(LIBCOMPAT) 2991 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 2992 -p ${XDDESTDIR}/usr >/dev/null 2993.endif 2994.if ${MK_TESTS} != "no" 2995 mkdir -p ${XDDESTDIR}${TESTSBASE} 2996 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ 2997 -p ${XDDESTDIR}${TESTSBASE} >/dev/null 2998.endif 2999 3000.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries 3001xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY 3002 3003_xi-cross-tools: .PHONY 3004 @echo "_xi-cross-tools" 3005.for _tool in ${XDEVDIRS} 3006 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ 3007 cd ${.CURDIR}/${_tool}; \ 3008 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} 3009.endfor 3010 3011_xi-includes: .PHONY 3012.if !defined(NO_OBJWALK) 3013 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \ 3014 DESTDIR=${XDDESTDIR} 3015.endif 3016 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \ 3017 DESTDIR=${XDDESTDIR} 3018 3019_xi-libraries: .PHONY 3020 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \ 3021 DESTDIR=${XDDESTDIR} 3022 3023xdev-links: .PHONY 3024 ${_+_}cd ${XDDESTDIR}/usr/bin; \ 3025 mkdir -p ../../../../usr/bin; \ 3026 for i in *; do \ 3027 ln -sf ../../${XDTP}/usr/bin/$$i \ 3028 ../../../../usr/bin/${XDDIR}-$$i; \ 3029 ln -sf ../../${XDTP}/usr/bin/$$i \ 3030 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \ 3031 done 3032