90 lines
2.8 KiB
Makefile
Raw Normal View History

# $FreeBSD$
# building clang is particularly tedious - so avoid re-inventing wheels
all: bootstrap-toolchain
UPDATE_DEPENDFILE= no
2014-05-16 14:54:05 +00:00
.export UPDATE_DEPENDFILE
# we build for the pseudo machine "host"
TARGET_MACHINE= host
HOST_MACHINE!= uname -m
HOST_MACHINE_ARCH!= uname -p
2014-05-16 14:54:05 +00:00
BTOOLSDIR?= ${HOST_OBJTOP}/tools
LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
BSENV= \
2014-05-16 14:54:05 +00:00
unset MAKEOBJDIR; MAKEOBJDIRPREFIX=${BTOOLSDIR} \
MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
2015-05-27 01:19:58 +00:00
WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
META MODE: Rework [bootstrapped] tools PATH support. - Support more of the toolchain from TOOLSDIR. - This also improves 'make bootstrap-tools' to pass, for example, AS=/usr/bin/as to Makefile.inc1, which will tell cross-tools to use external toolchain support and avoid building things we won't be using in the build. - Always set the PATH to contain the staged TOOLSDIR directories when not building the bootstrap targets. The previous version was only setting this at MAKE.LEVEL==0 and if the TOOLSDIR existed. Both of these prevented using staged tools that were built during the build though as DIRDEPS with .host dependencies, such as the fix for needing usr.bin/localedef.host in r291311. This is not a common tool so we must build and use it during the build, and need to be prepared to change PATH as soon as it appears. This should also fix the issue of host dependencies disappearing from Makefile.depend and then reappearing due to the start of the fresh build not having the directory yet, resulting in the tools that were built not actually being used. - Only use LEGACY_TOOLS while building in Makefile.inc1. After r291317 and r291546 there is no need to add LEGACY_TOOLS into the PATH for the pseudo/targets/toolchain build. - Because the pseudo/targets/toolchain will now build its own [clang-]tblgen, the special logic in clang.build.mk is no longer needed. - LEGACY_TOOLS is no longer used outside of targets/pseudo/bootstrap-tools so is no longer passed into the environment in its build. Sponsored by: EMC / Isilon Storage Division
2015-12-01 05:19:02 +00:00
WORLDTMP=${BTOOLSDIR} \
INSTALL="sh ${SRCTOP}/tools/install.sh" \
PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
2015-05-27 01:19:58 +00:00
.if !defined(OSRELDATE)
ord_h= /usr/include/osreldate.h
.if exists(${ord_h})
OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
.endif
OSRELDATE?= 0
.endif
# need to keep this in sync with src/Makefile.inc1
BSARGS= DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} \
SSP_CFLAGS= \
MK_HTML=no NO_LINT=yes MK_MAN=no \
-DNO_PIC MK_PROFILE=no -DNO_SHARED \
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
MK_LLDB=no MK_TESTS=no \
MK_INCLUDES=yes
# Need to override these so OBJTOP uses are proper in the non-meta build.
BSARGS+= OBJTOP=${BTOOLSDIR}${SRCTOP} OBJROOT='$${OBJTOP}/'
# We will handle building the toolchain and cross-compiler.
BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_GCC=no
DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
legacy: .MAKE ${META_DEPS}
mkdir -p ${LEGACY_TOOLS}
${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
bootstrap-tools: legacy
build-tools: bootstrap-tools
cross-tools: build-tools
cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
# MAKELEVEL=0 so that dirdeps.mk does its thing
META MODE: Rework [bootstrapped] tools PATH support. - Support more of the toolchain from TOOLSDIR. - This also improves 'make bootstrap-tools' to pass, for example, AS=/usr/bin/as to Makefile.inc1, which will tell cross-tools to use external toolchain support and avoid building things we won't be using in the build. - Always set the PATH to contain the staged TOOLSDIR directories when not building the bootstrap targets. The previous version was only setting this at MAKE.LEVEL==0 and if the TOOLSDIR existed. Both of these prevented using staged tools that were built during the build though as DIRDEPS with .host dependencies, such as the fix for needing usr.bin/localedef.host in r291311. This is not a common tool so we must build and use it during the build, and need to be prepared to change PATH as soon as it appears. This should also fix the issue of host dependencies disappearing from Makefile.depend and then reappearing due to the start of the fresh build not having the directory yet, resulting in the tools that were built not actually being used. - Only use LEGACY_TOOLS while building in Makefile.inc1. After r291317 and r291546 there is no need to add LEGACY_TOOLS into the PATH for the pseudo/targets/toolchain build. - Because the pseudo/targets/toolchain will now build its own [clang-]tblgen, the special logic in clang.build.mk is no longer needed. - LEGACY_TOOLS is no longer used outside of targets/pseudo/bootstrap-tools so is no longer passed into the environment in its build. Sponsored by: EMC / Isilon Storage Division
2015-12-01 05:19:02 +00:00
# BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
# TARGET* is so that MK_CLANG gets set correctly.
BSTCENV= \
MAKELEVEL=0 \
MACHINE=host \
META MODE: Rework [bootstrapped] tools PATH support. - Support more of the toolchain from TOOLSDIR. - This also improves 'make bootstrap-tools' to pass, for example, AS=/usr/bin/as to Makefile.inc1, which will tell cross-tools to use external toolchain support and avoid building things we won't be using in the build. - Always set the PATH to contain the staged TOOLSDIR directories when not building the bootstrap targets. The previous version was only setting this at MAKE.LEVEL==0 and if the TOOLSDIR existed. Both of these prevented using staged tools that were built during the build though as DIRDEPS with .host dependencies, such as the fix for needing usr.bin/localedef.host in r291311. This is not a common tool so we must build and use it during the build, and need to be prepared to change PATH as soon as it appears. This should also fix the issue of host dependencies disappearing from Makefile.depend and then reappearing due to the start of the fresh build not having the directory yet, resulting in the tools that were built not actually being used. - Only use LEGACY_TOOLS while building in Makefile.inc1. After r291317 and r291546 there is no need to add LEGACY_TOOLS into the PATH for the pseudo/targets/toolchain build. - Because the pseudo/targets/toolchain will now build its own [clang-]tblgen, the special logic in clang.build.mk is no longer needed. - LEGACY_TOOLS is no longer used outside of targets/pseudo/bootstrap-tools so is no longer passed into the environment in its build. Sponsored by: EMC / Isilon Storage Division
2015-12-01 05:19:02 +00:00
BOOTSTRAPPING_TOOLS=1 \
TARGET=${HOST_MACHINE} \
META MODE: Rework [bootstrapped] tools PATH support. - Support more of the toolchain from TOOLSDIR. - This also improves 'make bootstrap-tools' to pass, for example, AS=/usr/bin/as to Makefile.inc1, which will tell cross-tools to use external toolchain support and avoid building things we won't be using in the build. - Always set the PATH to contain the staged TOOLSDIR directories when not building the bootstrap targets. The previous version was only setting this at MAKE.LEVEL==0 and if the TOOLSDIR existed. Both of these prevented using staged tools that were built during the build though as DIRDEPS with .host dependencies, such as the fix for needing usr.bin/localedef.host in r291311. This is not a common tool so we must build and use it during the build, and need to be prepared to change PATH as soon as it appears. This should also fix the issue of host dependencies disappearing from Makefile.depend and then reappearing due to the start of the fresh build not having the directory yet, resulting in the tools that were built not actually being used. - Only use LEGACY_TOOLS while building in Makefile.inc1. After r291317 and r291546 there is no need to add LEGACY_TOOLS into the PATH for the pseudo/targets/toolchain build. - Because the pseudo/targets/toolchain will now build its own [clang-]tblgen, the special logic in clang.build.mk is no longer needed. - LEGACY_TOOLS is no longer used outside of targets/pseudo/bootstrap-tools so is no longer passed into the environment in its build. Sponsored by: EMC / Isilon Storage Division
2015-12-01 05:19:02 +00:00
TARGET_ARCH=${HOST_MACHINE_ARCH} \
${BSENV:MPATH=*}
BSTCARGS= \
${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*:NMK_GCC=*} \
2015-05-27 01:19:58 +00:00
BUILD_DIRDEPS=yes \
-DWITH_STAGING \
-DWITH_TOOLSDIR
# finally we build toolchain leveraging the above.
bootstrap-toolchain: .MAKE cross-tools
${BSTCENV} ${MAKE} -C ${.CURDIR:H:H} ${BSTCARGS} toolchain
# Ensure CCACHE_DIR is ignored since we are processing .meta files here.
.include <bsd.compiler.mk>