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