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