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.

772 lines
29 KiB

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