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.

3398 lines
114KB

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