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