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