xref: /freebsd/targets/pseudo/bootstrap-tools/Makefile (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
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
16LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
17
18BSENV= \
19	unset MAKEOBJDIR; MAKEOBJDIRPREFIX=${BTOOLSDIR} \
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} LEGACY_TOOLS=${LEGACY_TOOLS}
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= \
35	DESTDIR= \
36	BOOTSTRAPPING=${OSRELDATE} \
37	SSP_CFLAGS= \
38	MK_HTML=no NO_LINT=yes MK_MAN=no \
39	-DNO_PIC MK_PROFILE=no -DNO_SHARED \
40	-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
41	MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
42	MK_LLDB=no MK_TESTS=no \
43	MK_INCLUDES=yes
44
45
46legacy: .MAKE .META
47	mkdir -p ${LEGACY_TOOLS}
48	${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${BTOOLSDIR} > $@2
49	${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${LEGACY_TOOLS} > $@
50	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
51	touch $@
52
53bootstrap-tools: legacy
54build-tools: bootstrap-tools
55cross-tools: build-tools
56
57cross-tools build-tools bootstrap-tools: .MAKE .META
58	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
59	touch $@
60
61# MAKELEVEL=0 so that dirdeps.mk does its thing
62# LEGACY_TOOLS lets us use the bootstaped stuff above
63# TARGET* is so that MK_CLANG gets set correctly.
64BSTCENV= \
65	MAKELEVEL=0 \
66	MACHINE=host \
67	LEGACY_TOOLS=${LEGACY_TOOLS} \
68	TARGET=${HOST_MACHINE} \
69	TARGET_ARCH=${HOST_MACHINE_ARCH}
70
71BSTCARGS= \
72	${BSARGS} \
73	BUILD_DIRDEPS=yes \
74	-DWITH_STAGING \
75	-DWITH_TOOLSDIR
76
77# finally we build toolchain leveraging the above.
78bootstrap-toolchain:	.MAKE cross-tools
79	${BSTCENV} ${MAKE} -C ${.CURDIR:H:H} ${BSTCARGS} toolchain
80