summaryrefslogtreecommitdiff
path: root/toolchain/Makefile
blob: 19ee5dd44435139d2df9ff7c2f5dacd4cf5d84f7 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

# Steps to build toolchains
# 1) build and install binutils
# 2) build and install mpfr, mpc, libelf and gmp
# 3) build and install minimal gcc c compiler
# 4) install kernel-headers
# 5) install libc headers
# 6) build and install initial static gcc
# 7) build and install full libc
# 8) build and install full shared gcc
# 9) rebuild and install full libc (in case of musl/uclibc)
# 10) build and install gdb debugger

include $(ADK_TOPDIR)/rules.mk

TARGETS:=binutils gmp mpfr mpc libelf gcc

ifeq ($(ADK_TARGET_LIB_GLIBC),y)
TARGETS+=glibc
CLIB:=glibc
endif
ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
TARGETS+=uclibc-ng
CLIB:=uclibc-ng
endif
ifeq ($(ADK_TARGET_LIB_MUSL),y)
TARGETS+=musl
CLIB:=musl
endif

ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
TARGETS+=elf2flt
ELF2FLT:=elf2flt-install
endif

# disable gdb for arc
ifeq ($(ADK_TARGET_ARCH_ARC)$(ADK_TARGET_ARCH_METAG)$(ADK_TARGET_ARCH_OR1K),)
TARGETS+=gdb
GDB:=gdb-install
endif
ifeq (${ADK_PRELINK},y)
TARGETS+=prelink-cross
endif

DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
FIXUP:=$(patsubst %,%-fixup,$(CLIB))
TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))

install: $(TARGETS_INSTALL)
clean: $(TARGETS_CLEAN)
download: $(DOWNLOAD)
fixup: $(FIXUP)

gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
$(CLIB)-prepare: gcc-prepare kernel-headers-prepare
gcc-configure: $(CLIB)-prepare
$(CLIB)-compile: gcc-configure
gcc-compile: $(CLIB)-install
$(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)

%-download:
	$(TRACE) toolchain/$(patsubst %-download,%,$@)/download
	$(MAKE) -C $(patsubst %-download,%,$@) fetch

%-prepare:
	$(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
	@if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
		    $(MAKE_TRACE); \
	else \
		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
	fi

%-configure: %-prepare
	$(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
	@if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
		$(MAKE) -C $(patsubst %-configure,%,$@) configure \
		    $(MAKE_TRACE); \
	else \
		$(MAKE) -C $(patsubst %-configure,%,$@) configure \
		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
	fi

%-compile: %-configure
	$(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
	@if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
		$(MAKE) -C $(patsubst %-compile,%,$@) compile \
		    $(MAKE_TRACE); \
	else \
		$(MAKE) -C $(patsubst %-compile,%,$@) compile \
		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
	fi

%-install: %-compile
	$(TRACE) toolchain/$(patsubst %-install,%,$@)/install
	@if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
		$(MAKE) -C $(patsubst %-install,%,$@) install \
		    $(MAKE_TRACE); \
	else \
		$(MAKE) -C $(patsubst %-install,%,$@) install \
		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
	fi

%-fixup: %-install
	$(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
	@$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)

%-clean:
	$(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
	@$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)