3 # building clang is particularly tedious - so avoid re-inventing wheels
5 all: bootstrap-toolchain
8 .export UPDATE_DEPENDFILE
10 # we build for the pseudo machine "host"
13 HOST_MACHINE!= uname -m
14 HOST_MACHINE_ARCH!= uname -p
15 BTOOLSDIR?= ${HOST_OBJTOP}/tools
16 WORLDTMP= ${BTOOLSDIR}
17 LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
20 MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
21 TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
22 WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
23 WORLDTMP=${BTOOLSDIR} \
24 INSTALL="sh ${SRCTOP}/tools/install.sh" \
25 PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
27 .if !defined(OSRELDATE)
28 ord_h= /usr/include/osreldate.h
30 OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
35 # need to keep this in sync with src/Makefile.inc1
37 OBJTOP='${WORLDTMP}/obj-tools' \
38 OBJROOT='$${OBJTOP}/' \
40 BOOTSTRAPPING=${OSRELDATE} \
59 # We will handle building the toolchain and cross-compiler.
60 BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_GCC=no
62 DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
63 legacy: .MAKE ${META_DEPS}
64 mkdir -p ${LEGACY_TOOLS}
65 ${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
66 DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
67 ${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
68 DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
69 ${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
71 bootstrap-tools: legacy
72 build-tools: bootstrap-tools
73 cross-tools: build-tools
75 cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
76 ${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
78 # MAKELEVEL=0 so that dirdeps.mk does its thing
79 # BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
80 # TARGET* is so that MK_CLANG gets set correctly.
84 BOOTSTRAPPING_TOOLS=1 \
85 TARGET=${HOST_MACHINE} \
86 TARGET_ARCH=${HOST_MACHINE_ARCH} \
90 ${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*:NMK_GCC=*} \
92 LLVM_TBLGEN=${TOOLSDIR}/usr/bin/llvm-tblgen \
93 CLANG_TBLGEN=${TOOLSDIR}/usr/bin/clang-tblgen \
97 # finally we build toolchain leveraging the above.
98 bootstrap-toolchain: .MAKE cross-tools
99 ${BSTCENV} ${MAKE} -C ${SRCTOP} ${BSTCARGS} toolchain
101 # Ensure CCACHE_DIR is ignored since we are processing .meta files here.
102 .include <bsd.compiler.mk>