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