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