aboutsummaryrefslogtreecommitdiff
path: root/targets/pseudo/bootstrap-tools/Makefile
blob: f196c8a7322fd8d2c4941239b31b3cb8b51f5cca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# $FreeBSD$

# building clang is particularly tedious - so avoid re-inventing wheels

all: bootstrap-toolchain

UPDATE_DEPENDFILE= no
.export UPDATE_DEPENDFILE

# we build for the pseudo machine "host"
TARGET_MACHINE= host

HOST_MACHINE!= uname -m
HOST_MACHINE_ARCH!= uname -p
BTOOLSDIR?= ${HOST_OBJTOP}/tools
LEGACY_TOOLS?= ${BTOOLSDIR}/legacy

BSENV= \
	unset MAKEOBJDIR; MAKEOBJDIRPREFIX=${BTOOLSDIR} \
	MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
	TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
	WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
	WORLDTMP=${BTOOLSDIR} LEGACY_TOOLS=${LEGACY_TOOLS} \
	INSTALL="sh ${SRCTOP}/tools/install.sh" \
	PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}

.if !defined(OSRELDATE)
ord_h= /usr/include/osreldate.h
.if exists(${ord_h})
OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
.endif
OSRELDATE?= 0
.endif

# need to keep this in sync with src/Makefile.inc1 
BSARGS= 	DESTDIR= \
		BOOTSTRAPPING=${OSRELDATE} \
		SSP_CFLAGS= \
		MK_HTML=no NO_LINT=yes MK_MAN=no \
		-DNO_PIC MK_PROFILE=no -DNO_SHARED \
		-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
		MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
		MK_LLDB=no MK_TESTS=no \
		MK_INCLUDES=yes

DISTRIB_ENV=	INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
legacy: .MAKE .META
	mkdir -p ${LEGACY_TOOLS}
	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
	    DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
	${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
	    DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
	touch $@

bootstrap-tools: legacy
build-tools: bootstrap-tools
cross-tools: build-tools

cross-tools build-tools bootstrap-tools: .MAKE .META
	${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
	touch $@

# MAKELEVEL=0 so that dirdeps.mk does its thing
# LEGACY_TOOLS lets us use the bootstrapped stuff above
# TARGET* is so that MK_CLANG gets set correctly.
BSTCENV= \
	MAKELEVEL=0 \
	MACHINE=host \
	LEGACY_TOOLS=${LEGACY_TOOLS} \
	TARGET=${HOST_MACHINE} \
	TARGET_ARCH=${HOST_MACHINE_ARCH}

BSTCARGS= \
	${BSARGS} \
	BUILD_DIRDEPS=yes \
	-DWITH_STAGING \
	-DWITH_TOOLSDIR

# finally we build toolchain leveraging the above.
bootstrap-toolchain:	.MAKE cross-tools
	${BSTCENV} ${MAKE} -C ${.CURDIR:H:H} ${BSTCARGS:NDESTDIR=} toolchain