HardenedBSD src tree https://hardenedbsd.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3341 lines
112KB

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