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