HardenedBSD src tree https://hardenedbsd.org/
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.

780 lines
29KB

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