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