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