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.
 
 
 
 
 
 

3330 lines
112 KiB

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