xref: /freebsd/targets/pseudo/bootstrap-tools/Makefile (revision 8c2f6c3be0125142d3c1782e4b0ee0634c584b9e)
1
2# building clang is particularly tedious - so avoid re-inventing wheels
3
4all: bootstrap-toolchain
5
6UPDATE_DEPENDFILE= no
7.export UPDATE_DEPENDFILE
8
9# we build for the pseudo machine "host"
10TARGET_MACHINE= host
11
12HOST_MACHINE!= uname -m
13HOST_MACHINE_ARCH!= uname -p
14BTOOLSDIR?= ${HOST_OBJTOP}/tools
15WORLDTMP= ${BTOOLSDIR}
16LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
17
18BSENV= \
19	MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
20	TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
21	WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
22	WORLDTMP=${BTOOLSDIR} \
23	INSTALL="sh ${SRCTOP}/tools/install.sh" \
24	PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
25
26.if !defined(OSRELDATE)
27ord_h= /usr/include/osreldate.h
28.if exists(${ord_h})
29OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
30.endif
31OSRELDATE?= 0
32.endif
33
34# need to keep this in sync with src/Makefile.inc1
35BSARGS= 	DESTDIR= \
36		OBJTOP='${WORLDTMP}/obj-tools' \
37		OBJROOT='$${OBJTOP}/' \
38		MAKEOBJDIRPREFIX= \
39		BOOTSTRAPPING=${OSRELDATE} \
40		BWPHASE=${.TARGET} \
41		-DNO_CPU_CFLAGS \
42		-DNO_LINT \
43		-DNO_PIC \
44		-DNO_SHARED \
45		MK_CTF=no \
46		MK_CLANG_EXTRAS=no \
47		MK_CLANG_FORMAT=no \
48		MK_CLANG_FULL=no \
49		MK_HTML=no \
50		MK_MAN=no \
51		MK_PROFILE=no \
52		MK_RETPOLINE=no \
53		MK_SSP=no \
54		MK_TESTS=no \
55		MK_WERROR=no \
56		MK_INCLUDES=yes \
57		MK_MAN_UTILS=yes
58
59# We will handle building the toolchain and cross-compiler.
60BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no
61
62DISTRIB_ENV=	INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
63legacy: .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} $@
70
71bootstrap-tools: legacy
72build-tools: bootstrap-tools
73cross-tools: build-tools
74
75cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
76	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
77
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.
81BSTCENV= \
82	MAKELEVEL=0 \
83	MACHINE=host \
84	BOOTSTRAPPING_TOOLS=1 \
85	TARGET=${HOST_MACHINE} \
86	TARGET_ARCH=${HOST_MACHINE_ARCH} \
87	${BSENV:MPATH=*}
88
89BSTCARGS= \
90	${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*} \
91	BUILD_DIRDEPS=yes \
92	LLVM_MIN_TBLGEN=${TOOLSDIR}/usr/bin/llvm-min-tblgen \
93	LLVM_TBLGEN=${TOOLSDIR}/usr/bin/llvm-tblgen \
94	CLANG_TBLGEN=${TOOLSDIR}/usr/bin/clang-tblgen \
95	-DWITH_STAGING \
96	-DWITH_TOOLSDIR
97
98# finally we build toolchain leveraging the above.
99bootstrap-toolchain:	.MAKE cross-tools
100	${BSTCENV} ${MAKE} -C ${SRCTOP} ${BSTCARGS} toolchain
101
102# Ensure CCACHE_DIR is ignored since we are processing .meta files here.
103.include <bsd.compiler.mk>
104