xref: /freebsd/targets/pseudo/bootstrap-tools/Makefile (revision 2b8331622f0b212cf3bb4fc4914a501e5321d506)
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_MAN=no \
52		MK_PROFILE=no \
53		MK_RETPOLINE=no \
54		MK_SSP=no \
55		MK_TESTS=no \
56		MK_WERROR=no \
57		MK_INCLUDES=yes \
58		MK_MAN_UTILS=yes
59
60# We will handle building the toolchain and cross-compiler.
61BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no
62
63DISTRIB_ENV=	INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
64legacy: .MAKE ${META_DEPS}
65	mkdir -p ${LEGACY_TOOLS}
66	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
67	    DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
68	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
69	    DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
70	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
71
72bootstrap-tools: legacy
73build-tools: bootstrap-tools
74cross-tools: build-tools
75
76cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
77	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
78
79# MAKELEVEL=0 so that dirdeps.mk does its thing
80# BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
81# TARGET* is so that MK_CLANG gets set correctly.
82BSTCENV= \
83	MAKELEVEL=0 \
84	MACHINE=host \
85	BOOTSTRAPPING_TOOLS=1 \
86	TARGET=${HOST_MACHINE} \
87	TARGET_ARCH=${HOST_MACHINE_ARCH} \
88	${BSENV:MPATH=*}
89
90BSTCARGS= \
91	${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*} \
92	BUILD_DIRDEPS=yes \
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