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