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.
 
 
 
 
 
 

95 lines
2.8 KiB

  1. # $FreeBSD$
  2. # building clang is particularly tedious - so avoid re-inventing wheels
  3. all: bootstrap-toolchain
  4. UPDATE_DEPENDFILE= no
  5. .export UPDATE_DEPENDFILE
  6. # we build for the pseudo machine "host"
  7. TARGET_MACHINE= host
  8. HOST_MACHINE!= uname -m
  9. HOST_MACHINE_ARCH!= uname -p
  10. BTOOLSDIR?= ${HOST_OBJTOP}/tools
  11. WORLDTMP= ${BTOOLSDIR}
  12. LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
  13. BSENV= \
  14. MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
  15. TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
  16. WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
  17. WORLDTMP=${BTOOLSDIR} \
  18. INSTALL="sh ${SRCTOP}/tools/install.sh" \
  19. PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
  20. .if !defined(OSRELDATE)
  21. ord_h= /usr/include/osreldate.h
  22. .if exists(${ord_h})
  23. OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
  24. .endif
  25. OSRELDATE?= 0
  26. .endif
  27. # need to keep this in sync with src/Makefile.inc1
  28. BSARGS= DESTDIR= \
  29. OBJTOP='${WORLDTMP}/obj-tools' \
  30. OBJROOT='$${OBJTOP}/' \
  31. MAKEOBJDIRPREFIX= \
  32. BOOTSTRAPPING=${OSRELDATE} \
  33. BWPHASE=${.TARGET} \
  34. SSP_CFLAGS= \
  35. MK_HTML=no NO_LINT=yes MK_MAN=no \
  36. -DNO_PIC MK_PROFILE=no -DNO_SHARED \
  37. -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
  38. MK_CLANG_EXTRAS=yes MK_CLANG_FULL=no \
  39. MK_CLANG_FORMAT=no
  40. MK_LLDB=no MK_TESTS=no \
  41. MK_INCLUDES=yes
  42. # We will handle building the toolchain and cross-compiler.
  43. BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no
  44. DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
  45. legacy: .MAKE ${META_DEPS}
  46. mkdir -p ${LEGACY_TOOLS}
  47. ${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
  48. DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
  49. ${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
  50. DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
  51. ${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
  52. bootstrap-tools: legacy
  53. build-tools: bootstrap-tools
  54. cross-tools: build-tools
  55. cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
  56. ${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
  57. # MAKELEVEL=0 so that dirdeps.mk does its thing
  58. # BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
  59. # TARGET* is so that MK_CLANG gets set correctly.
  60. BSTCENV= \
  61. MAKELEVEL=0 \
  62. MACHINE=host \
  63. BOOTSTRAPPING_TOOLS=1 \
  64. TARGET=${HOST_MACHINE} \
  65. TARGET_ARCH=${HOST_MACHINE_ARCH} \
  66. ${BSENV:MPATH=*}
  67. BSTCARGS= \
  68. ${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*} \
  69. BUILD_DIRDEPS=yes \
  70. LLVM_TBLGEN=${TOOLSDIR}/usr/bin/llvm-tblgen \
  71. CLANG_TBLGEN=${TOOLSDIR}/usr/bin/clang-tblgen \
  72. -DWITH_STAGING \
  73. -DWITH_TOOLSDIR
  74. # finally we build toolchain leveraging the above.
  75. bootstrap-toolchain: .MAKE cross-tools
  76. ${BSTCENV} ${MAKE} -C ${SRCTOP} ${BSTCARGS} toolchain
  77. # Ensure CCACHE_DIR is ignored since we are processing .meta files here.
  78. .include <bsd.compiler.mk>