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