xref: /freebsd/targets/pseudo/bootstrap-tools/Makefile (revision 357378bbdedf24ce2b90e9bd831af4a9db3ec70a)
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_PROFILE=no \
51		MK_RETPOLINE=no \
52		MK_SSP=no \
53		MK_TESTS=no \
54		MK_WERROR=no \
55		MK_INCLUDES=yes \
56		MK_MAN_UTILS=yes
57
58# We will handle building the toolchain and cross-compiler.
59BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no
60
61DISTRIB_ENV=	INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
62legacy: .MAKE ${META_DEPS}
63	mkdir -p ${LEGACY_TOOLS}
64	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
65	    DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
66	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
67	    DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
68	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
69
70bootstrap-tools: legacy
71build-tools: bootstrap-tools
72cross-tools: build-tools
73
74cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
75	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
76
77# MAKELEVEL=0 so that dirdeps.mk does its thing
78# BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
79# TARGET* is so that MK_CLANG gets set correctly.
80BSTCENV= \
81	MAKELEVEL=0 \
82	MACHINE=host \
83	BOOTSTRAPPING_TOOLS=1 \
84	TARGET=${HOST_MACHINE} \
85	TARGET_ARCH=${HOST_MACHINE_ARCH} \
86	${BSENV:MPATH=*}
87
88BSTCARGS= \
89	${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*} \
90	BUILD_DIRDEPS=yes \
91	LLVM_MIN_TBLGEN=${TOOLSDIR}/usr/bin/llvm-min-tblgen \
92	LLVM_TBLGEN=${TOOLSDIR}/usr/bin/llvm-tblgen \
93	CLANG_TBLGEN=${TOOLSDIR}/usr/bin/clang-tblgen \
94	-DWITH_STAGING \
95	-DWITH_TOOLSDIR
96
97# finally we build toolchain leveraging the above.
98bootstrap-toolchain:	.MAKE cross-tools
99	${BSTCENV} ${MAKE} -C ${SRCTOP} ${BSTCARGS} toolchain
100
101# Ensure CCACHE_DIR is ignored since we are processing .meta files here.
102.include <bsd.compiler.mk>
103