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.

3472 lines
116KB

  1. #
  2. # $FreeBSD$
  3. #
  4. # Make command line options:
  5. # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
  6. # -DNO_CLEAN do not clean at all
  7. # -DDB_FROM_SRC use the user/group databases in src/etc instead of
  8. # the system database when installing.
  9. # -DNO_SHARE do not go into share subdir
  10. # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
  11. # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
  12. # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
  13. # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
  14. # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
  15. # -DNO_ROOT install without using root privilege
  16. # -DNO_DOCUPDATE do not update doc in ${MAKE} update
  17. # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
  18. # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
  19. # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
  20. # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
  21. # LOCAL_MTREE="list of mtree files" to process to allow local directories
  22. # to be created before files are installed
  23. # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
  24. # list
  25. # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
  26. # cross-tools target
  27. # METALOG="path to metadata log" to write permission and ownership
  28. # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
  29. # TARGET="machine" to crossbuild world for a different machine type
  30. # TARGET_ARCH= may be required when a TARGET supports multiple endians
  31. # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
  32. # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
  33. # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
  34. # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
  35. # All libraries and includes, and some build tools will still build.
  36. #
  37. # The intended user-driven targets are:
  38. # buildworld - rebuild *everything*, including glue to help do upgrades
  39. # installworld- install everything built by "buildworld"
  40. # checkworld - run test suite on installed world
  41. # doxygen - build API documentation of the kernel
  42. # update - convenient way to update your source tree (eg: svn/svnup)
  43. #
  44. # Standard targets (not defined here) are documented in the makefiles in
  45. # /usr/share/mk. These include:
  46. # obj depend all install clean cleandepend cleanobj
  47. .if !defined(TARGET) || !defined(TARGET_ARCH)
  48. .error "Both TARGET and TARGET_ARCH must be defined."
  49. .endif
  50. .if make(showconfig) || make(test-system-*)
  51. _MKSHOWCONFIG= t
  52. .endif
  53. SRCDIR?= ${.CURDIR}
  54. LOCALBASE?= /usr/local
  55. # Cross toolchain changes must be in effect before bsd.compiler.mk
  56. # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
  57. .if defined(CROSS_TOOLCHAIN)
  58. .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
  59. .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
  60. .elif exists(${CROSS_TOOLCHAIN})
  61. .include "${CROSS_TOOLCHAIN}"
  62. .else
  63. .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
  64. .endif
  65. CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
  66. .endif
  67. .if defined(CROSS_TOOLCHAIN_PREFIX)
  68. CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
  69. .endif
  70. XCOMPILERS= CC CXX CPP
  71. .for COMPILER in ${XCOMPILERS}
  72. .if defined(CROSS_COMPILER_PREFIX)
  73. X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
  74. .else
  75. X${COMPILER}?= ${${COMPILER}}
  76. .endif
  77. .endfor
  78. # If a full path to an external cross compiler is given, don't build
  79. # a cross compiler.
  80. .if ${XCC:N${CCACHE_BIN}:M/*}
  81. MK_CLANG_BOOTSTRAP= no
  82. MK_GCC_BOOTSTRAP= no
  83. .endif
  84. # Pull in compiler metadata from buildworld/toolchain if possible to avoid
  85. # running CC from bsd.compiler.mk.
  86. .if make(installworld) || make(install) || make(distributeworld) || \
  87. make(stageworld)
  88. .-include "${OBJTOP}/toolchain-metadata.mk"
  89. .if !defined(_LOADED_TOOLCHAIN_METADATA)
  90. .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
  91. .endif
  92. .endif
  93. # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
  94. # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
  95. # here since we will always have the right make, unlike in src/Makefile
  96. # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
  97. _NO_INCLUDE_LINKERMK= t
  98. # We also want the X_COMPILER* variables if we are using an external toolchain.
  99. _WANT_TOOLCHAIN_CROSS_VARS= t
  100. .include "share/mk/bsd.compiler.mk"
  101. .undef _NO_INCLUDE_LINKERMK
  102. .undef _WANT_TOOLCHAIN_CROSS_VARS
  103. # src.opts.mk depends on COMPILER_FEATURES
  104. .include "share/mk/src.opts.mk"
  105. .if ${TARGET} == ${MACHINE}
  106. TARGET_CPUTYPE?=${CPUTYPE}
  107. .else
  108. TARGET_CPUTYPE?=
  109. .endif
  110. .if !empty(TARGET_CPUTYPE)
  111. _TARGET_CPUTYPE=${TARGET_CPUTYPE}
  112. .else
  113. _TARGET_CPUTYPE=dummy
  114. .endif
  115. .if ${TARGET} == "arm"
  116. .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
  117. TARGET_ABI= gnueabihf
  118. .else
  119. TARGET_ABI= gnueabi
  120. .endif
  121. .endif
  122. MACHINE_ABI?= unknown
  123. MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd13.0
  124. TARGET_ABI?= unknown
  125. TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd13.0
  126. KNOWN_ARCHES?= aarch64/arm64 \
  127. amd64 \
  128. arm \
  129. armv6/arm \
  130. armv7/arm \
  131. i386 \
  132. mips \
  133. mipsel/mips \
  134. mips64el/mips \
  135. mipsn32el/mips \
  136. mips64/mips \
  137. mipsn32/mips \
  138. mipshf/mips \
  139. mipselhf/mips \
  140. mips64elhf/mips \
  141. mips64hf/mips \
  142. powerpc \
  143. powerpc64/powerpc \
  144. powerpcspe/powerpc \
  145. riscv64/riscv \
  146. riscv64sf/riscv \
  147. sparc64
  148. .if ${TARGET} == ${TARGET_ARCH}
  149. _t= ${TARGET}
  150. .else
  151. _t= ${TARGET_ARCH}/${TARGET}
  152. .endif
  153. .for _t in ${_t}
  154. .if empty(KNOWN_ARCHES:M${_t})
  155. .error Unknown target ${TARGET_ARCH}:${TARGET}.
  156. .endif
  157. .endfor
  158. # If all targets are disabled for system llvm then don't expect it to work
  159. # for cross-builds.
  160. .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
  161. ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
  162. !make(showconfig)
  163. MK_SYSTEM_COMPILER= no
  164. MK_SYSTEM_LINKER= no
  165. .endif
  166. # Handle external binutils.
  167. .if defined(CROSS_TOOLCHAIN_PREFIX)
  168. CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
  169. .endif
  170. # If we do not have a bootstrap binutils (because the in-tree one does not
  171. # support the target architecture), provide a default cross-binutils prefix.
  172. # This allows riscv64 builds, for example, to automatically use the
  173. # riscv64-binutils port or package.
  174. .if !make(showconfig) && !defined(_NO_INCLUDE_COMPILERMK)
  175. .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
  176. ${MK_LLD_BOOTSTRAP} == "no" && \
  177. !defined(CROSS_BINUTILS_PREFIX)
  178. CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_TRIPLE}/bin/
  179. .if !exists(${CROSS_BINUTILS_PREFIX})
  180. .if !empty(BROKEN_OPTIONS:MGCC_BOOTSTRAP) && ${MK_CLANG_BOOTSTRAP} == "no"
  181. .error In-tree toolchain does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-xtoolchain-gcc port or package or set CROSS_TOOLCHAIN_PREFIX.
  182. .else
  183. .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
  184. .endif
  185. .endif
  186. .endif
  187. .endif
  188. XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
  189. .for BINUTIL in ${XBINUTILS}
  190. .if defined(CROSS_BINUTILS_PREFIX) && \
  191. exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
  192. X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
  193. .else
  194. X${BINUTIL}?= ${${BINUTIL}}
  195. .endif
  196. .endfor
  197. # If a full path to an external linker is given, don't build lld.
  198. .if ${XLD:M/*}
  199. MK_LLD_BOOTSTRAP= no
  200. .endif
  201. # We also want the X_LINKER* variables if we are using an external toolchain.
  202. _WANT_TOOLCHAIN_CROSS_VARS= t
  203. .include "share/mk/bsd.linker.mk"
  204. .undef _WANT_TOOLCHAIN_CROSS_VARS
  205. # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
  206. # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
  207. # Check if there is a local compiler that can satisfy as an external compiler.
  208. # Which compiler is expected to be used?
  209. .if ${MK_CLANG_BOOTSTRAP} == "yes"
  210. WANT_COMPILER_TYPE= clang
  211. .elif ${MK_GCC_BOOTSTRAP} == "yes"
  212. WANT_COMPILER_TYPE= gcc
  213. .else
  214. WANT_COMPILER_TYPE=
  215. .endif
  216. .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
  217. !make(test-system-linker)
  218. .if ${WANT_COMPILER_TYPE} == "clang"
  219. WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
  220. WANT_COMPILER_FREEBSD_VERSION!= \
  221. awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
  222. ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
  223. WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
  224. WANT_COMPILER_VERSION!= \
  225. awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
  226. ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
  227. .elif ${WANT_COMPILER_TYPE} == "gcc"
  228. WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
  229. WANT_COMPILER_FREEBSD_VERSION!= \
  230. awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
  231. ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
  232. WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
  233. WANT_COMPILER_VERSION!= \
  234. awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
  235. ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
  236. .endif
  237. .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
  238. .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
  239. # It needs to be the same revision as we would build for the bootstrap.
  240. # If the expected vs CC is different then we can't skip.
  241. # GCC cannot be used for cross-arch yet. For clang we pass -target later if
  242. # TARGET_ARCH!=MACHINE_ARCH.
  243. .if ${MK_SYSTEM_COMPILER} == "yes" && \
  244. defined(WANT_COMPILER_FREEBSD_VERSION) && \
  245. (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
  246. !make(xdev*) && \
  247. ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
  248. (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
  249. ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
  250. ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
  251. # Everything matches, disable the bootstrap compiler.
  252. MK_CLANG_BOOTSTRAP= no
  253. MK_GCC_BOOTSTRAP= no
  254. USING_SYSTEM_COMPILER= yes
  255. .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
  256. # WITH_SYSTEM_LD - Pull in needed values and make a decision.
  257. # Check if there is a local linker that can satisfy as an external linker.
  258. # Which linker is expected to be used?
  259. .if ${MK_LLD_BOOTSTRAP} == "yes"
  260. WANT_LINKER_TYPE= lld
  261. .elif ${MK_BINUTILS_BOOTSTRAP} == "yes"
  262. # Note that there's no support for bfd in WITH_SYSTEM_LINKER.
  263. WANT_LINKER_TYPE= bfd
  264. .else
  265. WANT_LINKER_TYPE=
  266. .endif
  267. .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
  268. !make(test-system-compiler)
  269. .if ${WANT_LINKER_TYPE} == "lld"
  270. WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
  271. WANT_LINKER_FREEBSD_VERSION!= \
  272. awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
  273. ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
  274. WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
  275. WANT_LINKER_VERSION!= \
  276. awk '$$2 == "LLD_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
  277. ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
  278. .else
  279. WANT_LINKER_FREEBSD_VERSION_FILE=
  280. WANT_LINKER_FREEBSD_VERSION=
  281. .endif
  282. .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
  283. .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
  284. .if ${MK_SYSTEM_LINKER} == "yes" && \
  285. defined(WANT_LINKER_FREEBSD_VERSION) && \
  286. (${MK_LLD_BOOTSTRAP} == "yes") && \
  287. !make(xdev*) && \
  288. ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
  289. ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
  290. ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
  291. # Everything matches, disable the bootstrap linker.
  292. MK_LLD_BOOTSTRAP= no
  293. USING_SYSTEM_LINKER= yes
  294. .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
  295. # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
  296. USING_SYSTEM_COMPILER?= no
  297. USING_SYSTEM_LINKER?= no
  298. TEST_SYSTEM_COMPILER_VARS= \
  299. USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
  300. MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
  301. WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
  302. WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
  303. CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
  304. COMPILER_FREEBSD_VERSION \
  305. XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
  306. X_COMPILER_FREEBSD_VERSION
  307. TEST_SYSTEM_LINKER_VARS= \
  308. USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
  309. MK_LLD_BOOTSTRAP MK_BINUTILS_BOOTSTRAP \
  310. WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
  311. WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
  312. LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
  313. LINKER_FREEBSD_VERSION \
  314. XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
  315. X_LINKER_FREEBSD_VERSION
  316. .for _t in compiler linker
  317. test-system-${_t}: .PHONY
  318. .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
  319. ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
  320. .endfor
  321. .endfor
  322. .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
  323. make(toolchain) || make(_cross-tools))
  324. .if ${USING_SYSTEM_COMPILER} == "yes"
  325. .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
  326. .elif ${MK_CLANG_BOOTSTRAP} == "yes"
  327. .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
  328. .endif
  329. .if ${USING_SYSTEM_LINKER} == "yes"
  330. .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
  331. .elif ${MK_LLD_BOOTSTRAP} == "yes"
  332. .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
  333. .endif
  334. .endif
  335. # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
  336. # Store some compiler metadata for use in installworld where we don't
  337. # want to invoke CC at all.
  338. _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
  339. COMPILER_TYPE \
  340. COMPILER_FEATURES \
  341. COMPILER_FREEBSD_VERSION \
  342. LINKER_VERSION \
  343. LINKER_FEATURES \
  344. LINKER_TYPE \
  345. LINKER_FREEBSD_VERSION
  346. toolchain-metadata.mk: .PHONY .META
  347. @: > ${.TARGET}
  348. @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
  349. > ${.TARGET}
  350. @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
  351. .for v in ${_TOOLCHAIN_METADATA_VARS}
  352. @echo "${v}=${${v}}" >> ${.TARGET}
  353. @echo "X_${v}=${X_${v}}" >> ${.TARGET}
  354. .endfor
  355. @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
  356. @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
  357. # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
  358. # keep the users system reasonably usable. For static->dynamic root upgrades,
  359. # we don't want to install a dynamic binary without rtld and the needed
  360. # libraries. More commonly, for dynamic root, we don't want to install a
  361. # binary that requires a newer library version that hasn't been installed yet.
  362. # This ordering is not a guarantee though. The only guarantee of a working
  363. # system here would require fine-grained ordering of all components based
  364. # on their dependencies.
  365. .if !empty(SUBDIR_OVERRIDE)
  366. SUBDIR= ${SUBDIR_OVERRIDE}
  367. .else
  368. SUBDIR= lib libexec
  369. # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
  370. # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
  371. # LOCAL_LIB_DIRS=foo/lib to behave as expected.
  372. .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
  373. _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
  374. .endfor
  375. .for _DIR in ${LOCAL_LIB_DIRS}
  376. .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
  377. SUBDIR+= ${_DIR}
  378. .endif
  379. .endfor
  380. .if !defined(NO_ROOT) && (make(installworld) || make(install))
  381. # Ensure libraries are installed before progressing.
  382. SUBDIR+=.WAIT
  383. .endif
  384. SUBDIR+=bin
  385. .if ${MK_CDDL} != "no"
  386. SUBDIR+=cddl
  387. .endif
  388. SUBDIR+=gnu include
  389. .if ${MK_KERBEROS} != "no"
  390. SUBDIR+=kerberos5
  391. .endif
  392. .if ${MK_RESCUE} != "no"
  393. SUBDIR+=rescue
  394. .endif
  395. SUBDIR+=sbin
  396. .if ${MK_CRYPT} != "no"
  397. SUBDIR+=secure
  398. .endif
  399. .if !defined(NO_SHARE)
  400. SUBDIR+=share
  401. .endif
  402. .if ${MK_BOOT} != "no"
  403. SUBDIR+=stand
  404. .endif
  405. SUBDIR+=sys usr.bin usr.sbin
  406. .if ${MK_TESTS} != "no"
  407. SUBDIR+= tests
  408. .endif
  409. # Local directories are built in parallel with the base system directories.
  410. # Users may insert a .WAIT directive at the beginning or elsewhere within
  411. # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
  412. .for _DIR in ${LOCAL_DIRS}
  413. .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
  414. SUBDIR+= ${_DIR}
  415. .endif
  416. .endfor
  417. # We must do etc/ last as it hooks into building the man whatis file
  418. # by calling 'makedb' in share/man. This is only relevant for
  419. # install/distribute so they build the whatis file after every manpage is
  420. # installed.
  421. .if make(installworld) || make(install)
  422. SUBDIR+=.WAIT
  423. .endif
  424. SUBDIR+=etc
  425. .endif # !empty(SUBDIR_OVERRIDE)
  426. .if defined(NOCLEAN)
  427. .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
  428. NO_CLEAN= ${NOCLEAN}
  429. .endif
  430. .if defined(NO_CLEANDIR)
  431. CLEANDIR= clean cleandepend
  432. .else
  433. CLEANDIR= cleandir
  434. .endif
  435. .if defined(WORLDFAST)
  436. NO_CLEAN= t
  437. NO_OBJWALK= t
  438. .endif
  439. .if ${MK_META_MODE} == "yes"
  440. # If filemon is used then we can rely on the build being incremental-safe.
  441. # The .meta files will also track the build command and rebuild should
  442. # it change.
  443. .if empty(.MAKE.MODE:Mnofilemon)
  444. NO_CLEAN= t
  445. .endif
  446. .endif
  447. .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
  448. NO_OBJWALK= t
  449. NO_KERNELOBJ= t
  450. .endif
  451. .if !defined(NO_OBJWALK)
  452. _obj= obj
  453. .endif
  454. LOCAL_TOOL_DIRS?=
  455. PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
  456. .if empty(SHELL:M*csh*)
  457. BUILDENV_SHELL?=${SHELL}
  458. .else
  459. BUILDENV_SHELL?=/bin/sh
  460. .endif
  461. .if !defined(_MKSHOWCONFIG)
  462. .if !defined(SVN_CMD) || empty(SVN_CMD)
  463. . for _P in /usr/bin /usr/local/bin
  464. . for _S in svn svnlite
  465. . if exists(${_P}/${_S})
  466. SVN_CMD= ${_P}/${_S}
  467. . endif
  468. . endfor
  469. . endfor
  470. .export SVN_CMD
  471. .endif
  472. SVNFLAGS?= -r HEAD
  473. .if !defined(VCS_REVISION) || empty(VCS_REVISION)
  474. .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
  475. . for _D in ${PATH:S,:, ,g}
  476. . if exists(${_D}/svnversion)
  477. SVNVERSION_CMD?=${_D}/svnversion
  478. . endif
  479. . if exists(${_D}/svnliteversion)
  480. SVNVERSION_CMD?=${_D}/svnliteversion
  481. . endif
  482. . endfor
  483. .endif
  484. _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
  485. . if !empty(_VCS_REVISION)
  486. VCS_REVISION= $$(echo r${_VCS_REVISION})
  487. . endif
  488. .export VCS_REVISION
  489. .endif
  490. .if !defined(OSRELDATE)
  491. .if exists(/usr/include/osreldate.h)
  492. OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  493. /usr/include/osreldate.h
  494. .else
  495. OSRELDATE= 0
  496. .endif
  497. .export OSRELDATE
  498. .endif
  499. # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
  500. .if !defined(_REVISION)
  501. _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
  502. .export _REVISION
  503. .endif
  504. .if !defined(_BRANCH)
  505. _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
  506. .export _BRANCH
  507. .endif
  508. .if !defined(SRCRELDATE)
  509. SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  510. ${SRCDIR}/sys/sys/param.h
  511. .export SRCRELDATE
  512. .endif
  513. .if !defined(VERSION)
  514. VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
  515. .export VERSION
  516. .endif
  517. .if !defined(PKG_VERSION)
  518. .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*}
  519. TIMENOW= %Y%m%d%H%M%S
  520. EXTRA_REVISION= .s${TIMENOW:gmtime}
  521. .elif ${_BRANCH:MALPHA*}
  522. EXTRA_REVISION= _${_BRANCH:C/-ALPHA/.a/}
  523. .elif ${_BRANCH:MBETA*}
  524. EXTRA_REVISION= _${_BRANCH:C/-BETA/.b/}
  525. .elif ${_BRANCH:MRC*}
  526. EXTRA_REVISION= _${_BRANCH:C/-RC/.r/}
  527. .elif ${_BRANCH:MPRERELEASE*}
  528. EXTRA_REVISION= _${_BRANCH:C/-PRERELEASE/.p/}
  529. .elif ${_BRANCH:M*-p*}
  530. EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
  531. .endif
  532. PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
  533. .endif
  534. .endif # !defined(PKG_VERSION)
  535. .if !defined(_MKSHOWCONFIG)
  536. _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
  537. -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
  538. .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
  539. .error CPUTYPE global should be set with ?=.
  540. .endif
  541. .endif
  542. .if make(buildworld)
  543. BUILD_ARCH!= uname -p
  544. .if ${MACHINE_ARCH} != ${BUILD_ARCH}
  545. .error To cross-build, set TARGET_ARCH.
  546. .endif
  547. .endif
  548. WORLDTMP?= ${OBJTOP}/tmp
  549. BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
  550. XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
  551. # When building we want to find the cross tools before the host tools in ${BPATH}.
  552. # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
  553. # toolchain files (clang, lld, etc.) during make universe/tinderbox
  554. STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
  555. # We should not be using tools from /usr/bin accidentally since this could cause
  556. # the build to break on other systems that don't have that tool. For now we
  557. # still allow using the old behaviour (inheriting $PATH) if
  558. # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
  559. # Currently strict $PATH can cause build failures and does not work yet with
  560. # USING_SYSTEM_LINKER/USING_SYSTEM_COMPILER. Once these issues have been
  561. # resolved it will be turned on by default.
  562. BUILD_WITH_STRICT_TMPPATH?=0
  563. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  564. TMPPATH= ${STRICTTMPPATH}
  565. .else
  566. TMPPATH= ${STRICTTMPPATH}:${PATH}
  567. .endif
  568. #
  569. # Avoid running mktemp(1) unless actually needed.
  570. # It may not be functional, e.g., due to new ABI
  571. # when in the middle of installing over this system.
  572. #
  573. .if make(distributeworld) || make(installworld) || make(stageworld)
  574. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  575. MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
  576. .if !exists(${MKTEMP})
  577. .error "mktemp binary doesn't exist in expected location: ${MKTEMP}"
  578. .endif
  579. .else
  580. MKTEMP=mktemp
  581. .endif
  582. INSTALLTMP!= ${MKTEMP} -d -u -t install
  583. .endif
  584. .if make(stagekernel) || make(distributekernel)
  585. TAGS+= kernel
  586. PACKAGE= kernel
  587. .endif
  588. #
  589. # Building a world goes through the following stages
  590. #
  591. # 1. legacy stage [BMAKE]
  592. # This stage is responsible for creating compatibility
  593. # shims that are needed by the bootstrap-tools,
  594. # build-tools and cross-tools stages. These are generally
  595. # APIs that tools from one of those three stages need to
  596. # build that aren't present on the host.
  597. # 1. bootstrap-tools stage [BMAKE]
  598. # This stage is responsible for creating programs that
  599. # are needed for backward compatibility reasons. They
  600. # are not built as cross-tools.
  601. # 2. build-tools stage [TMAKE]
  602. # This stage is responsible for creating the object
  603. # tree and building any tools that are needed during
  604. # the build process. Some programs are listed during
  605. # this phase because they build binaries to generate
  606. # files needed to build these programs. This stage also
  607. # builds the 'build-tools' target rather than 'all'.
  608. # 3. cross-tools stage [XMAKE]
  609. # This stage is responsible for creating any tools that
  610. # are needed for building the system. A cross-compiler is one
  611. # of them. This differs from build tools in two ways:
  612. # 1. the 'all' target is built rather than 'build-tools'
  613. # 2. these tools are installed into TMPPATH for stage 4.
  614. # 4. world stage [WMAKE]
  615. # This stage actually builds the world.
  616. # 5. install stage (optional) [IMAKE]
  617. # This stage installs a previously built world.
  618. #
  619. BOOTSTRAPPING?= 0
  620. # Keep these in sync
  621. MINIMUM_SUPPORTED_OSREL?= 1002501
  622. MINIMUM_SUPPORTED_REL?= 10.3
  623. # Common environment for world related stages
  624. CROSSENV+= \
  625. MACHINE_ARCH=${TARGET_ARCH} \
  626. MACHINE=${TARGET} \
  627. CPUTYPE=${TARGET_CPUTYPE}
  628. .if ${MK_META_MODE} != "no"
  629. # Don't rebuild build-tools targets during normal build.
  630. CROSSENV+= BUILD_TOOLS_META=.NOMETA
  631. .endif
  632. .if defined(TARGET_CFLAGS)
  633. CROSSENV+= ${TARGET_CFLAGS}
  634. .endif
  635. .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
  636. defined(WITHOUT_LOCAL_MODULES)
  637. CROSSENV+= LOCAL_MODULES=
  638. .endif
  639. BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
  640. # bootstrap-tools stage
  641. BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
  642. TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
  643. PATH=${BPATH}:${PATH} \
  644. WORLDTMP=${WORLDTMP} \
  645. MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
  646. # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
  647. BSARGS= DESTDIR= \
  648. OBJTOP='${WORLDTMP}/obj-tools' \
  649. OBJROOT='$${OBJTOP}/' \
  650. MAKEOBJDIRPREFIX= \
  651. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  652. BWPHASE=${.TARGET:C,^_,,} \
  653. SSP_CFLAGS= \
  654. MK_HTML=no NO_LINT=yes MK_MAN=no \
  655. -DNO_PIC MK_PROFILE=no -DNO_SHARED \
  656. -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
  657. MK_CLANG_EXTRAS=yes MK_CLANG_FULL=no \
  658. MK_LLDB=no MK_TESTS=no \
  659. MK_INCLUDES=yes MK_CFI=no MK_RETPOLINE=no
  660. BMAKE= \
  661. ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  662. ${BSARGS}
  663. .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
  664. BMAKE+= MK_LLVM_TARGET_ALL=no
  665. .endif
  666. # build-tools stage
  667. TMAKE= \
  668. ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  669. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  670. DESTDIR= \
  671. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  672. BWPHASE=${.TARGET:C,^_,,} \
  673. SSP_CFLAGS= \
  674. -DNO_LINT \
  675. -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
  676. MK_CLANG_EXTRAS=yes MK_CLANG_FULL=no \
  677. MK_LLDB=no MK_TESTS=no MK_CFI=no MK_RETPOLINE=no
  678. # cross-tools stage
  679. # TOOLS_PREFIX set in BMAKE
  680. XMAKE= ${BMAKE} \
  681. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  682. MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
  683. MK_GDB=no MK_TESTS=no
  684. # kernel-tools stage
  685. KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
  686. PATH=${BPATH}:${PATH} \
  687. WORLDTMP=${WORLDTMP}
  688. KTMAKE= \
  689. TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
  690. ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  691. DESTDIR= \
  692. OBJTOP='${WORLDTMP}/obj-kernel-tools' \
  693. OBJROOT='$${OBJTOP}/' \
  694. MAKEOBJDIRPREFIX= \
  695. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  696. SSP_CFLAGS= \
  697. MK_HTML=no -DNO_LINT MK_MAN=no \
  698. -DNO_PIC MK_PROFILE=no -DNO_SHARED \
  699. -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no MK_CFI=no \
  700. MK_RETPOLINE=no
  701. # world stage
  702. WMAKEENV= ${CROSSENV} \
  703. INSTALL="sh ${.CURDIR}/tools/install.sh" \
  704. PATH=${TMPPATH} \
  705. SYSROOT=${WORLDTMP}
  706. # make hierarchy
  707. HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
  708. .if defined(NO_ROOT)
  709. HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
  710. .endif
  711. CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
  712. CPP="${XCPP} ${XCFLAGS}" \
  713. AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
  714. NM=${XNM} OBJCOPY="${XOBJCOPY}" \
  715. RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
  716. SIZE="${XSIZE}"
  717. .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
  718. # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
  719. # directory, but the compiler will look in the right place for its
  720. # tools so we don't need to tell it where to look.
  721. BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
  722. .endif
  723. # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
  724. # and target set by TARGET/TARGET_ARCH. However, there are several needs to
  725. # always pass an explicit --sysroot and -target.
  726. # - External compiler needs sysroot and target flags.
  727. # - External ld needs sysroot.
  728. # - To be clear about the use of a sysroot when using the internal compiler.
  729. # - Easier debugging.
  730. # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
  731. # the flip-flopping build command when sometimes using external and
  732. # sometimes using internal.
  733. # - Allow using lld which has no support for default paths.
  734. .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
  735. BFLAGS+= -B${WORLDTMP}/usr/bin
  736. .endif
  737. .if ${WANT_COMPILER_TYPE} == gcc || \
  738. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  739. .elif ${WANT_COMPILER_TYPE} == clang || \
  740. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
  741. XCFLAGS+= -target ${TARGET_TRIPLE}
  742. .endif
  743. XCFLAGS+= --sysroot=${WORLDTMP}
  744. .if !empty(BFLAGS)
  745. XCFLAGS+= ${BFLAGS}
  746. .endif
  747. .if ${MK_LIB32} == "yes"
  748. _LIBCOMPAT= 32
  749. .include "Makefile.libcompat"
  750. .elif ${MK_LIBSOFT} == "yes"
  751. _LIBCOMPAT= SOFT
  752. .include "Makefile.libcompat"
  753. .endif
  754. # META_MODE normally ignores host file changes since every build updates
  755. # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
  756. # when the ABI breaks though that we want to force rebuilding WORLDTMP
  757. # to get updated host tools.
  758. .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
  759. !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
  760. !defined(_MKSHOWCONFIG)
  761. # r318736 - ino64 major ABI breakage
  762. META_MODE_BAD_ABI_VERS+= 1200031
  763. .if !defined(OBJDIR_HOST_OSRELDATE)
  764. .if exists(${OBJTOP}/host-osreldate.h)
  765. OBJDIR_HOST_OSRELDATE!= \
  766. awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  767. ${OBJTOP}/host-osreldate.h
  768. .elif exists(${WORLDTMP}/usr/include/osreldate.h)
  769. OBJDIR_HOST_OSRELDATE= 0
  770. .endif
  771. .export OBJDIR_HOST_OSRELDATE
  772. .endif
  773. # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
  774. # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
  775. # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
  776. .if defined(OBJDIR_HOST_OSRELDATE)
  777. .for _ver in ${META_MODE_BAD_ABI_VERS}
  778. .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
  779. _meta_mode_need_rebuild= ${_ver}
  780. .endif
  781. .endfor
  782. .if defined(_meta_mode_need_rebuild)
  783. .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
  784. NO_META_IGNORE_HOST_HEADERS= 1
  785. .export NO_META_IGNORE_HOST_HEADERS
  786. .endif # defined(_meta_mode_need_rebuild)
  787. .endif # defined(OBJDIR_HOST_OSRELDATE)
  788. .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
  789. # This is only used for META_MODE+filemon to track what the oldest
  790. # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
  791. # a make dependency on /usr/include/osreldate.h as the file should
  792. # only be copied when it is missing or meta mode determines it has changed.
  793. # Since host files are normally ignored without NO_META_IGNORE_HOST
  794. # the file will never be updated unless that flag is specified. This
  795. # allows tracking the oldest osreldate to force rebuilds via
  796. # META_MODE_BADABI_REVS above.
  797. host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
  798. @cp -f /usr/include/osreldate.h ${.TARGET}
  799. WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  800. BWPHASE=${.TARGET:C,^_,,} \
  801. DESTDIR=${WORLDTMP}
  802. IMAKEENV= ${CROSSENV}
  803. IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
  804. ${IMAKE_INSTALL} ${IMAKE_MTREE}
  805. .if empty(.MAKEFLAGS:M-n)
  806. IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
  807. LD_LIBRARY_PATH=${INSTALLTMP} \
  808. PATH_LOCALE=${INSTALLTMP}/locale
  809. IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
  810. .else
  811. IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
  812. .endif
  813. # When generating install media, do not allow user and group information from
  814. # the build host to affect the contents of the distribution.
  815. .if make(distributeworld) || make(distrib-dirs) || make(distribution)
  816. DB_FROM_SRC= yes
  817. .endif
  818. .if defined(DB_FROM_SRC)
  819. INSTALLFLAGS+= -N ${.CURDIR}/etc
  820. MTREEFLAGS+= -N ${.CURDIR}/etc
  821. .endif
  822. _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
  823. INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
  824. .if defined(NO_ROOT)
  825. METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
  826. METALOG:= ${METALOG:C,//+,/,g}
  827. IMAKE+= -DNO_ROOT METALOG=${METALOG}
  828. INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
  829. MTREEFLAGS+= -W
  830. .endif
  831. .if defined(BUILD_PKGS)
  832. INSTALLFLAGS+= -h sha256
  833. .endif
  834. .if defined(DB_FROM_SRC) || defined(NO_ROOT)
  835. IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
  836. IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
  837. .endif
  838. DESTDIR_MTREEFLAGS= -deU
  839. # When creating worldtmp we don't need to set the directories as owned by root
  840. # so we also pass -W
  841. WORLDTMP_MTREEFLAGS= -deUW
  842. .if defined(NO_ROOT)
  843. # When building with -DNO_ROOT we shouldn't be changing the directories
  844. # that are created by mtree to be owned by root/wheel.
  845. DESTDIR_MTREEFLAGS+= -W
  846. .endif
  847. MTREE?= mtree
  848. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  849. MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
  850. .endif
  851. WORLDTMP_MTREE= ${MTREE} ${WORLDTMP_MTREEFLAGS}
  852. DESTDIR_MTREE= ${MTREE} ${DESTDIR_MTREEFLAGS}
  853. # kernel stage
  854. KMAKEENV= ${WMAKEENV:NSYSROOT=*}
  855. KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
  856. #
  857. # buildworld
  858. #
  859. # Attempt to rebuild the entire system, with reasonable chance of
  860. # success, regardless of how old your existing system is.
  861. #
  862. _sanity_check: .PHONY .MAKE
  863. .if ${.CURDIR:C/[^,]//g} != ""
  864. # The m4 build of sendmail files doesn't like it if ',' is used
  865. # anywhere in the path of it's files.
  866. @echo
  867. @echo "*** Error: path to source tree contains a comma ','"
  868. @echo
  869. @false
  870. .elif ${.CURDIR:M*\:*} != ""
  871. # Using ':' leaks into PATH and breaks finding cross-tools.
  872. @echo
  873. @echo "*** Error: path to source tree contains a colon ':'"
  874. @echo
  875. @false
  876. .endif
  877. # Our current approach to dependency tracking cannot cope with certain source
  878. # tree changes, particularly with respect to removing source files and
  879. # replacing generated files. Handle these cases here in an ad-hoc fashion.
  880. _cleanobj_fast_depend_hack: .PHONY
  881. # Syscall stubs rewritten in C and obsolete MD assembly implementations
  882. # Date SVN Rev Syscalls/Changes
  883. # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
  884. .if ${MACHINE} != i386
  885. .for f in opensolaris_atomic
  886. @if [ -e "${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o" ] && \
  887. egrep -qw 'opensolaris_atomic\.S' ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o; then \
  888. echo "Removing stale dependencies for opensolaris_atomic"; \
  889. rm -f ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.* \
  890. ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/cddl/lib/libzpool/.depend.${f}.*}; \
  891. fi
  892. .endfor
  893. .endif
  894. # 20190925 r352689 removal of obsolete i386 memchr.S
  895. .for f in memchr
  896. @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
  897. egrep -qw 'i386/string/memchr\.S' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
  898. echo "Removing stale dependencies for memchr"; \
  899. rm -f ${OBJTOP}/lib/libc/.depend.${f}.*; \
  900. fi
  901. .if defined(_LIBCOMPAT)
  902. @if [ -e "${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.o" ] && \
  903. egrep -qw 'i386/string/memchr\.S' ${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.o; then \
  904. echo "Removing stale dependencies for memchr"; \
  905. rm -f ${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*; \
  906. fi
  907. .endif
  908. .endfor
  909. # 20180604 r334626 brk sbrk
  910. # 20190916 r352703 shm_open
  911. .for f in brk sbrk shm_open
  912. @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
  913. egrep -qw '${f}\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
  914. echo "Removing stale dependencies for ${f} syscall wrappers"; \
  915. rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
  916. ${_LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
  917. fi
  918. .endfor
  919. # 20181013 r339348 bcopy reimplemented as .c
  920. .for f in bcopy memcpy memmove
  921. @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
  922. egrep -qw 'bcopy\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
  923. echo "Removing stale dependencies for bcopy"; \
  924. rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
  925. ${_LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
  926. fi
  927. .endfor
  928. # 20181115 r340463 bzero reimplemented as .c
  929. @if [ -e "${OBJTOP}/lib/libc/.depend.bzero.o" ] && \
  930. egrep -qw 'bzero\.[sS]' ${OBJTOP}/lib/libc/.depend.bzero.o; then \
  931. echo "Removing stale dependencies for bzero"; \
  932. rm -f ${OBJTOP}/lib/libc/.depend.bzero.* \
  933. ${_LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.bzero.*}; \
  934. fi
  935. # 20181009 track migration from ntp's embedded libevent to updated one
  936. @if [ -e "${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.bufferevent_openssl.o" ] && \
  937. egrep -q 'contrib/ntp/sntp/libevent/bufferevent_openssl.c' \
  938. ${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.bufferevent_openssl.o ; then \
  939. echo "Removing stale libevent dependencies"; \
  940. rm -f ${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.*; \
  941. fi
  942. # 20181209 r341759 track migration across wpa update
  943. @if [ -e "${OBJTOP}/usr.sbin/wpa/wpa_supplicant/.depend.rrm.o" ] && \
  944. egrep -q 'src/ap/rrm.c' \
  945. ${OBJTOP}/usr.sbin/wpa/wpa_supplicant/.depend.rrm.o; then \
  946. echo "Removing stale wpa dependencies"; \
  947. rm -f ${OBJTOP}/usr.sbin/wpa/*/.depend*; \
  948. fi
  949. _worldtmp: .PHONY
  950. @echo
  951. @echo "--------------------------------------------------------------"
  952. @echo ">>> Rebuilding the temporary build tree"
  953. @echo "--------------------------------------------------------------"
  954. .if !defined(NO_CLEAN)
  955. rm -rf ${WORLDTMP}
  956. .else
  957. # Note: for delete-old we need to set $PATH to also include the host $PATH
  958. # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
  959. # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
  960. # so we remove that assingnment from $WMAKE and prepend the new $PATH
  961. ${_+_}@if [ -e "${WORLDTMP}" ]; then \
  962. echo ">>> Deleting stale files in build tree..."; \
  963. cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
  964. _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
  965. delete-old-libs >/dev/null; \
  966. fi
  967. rm -rf ${WORLDTMP}/legacy/usr/include
  968. .if ${USING_SYSTEM_COMPILER} == "yes"
  969. .for cc in cc c++
  970. if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
  971. inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
  972. find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
  973. fi
  974. .endfor
  975. .endif # ${USING_SYSTEM_COMPILER} == "yes"
  976. .if ${USING_SYSTEM_LINKER} == "yes"
  977. @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
  978. .endif # ${USING_SYSTEM_LINKER} == "yes"
  979. .endif # !defined(NO_CLEAN)
  980. @mkdir -p ${WORLDTMP}
  981. @touch ${WORLDTMP}/${.TARGET}
  982. # We can't use mtree to create the worldtmp directories since it may not be
  983. # available on the target system (this happens e.g. when building on non-FreeBSD)
  984. cd ${.CURDIR}/tools/build; \
  985. ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
  986. # In order to build without inheriting $PATH we need to add symlinks to the host
  987. # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
  988. cd ${.CURDIR}/tools/build; \
  989. ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
  990. _legacy:
  991. @echo
  992. @echo "--------------------------------------------------------------"
  993. @echo ">>> stage 1.1: legacy release compatibility shims"
  994. @echo "--------------------------------------------------------------"
  995. ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
  996. _bootstrap-tools:
  997. @echo
  998. @echo "--------------------------------------------------------------"
  999. @echo ">>> stage 1.2: bootstrap tools"
  1000. @echo "--------------------------------------------------------------"
  1001. ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
  1002. mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/casper ${WORLDTMP}/lib/geom
  1003. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  1004. -p ${WORLDTMP}/usr >/dev/null
  1005. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  1006. -p ${WORLDTMP}/usr/include >/dev/null
  1007. ln -sf ${.CURDIR}/sys ${WORLDTMP}
  1008. .if ${MK_DEBUG_FILES} != "no"
  1009. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
  1010. -p ${WORLDTMP}/usr/lib >/dev/null
  1011. .endif
  1012. .for _mtree in ${LOCAL_MTREE}
  1013. ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
  1014. .endfor
  1015. _cleanobj:
  1016. .if !defined(NO_CLEAN)
  1017. @echo
  1018. @echo "--------------------------------------------------------------"
  1019. @echo ">>> stage 2.1: cleaning up the object tree"
  1020. @echo "--------------------------------------------------------------"
  1021. # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
  1022. # since the restricted $PATH might not contain a valid cc binary
  1023. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
  1024. .if defined(_LIBCOMPAT)
  1025. ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
  1026. .endif
  1027. .else
  1028. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
  1029. .endif # !defined(NO_CLEAN)
  1030. _obj:
  1031. @echo
  1032. @echo "--------------------------------------------------------------"
  1033. @echo ">>> stage 2.2: rebuilding the object tree"
  1034. @echo "--------------------------------------------------------------"
  1035. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
  1036. _build-tools:
  1037. @echo
  1038. @echo "--------------------------------------------------------------"
  1039. @echo ">>> stage 2.3: build tools"
  1040. @echo "--------------------------------------------------------------"
  1041. ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
  1042. _cross-tools:
  1043. @echo
  1044. @echo "--------------------------------------------------------------"
  1045. @echo ">>> stage 3: cross tools"
  1046. @echo "--------------------------------------------------------------"
  1047. @rm -f ${OBJTOP}/toolchain-metadata.mk
  1048. ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
  1049. ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
  1050. _build-metadata:
  1051. @echo
  1052. @echo "--------------------------------------------------------------"
  1053. @echo ">>> stage 3.1: recording build metadata"
  1054. @echo "--------------------------------------------------------------"
  1055. ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
  1056. ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
  1057. _includes:
  1058. @echo
  1059. @echo "--------------------------------------------------------------"
  1060. @echo ">>> stage 4.1: building includes"
  1061. @echo "--------------------------------------------------------------"
  1062. # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
  1063. # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
  1064. ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
  1065. MK_INCLUDES=yes includes
  1066. .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
  1067. ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
  1068. .endif
  1069. _libraries:
  1070. @echo
  1071. @echo "--------------------------------------------------------------"
  1072. @echo ">>> stage 4.2: building libraries"
  1073. @echo "--------------------------------------------------------------"
  1074. ${_+_}cd ${.CURDIR}; \
  1075. ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
  1076. MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
  1077. everything: .PHONY
  1078. @echo
  1079. @echo "--------------------------------------------------------------"
  1080. @echo ">>> stage 4.4: building everything"
  1081. @echo "--------------------------------------------------------------"
  1082. ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
  1083. WMAKE_TGTS=
  1084. .if !defined(WORLDFAST)
  1085. WMAKE_TGTS+= _sanity_check _worldtmp _legacy
  1086. .if empty(SUBDIR_OVERRIDE)
  1087. WMAKE_TGTS+= _bootstrap-tools
  1088. .endif
  1089. WMAKE_TGTS+= _cleanobj
  1090. .if !defined(NO_OBJWALK)
  1091. WMAKE_TGTS+= _obj
  1092. .endif
  1093. WMAKE_TGTS+= _build-tools _cross-tools
  1094. WMAKE_TGTS+= _build-metadata
  1095. WMAKE_TGTS+= _includes
  1096. .endif
  1097. .if !defined(NO_LIBS)
  1098. WMAKE_TGTS+= _libraries
  1099. .endif
  1100. .if defined(_LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
  1101. WMAKE_TGTS+= build${libcompat}
  1102. .endif
  1103. WMAKE_TGTS+= everything
  1104. # record buildworld time in seconds
  1105. .if make(buildworld)
  1106. _BUILDWORLD_START!= date '+%s'
  1107. .export _BUILDWORLD_START
  1108. .endif
  1109. buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
  1110. .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
  1111. buildworld_prologue: .PHONY
  1112. @echo "--------------------------------------------------------------"
  1113. @echo ">>> World build started on `LC_ALL=C date`"
  1114. @echo "--------------------------------------------------------------"
  1115. buildworld_epilogue: .PHONY
  1116. @echo
  1117. @echo "--------------------------------------------------------------"
  1118. @echo ">>> World build completed on `LC_ALL=C date`"
  1119. @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
  1120. echo -n ">>> World built in $$seconds seconds, "; \
  1121. echo "ncpu: $$(sysctl -n hw.ncpu)${.MAKE.JOBS:S/^/, make -j/}"
  1122. @echo "--------------------------------------------------------------"
  1123. #
  1124. # We need to have this as a target because the indirection between Makefile
  1125. # and Makefile.inc1 causes the correct PATH to be used, rather than a
  1126. # modification of the current environment's PATH. In addition, we need
  1127. # to quote multiword values.
  1128. #
  1129. buildenvvars: .PHONY
  1130. @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
  1131. .if ${.TARGETS:Mbuildenv}
  1132. .if ${.MAKEFLAGS:M-j}
  1133. .error The buildenv target is incompatible with -j
  1134. .endif
  1135. .endif
  1136. BUILDENV_DIR?= ${.CURDIR}
  1137. #
  1138. # Note: make will report any errors the shell reports. This can
  1139. # be odd if the last command in an interactive shell generates an
  1140. # error or is terminated by SIGINT. These reported errors look bad,
  1141. # but are harmless. Allowing them also allows BUIDLENV_SHELL to
  1142. # be a complex command whose status will be returned to the caller.
  1143. # Some scripts in tools rely on this behavior to report build errors.
  1144. #
  1145. buildenv: .PHONY
  1146. @echo Entering world for ${TARGET_ARCH}:${TARGET}
  1147. .if ${BUILDENV_SHELL:M*zsh*}
  1148. @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
  1149. .endif
  1150. @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
  1151. TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
  1152. toolchain: ${TOOLCHAIN_TGTS} .PHONY
  1153. KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
  1154. .if make(kernel-toolchain)
  1155. .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
  1156. .endif
  1157. kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
  1158. #
  1159. # installcheck
  1160. #
  1161. # Checks to be sure system is ready for installworld/installkernel.
  1162. #
  1163. installcheck: _installcheck_world _installcheck_kernel .PHONY
  1164. _installcheck_world: .PHONY
  1165. @echo "--------------------------------------------------------------"
  1166. @echo ">>> Install check world"
  1167. @echo "--------------------------------------------------------------"
  1168. _installcheck_kernel: .PHONY
  1169. @echo "--------------------------------------------------------------"
  1170. @echo ">>> Install check kernel"
  1171. @echo "--------------------------------------------------------------"
  1172. #
  1173. # Require DESTDIR to be set if installing for a different architecture or
  1174. # using the user/group database in the source tree.
  1175. #
  1176. .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
  1177. defined(DB_FROM_SRC)
  1178. .if !make(distributeworld)
  1179. _installcheck_world: __installcheck_DESTDIR
  1180. _installcheck_kernel: __installcheck_DESTDIR
  1181. __installcheck_DESTDIR: .PHONY
  1182. .if !defined(DESTDIR) || empty(DESTDIR)
  1183. @echo "ERROR: Please set DESTDIR!"; \
  1184. false
  1185. .endif
  1186. .endif
  1187. .endif
  1188. .if !defined(DB_FROM_SRC)
  1189. #
  1190. # Check for missing UIDs/GIDs.
  1191. #
  1192. CHECK_UIDS= auditdistd
  1193. CHECK_GIDS= audit
  1194. CHECK_UIDS+= ntpd
  1195. CHECK_GIDS+= ntpd
  1196. CHECK_UIDS+= proxy
  1197. CHECK_GIDS+= proxy authpf
  1198. CHECK_UIDS+= smmsp
  1199. CHECK_GIDS+= smmsp
  1200. CHECK_UIDS+= unbound
  1201. CHECK_GIDS+= unbound
  1202. _installcheck_world: __installcheck_UGID
  1203. __installcheck_UGID: .PHONY
  1204. .for uid in ${CHECK_UIDS}
  1205. @if ! `id -u ${uid} >/dev/null 2>&1`; then \
  1206. echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
  1207. false; \
  1208. fi
  1209. .endfor
  1210. .for gid in ${CHECK_GIDS}
  1211. @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
  1212. echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
  1213. false; \
  1214. fi
  1215. .endfor
  1216. .endif
  1217. #
  1218. # If installing over the running system (DESTDIR is / or unset) and the install
  1219. # includes rescue, try running rescue from the objdir as a sanity check. If
  1220. # rescue is not functional (e.g., because it depends on a system call not
  1221. # supported by the currently running kernel), abort the installation.
  1222. #
  1223. .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
  1224. (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
  1225. _installcheck_world: __installcheck_sh_check
  1226. __installcheck_sh_check: .PHONY
  1227. @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
  1228. OK ]; then \
  1229. echo "rescue/sh check failed, installation aborted" >&2; \
  1230. false; \
  1231. fi
  1232. .endif
  1233. #
  1234. # Required install tools to be saved in a scratch dir for safety.
  1235. #
  1236. .if ${MK_ZONEINFO} != "no"
  1237. _zoneinfo= zic tzsetup
  1238. .endif
  1239. ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
  1240. date echo egrep find grep id install ${_install-info} \
  1241. ln make mkdir mtree mv pwd_mkdb \
  1242. rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \
  1243. ${LOCAL_ITOOLS}
  1244. # Needed for share/man
  1245. .if ${MK_MAN_UTILS} != "no"
  1246. ITOOLS+=makewhatis
  1247. .endif
  1248. #
  1249. # distributeworld
  1250. #
  1251. # Distributes everything compiled by a `buildworld'.
  1252. #
  1253. # installworld
  1254. #
  1255. # Installs everything compiled by a 'buildworld'.
  1256. #
  1257. # Non-base distributions produced by the base system
  1258. EXTRA_DISTRIBUTIONS=
  1259. .if defined(_LIBCOMPAT)
  1260. EXTRA_DISTRIBUTIONS+= lib${libcompat}
  1261. .endif
  1262. .if ${MK_TESTS} != "no"
  1263. EXTRA_DISTRIBUTIONS+= tests
  1264. .endif
  1265. DEBUG_DISTRIBUTIONS=
  1266. .if ${MK_DEBUG_FILES} != "no"
  1267. DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
  1268. .endif
  1269. MTREE_MAGIC?= mtree 2.0
  1270. distributeworld installworld stageworld: _installcheck_world .PHONY
  1271. mkdir -p ${INSTALLTMP}
  1272. progs=$$(for prog in ${ITOOLS}; do \
  1273. if progpath=`which $$prog`; then \
  1274. echo $$progpath; \
  1275. else \
  1276. echo "Required tool $$prog not found in PATH." >&2; \
  1277. exit 1; \
  1278. fi; \
  1279. done); \
  1280. libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
  1281. while read line; do \
  1282. set -- $$line; \
  1283. if [ "$$2 $$3" != "not found" ]; then \
  1284. echo $$2; \
  1285. else \
  1286. echo "Required library $$1 not found." >&2; \
  1287. exit 1; \
  1288. fi; \
  1289. done); \
  1290. cp $$libs $$progs ${INSTALLTMP}
  1291. cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
  1292. .if defined(NO_ROOT)
  1293. -mkdir -p ${METALOG:H}
  1294. echo "#${MTREE_MAGIC}" > ${METALOG}
  1295. .endif
  1296. .if make(distributeworld)
  1297. .for dist in ${EXTRA_DISTRIBUTIONS}
  1298. -mkdir ${DESTDIR}/${DISTDIR}/${dist}
  1299. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
  1300. -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
  1301. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  1302. -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
  1303. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  1304. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
  1305. .if ${MK_DEBUG_FILES} != "no"
  1306. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
  1307. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
  1308. .endif
  1309. .if defined(_LIBCOMPAT)
  1310. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  1311. -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
  1312. .if ${MK_DEBUG_FILES} != "no"
  1313. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  1314. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
  1315. .endif
  1316. .endif
  1317. .if ${MK_TESTS} != "no" && ${dist} == "tests"
  1318. -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
  1319. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  1320. -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
  1321. .if ${MK_DEBUG_FILES} != "no"
  1322. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  1323. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
  1324. .endif
  1325. .endif
  1326. .if defined(NO_ROOT)
  1327. ${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
  1328. sed -e 's#^\./#./${dist}/#' >> ${METALOG}
  1329. ${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
  1330. sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
  1331. ${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
  1332. sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
  1333. .if defined(_LIBCOMPAT)
  1334. ${IMAKEENV} ${MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
  1335. sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
  1336. .endif
  1337. .endif
  1338. .endfor
  1339. -mkdir ${DESTDIR}/${DISTDIR}/base
  1340. ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
  1341. METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
  1342. DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
  1343. LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
  1344. ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
  1345. .endif
  1346. ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
  1347. ${IMAKEENV} rm -rf ${INSTALLTMP}
  1348. .if make(distributeworld)
  1349. .for dist in ${EXTRA_DISTRIBUTIONS}
  1350. find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
  1351. .endfor
  1352. .if defined(NO_ROOT)
  1353. .for dist in base ${EXTRA_DISTRIBUTIONS}
  1354. @# For each file that exists in this dist, print the corresponding
  1355. @# line from the METALOG. This relies on the fact that
  1356. @# a line containing only the filename will sort immediately before
  1357. @# the relevant mtree line.
  1358. cd ${DESTDIR}/${DISTDIR}; \
  1359. find ./${dist} | sort -u ${METALOG} - | \
  1360. awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
  1361. ${DESTDIR}/${DISTDIR}/${dist}.meta
  1362. .endfor
  1363. .for dist in ${DEBUG_DISTRIBUTIONS}
  1364. @# For each file that exists in this dist, print the corresponding
  1365. @# line from the METALOG. This relies on the fact that
  1366. @# a line containing only the filename will sort immediately before
  1367. @# the relevant mtree line.
  1368. cd ${DESTDIR}/${DISTDIR}; \
  1369. find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
  1370. awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
  1371. ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
  1372. .endfor
  1373. .endif
  1374. .endif
  1375. packageworld: .PHONY
  1376. .for dist in base ${EXTRA_DISTRIBUTIONS}
  1377. .if defined(NO_ROOT)
  1378. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1379. tar cvf - --exclude usr/lib/debug \
  1380. @${DESTDIR}/${DISTDIR}/${dist}.meta | \
  1381. ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
  1382. .else
  1383. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1384. tar cvf - --exclude usr/lib/debug . | \
  1385. ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
  1386. .endif
  1387. .endfor
  1388. .for dist in ${DEBUG_DISTRIBUTIONS}
  1389. . if defined(NO_ROOT)
  1390. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1391. tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
  1392. ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
  1393. . else
  1394. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1395. tar cvLf - usr/lib/debug | \
  1396. ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
  1397. . endif
  1398. .endfor
  1399. makeman: .PHONY
  1400. ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
  1401. ${.CURDIR}/share/man/man5/src.conf.5
  1402. .if make(sysent)
  1403. .include <src.lua.mk>
  1404. .endif
  1405. _sysent_PATH= ${WORLDTMP}/legacy/usr/libexec:/usr/libexec:${PATH}
  1406. _sysent_dirs= sys/kern
  1407. _sysent_dirs+= sys/compat/freebsd32
  1408. _sysent_dirs+= sys/compat/cloudabi32 \
  1409. sys/compat/cloudabi64
  1410. _sysent_dirs+= sys/amd64/linux \
  1411. sys/amd64/linux32 \
  1412. sys/arm/linux \
  1413. sys/arm64/linux \
  1414. sys/i386/linux
  1415. sysent: .PHONY
  1416. .for _dir in ${_sysent_dirs}
  1417. @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
  1418. ${_+_}@env PATH=${_sysent_PATH} LUA=${LUA_CMD} \
  1419. ${MAKE} -C ${.CURDIR}/${_dir} sysent
  1420. .endfor
  1421. #
  1422. # reinstall
  1423. #
  1424. # If you have a build server, you can NFS mount the source and obj directories
  1425. # and do a 'make reinstall' on the *client* to install new binaries from the
  1426. # most recent server build.
  1427. #
  1428. restage reinstall: .MAKE .PHONY
  1429. @echo "--------------------------------------------------------------"
  1430. @echo ">>> Making hierarchy"
  1431. @echo "--------------------------------------------------------------"
  1432. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
  1433. LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
  1434. .if make(restage)
  1435. @echo "--------------------------------------------------------------"
  1436. @echo ">>> Making distribution"
  1437. @echo "--------------------------------------------------------------"
  1438. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
  1439. LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
  1440. .endif
  1441. @echo
  1442. @echo "--------------------------------------------------------------"
  1443. @echo ">>> Installing everything started on `LC_ALL=C date`"
  1444. @echo "--------------------------------------------------------------"
  1445. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
  1446. .if defined(_LIBCOMPAT)
  1447. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
  1448. .endif
  1449. @echo "--------------------------------------------------------------"
  1450. @echo ">>> Installing everything completed on `LC_ALL=C date`"
  1451. @echo "--------------------------------------------------------------"
  1452. redistribute: .MAKE .PHONY
  1453. @echo "--------------------------------------------------------------"
  1454. @echo ">>> Distributing everything"
  1455. @echo "--------------------------------------------------------------"
  1456. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
  1457. .if defined(_LIBCOMPAT)
  1458. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
  1459. DISTRIBUTION=lib${libcompat}
  1460. .endif
  1461. distrib-dirs distribution: .MAKE .PHONY
  1462. ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
  1463. ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
  1464. .if make(distribution)
  1465. ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
  1466. ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
  1467. METALOG=${METALOG} MK_TESTS=no installconfig
  1468. .endif
  1469. #
  1470. # buildkernel and installkernel
  1471. #
  1472. # Which kernels to build and/or install is specified by setting
  1473. # KERNCONF. If not defined a GENERIC kernel is built/installed.
  1474. # Only the existing (depending TARGET) config files are used
  1475. # for building kernels and only the first of these is designated
  1476. # as the one being installed.
  1477. #
  1478. # Note that we have to use TARGET instead of TARGET_ARCH when
  1479. # we're in kernel-land. Since only TARGET_ARCH is (expected) to
  1480. # be set to cross-build, we have to make sure TARGET is set
  1481. # properly.
  1482. .if defined(KERNFAST)
  1483. NO_KERNELCLEAN= t
  1484. NO_KERNELCONFIG= t
  1485. NO_KERNELOBJ= t
  1486. # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
  1487. .if !defined(KERNCONF) && ${KERNFAST} != "1"
  1488. KERNCONF=${KERNFAST}
  1489. .endif
  1490. .endif
  1491. .if ${TARGET_ARCH} == "powerpc64"
  1492. KERNCONF?= HARDENEDBSD64
  1493. .else
  1494. KERNCONF?= HARDENEDBSD
  1495. .endif
  1496. INSTKERNNAME?= kernel
  1497. KERNSRCDIR?= ${.CURDIR}/sys
  1498. KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
  1499. KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
  1500. KERNCONFDIR?= ${KRNLCONFDIR}
  1501. BUILDKERNELS=
  1502. INSTALLKERNEL=
  1503. .if defined(NO_INSTALLKERNEL)
  1504. # All of the BUILDKERNELS loops start at index 1.
  1505. BUILDKERNELS+= dummy
  1506. .endif
  1507. .for _kernel in ${KERNCONF}
  1508. .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
  1509. BUILDKERNELS+= ${_kernel}
  1510. .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
  1511. INSTALLKERNEL= ${_kernel}
  1512. .endif
  1513. .else
  1514. .if make(buildkernel)
  1515. .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
  1516. .endif
  1517. .endif
  1518. .endfor
  1519. _cleankernobj_fast_depend_hack: .PHONY
  1520. # 20180320 remove stale generated assym.s after renaming to .inc in r331254
  1521. @if [ -e "${OBJTOP}/sys/${KERNCONF}/assym.s" ]; then \
  1522. echo "Removing stale generated assym files"; \
  1523. rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \
  1524. ${OBJTOP}/sys/${KERNCONF}/.depend.assym.*; \
  1525. fi
  1526. # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
  1527. .if ${MACHINE} != i386
  1528. .for f in opensolaris_atomic
  1529. .for m in opensolaris zfs
  1530. @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
  1531. grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
  1532. echo "Removing stale dependencies for opensolaris_atomic"; \
  1533. rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
  1534. fi
  1535. .endfor
  1536. .endfor
  1537. .endif
  1538. ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
  1539. # record kernel(s) build time in seconds
  1540. .if make(buildkernel)
  1541. _BUILDKERNEL_START!= date '+%s'
  1542. .endif
  1543. #
  1544. # buildkernel
  1545. #
  1546. # Builds all kernels defined by BUILDKERNELS.
  1547. #
  1548. buildkernel: .MAKE .PHONY
  1549. .if empty(BUILDKERNELS:Ndummy)
  1550. @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
  1551. false
  1552. .endif
  1553. @echo
  1554. .for _kernel in ${BUILDKERNELS:Ndummy}
  1555. @echo "--------------------------------------------------------------"
  1556. @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
  1557. @echo "--------------------------------------------------------------"
  1558. @echo "===> ${_kernel}"
  1559. mkdir -p ${KRNLOBJDIR}
  1560. .if !defined(NO_KERNELCONFIG)
  1561. @echo
  1562. @echo "--------------------------------------------------------------"
  1563. @echo ">>> stage 1: configuring the kernel"
  1564. @echo "--------------------------------------------------------------"
  1565. cd ${KRNLCONFDIR}; \
  1566. PATH=${TMPPATH} \
  1567. config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
  1568. -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
  1569. '${KERNCONFDIR}/${_kernel}'
  1570. .endif
  1571. .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
  1572. @echo
  1573. @echo "--------------------------------------------------------------"
  1574. @echo ">>> stage 2.1: cleaning up the object tree"
  1575. @echo "--------------------------------------------------------------"
  1576. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
  1577. .else
  1578. ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
  1579. .endif
  1580. .if !defined(NO_KERNELOBJ)
  1581. @echo
  1582. @echo "--------------------------------------------------------------"
  1583. @echo ">>> stage 2.2: rebuilding the object tree"
  1584. @echo "--------------------------------------------------------------"
  1585. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
  1586. .endif
  1587. @echo
  1588. @echo "--------------------------------------------------------------"
  1589. @echo ">>> stage 2.3: build tools"
  1590. @echo "--------------------------------------------------------------"
  1591. ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
  1592. @echo
  1593. @echo "--------------------------------------------------------------"
  1594. @echo ">>> stage 3.1: building everything"
  1595. @echo "--------------------------------------------------------------"
  1596. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
  1597. @echo "--------------------------------------------------------------"
  1598. @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
  1599. @echo "--------------------------------------------------------------"
  1600. .endfor
  1601. @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
  1602. echo -n ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, "; \
  1603. echo "ncpu: $$(sysctl -n hw.ncpu)${.MAKE.JOBS:S/^/, make -j/}"
  1604. @echo "--------------------------------------------------------------"
  1605. NO_INSTALLEXTRAKERNELS?= yes
  1606. #
  1607. # installkernel, etc.
  1608. #
  1609. # Install the kernel defined by INSTALLKERNEL
  1610. #
  1611. installkernel installkernel.debug \
  1612. reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
  1613. .if !defined(NO_INSTALLKERNEL)
  1614. .if empty(INSTALLKERNEL)
  1615. @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
  1616. false
  1617. .endif
  1618. @echo "--------------------------------------------------------------"
  1619. @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
  1620. @echo "--------------------------------------------------------------"
  1621. ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
  1622. ${CROSSENV} PATH=${TMPPATH} \
  1623. ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
  1624. @echo "--------------------------------------------------------------"
  1625. @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
  1626. @echo "--------------------------------------------------------------"
  1627. .endif
  1628. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1629. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1630. @echo "--------------------------------------------------------------"
  1631. @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
  1632. @echo "--------------------------------------------------------------"
  1633. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
  1634. ${CROSSENV} PATH=${TMPPATH} \
  1635. ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
  1636. @echo "--------------------------------------------------------------"
  1637. @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
  1638. @echo "--------------------------------------------------------------"
  1639. .endfor
  1640. .endif
  1641. distributekernel distributekernel.debug: .PHONY
  1642. .if !defined(NO_INSTALLKERNEL)
  1643. .if empty(INSTALLKERNEL)
  1644. @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
  1645. false
  1646. .endif
  1647. mkdir -p ${DESTDIR}/${DISTDIR}
  1648. .if defined(NO_ROOT)
  1649. @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
  1650. .endif
  1651. ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
  1652. ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
  1653. ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
  1654. DESTDIR=${INSTALL_DDIR}/kernel \
  1655. ${.TARGET:S/distributekernel/install/}
  1656. .if defined(NO_ROOT)
  1657. @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
  1658. ${DESTDIR}/${DISTDIR}/kernel.meta
  1659. .endif
  1660. .endif
  1661. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1662. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1663. .if defined(NO_ROOT)
  1664. @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
  1665. .endif
  1666. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
  1667. ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
  1668. ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
  1669. KERNEL=${INSTKERNNAME}.${_kernel} \
  1670. DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
  1671. ${.TARGET:S/distributekernel/install/}
  1672. .if defined(NO_ROOT)
  1673. @sed -e "s|^./kernel.${_kernel}|.|" \
  1674. ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
  1675. ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
  1676. .endif
  1677. .endfor
  1678. .endif
  1679. packagekernel: .PHONY
  1680. .if defined(NO_ROOT)
  1681. .if !defined(NO_INSTALLKERNEL)
  1682. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1683. tar cvf - --exclude '*.debug' \
  1684. @${DESTDIR}/${DISTDIR}/kernel.meta | \
  1685. ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
  1686. .endif
  1687. .if ${MK_DEBUG_FILES} != "no"
  1688. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1689. tar cvf - --include '*/*/*.debug' \
  1690. @${DESTDIR}/${DISTDIR}/kernel.meta | \
  1691. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
  1692. .endif
  1693. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1694. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1695. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1696. tar cvf - --exclude '*.debug' \
  1697. @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
  1698. ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
  1699. .if ${MK_DEBUG_FILES} != "no"
  1700. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1701. tar cvf - --include '*/*/*.debug' \
  1702. @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
  1703. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
  1704. .endif
  1705. .endfor
  1706. .endif
  1707. .else
  1708. .if !defined(NO_INSTALLKERNEL)
  1709. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1710. tar cvf - --exclude '*.debug' . | \
  1711. ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
  1712. .endif
  1713. .if ${MK_DEBUG_FILES} != "no"
  1714. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1715. tar cvf - --include '*/*/*.debug' $$(eval find .) | \
  1716. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
  1717. .endif
  1718. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1719. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1720. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1721. tar cvf - --exclude '*.debug' . | \
  1722. ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
  1723. .if ${MK_DEBUG_FILES} != "no"
  1724. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1725. tar cvf - --include '*/*/*.debug' $$(eval find .) | \
  1726. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
  1727. .endif
  1728. .endfor
  1729. .endif
  1730. .endif
  1731. stagekernel: .PHONY
  1732. ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
  1733. PORTSDIR?= /usr/ports
  1734. WSTAGEDIR?= ${OBJTOP}/worldstage
  1735. KSTAGEDIR?= ${OBJTOP}/kernelstage
  1736. REPODIR?= ${OBJROOT}repo
  1737. PKGSIGNKEY?= # empty
  1738. .ORDER: stage-packages create-packages
  1739. .ORDER: create-packages create-world-packages
  1740. .ORDER: create-packages create-kernel-packages
  1741. .ORDER: create-packages sign-packages
  1742. _pkgbootstrap: .PHONY
  1743. .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
  1744. @env ASSUME_ALWAYS_YES=YES pkg bootstrap
  1745. .endif
  1746. packages: .PHONY
  1747. ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
  1748. package-pkg: .PHONY
  1749. rm -rf /tmp/ports.${TARGET} || :
  1750. env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
  1751. PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
  1752. WSTAGEDIR=${WSTAGEDIR} \
  1753. sh ${.CURDIR}/release/scripts/make-pkg-package.sh
  1754. real-packages: stage-packages create-packages sign-packages .PHONY
  1755. stage-packages-world: .PHONY
  1756. @mkdir -p ${WSTAGEDIR}
  1757. ${_+_}@cd ${.CURDIR}; \
  1758. ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
  1759. stage-packages-kernel: .PHONY
  1760. @mkdir -p ${KSTAGEDIR}
  1761. ${_+_}@cd ${.CURDIR}; \
  1762. ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
  1763. stage-packages: .PHONY stage-packages-world stage-packages-kernel
  1764. _repodir: .PHONY
  1765. @mkdir -p ${REPODIR}
  1766. create-packages-world: _pkgbootstrap _repodir .PHONY
  1767. ${_+_}@cd ${.CURDIR}; \
  1768. ${MAKE} -f Makefile.inc1 \
  1769. DESTDIR=${WSTAGEDIR} \
  1770. PKG_VERSION=${PKG_VERSION} create-world-packages
  1771. create-packages-kernel: _pkgbootstrap _repodir .PHONY
  1772. ${_+_}@cd ${.CURDIR}; \
  1773. ${MAKE} -f Makefile.inc1 \
  1774. DESTDIR=${KSTAGEDIR} \
  1775. PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
  1776. create-kernel-packages
  1777. create-packages: .PHONY create-packages-world create-packages-kernel
  1778. create-world-packages: _pkgbootstrap .PHONY
  1779. @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
  1780. @cd ${WSTAGEDIR} ; \
  1781. env -i LC_COLLATE=C sort ${WSTAGEDIR}/${DISTDIR}/METALOG | \
  1782. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
  1783. @for plist in ${WSTAGEDIR}/*.plist; do \
  1784. plist=$${plist##*/} ; \
  1785. pkgname=$${plist%.plist} ; \
  1786. echo "_PKGS+= $${pkgname}" ; \
  1787. done > ${WSTAGEDIR}/packages.mk
  1788. ${_+_}@cd ${.CURDIR}; \
  1789. ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
  1790. .MAKE.JOB.PREFIX=
  1791. .if make(create-world-packages-jobs)
  1792. .include "${WSTAGEDIR}/packages.mk"
  1793. .endif
  1794. create-world-packages-jobs: .PHONY
  1795. .for pkgname in ${_PKGS}
  1796. create-world-packages-jobs: create-world-package-${pkgname}
  1797. create-world-package-${pkgname}: .PHONY
  1798. @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
  1799. -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
  1800. @awk -F\" ' \
  1801. /^name/ { printf("===> Creating %s-", $$2); next } \
  1802. /^version/ { print $$2; next } \
  1803. ' ${WSTAGEDIR}/${pkgname}.ucl
  1804. @if [ "${pkgname}" == "runtime" ]; then \
  1805. sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
  1806. fi
  1807. ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
  1808. create -M ${WSTAGEDIR}/${pkgname}.ucl \
  1809. -p ${WSTAGEDIR}/${pkgname}.plist \
  1810. -r ${WSTAGEDIR} \
  1811. -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION}
  1812. .endfor
  1813. _default_flavor= -default
  1814. .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
  1815. . if ${MK_DEBUG_FILES} != "no"
  1816. _debug=-debug
  1817. . endif
  1818. create-kernel-packages: .PHONY
  1819. . for flavor in "" ${_debug}
  1820. create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
  1821. create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
  1822. @cd ${KSTAGEDIR}/${DISTDIR} ; \
  1823. env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
  1824. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
  1825. -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
  1826. sed -e "s/%VERSION%/${PKG_VERSION}/" \
  1827. -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
  1828. -e "s/%KERNELDIR%/kernel/" \
  1829. -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
  1830. -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
  1831. -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
  1832. ${SRCDIR}/release/packages/kernel.ucl \
  1833. > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
  1834. awk -F\" ' \
  1835. /name/ { printf("===> Creating %s-", $$2); next } \
  1836. /version/ {print $$2; next } ' \
  1837. ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
  1838. ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
  1839. create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
  1840. -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
  1841. -r ${KSTAGEDIR}/${DISTDIR} \
  1842. -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION}
  1843. . endfor
  1844. .endif
  1845. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1846. . for _kernel in ${BUILDKERNELS:[2..-1]}
  1847. . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
  1848. . if ${MK_DEBUG_FILES} != "no"
  1849. _debug=-debug
  1850. . endif
  1851. . for flavor in "" ${_debug}
  1852. create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
  1853. create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
  1854. @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
  1855. env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
  1856. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
  1857. -v kernel=yes -v _kernconf=${_kernel} ; \
  1858. sed -e "s/%VERSION%/${PKG_VERSION}/" \
  1859. -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
  1860. -e "s/%KERNELDIR%/kernel.${_kernel}/" \
  1861. -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
  1862. -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
  1863. -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
  1864. ${SRCDIR}/release/packages/kernel.ucl \
  1865. > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
  1866. awk -F\" ' \
  1867. /name/ { printf("===> Creating %s-", $$2); next } \
  1868. /version/ {print $$2; next } ' \
  1869. ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
  1870. ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
  1871. create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
  1872. -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
  1873. -r ${KSTAGEDIR}/kernel.${_kernel} \
  1874. -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION}
  1875. . endfor
  1876. . endif
  1877. . endfor
  1878. .endif
  1879. sign-packages: _pkgbootstrap .PHONY
  1880. @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest" ] && \
  1881. unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest ; \
  1882. ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname repo \
  1883. -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
  1884. ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
  1885. ${PKGSIGNKEY} ; \
  1886. cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI); \
  1887. ln -s ${PKG_VERSION} latest
  1888. #
  1889. #
  1890. # checkworld
  1891. #
  1892. # Run test suite on installed world.
  1893. #
  1894. checkworld: .PHONY
  1895. @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
  1896. echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
  1897. exit 1; \
  1898. fi
  1899. ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
  1900. #
  1901. #
  1902. # doxygen
  1903. #
  1904. # Build the API documentation with doxygen
  1905. #
  1906. doxygen: .PHONY
  1907. @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
  1908. echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
  1909. exit 1; \
  1910. fi
  1911. ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
  1912. #
  1913. # update
  1914. #
  1915. # Update the source tree(s), by running svn/svnup to update to the
  1916. # latest copy.
  1917. #
  1918. update: .PHONY
  1919. .if defined(SVN_UPDATE)
  1920. @echo "--------------------------------------------------------------"
  1921. @echo ">>> Updating ${.CURDIR} using Subversion"
  1922. @echo "--------------------------------------------------------------"
  1923. @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS})
  1924. .endif
  1925. #
  1926. # ------------------------------------------------------------------------
  1927. #
  1928. # From here onwards are utility targets used by the 'make world' and
  1929. # related targets. If your 'world' breaks, you may like to try to fix
  1930. # the problem and manually run the following targets to attempt to
  1931. # complete the build. Beware, this is *not* guaranteed to work, you
  1932. # need to have a pretty good grip on the current state of the system
  1933. # to attempt to manually finish it. If in doubt, 'make world' again.
  1934. #
  1935. #
  1936. # legacy: Build compatibility shims for the next three targets. This is a
  1937. # minimal set of tools and shims necessary to compensate for older systems
  1938. # which don't have the APIs required by the targets built in bootstrap-tools,
  1939. # build-tools or cross-tools.
  1940. #
  1941. # libnv and libl are both requirements for config(8), which is an unconditional
  1942. # bootstrap-tool.
  1943. _config_deps= lib/libnv usr.bin/lex/lib
  1944. legacy: .PHONY
  1945. .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
  1946. @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
  1947. false
  1948. .endif
  1949. .for _tool in tools/build ${_config_deps}
  1950. ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
  1951. cd ${.CURDIR}/${_tool}; \
  1952. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  1953. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
  1954. ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
  1955. ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
  1956. DESTDIR=${WORLDTMP}/legacy install
  1957. .endfor
  1958. #
  1959. # bootstrap-tools: Build tools needed for compatibility. These are binaries that
  1960. # are built to build other binaries in the system. However, the focus of these
  1961. # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
  1962. # libraries, augmented by -legacy, in addition to the libraries built during
  1963. # bootstrap-tools.
  1964. #
  1965. _bt= _bootstrap-tools
  1966. # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
  1967. # accidentally run tools that are incompatible but happen to be in $PATH.
  1968. # This is especially important when building on Linux/MacOS where many of the
  1969. # programs used during the build accept different flags or generate different
  1970. # output. On those platforms we only symlink the tools known to be compatible
  1971. # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
  1972. # from the FreeBSD sources during the bootstrap-tools stage.
  1973. # We want to build without the user's $PATH starting in the bootstrap-tools
  1974. # phase so the tools used in that phase (ln, cp, etc) must have already been
  1975. # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
  1976. # variable in tools/build/Makefile and are linked during the legacy phase.
  1977. # Since they could be Linux or MacOS binaries, too we must only use flags that
  1978. # are portable across operating systems.
  1979. # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
  1980. # current source tree. Otherwise we create a symlink to the version found in
  1981. # $PATH during the bootstrap-tools stage.
  1982. .if defined(BOOTSTRAP_ALL_TOOLS)
  1983. # BOOTSTRAPPING will be set on the command line so we can't override it here.
  1984. # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
  1985. BOOTSTRAPPING_OSRELDATE:= 0
  1986. .endif
  1987. .if ${MK_GAMES} != "no"
  1988. _strfile= usr.bin/fortune/strfile
  1989. .endif
  1990. .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
  1991. _gperf= gnu/usr.bin/gperf
  1992. .endif
  1993. .if ${MK_VT} != "no"
  1994. _vtfontcvt= usr.bin/vtfontcvt
  1995. .endif
  1996. # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
  1997. # we symlink the host version to $WORLDTMP instead. By doing this we can also
  1998. # detect when a bootstrap tool is being used without the required MK_FOO.
  1999. # If you add a new bootstrap tool where we could also use the host version,
  2000. # please ensure that you also add a .else case where you add the tool to the
  2001. # _bootstrap_tools_links variable.
  2002. .if ${BOOTSTRAPPING} < 1000033
  2003. _m4= usr.bin/m4
  2004. _lex= usr.bin/lex
  2005. # Note: lex needs m4 to build but m4 also depends on lex. However, lex can be
  2006. # bootstrapped so we build lex first.
  2007. ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-${_lex}
  2008. _bt_m4_depend=${_bt}-${_m4}
  2009. _bt_lex_depend=${_bt}-${_lex} ${_bt_m4_depend}
  2010. .else
  2011. _bootstrap_tools_links+=m4 lex
  2012. .endif
  2013. # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
  2014. # r296685 fix cross-endian objcopy
  2015. # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
  2016. # r334881 added libdwarf constants used by ctfconvert.
  2017. # r338478 fixed a crash in objcopy for mips64el objects
  2018. # r339083 libelf: correct mips64el test to use ELF header
  2019. # r348347 Add missing powerpc64 relocation support to libdwarf
  2020. .if ${BOOTSTRAPPING} < 1300030
  2021. _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
  2022. ${_bt}-lib/libelf: ${_bt_m4_depend}
  2023. ${_bt}-lib/libdwarf: ${_bt_m4_depend}
  2024. .endif
  2025. # flua is required to regenerate syscall files. It first appeared during the
  2026. # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
  2027. # branches.
  2028. .if ${BOOTSTRAPPING} < 1300059
  2029. _flua= libexec/flua
  2030. .endif
  2031. # r245440 mtree -N support added
  2032. # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
  2033. .if ${BOOTSTRAPPING} < 1100093
  2034. _nmtree= lib/libmd \
  2035. lib/libnetbsd \
  2036. usr.sbin/nmtree
  2037. ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
  2038. ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
  2039. .else
  2040. _bootstrap_tools_links+=mtree
  2041. .endif
  2042. # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
  2043. .if ${BOOTSTRAPPING} < 1000027
  2044. _cat= bin/cat
  2045. .else
  2046. _bootstrap_tools_links+=cat
  2047. .endif
  2048. # r277259 crunchide: Correct 64-bit section header offset
  2049. # r281674 crunchide: always include both 32- and 64-bit ELF support
  2050. .if ${BOOTSTRAPPING} < 1100078
  2051. _crunchide= usr.sbin/crunch/crunchide
  2052. .else
  2053. _bootstrap_tools_links+=crunchide
  2054. .endif
  2055. # r285986 crunchen: use STRIPBIN rather than STRIP
  2056. # 1100113: Support MK_AUTO_OBJ
  2057. # 1200006: META_MODE fixes
  2058. .if ${BOOTSTRAPPING} < 1100078 || \
  2059. (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
  2060. (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
  2061. _crunchgen= usr.sbin/crunch/crunchgen
  2062. .else
  2063. _bootstrap_tools_links+=crunchgen
  2064. .endif
  2065. # r296926 -P keymap search path, MFC to stable/10 in r298297
  2066. .if ${BOOTSTRAPPING} < 1003501 || \
  2067. (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
  2068. _kbdcontrol= usr.sbin/kbdcontrol
  2069. .else
  2070. _bootstrap_tools_links+=kbdcontrol
  2071. .endif
  2072. _yacc= lib/liby \
  2073. usr.bin/yacc
  2074. ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
  2075. .if ${MK_BSNMP} != "no"
  2076. _gensnmptree= usr.sbin/bsnmpd/gensnmptree
  2077. .endif
  2078. .if ${MK_LOCALES} != "no"
  2079. _localedef= usr.bin/localedef
  2080. .endif
  2081. # We need to build tblgen when we're building clang or lld, either as
  2082. # bootstrap tools, or as the part of the normal build.
  2083. .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
  2084. ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
  2085. _clang_tblgen= \
  2086. lib/clang/libllvmminimal \
  2087. usr.bin/clang/llvm-tblgen \
  2088. usr.bin/clang/clang-tblgen \
  2089. usr.bin/clang/lldb-tblgen
  2090. # XXX: lldb-tblgen is not needed, if top-level MK_LLDB=no
  2091. ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
  2092. ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
  2093. ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
  2094. .endif
  2095. # Build BSDL or GPL DTC depending on GPL_DTC option.
  2096. _dtc= usr.bin/dtc
  2097. .if ${MK_GPL_DTC} != "no"
  2098. _dtc= gnu/usr.bin/dtc
  2099. .endif
  2100. .if ${MK_LOCALES} != "no"
  2101. _localedef= usr.bin/localedef
  2102. .endif
  2103. .if ${MK_KERBEROS} != "no"
  2104. _kerberos5_bootstrap_tools= \
  2105. kerberos5/tools/make-roken \
  2106. kerberos5/lib/libroken \
  2107. kerberos5/lib/libvers \
  2108. kerberos5/tools/asn1_compile \
  2109. kerberos5/tools/slc \
  2110. usr.bin/compile_et
  2111. .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
  2112. .for _tool in ${_kerberos5_bootstrap_tools}
  2113. ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
  2114. .endfor
  2115. .endif
  2116. ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
  2117. # The tools listed in _basic_bootstrap_tools will generally not be
  2118. # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
  2119. # Linux or MacOS host the host versions are incompatible so we need to build
  2120. # them from the source tree. Usually the link name will be the same as the subdir,
  2121. # but some directories such as grep or test install multiple binaries. In that
  2122. # case we use the _basic_bootstrap_tools_multilink variable which is a list of
  2123. # subdirectory and comma-separated list of files.
  2124. _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
  2125. _basic_bootstrap_tools_multilink+=bin/test test,[
  2126. # bootstrap tools needed by buildworld:
  2127. _basic_bootstrap_tools=usr.bin/awk usr.bin/cut bin/expr usr.bin/gencat \
  2128. usr.bin/join usr.bin/mktemp bin/rmdir usr.bin/sed usr.bin/sort \
  2129. usr.bin/truncate usr.bin/tsort
  2130. # elf2aout is required for sparc64 build
  2131. _basic_bootstrap_tools+=usr.bin/elf2aout
  2132. # file2c is required for building usr.sbin/config:
  2133. _basic_bootstrap_tools+=usr.bin/file2c
  2134. # uuencode/uudecode required for share/tabset
  2135. _basic_bootstrap_tools+=usr.bin/uuencode usr.bin/uudecode
  2136. # xargs is required by mkioctls
  2137. _basic_bootstrap_tools+=usr.bin/xargs
  2138. # cap_mkdb is required for share/termcap:
  2139. _basic_bootstrap_tools+=usr.bin/cap_mkdb
  2140. # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
  2141. _basic_bootstrap_tools+=usr.bin/ldd
  2142. # services_mkdb/pwd_mkdb are required for installworld:
  2143. _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
  2144. # sysctl/chflags are required for installkernel:
  2145. _basic_bootstrap_tools+=sbin/sysctl bin/chflags
  2146. # mkfifo is used by sys/conf/newvers.sh
  2147. _basic_bootstrap_tools+=usr.bin/mkfifo
  2148. .if ${MK_AMD} != "no"
  2149. # unifdef is only used by usr.sbin/amd/libamu/Makefile
  2150. _basic_bootstrap_tools+=usr.bin/unifdef
  2151. .endif
  2152. .if ${MK_BOOT} != "no"
  2153. _basic_bootstrap_tools+=bin/dd
  2154. # xz/unxz is used by EFI
  2155. _basic_bootstrap_tools_multilink+=usr.bin/xz xz,unxz
  2156. # md5 is used by boot/beri (and possibly others)
  2157. _basic_bootstrap_tools+=sbin/md5
  2158. .if defined(BOOTSTRAP_ALL_TOOLS)
  2159. ${_bt}-sbin/md5: ${_bt}-lib/libmd
  2160. .endif
  2161. .endif
  2162. .if ${MK_ZONEINFO} != "no"
  2163. _basic_bootstrap_tools+=usr.sbin/zic usr.sbin/tzsetup
  2164. .endif
  2165. .if defined(BOOTSTRAP_ALL_TOOLS)
  2166. _other_bootstrap_tools+=${_basic_bootstrap_tools}
  2167. .for _subdir _links in ${_basic_bootstrap_tools_multilink}
  2168. _other_bootstrap_tools+=${_subdir}
  2169. .endfor
  2170. ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
  2171. ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
  2172. # If we are bootstrapping file2c, we have to build it before config:
  2173. ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
  2174. # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
  2175. # the links to make/bmake make links will have already have been created in the
  2176. # `make legacy` step. Not adding a link to make is important on non-FreeBSD
  2177. # since "make" will usually point to GNU make there.
  2178. _other_bootstrap_tools+=usr.bin/bmake
  2179. .else
  2180. # All tools in _basic_bootstrap_tools have the same name as the subdirectory
  2181. # so we can use :T to get the name of the symlinks that we need to create.
  2182. _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
  2183. .for _subdir _links in ${_basic_bootstrap_tools_multilink}
  2184. _bootstrap_tools_links+=${_links:S/,/ /g}
  2185. .endfor
  2186. .endif # defined(BOOTSTRAP_ALL_TOOLS)
  2187. # Link the tools that we need for building but don't need to bootstrap because
  2188. # the host version is known to be compatible into ${WORLDTMP}/legacy
  2189. # We do this before building any of the bootstrap tools in case they depend on
  2190. # the presence of any of the links (e.g. as m4/lex/awk)
  2191. ${_bt}-links: .PHONY
  2192. .for _tool in ${_bootstrap_tools_links}
  2193. ${_bt}-link-${_tool}: .PHONY .MAKE
  2194. @if [ ! -e "${WORLDTMP}/legacy/bin/${_tool}" ]; then \
  2195. source_path=`which ${_tool}`; \
  2196. if [ ! -e "$${source_path}" ] ; then \
  2197. echo "Cannot find host tool '${_tool}'"; false; \
  2198. fi; \
  2199. ln -sfnv "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"; \
  2200. fi
  2201. ${_bt}-links: ${_bt}-link-${_tool}
  2202. .endfor
  2203. bootstrap-tools: ${_bt}-links .PHONY
  2204. # Please document (add comment) why something is in 'bootstrap-tools'.
  2205. # Try to bound the building of the bootstrap-tool to just the
  2206. # FreeBSD versions that need the tool built at this stage of the build.
  2207. .for _tool in \
  2208. ${_clang_tblgen} \
  2209. ${_kerberos5_bootstrap_tools} \
  2210. ${_strfile} \
  2211. ${_gperf} \
  2212. ${_dtc} \
  2213. ${_cat} \
  2214. ${_kbdcontrol} \
  2215. ${_elftoolchain_libs} \
  2216. usr.bin/lorder \
  2217. lib/libopenbsd \
  2218. usr.bin/mandoc \
  2219. usr.bin/rpcgen \
  2220. ${_yacc} \
  2221. ${_m4} \
  2222. ${_lex} \
  2223. ${_other_bootstrap_tools} \
  2224. usr.bin/xinstall \
  2225. ${_gensnmptree} \
  2226. usr.sbin/config \
  2227. ${_flua} \
  2228. ${_crunchide} \
  2229. ${_crunchgen} \
  2230. ${_nmtree} \
  2231. ${_vtfontcvt} \
  2232. ${_localedef}
  2233. ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
  2234. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  2235. cd ${.CURDIR}/${_tool}; \
  2236. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2237. if [ "${_tool}" = "usr.bin/lex" ]; then \
  2238. ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
  2239. fi; \
  2240. ${MAKE} DIRPRFX=${_tool}/ all; \
  2241. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
  2242. bootstrap-tools: ${_bt}-${_tool}
  2243. .endfor
  2244. #
  2245. # build-tools: Build special purpose build tools
  2246. #
  2247. .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
  2248. _share= share/syscons/scrnmaps
  2249. .endif
  2250. .if ${MK_GCC} != "no"
  2251. _gcc_tools= gnu/usr.bin/cc/cc_tools
  2252. .endif
  2253. .if ${MK_RESCUE} != "no"
  2254. # rescue includes programs that have build-tools targets
  2255. _rescue=rescue/rescue
  2256. .endif
  2257. .if ${MK_TCSH} != "no"
  2258. _tcsh=bin/csh
  2259. .endif
  2260. .if ${MK_FILE} != "no"
  2261. _libmagic=lib/libmagic
  2262. .endif
  2263. .if ${MK_PMC} != "no" && \
  2264. (${TARGET_ARCH} == "aarch64" || ${TARGET_ARCH} == "amd64" || \
  2265. ${TARGET_ARCH} == "i386")
  2266. _jevents=lib/libpmc/pmu-events
  2267. .endif
  2268. # kernel-toolchain skips _cleanobj, so handle cleaning up previous
  2269. # build-tools directories if needed.
  2270. .if !defined(NO_CLEAN) && make(kernel-toolchain)
  2271. _bt_clean= ${CLEANDIR}
  2272. .endif
  2273. .for _tool in \
  2274. ${_tcsh} \
  2275. bin/sh \
  2276. ${LOCAL_TOOL_DIRS} \
  2277. ${_jevents} \
  2278. lib/ncurses/ncurses \
  2279. lib/ncurses/ncursesw \
  2280. ${_rescue} \
  2281. ${_share} \
  2282. usr.bin/awk \
  2283. ${_libmagic} \
  2284. usr.bin/mkesdb_static \
  2285. usr.bin/mkcsmapper_static \
  2286. usr.bin/vi/catalog \
  2287. ${_gcc_tools}
  2288. build-tools_${_tool}: .PHONY
  2289. ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
  2290. cd ${.CURDIR}/${_tool}; \
  2291. if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
  2292. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2293. ${MAKE} DIRPRFX=${_tool}/ build-tools
  2294. build-tools: build-tools_${_tool}
  2295. .endfor
  2296. #
  2297. # kernel-tools: Build kernel-building tools
  2298. #
  2299. kernel-tools: .PHONY
  2300. mkdir -p ${WORLDTMP}/usr
  2301. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  2302. -p ${WORLDTMP}/usr >/dev/null
  2303. #
  2304. # cross-tools: All the tools needed to build the rest of the system after
  2305. # we get done with the earlier stages. It is the last set of tools needed
  2306. # to begin building the target binaries.
  2307. #
  2308. .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
  2309. .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
  2310. _btxld= usr.sbin/btxld
  2311. .endif
  2312. .endif
  2313. # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
  2314. # resulting from missing bug fixes or ELF Toolchain updates.
  2315. .if ${MK_CDDL} != "no"
  2316. _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
  2317. cddl/usr.bin/ctfmerge
  2318. .endif
  2319. # If we're given an XAS, don't build binutils.
  2320. .if ${XAS:M/*} == ""
  2321. .if ${MK_BINUTILS_BOOTSTRAP} != "no"
  2322. _binutils= gnu/usr.bin/binutils
  2323. .endif
  2324. .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
  2325. _elftctools= lib/libelftc \
  2326. lib/libpe \
  2327. usr.bin/objcopy \
  2328. usr.bin/nm \
  2329. usr.bin/size \
  2330. usr.bin/strings
  2331. # These are not required by the build, but can be useful for developers who
  2332. # cross-build on a FreeBSD 10 host:
  2333. _elftctools+= usr.bin/addr2line
  2334. .endif
  2335. .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
  2336. # If cross-building with an external binutils we still need to build strip for
  2337. # the target (for at least crunchide).
  2338. _elftctools= lib/libelftc \
  2339. lib/libpe \
  2340. usr.bin/objcopy
  2341. .endif
  2342. .if ${MK_CLANG_BOOTSTRAP} != "no"
  2343. _clang= usr.bin/clang
  2344. .endif
  2345. .if ${MK_LLD_BOOTSTRAP} != "no"
  2346. _lld= usr.bin/clang/lld
  2347. .endif
  2348. .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
  2349. _clang_libs= lib/clang
  2350. .endif
  2351. .if ${MK_GCC_BOOTSTRAP} != "no"
  2352. _gcc= gnu/usr.bin/cc
  2353. .endif
  2354. .if ${MK_USB} != "no"
  2355. _usb_tools= stand/usb/tools
  2356. .endif
  2357. .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
  2358. _ar=usr.bin/ar
  2359. .endif
  2360. cross-tools: .MAKE .PHONY
  2361. .for _tool in \
  2362. ${LOCAL_XTOOL_DIRS} \
  2363. ${_ar} \
  2364. ${_clang_libs} \
  2365. ${_clang} \
  2366. ${_lld} \
  2367. ${_binutils} \
  2368. ${_elftctools} \
  2369. ${_dtrace_tools} \
  2370. ${_gcc} \
  2371. ${_btxld} \
  2372. ${_usb_tools}
  2373. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  2374. cd ${.CURDIR}/${_tool}; \
  2375. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2376. ${MAKE} DIRPRFX=${_tool}/ all; \
  2377. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
  2378. .endfor
  2379. #
  2380. # native-xtools is the current target for qemu-user cross builds of ports
  2381. # via poudriere and the imgact_binmisc kernel module.
  2382. # This target merely builds a toolchan/sysroot, then builds the tools it wants
  2383. # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
  2384. # already built. It then installs the static tools to NXBDESTDIR for Poudriere
  2385. # to pickup.
  2386. #
  2387. NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
  2388. NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
  2389. NXTP?= /nxb-bin
  2390. .if ${NXTP:N/*}
  2391. .error NXTP variable should be an absolute path
  2392. .endif
  2393. NXBDESTDIR?= ${DESTDIR}${NXTP}
  2394. # This is the list of tools to be built/installed as static and where
  2395. # appropriate to build for the given TARGET.TARGET_ARCH.
  2396. NXBDIRS+= \
  2397. bin/cat \
  2398. bin/chmod \
  2399. bin/cp \
  2400. ${_tcsh} \
  2401. bin/echo \
  2402. bin/expr \
  2403. bin/hostname \
  2404. bin/ln \
  2405. bin/ls \
  2406. bin/mkdir \
  2407. bin/mv \
  2408. bin/ps \
  2409. bin/realpath \
  2410. bin/rm \
  2411. bin/rmdir \
  2412. bin/sh \
  2413. bin/sleep \
  2414. sbin/md5 \
  2415. sbin/sysctl \
  2416. usr.bin/addr2line \
  2417. usr.bin/ar \
  2418. usr.bin/awk \
  2419. usr.bin/basename \
  2420. usr.bin/bmake \
  2421. usr.bin/bzip2 \
  2422. usr.bin/cmp \
  2423. usr.bin/diff \
  2424. usr.bin/dirname \
  2425. usr.bin/objcopy \
  2426. usr.bin/env \
  2427. usr.bin/fetch \
  2428. usr.bin/find \
  2429. usr.bin/grep \
  2430. usr.bin/gzip \
  2431. usr.bin/head \
  2432. usr.bin/id \
  2433. usr.bin/lex \
  2434. usr.bin/limits \
  2435. usr.bin/lorder \
  2436. usr.bin/mandoc \
  2437. usr.bin/mktemp \
  2438. usr.bin/mt \
  2439. usr.bin/nm \
  2440. usr.bin/patch \
  2441. usr.bin/readelf \
  2442. usr.bin/sed \
  2443. usr.bin/size \
  2444. usr.bin/sort \
  2445. usr.bin/strings \
  2446. usr.bin/tar \
  2447. usr.bin/touch \
  2448. usr.bin/tr \
  2449. usr.bin/true \
  2450. usr.bin/uniq \
  2451. usr.bin/unzip \
  2452. usr.bin/wc \
  2453. usr.bin/xargs \
  2454. usr.bin/xinstall \
  2455. usr.bin/xz \
  2456. usr.bin/yacc \
  2457. usr.sbin/chown
  2458. SUBDIR_DEPEND_usr.bin/clang= lib/clang
  2459. .if ${MK_CLANG} != "no"
  2460. NXBDIRS+= lib/clang
  2461. NXBDIRS+= usr.bin/clang
  2462. .endif
  2463. .if ${MK_GCC} != "no"
  2464. NXBDIRS+= gnu/usr.bin/cc
  2465. .endif
  2466. .if ${MK_BINUTILS} != "no"
  2467. NXBDIRS+= gnu/usr.bin/binutils
  2468. .endif
  2469. # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
  2470. # to be evaluated after NXBDIRS is set.
  2471. .if make(install) && !empty(SUBDIR_OVERRIDE)
  2472. SUBDIR= ${SUBDIR_OVERRIDE}
  2473. .endif
  2474. NXBMAKEARGS+= \
  2475. OBJTOP=${NXBOBJTOP:Q} \
  2476. OBJROOT=${NXBOBJROOT:Q} \
  2477. MAKEOBJDIRPREFIX= \
  2478. -DNO_SHARED \
  2479. -DNO_CPU_CFLAGS \
  2480. -DNO_PIC \
  2481. SSP_CFLAGS= \
  2482. MK_CASPER=no \
  2483. MK_CLANG_EXTRAS=yes \
  2484. MK_CLANG_FULL=no \
  2485. MK_CTF=no \
  2486. MK_DEBUG_FILES=no \
  2487. MK_GDB=no \
  2488. MK_HTML=no \
  2489. MK_LLDB=no \
  2490. MK_MAN=no \
  2491. MK_MAN_UTILS=yes \
  2492. MK_OFED=no \
  2493. MK_OPENSSH=no \
  2494. MK_PROFILE=no \
  2495. MK_RETPOLINE=no \
  2496. MK_SENDMAIL=no \
  2497. MK_SVNLITE=no \
  2498. MK_TESTS=no \
  2499. MK_WARNS=no \
  2500. MK_ZFS=no
  2501. .if make(native-xtools*) && \
  2502. (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
  2503. .error Missing NXB_TARGET / NXB_TARGET_ARCH
  2504. .endif
  2505. # For 'toolchain' we want to produce native binaries that themselves generate
  2506. # native binaries.
  2507. NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
  2508. TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
  2509. # For 'everything' we want to produce native binaries (hence -target to
  2510. # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
  2511. # TARGET/TARGET_ARCH are still passed along from user.
  2512. #
  2513. # Use the toolchain we create as an external toolchain.
  2514. .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
  2515. NXBMAKE+= XCC="${XCC}" \
  2516. XCXX="${XCXX}" \
  2517. XCPP="${XCPP}"
  2518. .else
  2519. NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
  2520. XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
  2521. XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
  2522. .endif
  2523. NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
  2524. TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
  2525. TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
  2526. # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
  2527. # invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS.
  2528. NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
  2529. # Need to avoid the -isystem logic when using clang as an external toolchain
  2530. # even if the TARGET being built for wants GCC.
  2531. NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
  2532. native-xtools: .PHONY
  2533. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes
  2534. # Build the bootstrap/host/cross tools that produce native binaries
  2535. # Pass along MK_GCC=yes to ensure GCC-needed build tools are built.
  2536. # We don't quite know what the NXB_TARGET wants so just build it.
  2537. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes
  2538. # Populate includes/libraries sysroot that produce native binaries.
  2539. # This is split out from 'toolchain' above mostly so that target LLVM
  2540. # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
  2541. # polluting the cross-compiler build. The LLVM/GCC libs are skipped
  2542. # here to avoid the problem but are kept in 'toolchain' so that
  2543. # needed build tools are built.
  2544. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
  2545. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
  2546. # Clean out improper TARGET=MACHINE files
  2547. ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
  2548. .if !defined(NO_OBJWALK)
  2549. ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
  2550. .endif
  2551. ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
  2552. @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
  2553. native-xtools-install: .PHONY
  2554. mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
  2555. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  2556. -p ${NXBDESTDIR}/usr >/dev/null
  2557. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  2558. -p ${NXBDESTDIR}/usr/include >/dev/null
  2559. ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
  2560. DESTDIR=${NXBDESTDIR} \
  2561. -DNO_ROOT \
  2562. install
  2563. #
  2564. # hierarchy - ensure that all the needed directories are present
  2565. #
  2566. hierarchy hier: .MAKE .PHONY
  2567. ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
  2568. #
  2569. # libraries - build all libraries, and install them under ${DESTDIR}.
  2570. #
  2571. # The list of libraries with dependents (${_prebuild_libs}) and their
  2572. # interdependencies (__L) are built automatically by the
  2573. # ${.CURDIR}/tools/make_libdeps.sh script.
  2574. #
  2575. libraries: .MAKE .PHONY
  2576. ${_+_}cd ${.CURDIR}; \
  2577. ${MAKE} -f Makefile.inc1 _prereq_libs; \
  2578. ${MAKE} -f Makefile.inc1 _startup_libs; \
  2579. ${MAKE} -f Makefile.inc1 _prebuild_libs; \
  2580. ${MAKE} -f Makefile.inc1 _generic_libs
  2581. #
  2582. # static libgcc.a prerequisite for shared libc
  2583. #
  2584. _prereq_libs= lib/libcompiler_rt
  2585. .if ${MK_SSP} != "no"
  2586. _prereq_libs+= gnu/lib/libssp/libssp_nonshared
  2587. .endif
  2588. # These dependencies are not automatically generated:
  2589. #
  2590. # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
  2591. # all shared libraries for ELF.
  2592. #
  2593. _startup_libs= lib/csu
  2594. .if ${MK_BSD_CRTBEGIN} == "no"
  2595. _startup_libs+= gnu/lib/csu
  2596. .endif
  2597. _startup_libs+= lib/libcompiler_rt
  2598. _startup_libs+= lib/libc
  2599. _startup_libs+= lib/libc_nonshared
  2600. .if ${MK_LIBCPLUSPLUS} != "no"
  2601. _startup_libs+= lib/libcxxrt
  2602. .endif
  2603. .if ${MK_LLVM_LIBUNWIND} != "no"
  2604. _prereq_libs+= lib/libgcc_eh lib/libgcc_s
  2605. _startup_libs+= lib/libgcc_eh lib/libgcc_s
  2606. lib/libgcc_s__L: lib/libc__L
  2607. lib/libgcc_s__L: lib/libc_nonshared__L
  2608. .if ${MK_LIBCPLUSPLUS} != "no"
  2609. lib/libcxxrt__L: lib/libgcc_s__L
  2610. .endif
  2611. .else # MK_LLVM_LIBUNWIND == no
  2612. _prereq_libs+= gnu/lib/libgcc
  2613. _startup_libs+= gnu/lib/libgcc
  2614. gnu/lib/libgcc__L: lib/libc__L
  2615. gnu/lib/libgcc__L: lib/libc_nonshared__L
  2616. .if ${MK_LIBCPLUSPLUS} != "no"
  2617. lib/libcxxrt__L: gnu/lib/libgcc__L
  2618. .endif
  2619. .endif
  2620. _prebuild_libs= ${_kerberos5_lib_libasn1} \
  2621. ${_kerberos5_lib_libhdb} \
  2622. ${_kerberos5_lib_libheimbase} \
  2623. ${_kerberos5_lib_libheimntlm} \
  2624. ${_libsqlite3} \
  2625. ${_kerberos5_lib_libheimipcc} \
  2626. ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
  2627. ${_kerberos5_lib_libroken} \
  2628. ${_kerberos5_lib_libwind} \
  2629. lib/libbz2 ${_libcom_err} lib/libcrypt \
  2630. lib/libelf lib/libexpat \
  2631. lib/libfigpar \
  2632. ${_lib_libgssapi} \
  2633. lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
  2634. lib/libzstd \
  2635. ${_lib_casper} \
  2636. lib/ncurses/ncurses lib/ncurses/ncursesw \
  2637. lib/libopie lib/libpam/libpam ${_lib_libthr} \
  2638. ${_lib_libradius} lib/libsbuf lib/libtacplus \
  2639. lib/libgeom \
  2640. ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
  2641. ${_cddl_lib_libuutil} \
  2642. ${_cddl_lib_libavl} \
  2643. ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
  2644. ${_cddl_lib_libctf} \
  2645. lib/libufs \
  2646. lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
  2647. ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
  2648. ${_lib_libldns} ${_secure_lib_libssh}
  2649. .if ${MK_GNUCXX} != "no"
  2650. _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
  2651. gnu/lib/libstdc++__L: lib/msun__L
  2652. gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
  2653. .endif
  2654. .if ${MK_DIALOG} != "no"
  2655. _prebuild_libs+= gnu/lib/libdialog
  2656. gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
  2657. .endif
  2658. .if ${MK_LIBCPLUSPLUS} != "no"
  2659. _prebuild_libs+= lib/libc++
  2660. .endif
  2661. lib/libgeom__L: lib/libexpat__L
  2662. lib/libkvm__L: lib/libelf__L
  2663. .if ${MK_LIBTHR} != "no"
  2664. _lib_libthr= lib/libthr
  2665. .endif
  2666. .if ${MK_RADIUS_SUPPORT} != "no"
  2667. _lib_libradius= lib/libradius
  2668. .endif
  2669. .if ${MK_OFED} != "no"
  2670. _prebuild_libs+= \
  2671. lib/ofed/libibverbs \
  2672. lib/ofed/libibmad \
  2673. lib/ofed/libibumad \
  2674. lib/ofed/complib \
  2675. lib/ofed/libmlx5
  2676. lib/ofed/libibmad__L: lib/ofed/libibumad__L
  2677. lib/ofed/complib__L: lib/libthr__L
  2678. lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
  2679. .endif
  2680. .if ${MK_CASPER} != "no"
  2681. _lib_casper= lib/libcasper
  2682. .endif
  2683. lib/libpjdlog__L: lib/libutil__L
  2684. lib/libcasper__L: lib/libnv__L
  2685. lib/liblzma__L: lib/libthr__L
  2686. lib/libzstd__L: lib/libthr__L
  2687. _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
  2688. .if ${MK_IPFILTER} != "no"
  2689. _generic_libs+= sbin/ipf/libipf
  2690. .endif
  2691. .for _DIR in ${LOCAL_LIB_DIRS}
  2692. .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
  2693. _generic_libs+= ${_DIR}
  2694. .endif
  2695. .endfor
  2696. lib/libopie__L lib/libtacplus__L: lib/libmd__L
  2697. .if ${MK_CDDL} != "no"
  2698. _cddl_lib_libumem= cddl/lib/libumem
  2699. _cddl_lib_libnvpair= cddl/lib/libnvpair
  2700. _cddl_lib_libavl= cddl/lib/libavl
  2701. _cddl_lib_libuutil= cddl/lib/libuutil
  2702. .if ${MK_ZFS} != "no"
  2703. _cddl_lib_libzfs_core= cddl/lib/libzfs_core
  2704. _cddl_lib_libzfs= cddl/lib/libzfs
  2705. cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
  2706. cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
  2707. cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
  2708. cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
  2709. lib/libbe__L: cddl/lib/libzfs__L
  2710. .endif
  2711. _cddl_lib_libctf= cddl/lib/libctf
  2712. _cddl_lib= cddl/lib
  2713. cddl/lib/libctf__L: lib/libz__L
  2714. .endif
  2715. # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
  2716. # on select architectures though (see cddl/lib/Makefile)
  2717. .if ${MACHINE_CPUARCH} != "sparc64"
  2718. _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
  2719. lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
  2720. lib/libproc__L: lib/libprocstat__L
  2721. lib/librtld_db__L: lib/libprocstat__L
  2722. .endif
  2723. .if ${MK_CRYPT} != "no"
  2724. .if ${MK_OPENSSL} != "no"
  2725. _secure_lib_libcrypto= secure/lib/libcrypto
  2726. _secure_lib_libssl= secure/lib/libssl
  2727. lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
  2728. secure/lib/libcrypto__L: lib/libthr__L
  2729. .if ${MK_LDNS} != "no"
  2730. _lib_libldns= lib/libldns
  2731. lib/libldns__L: secure/lib/libssl__L
  2732. .endif
  2733. .if ${MK_OPENSSH} != "no"
  2734. _secure_lib_libssh= secure/lib/libssh
  2735. secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
  2736. .if ${MK_LDNS} != "no"
  2737. secure/lib/libssh__L: lib/libldns__L
  2738. .endif
  2739. .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
  2740. secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
  2741. kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
  2742. lib/libmd__L kerberos5/lib/libroken__L
  2743. .endif
  2744. .endif
  2745. .endif
  2746. _secure_lib= secure/lib
  2747. .endif
  2748. .if ${MK_KERBEROS} != "no"
  2749. kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
  2750. kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  2751. kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
  2752. kerberos5/lib/libwind__L lib/libsqlite3__L
  2753. kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
  2754. kerberos5/lib/libroken__L lib/libcom_err__L
  2755. kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  2756. secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
  2757. kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  2758. lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
  2759. kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
  2760. kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
  2761. kerberos5/lib/libroken__L: lib/libcrypt__L
  2762. kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
  2763. kerberos5/lib/libheimbase__L: lib/libthr__L
  2764. kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
  2765. .endif
  2766. lib/libsqlite3__L: lib/libthr__L
  2767. .if ${MK_GSSAPI} != "no"
  2768. _lib_libgssapi= lib/libgssapi
  2769. .endif
  2770. .if ${MK_KERBEROS} != "no"
  2771. _kerberos5_lib= kerberos5/lib
  2772. _kerberos5_lib_libasn1= kerberos5/lib/libasn1
  2773. _kerberos5_lib_libhdb= kerberos5/lib/libhdb
  2774. _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
  2775. _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
  2776. _kerberos5_lib_libhx509= kerberos5/lib/libhx509
  2777. _kerberos5_lib_libroken= kerberos5/lib/libroken
  2778. _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
  2779. _libsqlite3= lib/libsqlite3
  2780. _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
  2781. _kerberos5_lib_libwind= kerberos5/lib/libwind
  2782. _libcom_err= lib/libcom_err
  2783. .endif
  2784. .if ${MK_NIS} != "no"
  2785. _lib_libypclnt= lib/libypclnt
  2786. .endif
  2787. .if ${MK_OPENSSL} == "no"
  2788. lib/libradius__L: lib/libmd__L
  2789. .endif
  2790. lib/libproc__L: \
  2791. ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
  2792. .if ${MK_CXX} != "no"
  2793. .if ${MK_LIBCPLUSPLUS} != "no"
  2794. lib/libproc__L: lib/libcxxrt__L
  2795. .else # This implies MK_GNUCXX != "no"; see lib/libproc
  2796. lib/libproc__L: gnu/lib/libsupc++__L
  2797. .endif
  2798. .endif
  2799. .for _lib in ${_prereq_libs}
  2800. ${_lib}__PL: .PHONY .MAKE
  2801. .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
  2802. ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
  2803. cd ${.CURDIR}/${_lib}; \
  2804. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
  2805. ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
  2806. DIRPRFX=${_lib}/ all; \
  2807. ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
  2808. DIRPRFX=${_lib}/ install
  2809. .endif
  2810. .endfor
  2811. .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
  2812. ${_lib}__L: .PHONY .MAKE
  2813. .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
  2814. ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
  2815. cd ${.CURDIR}/${_lib}; \
  2816. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
  2817. ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
  2818. ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
  2819. .endif
  2820. .endfor
  2821. _prereq_libs: ${_prereq_libs:S/$/__PL/}
  2822. _startup_libs: ${_startup_libs:S/$/__L/}
  2823. _prebuild_libs: ${_prebuild_libs:S/$/__L/}
  2824. _generic_libs: ${_generic_libs:S/$/__L/}
  2825. # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
  2826. # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
  2827. # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
  2828. # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
  2829. # parallel. This is safe for the world stage of buildworld though since it has
  2830. # already built libraries in a proper order and installed includes into
  2831. # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
  2832. # avoid trashing a system if it crashes mid-install.
  2833. .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
  2834. SUBDIR_PARALLEL=
  2835. .endif
  2836. .include <bsd.subdir.mk>
  2837. .if make(check-old) || make(check-old-dirs) || \
  2838. make(check-old-files) || make(check-old-libs) || \
  2839. make(delete-old) || make(delete-old-dirs) || \
  2840. make(delete-old-files) || make(delete-old-libs)
  2841. #
  2842. # check for / delete old files section
  2843. #
  2844. .include "ObsoleteFiles.inc"
  2845. OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
  2846. else you can not start such an application. Consult UPDATING for more \
  2847. information regarding how to cope with the removal/revision bump of a \
  2848. specific library."
  2849. .if !defined(BATCH_DELETE_OLD_FILES)
  2850. RM_I=-i
  2851. .else
  2852. RM_I=-v
  2853. .endif
  2854. delete-old-files: .PHONY
  2855. @echo ">>> Removing old files (only deletes safe to delete libs)"
  2856. # Ask for every old file if the user really wants to remove it.
  2857. # It's annoying, but better safe than sorry.
  2858. # NB: We cannot pass the list of OLD_FILES as a parameter because the
  2859. # argument list will get too long. Using .for/.endfor make "loops" will make
  2860. # the Makefile parser segfault.
  2861. @exec 3<&0; \
  2862. cd ${.CURDIR}; \
  2863. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2864. -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
  2865. while read file; do \
  2866. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  2867. chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
  2868. rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
  2869. fi; \
  2870. for ext in debug symbols; do \
  2871. if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
  2872. "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  2873. rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
  2874. <&3; \
  2875. fi; \
  2876. done; \
  2877. done
  2878. # Remove catpages without corresponding manpages.
  2879. @exec 3<&0; \
  2880. find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
  2881. sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
  2882. while read catpage; do \
  2883. read manpage; \
  2884. if [ ! -e "$${manpage}" ]; then \
  2885. rm ${RM_I} $${catpage} <&3; \
  2886. fi; \
  2887. done
  2888. @echo ">>> Old files removed"
  2889. check-old-files: .PHONY
  2890. @echo ">>> Checking for old files"
  2891. @cd ${.CURDIR}; \
  2892. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2893. -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
  2894. while read file; do \
  2895. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  2896. echo "${DESTDIR}/$${file}"; \
  2897. fi; \
  2898. for ext in debug symbols; do \
  2899. if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  2900. echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
  2901. fi; \
  2902. done; \
  2903. done | sort
  2904. # Check for catpages without corresponding manpages.
  2905. @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
  2906. sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
  2907. while read catpage; do \
  2908. read manpage; \
  2909. if [ ! -e "$${manpage}" ]; then \
  2910. echo $${catpage}; \
  2911. fi; \
  2912. done | sort
  2913. delete-old-libs: .PHONY
  2914. @echo ">>> Removing old libraries"
  2915. @echo "${OLD_LIBS_MESSAGE}" | fmt
  2916. @exec 3<&0; \
  2917. cd ${.CURDIR}; \
  2918. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2919. -V OLD_LIBS | xargs -n1 | sort | \
  2920. while read file; do \
  2921. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  2922. chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
  2923. rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
  2924. fi; \
  2925. for ext in debug symbols; do \
  2926. if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
  2927. "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  2928. rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
  2929. <&3; \
  2930. fi; \
  2931. done; \
  2932. done
  2933. @echo ">>> Old libraries removed"
  2934. check-old-libs: .PHONY
  2935. @echo ">>> Checking for old libraries"
  2936. @cd ${.CURDIR}; \
  2937. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2938. -V OLD_LIBS | xargs -n1 | \
  2939. while read file; do \
  2940. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  2941. echo "${DESTDIR}/$${file}"; \
  2942. fi; \
  2943. for ext in debug symbols; do \
  2944. if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  2945. echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
  2946. fi; \
  2947. done; \
  2948. done | sort
  2949. delete-old-dirs: .PHONY
  2950. @echo ">>> Removing old directories"
  2951. @cd ${.CURDIR}; \
  2952. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2953. -V OLD_DIRS | xargs -n1 | sort -r | \
  2954. while read dir; do \
  2955. if [ -d "${DESTDIR}/$${dir}" ]; then \
  2956. rmdir -v "${DESTDIR}/$${dir}" || true; \
  2957. elif [ -L "${DESTDIR}/$${dir}" ]; then \
  2958. echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
  2959. fi; \
  2960. if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  2961. rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
  2962. elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  2963. echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
  2964. fi; \
  2965. done
  2966. @echo ">>> Old directories removed"
  2967. check-old-dirs: .PHONY
  2968. @echo ">>> Checking for old directories"
  2969. @cd ${.CURDIR}; \
  2970. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  2971. -V OLD_DIRS | xargs -n1 | sort -r | \
  2972. while read dir; do \
  2973. if [ -d "${DESTDIR}/$${dir}" ]; then \
  2974. echo "${DESTDIR}/$${dir}"; \
  2975. elif [ -L "${DESTDIR}/$${dir}" ]; then \
  2976. echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
  2977. fi; \
  2978. if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  2979. echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
  2980. elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  2981. echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
  2982. fi; \
  2983. done
  2984. delete-old: delete-old-files delete-old-dirs .PHONY
  2985. @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
  2986. check-old: check-old-files check-old-libs check-old-dirs .PHONY
  2987. @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
  2988. @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
  2989. .endif
  2990. #
  2991. # showconfig - show build configuration.
  2992. #
  2993. showconfig: .PHONY
  2994. @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
  2995. ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
  2996. .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
  2997. DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
  2998. .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
  2999. .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
  3000. FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
  3001. '${KERNCONFDIR}/${KERNCONF}' ; echo
  3002. .endif
  3003. .endif
  3004. .endif
  3005. .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
  3006. DTBOUTPUTPATH= ${.CURDIR}
  3007. .endif
  3008. #
  3009. # Build 'standalone' Device Tree Blob
  3010. #
  3011. builddtb: .PHONY
  3012. @PATH=${TMPPATH} MACHINE=${TARGET} \
  3013. ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
  3014. "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
  3015. ###############
  3016. # cleanworld
  3017. # In the following, the first 'rm' in a series will usually remove all
  3018. # files and directories. If it does not, then there are probably some
  3019. # files with file flags set, so this unsets them and tries the 'rm' a
  3020. # second time. There are situations where this target will be cleaning
  3021. # some directories via more than one method, but that duplication is
  3022. # needed to correctly handle all the possible situations. Removing all
  3023. # files without file flags set in the first 'rm' instance saves time,
  3024. # because 'chflags' will need to operate on fewer files afterwards.
  3025. #
  3026. # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
  3027. # created by bsd.obj.mk, except that we don't want to .include that file
  3028. # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
  3029. # since it is not possible for files to land in the wrong place.
  3030. #
  3031. .if make(cleanworld)
  3032. BW_CANONICALOBJDIR:=${OBJTOP}/
  3033. .elif make(cleanuniverse)
  3034. BW_CANONICALOBJDIR:=${OBJROOT}
  3035. .if ${MK_UNIFIED_OBJDIR} == "no"
  3036. .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
  3037. .endif
  3038. .endif
  3039. cleanworld cleanuniverse: .PHONY
  3040. .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
  3041. ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
  3042. -rm -rf ${BW_CANONICALOBJDIR}*
  3043. -chflags -R 0 ${BW_CANONICALOBJDIR}
  3044. rm -rf ${BW_CANONICALOBJDIR}*
  3045. .endif
  3046. .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
  3047. (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
  3048. .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
  3049. # To be safe in this case, fall back to a 'make cleandir'
  3050. ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
  3051. .endif
  3052. .endif
  3053. .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
  3054. XDEV_CPUTYPE?=${CPUTYPE}
  3055. .else
  3056. XDEV_CPUTYPE?=${TARGET_CPUTYPE}
  3057. .endif
  3058. NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
  3059. MK_MAN=no MK_NLS=no MK_PROFILE=no \
  3060. MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
  3061. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  3062. CPUTYPE=${XDEV_CPUTYPE}
  3063. XDDIR=${TARGET_ARCH}-freebsd
  3064. XDTP?=/usr/${XDDIR}
  3065. .if ${XDTP:N/*}
  3066. .error XDTP variable should be an absolute path
  3067. .endif
  3068. CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
  3069. CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
  3070. CDBENV= \
  3071. INSTALL="sh ${.CURDIR}/tools/install.sh"
  3072. CDENV= ${CDBENV} \
  3073. TOOLS_PREFIX=${XDTP}
  3074. CDMAKEARGS= \
  3075. OBJTOP=${CDBOBJTOP:Q} \
  3076. OBJROOT=${CDBOBJROOT:Q}
  3077. CD2MAKEARGS= ${CDMAKEARGS}
  3078. .if ${WANT_COMPILER_TYPE} == gcc || \
  3079. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  3080. # GCC requires -isystem and -L when using a cross-compiler. --sysroot
  3081. # won't set header path and -L is used to ensure the base library path
  3082. # is added before the port PREFIX library path.
  3083. CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
  3084. # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
  3085. # combined with --sysroot.
  3086. CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
  3087. # Force using libc++ for external GCC.
  3088. .if defined(X_COMPILER_TYPE) && \
  3089. ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
  3090. CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
  3091. -nostdinc++
  3092. .endif
  3093. .endif
  3094. CD2CFLAGS+= --sysroot=${XDDESTDIR}/
  3095. CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
  3096. CPP="${CPP} ${CD2CFLAGS}" \
  3097. MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
  3098. CDTMP= ${OBJTOP}/${XDDIR}/tmp
  3099. CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
  3100. CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
  3101. ${MAKE} ${CD2MAKEARGS} ${NOFUN}
  3102. .if ${MK_META_MODE} != "no"
  3103. # Don't rebuild build-tools targets during normal build.
  3104. CD2MAKE+= BUILD_TOOLS_META=.NOMETA
  3105. .endif
  3106. XDDESTDIR=${DESTDIR}${XDTP}
  3107. .ORDER: xdev-build xdev-install xdev-links
  3108. xdev: xdev-build xdev-install .PHONY
  3109. .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
  3110. xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
  3111. _xb-worldtmp: .PHONY
  3112. mkdir -p ${CDTMP}/usr
  3113. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  3114. -p ${CDTMP}/usr >/dev/null
  3115. _xb-bootstrap-tools: .PHONY
  3116. .for _tool in \
  3117. ${_clang_tblgen} \
  3118. ${_gperf} \
  3119. ${_yacc}
  3120. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  3121. cd ${.CURDIR}/${_tool}; \
  3122. if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
  3123. ${CDMAKE} DIRPRFX=${_tool}/ all; \
  3124. ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
  3125. .endfor
  3126. _xb-build-tools: .PHONY
  3127. ${_+_}@cd ${.CURDIR}; \
  3128. ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
  3129. XDEVDIRS= \
  3130. ${_clang_libs} \
  3131. ${_lld} \
  3132. ${_binutils} \
  3133. ${_elftctools} \
  3134. usr.bin/ar \
  3135. ${_clang} \
  3136. ${_gcc}
  3137. _xb-cross-tools: .PHONY
  3138. .for _tool in ${XDEVDIRS}
  3139. ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
  3140. cd ${.CURDIR}/${_tool}; \
  3141. if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
  3142. ${CDMAKE} DIRPRFX=${_tool}/ all
  3143. .endfor
  3144. _xi-mtree: .PHONY
  3145. ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
  3146. mkdir -p ${XDDESTDIR}
  3147. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
  3148. -p ${XDDESTDIR} >/dev/null
  3149. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  3150. -p ${XDDESTDIR}/usr >/dev/null
  3151. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  3152. -p ${XDDESTDIR}/usr/include >/dev/null
  3153. .if defined(_LIBCOMPAT)
  3154. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  3155. -p ${XDDESTDIR}/usr >/dev/null
  3156. .endif
  3157. .if ${MK_TESTS} != "no"
  3158. mkdir -p ${XDDESTDIR}${TESTSBASE}
  3159. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  3160. -p ${XDDESTDIR}${TESTSBASE} >/dev/null
  3161. .endif
  3162. .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
  3163. xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
  3164. _xi-cross-tools: .PHONY
  3165. @echo "_xi-cross-tools"
  3166. .for _tool in ${XDEVDIRS}
  3167. ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
  3168. cd ${.CURDIR}/${_tool}; \
  3169. ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
  3170. .endfor
  3171. _xi-includes: .PHONY
  3172. .if !defined(NO_OBJWALK)
  3173. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
  3174. DESTDIR=${XDDESTDIR}
  3175. .endif
  3176. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
  3177. DESTDIR=${XDDESTDIR}
  3178. _xi-libraries: .PHONY
  3179. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
  3180. DESTDIR=${XDDESTDIR}
  3181. xdev-links: .PHONY
  3182. ${_+_}cd ${XDDESTDIR}/usr/bin; \
  3183. mkdir -p ../../../../usr/bin; \
  3184. for i in *; do \
  3185. ln -sf ../../${XDTP}/usr/bin/$$i \
  3186. ../../../../usr/bin/${XDDIR}-$$i; \
  3187. ln -sf ../../${XDTP}/usr/bin/$$i \
  3188. ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
  3189. done