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