You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

757 lines
28KB

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