1# 2# $FreeBSD$ 3# 4# The common user-driven targets are (for a complete list, see build(7)): 5# 6# universe - *Really* build *everything* (buildworld and 7# all kernels on all architectures). Define 8# MAKE_JUST_KERNELS or WITHOUT_WORLDS to only build kernels, 9# MAKE_JUST_WORLDS or WITHOUT_KERNELS to only build userland. 10# tinderbox - Same as universe, but presents a list of failed build 11# targets and exits with an error if there were any. 12# worlds - Same as universe, except just makes the worlds. 13# kernels - Same as universe, except just makes the kernels. 14# buildworld - Rebuild *everything*, including glue to help do 15# upgrades. 16# installworld - Install everything built by "buildworld". 17# world - buildworld + installworld, no kernel. 18# buildkernel - Rebuild the kernel and the kernel-modules. 19# installkernel - Install the kernel and the kernel-modules. 20# installkernel.debug 21# reinstallkernel - Reinstall the kernel and the kernel-modules. 22# reinstallkernel.debug 23# kernel - buildkernel + installkernel. 24# kernel-toolchain - Builds the subset of world necessary to build a kernel 25# kernel-toolchains - Build kernel-toolchain for all universe targets. 26# doxygen - Build API documentation of the kernel, needs doxygen. 27# checkworld - Run test suite on installed world. 28# check-old - List obsolete directories/files/libraries. 29# check-old-dirs - List obsolete directories. 30# check-old-files - List obsolete files. 31# check-old-libs - List obsolete libraries. 32# delete-old - Delete obsolete directories/files. 33# delete-old-dirs - Delete obsolete directories. 34# delete-old-files - Delete obsolete files. 35# delete-old-libs - Delete obsolete libraries. 36# list-old-dirs - Raw list of possibly obsolete directories. 37# list-old-files - Raw list of possibly obsolete files. 38# list-old-libs - Raw list of possibly obsolete libraries. 39# targets - Print a list of supported TARGET/TARGET_ARCH pairs 40# for world and kernel targets. 41# toolchains - Build a toolchain for all world and kernel targets. 42# makeman - Regenerate src.conf(5) 43# sysent - (Re)build syscall entries from syscalls.master. 44# xdev - xdev-build + xdev-install for the architecture 45# specified with TARGET and TARGET_ARCH. 46# xdev-build - Build cross-development tools. 47# xdev-install - Install cross-development tools. 48# xdev-links - Create traditional links in /usr/bin for cc, etc 49# native-xtools - Create host binaries that produce target objects 50# for use in qemu user-mode jails. TARGET and 51# TARGET_ARCH should be defined. 52# native-xtools-install 53# - Install the files to the given DESTDIR/NXTP where 54# NXTP defaults to /nxb-bin. 55# 56# This makefile is simple by design. The FreeBSD make automatically reads 57# the /usr/share/mk/sys.mk unless the -m argument is specified on the 58# command line. By keeping this makefile simple, it doesn't matter too 59# much how different the installed mk files are from those in the source 60# tree. This makefile executes a child make process, forcing it to use 61# the mk files from the source tree which are supposed to DTRT. 62# 63# Most of the user-driven targets (as listed above) are implemented in 64# Makefile.inc1. The exceptions are universe, tinderbox and targets. 65# 66# If you want to build your system from source, be sure that /usr/obj has 67# at least 6 GB of disk space available. A complete 'universe' build of 68# r340283 (2018-11) required 167 GB of space. ZFS lz4 compression 69# achieved a 2.18x ratio, reducing actual space to 81 GB. 70# 71# For individuals wanting to build from the sources currently on their 72# system, the simple instructions are: 73# 74# 1. `cd /usr/src' (or to the directory containing your source tree). 75# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 76# 3. `make world' 77# 78# For individuals wanting to upgrade their sources (even if only a 79# delta of a few days): 80# 81# 1. `cd /usr/src' (or to the directory containing your source tree). 82# 2. `make buildworld' 83# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 84# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 85# [steps 3. & 4. can be combined by using the "kernel" target] 86# 5. `reboot' (in single user mode: boot -s from the loader prompt). 87# 6. `mergemaster -p' 88# 7. `make installworld' 89# 8. `mergemaster' (you may wish to use -i, along with -U or -F). 90# 9. `make delete-old' 91# 10. `reboot' 92# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 93# 94# For individuals wanting to build from source with GCC from ports, first 95# install the appropriate GCC cross toolchain package: 96# `pkg install ${TARGET_ARCH}-gccN` 97# 98# Once you have installed the necessary cross toolchain, simply pass 99# CROSS_TOOLCHAIN=${TARGET_ARCH}-gccN while building with the above steps, 100# e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc6`. 101# 102# The ${TARGET_ARCH}-gccN packages are provided as flavors of the 103# devel/freebsd-gccN ports. 104# 105# See src/UPDATING `COMMON ITEMS' for more complete information. 106# 107# If TARGET=machine (e.g. powerpc, arm64, ...) is specified you can 108# cross build world for other machine types using the buildworld target, 109# and once the world is built you can cross build a kernel using the 110# buildkernel target. 111# 112# Define the user-driven targets. These are listed here in alphabetical 113# order, but that's not important. 114# 115# Targets that begin with underscore are internal targets intended for 116# developer convenience only. They are intentionally not documented and 117# completely subject to change without notice. 118# 119# For more information, see the build(7) manual page. 120# 121 122.if defined(UNIVERSE_TARGET) || defined(MAKE_JUST_WORLDS) || defined(WITHOUT_KERNELS) 123__DO_KERNELS=no 124.endif 125.if defined(MAKE_JUST_KERNELS) || defined(WITHOUT_WORLDS) 126__DO_WORLDS=no 127.endif 128__DO_WORLDS?=yes 129__DO_KERNELS?=yes 130 131# This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION 132# can be cached for sub-makes. We can't do this while still running on the 133# old fmake from FreeBSD 9.x or older, so avoid including it then to avoid 134# heartburn upgrading from older systems. The need for CC is done with new 135# make later in the build, and caching COMPILER_TYPE/VERSION is only an 136# optimization. Also sinclude it to be friendlier to foreign OS hosted builds. 137.if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR) 138.sinclude <bsd.compiler.mk> 139.endif 140 141# Note: we use this awkward construct to be compatible with FreeBSD's 142# old make used in 10.0 and 9.2 and earlier. 143.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \ 144 !make(showconfig) && !make(print-dir) 145# targets/Makefile plays the role of top-level 146.include "targets/Makefile" 147.else 148 149TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 150 check check-old check-old-dirs check-old-files check-old-libs \ 151 checkdpadd checkworld clean cleandepend cleandir cleankernel \ 152 cleanworld cleanuniverse \ 153 delete-old delete-old-dirs delete-old-files delete-old-libs \ 154 depend distribute distributekernel distributekernel.debug \ 155 distributeworld distrib-dirs distribution doxygen \ 156 everything hier hierarchy install installcheck installkernel \ 157 installkernel.debug packagekernel packageworld \ 158 reinstallkernel reinstallkernel.debug \ 159 installworld kernel-toolchain libraries maninstall \ 160 list-old-dirs list-old-files list-old-libs \ 161 obj objlink showconfig tags toolchain \ 162 makeman sysent \ 163 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 164 _build-tools _build-metadata _cross-tools _includes _libraries \ 165 build32 distribute32 install32 \ 166 builddtb xdev xdev-build xdev-install \ 167 xdev-links native-xtools native-xtools-install stageworld stagekernel \ 168 stage-packages stage-packages-kernel stage-packages-world \ 169 create-packages-world create-packages-kernel create-packages \ 170 update-packages packages installconfig real-packages real-update-packages \ 171 sign-packages package-pkg print-dir test-system-compiler test-system-linker \ 172 test-includes 173 174# These targets require a TARGET and TARGET_ARCH be defined. 175XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \ 176 xdev-links 177 178# XXX: r156740: This can't work since bsd.subdir.mk is not included ever. 179# It will only work for SUBDIR_TARGETS in make.conf. 180TGTS+= ${SUBDIR_TARGETS} 181 182BITGTS= files includes 183BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 184TGTS+= ${BITGTS} 185 186# Only some targets are allowed to use meta mode. Others get it 187# disabled. In some cases, such as 'install', meta mode can be dangerous 188# as a cookie may be used to prevent redundant installations (such as 189# for WORLDTMP staging). For DESTDIR=/ we always want to install though. 190# For other cases, such as delete-old-libs, meta mode may break 191# the interactive tty prompt. The safest route is to just whitelist 192# the ones that benefit from it. 193META_TGT_WHITELIST+= \ 194 _* build32 buildfiles buildincludes buildkernel \ 195 buildworld everything kernel-toolchain kernel-toolchains kernel \ 196 kernels libraries native-xtools showconfig test-includes \ 197 test-system-compiler test-system-linker tinderbox toolchain \ 198 toolchains universe universe-toolchain world worlds xdev xdev-build 199 200.ORDER: buildworld installworld 201.ORDER: buildworld distrib-dirs 202.ORDER: buildworld distribution 203.ORDER: buildworld distribute 204.ORDER: buildworld distributeworld 205.ORDER: buildworld buildkernel 206.ORDER: distrib-dirs distribute 207.ORDER: distrib-dirs distributeworld 208.ORDER: distrib-dirs installworld 209.ORDER: distribution distribute 210.ORDER: distributeworld distribute 211.ORDER: distributeworld distribution 212.ORDER: installworld distribute 213.ORDER: installworld distribution 214.ORDER: installworld installkernel 215.ORDER: buildkernel installkernel 216.ORDER: buildkernel installkernel.debug 217.ORDER: buildkernel reinstallkernel 218.ORDER: buildkernel reinstallkernel.debug 219 220PATH= /sbin:/bin:/usr/sbin:/usr/bin 221MAKEOBJDIRPREFIX?= /usr/obj 222_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \ 223 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 224 SRCCONF=${SRCCONF} SRC_ENV_CONF= \ 225 -f /dev/null -V MAKEOBJDIRPREFIX dummy 226.if !empty(_MAKEOBJDIRPREFIX) || !empty(.MAKEOVERRIDES:MMAKEOBJDIRPREFIX) 227.error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\ 228 not as a global (in make.conf(5) or src.conf(5)) or command-line variable. 229.endif 230 231# We often need to use the tree's version of make to build it. 232# Choices add to complexity though. 233# We cannot blindly use a make which may not be the one we want 234# so be explicit - until all choice is removed. 235WANT_MAKE= bmake 236.if !empty(.MAKE.MODE:Mmeta) 237# 20160604 - support missing-meta,missing-filemon and performance improvements 238WANT_MAKE_VERSION= 20160604 239.else 240# 20160220 - support .dinclude for FAST_DEPEND. 241WANT_MAKE_VERSION= 20160220 242.endif 243MYMAKE= ${OBJROOT}make.${MACHINE}/${WANT_MAKE} 244.if defined(.PARSEDIR) 245HAVE_MAKE= bmake 246.else 247HAVE_MAKE= fmake 248.endif 249.if defined(ALWAYS_BOOTSTRAP_MAKE) || \ 250 ${HAVE_MAKE} != ${WANT_MAKE} || \ 251 (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION}) 252NEED_MAKE_UPGRADE= t 253.endif 254.if exists(${MYMAKE}) 255SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk 256.elif defined(NEED_MAKE_UPGRADE) 257# It may not exist yet but we may cause it to. 258# In the case of fmake, upgrade_checks may cause a newer version to be built. 259SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \ 260 -m ${.CURDIR}/share/mk 261.else 262SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk 263.endif 264 265_MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \ 266 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS} 267 268.if defined(MK_META_MODE) && ${MK_META_MODE} == "yes" 269# Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST 270# above. If overridden as a make argument then don't bother trying to 271# disable it. 272.if empty(.MAKEOVERRIDES:MMK_META_MODE) 273.for _tgt in ${META_TGT_WHITELIST} 274.if make(${_tgt}) 275_CAN_USE_META_MODE?= yes 276.endif 277.endfor 278.if !defined(_CAN_USE_META_MODE) 279_MAKE+= MK_META_MODE=no 280MK_META_MODE= no 281.if defined(.PARSEDIR) 282.unexport META_MODE 283.endif 284.endif # !defined(_CAN_USE_META_MODE) 285.endif # empty(.MAKEOVERRIDES:MMK_META_MODE) 286 287.if ${MK_META_MODE} == "yes" 288.if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig) 289# Require filemon be loaded to provide a working incremental build 290.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \ 291 ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \ 292 ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error. 293.endif # !exists(/dev/filemon) && !defined(NO_FILEMON) 294.endif # ${MK_META_MODE} == yes 295.endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes 296 297# Guess target architecture from target type, and vice versa, based on 298# historic FreeBSD practice of tending to have TARGET == TARGET_ARCH 299# expanding to TARGET == TARGET_CPUARCH in recent times, with known 300# exceptions. 301.if !defined(TARGET_ARCH) && defined(TARGET) 302# T->TA mapping is usually TARGET with arm64 the odd man out 303_TARGET_ARCH= ${TARGET:S/arm64/aarch64/:S/riscv/riscv64/:S/arm/armv7/} 304.elif !defined(TARGET) && defined(TARGET_ARCH) && \ 305 ${TARGET_ARCH} != ${MACHINE_ARCH} 306# TA->T mapping is accidentally CPUARCH with aarch64 the odd man out 307_TARGET= ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/} 308.endif 309.if defined(TARGET) && !defined(_TARGET) 310_TARGET=${TARGET} 311.endif 312.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH) 313_TARGET_ARCH=${TARGET_ARCH} 314.endif 315# for historical compatibility for xdev targets 316.if defined(XDEV) 317_TARGET= ${XDEV} 318.endif 319.if defined(XDEV_ARCH) 320_TARGET_ARCH= ${XDEV_ARCH} 321.endif 322# Some targets require a set TARGET/TARGET_ARCH, check before the default 323# MACHINE and after the compatibility handling. 324.if !defined(_TARGET) || !defined(_TARGET_ARCH) 325${XTGTS}: _assert_target 326.endif 327# Otherwise, default to current machine type and architecture. 328_TARGET?= ${MACHINE} 329_TARGET_ARCH?= ${MACHINE_ARCH} 330 331.if make(native-xtools*) 332NXB_TARGET:= ${_TARGET} 333NXB_TARGET_ARCH:= ${_TARGET_ARCH} 334_TARGET= ${MACHINE} 335_TARGET_ARCH= ${MACHINE_ARCH} 336_MAKE+= NXB_TARGET=${NXB_TARGET} \ 337 NXB_TARGET_ARCH=${NXB_TARGET_ARCH} 338.endif 339 340.if make(print-dir) 341.SILENT: 342.endif 343 344_assert_target: .PHONY .MAKE 345.for _tgt in ${XTGTS} 346.if make(${_tgt}) 347 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target" 348 @false 349.endif 350.endfor 351 352# 353# Make sure we have an up-to-date make(1). Only world and buildworld 354# should do this as those are the initial targets used for upgrades. 355# The user can define ALWAYS_CHECK_MAKE to have this check performed 356# for all targets. 357# 358.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR) 359${TGTS}: upgrade_checks 360.else 361buildworld: upgrade_checks 362.endif 363 364# 365# Handle the user-driven targets, using the source relative mk files. 366# 367 368tinderbox toolchains kernel-toolchains: .MAKE 369${TGTS}: .PHONY .MAKE 370 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET} 371 372# The historic default "all" target creates files which may cause stale 373# or (in the cross build case) unlinkable results. Fail with an error 374# when no target is given. The users can explicitly specify "all" 375# if they want the historic behavior. 376.MAIN: _guard 377 378_guard: .PHONY 379 @echo 380 @echo "Explicit target required. Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted. See build(7)." 381 @echo 382 @false 383 384STARTTIME!= LC_ALL=C date 385CHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo 386.if !empty(CHECK_TIME) 387.error check your date/time: ${STARTTIME} 388.endif 389 390.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 391# 392# world 393# 394# Attempt to rebuild and reinstall everything. This target is not to be 395# used for upgrading an existing FreeBSD system, because the kernel is 396# not included. One can argue that this target doesn't build everything 397# then. 398# 399world: upgrade_checks .PHONY 400 @echo "--------------------------------------------------------------" 401 @echo ">>> make world started on ${STARTTIME}" 402 @echo "--------------------------------------------------------------" 403.if target(pre-world) 404 @echo 405 @echo "--------------------------------------------------------------" 406 @echo ">>> Making 'pre-world' target" 407 @echo "--------------------------------------------------------------" 408 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 409.endif 410 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 411 ${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no 412.if target(post-world) 413 @echo 414 @echo "--------------------------------------------------------------" 415 @echo ">>> Making 'post-world' target" 416 @echo "--------------------------------------------------------------" 417 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 418.endif 419 @echo 420 @echo "--------------------------------------------------------------" 421 @echo ">>> make world completed on `LC_ALL=C date`" 422 @echo " (started ${STARTTIME})" 423 @echo "--------------------------------------------------------------" 424.else 425world: .PHONY 426 @echo "WARNING: make world will overwrite your existing FreeBSD" 427 @echo "installation without also building and installing a new" 428 @echo "kernel. This can be dangerous. Please read the handbook," 429 @echo "'Rebuilding world', for how to upgrade your system." 430 @echo "Define DESTDIR to where you want to install FreeBSD," 431 @echo "including /, to override this warning and proceed as usual." 432 @echo "" 433 @echo "Bailing out now..." 434 @false 435.endif 436 437# 438# kernel 439# 440# Short hand for `make buildkernel installkernel' 441# 442kernel: buildkernel installkernel .PHONY 443 444# 445# Perform a few tests to determine if the installed tools are adequate 446# for building the world. 447# 448upgrade_checks: .PHONY 449.if defined(NEED_MAKE_UPGRADE) 450 @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,}) 451.endif 452 453# 454# Upgrade make(1) to the current version using the installed 455# headers, libraries and tools. Also, allow the location of 456# the system bsdmake-like utility to be overridden. 457# 458MMAKEENV= \ 459 DESTDIR= \ 460 INSTALL="sh ${.CURDIR}/tools/install.sh" 461MMAKE= ${MMAKEENV} ${MAKE} \ 462 OBJTOP=${MYMAKE:H}/obj \ 463 OBJROOT='$${OBJTOP}/' \ 464 MAKEOBJDIRPREFIX= \ 465 MK_MAN=no -DNO_SHARED \ 466 -DNO_CPU_CFLAGS MK_WERROR=no \ 467 -DNO_SUBDIR \ 468 DESTDIR= PROGNAME=${MYMAKE:T} 469 470bmake: .PHONY 471 @echo 472 @echo "--------------------------------------------------------------" 473 @echo ">>> Building an up-to-date ${.TARGET}(1)" 474 @echo "--------------------------------------------------------------" 475 ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \ 476 ${MMAKE} obj; \ 477 ${MMAKE} depend; \ 478 ${MMAKE} all; \ 479 ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= 480 481regress: .PHONY 482 @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt 483 @false 484 485tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks 486 487tinderbox: .PHONY 488 @cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe 489 490toolchains: .PHONY 491 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe 492 493kernel-toolchains: .PHONY 494 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe 495 496kernels: .PHONY 497 @cd ${.CURDIR}; ${SUB_MAKE} universe -DWITHOUT_WORLDS 498 499worlds: .PHONY 500 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe 501 502# 503# universe 504# 505# Attempt to rebuild *everything* for all supported architectures, 506# with a reasonable chance of success, regardless of how old your 507# existing system is. 508# 509.if make(universe) || make(universe_kernels) || make(tinderbox) || \ 510 make(targets) || make(universe-toolchain) 511# 512# Don't build rarely used, semi-supported architectures unless requested. 513# 514.if defined(EXTRA_TARGETS) 515# powerpcspe excluded from main list until clang fixed 516EXTRA_ARCHES_powerpc= powerpcspe 517.endif 518TARGETS?=amd64 arm arm64 i386 powerpc riscv 519_UNIVERSE_TARGETS= ${TARGETS} 520TARGET_ARCHES_arm?= armv6 armv7 521TARGET_ARCHES_arm64?= aarch64 522TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le ${EXTRA_ARCHES_powerpc} 523TARGET_ARCHES_riscv?= riscv64 riscv64sf 524.for target in ${TARGETS} 525TARGET_ARCHES_${target}?= ${target} 526.endfor 527 528.if defined(USE_GCC_TOOLCHAINS) 529TOOLCHAINS_amd64= amd64-gcc6 530TOOLCHAINS_arm64= aarch64-gcc6 531TOOLCHAINS_i386= i386-gcc6 532TOOLCHAINS_powerpc= powerpc-gcc6 powerpc64-gcc6 533TOOLCHAIN_powerpc64= powerpc64-gcc6 534.endif 535 536# If a target is using an external toolchain, set MAKE_PARAMS to enable use 537# of the toolchain. If the external toolchain is missing, exclude the target 538# from universe. 539.for target in ${_UNIVERSE_TARGETS} 540.if !empty(TOOLCHAINS_${target}) 541.for toolchain in ${TOOLCHAINS_${target}} 542.if !exists(/usr/local/share/toolchains/${toolchain}.mk) 543_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}} 544universe: universe_${toolchain}_skip .PHONY 545universe_epilogue: universe_${toolchain}_skip .PHONY 546universe_${toolchain}_skip: universe_prologue .PHONY 547 @echo ">> ${target} skipped - install ${toolchain} port or package to build" 548.endif 549.endfor 550.for arch in ${TARGET_ARCHES_${target}} 551TOOLCHAIN_${arch}?= ${TOOLCHAINS_${target}:[1]} 552MAKE_PARAMS_${arch}?= CROSS_TOOLCHAIN=${TOOLCHAIN_${arch}} 553.endfor 554.endif 555.endfor 556 557UNIVERSE_TARGET?= buildworld 558KERNSRCDIR?= ${.CURDIR}/sys 559 560targets: .PHONY 561 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets" 562.for target in ${TARGETS} 563.for target_arch in ${TARGET_ARCHES_${target}} 564 @echo " ${target}/${target_arch}" 565.endfor 566.endfor 567 568.if defined(DOING_TINDERBOX) 569FAILFILE=${.CURDIR}/_.tinderbox.failed 570MAKEFAIL=tee -a ${FAILFILE} 571.else 572MAKEFAIL=cat 573.endif 574 575universe_prologue: upgrade_checks 576universe: universe_prologue 577universe_prologue: .PHONY 578 @echo "--------------------------------------------------------------" 579 @echo ">>> make universe started on ${STARTTIME}" 580 @echo "--------------------------------------------------------------" 581.if defined(DOING_TINDERBOX) 582 @rm -f ${FAILFILE} 583.endif 584 585universe-toolchain: .PHONY universe_prologue 586 @echo "--------------------------------------------------------------" 587 @echo "> Toolchain bootstrap started on `LC_ALL=C date`" 588 @echo "--------------------------------------------------------------" 589 ${_+_}@cd ${.CURDIR}; \ 590 env PATH=${PATH} ${SUB_MAKE} ${JFLAG} kernel-toolchain \ 591 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \ 592 OBJTOP="${HOST_OBJTOP}" \ 593 WITHOUT_SYSTEM_COMPILER=yes \ 594 WITHOUT_SYSTEM_LINKER=yes \ 595 TOOLS_PREFIX_UNDEF= \ 596 kernel-toolchain \ 597 MK_LLVM_TARGET_ALL=yes \ 598 > _.${.TARGET} 2>&1 || \ 599 (echo "${.TARGET} failed," \ 600 "check _.${.TARGET} for details" | \ 601 ${MAKEFAIL}; false) 602 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/cc" ]; then \ 603 echo "Missing host compiler at ${HOST_OBJTOP}/tmp/usr/bin/cc?" >&2; \ 604 false; \ 605 fi 606 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/ld" ]; then \ 607 echo "Missing host linker at ${HOST_OBJTOP}/tmp/usr/bin/ld?" >&2; \ 608 false; \ 609 fi 610 @echo "--------------------------------------------------------------" 611 @echo "> Toolchain bootstrap completed on `LC_ALL=C date`" 612 @echo "--------------------------------------------------------------" 613 614.for target in ${_UNIVERSE_TARGETS} 615universe: universe_${target} 616universe_epilogue: universe_${target} 617universe_${target}: universe_${target}_prologue .PHONY 618universe_${target}_prologue: universe_prologue .PHONY 619 @echo ">> ${target} started on `LC_ALL=C date`" 620universe_${target}_worlds: .PHONY 621 622.if !make(targets) && !make(universe-toolchain) 623.for target_arch in ${TARGET_ARCHES_${target}} 624.if !defined(_need_clang_${target}_${target_arch}) 625_need_clang_${target}_${target_arch} != \ 626 env TARGET=${target} TARGET_ARCH=${target_arch} \ 627 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \ 628 ${MAKE_PARAMS_${target_arch}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \ 629 echo unknown 630.export _need_clang_${target}_${target_arch} 631.endif 632.if !defined(_need_lld_${target}_${target_arch}) 633_need_lld_${target}_${target_arch} != \ 634 env TARGET=${target} TARGET_ARCH=${target_arch} \ 635 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \ 636 ${MAKE_PARAMS_${target_arch}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \ 637 echo unknown 638.export _need_lld_${target}_${target_arch} 639.endif 640# Setup env for each arch to use the one clang. 641.if defined(_need_clang_${target}_${target_arch}) && \ 642 ${_need_clang_${target}_${target_arch}} == "yes" 643# No check on existing XCC or CROSS_BINUTILS_PREFIX, etc, is needed since 644# we use the test-system-compiler logic to determine if clang needs to be 645# built. It will be no from that logic if already using an external 646# toolchain or /usr/bin/cc. 647# XXX: Passing HOST_OBJTOP into the PATH would allow skipping legacy, 648# bootstrap-tools, and cross-tools. Need to ensure each tool actually 649# supports all TARGETS though. 650# For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end 651# of STRICTTMPPATH to ensure that the target-specific binaries come first. 652MAKE_PARAMS_${target_arch}+= \ 653 XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \ 654 XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \ 655 XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \ 656 UNIVERSE_TOOLCHAIN_PATH=${HOST_OBJTOP}/tmp/usr/bin 657.endif 658.if defined(_need_lld_${target}_${target_arch}) && \ 659 ${_need_lld_${target}_${target_arch}} == "yes" 660MAKE_PARAMS_${target_arch}+= \ 661 XLD="${HOST_OBJTOP}/tmp/usr/bin/ld" 662.endif 663.endfor 664.endif # !make(targets) 665 666.if ${__DO_WORLDS} == "yes" 667universe_${target}_done: universe_${target}_worlds .PHONY 668.for target_arch in ${TARGET_ARCHES_${target}} 669universe_${target}_worlds: universe_${target}_${target_arch} .PHONY 670.if (defined(_need_clang_${target}_${target_arch}) && \ 671 ${_need_clang_${target}_${target_arch}} == "yes") || \ 672 (defined(_need_lld_${target}_${target_arch}) && \ 673 ${_need_lld_${target}_${target_arch}} == "yes") 674universe_${target}_${target_arch}: universe-toolchain 675universe_${target}_prologue: universe-toolchain 676.endif 677universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY 678 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`" 679 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 680 ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ 681 TARGET=${target} \ 682 TARGET_ARCH=${target_arch} \ 683 ${MAKE_PARAMS_${target_arch}} \ 684 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ 685 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \ 686 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \ 687 ${MAKEFAIL})) 688 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`" 689.endfor 690.endif # ${__DO_WORLDS} == "yes" 691 692.if ${__DO_KERNELS} == "yes" 693universe_${target}_done: universe_${target}_kernels .PHONY 694universe_${target}_kernels: universe_${target}_worlds .PHONY 695universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY 696 @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \ 697 universe_kernels 698.endif # ${__DO_KERNELS} == "yes" 699 700# Tell the user the worlds and kernels have completed 701universe_${target}: universe_${target}_done 702universe_${target}_done: 703 @echo ">> ${target} completed on `LC_ALL=C date`" 704.endfor 705.if make(universe_kernconfs) || make(universe_kernels) 706.if !defined(TARGET) 707TARGET!= uname -m 708.endif 709universe_kernels_prologue: .PHONY 710 @echo ">> ${TARGET} kernels started on `LC_ALL=C date`" 711universe_kernels: universe_kernconfs .PHONY 712 @echo ">> ${TARGET} kernels completed on `LC_ALL=C date`" 713.if defined(MAKE_ALL_KERNELS) 714_THINNER=cat 715.elif defined(MAKE_LINT_KERNELS) 716_THINNER=grep 'LINT' || true 717.else 718_THINNER=xargs grep -L "^.NO_UNIVERSE" || true 719.endif 720KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 721 find [[:upper:][:digit:]]*[[:upper:][:digit:]] \ 722 -type f -maxdepth 0 \ 723 ! -name DEFAULTS ! -name NOTES | \ 724 ${_THINNER} 725universe_kernconfs: universe_kernels_prologue .PHONY 726.for kernel in ${KERNCONFS} 727TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 728 env PATH=${HOST_OBJTOP}/tmp/legacy/bin:${PATH:Q} \ 729 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \ 730 grep -v WARNING: | cut -f 2 731.if empty(TARGET_ARCH_${kernel}) 732.error Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old. 733.endif 734universe_kernconfs_${TARGET_ARCH_${kernel}}: universe_kernconf_${TARGET}_${kernel} 735universe_kernconf_${TARGET}_${kernel}: .MAKE 736 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel started on `LC_ALL=C date`" 737 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 738 ${SUB_MAKE} ${JFLAG} buildkernel \ 739 TARGET=${TARGET} \ 740 TARGET_ARCH=${TARGET_ARCH_${kernel}} \ 741 ${MAKE_PARAMS_${TARGET_ARCH_${kernel}}} \ 742 KERNCONF=${kernel} \ 743 > _.${TARGET}.${kernel} 2>&1 || \ 744 (echo "${TARGET} ${kernel} kernel failed," \ 745 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 746 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel completed on `LC_ALL=C date`" 747.endfor 748.for target_arch in ${TARGET_ARCHES_${TARGET}} 749universe_kernconfs: universe_kernconfs_${target_arch} .PHONY 750universe_kernconfs_${target_arch}: 751.endfor 752.endif # make(universe_kernels) 753universe: universe_epilogue 754universe_epilogue: .PHONY 755 @echo "--------------------------------------------------------------" 756 @echo ">>> make universe completed on `LC_ALL=C date`" 757 @echo " (started ${STARTTIME})" 758 @echo "--------------------------------------------------------------" 759.if defined(DOING_TINDERBOX) 760 @if [ -e ${FAILFILE} ] ; then \ 761 echo "Tinderbox failed:" ;\ 762 cat ${FAILFILE} ;\ 763 exit 1 ;\ 764 fi 765.endif 766.endif 767 768.if defined(.PARSEDIR) 769# This makefile does not run in meta mode 770.MAKE.MODE= normal 771# Normally the things we run from here don't either. 772# Using -DWITH_META_MODE 773# we can buildworld with meta files created which are useful 774# for debugging, but without any of the rest of a meta mode build. 775MK_DIRDEPS_BUILD= no 776MK_STAGING= no 777# tell meta.autodep.mk to not even think about updating anything. 778UPDATE_DEPENDFILE= NO 779.if !make(showconfig) 780.export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE 781.endif 782 783.if make(universe) 784# we do not want a failure of one branch abort all. 785MAKE_JOB_ERROR_TOKEN= no 786.export MAKE_JOB_ERROR_TOKEN 787.endif 788.endif # bmake 789 790.endif # DIRDEPS_BUILD 791