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