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