HardenedBSD src tree
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.

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