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