nios2: patch still required
[openadk.git] / toolchain / Makefile
bloba7302bdb238bae9bf7b5c220396f1a35fa1b08e8
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 # Steps to build toolchains
5 # 1) build and install binutils
6 # 2) build and install mpfr, mpc and gmp
7 # 3) build and install initial gcc
8 # 4) install kernel-headers
9 # 5) build and install full libc
10 # 6) build and install full gcc
11 # 7) build and install gdb debugger
13 include $(ADK_TOPDIR)/rules.mk
15 ifeq ($(ADK_BUILD_COMPILER_GCC),y)
16 TARGETS:=binutils gmp mpfr mpc
17 TARGETS+=gcc
18 COMPILER:=gcc
19 endif
20 ifeq ($(ADK_TARGET_LIB_GLIBC),y)
21 TARGETS+=glibc
22 CLIB:=glibc
23 endif
24 ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
25 TARGETS+=uclibc-ng
26 CLIB:=uclibc-ng
27 endif
28 ifeq ($(ADK_TARGET_LIB_MUSL),y)
29 TARGETS+=musl
30 CLIB:=musl
31 endif
32 ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
33 TARGETS+=newlib
34 CLIB:=newlib
35 endif
37 ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
38 TARGETS+=elf2flt
39 ELF2FLT:=elf2flt-install
40 endif
42 ifeq ($(ADK_TOOLCHAIN_WITH_GDB),y)
43 # disable gdb for some architectures
44 ifeq ($(ADK_TARGET_ARCH_ARC)$(ADK_TARGET_ARCH_CR16)$(ADK_TARGET_ARCH_EPIPHANY)$(ADK_TARGET_ARCH_METAG)$(ADK_TARGET_ARCH_NDS32)$(ADK_TARGET_ARCH_OR1K),)
45 TARGETS+=gdb
46 GDB:=gdb-install
47 endif
48 endif
50 ifeq (${ADK_PRELINK},y)
51 TARGETS+=prelink-cross
52 endif
54 DOWNLOAD:=$(ADK_TARGET_OS)-headers-download $(patsubst %,%-download,$(TARGETS))
55 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
56 FINAL:=$(patsubst %,%-final,$(COMPILER))
57 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
59 install: $(TARGETS_INSTALL)
60 clean: $(TARGETS_CLEAN)
61 download: $(DOWNLOAD)
62 final: $(FINAL)
64 $(COMPILER)-configure: binutils-install gmp-install mpfr-install mpc-install
66 ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
67 $(CLIB)-install: $(COMPILER)-configure
68 else
69 $(CLIB)-install: $(COMPILER)-configure $(ADK_TARGET_OS)-headers-configure
70 endif
71 $(COMPILER)-install: $(ELF2FLT) $(CLIB)-install
72 $(COMPILER)-final: $(COMPILER)-install $(GDB)
74 %-download:
75 $(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
76 $(MAKE) -C $(patsubst %-download,%,$@) fetch
77 $(CMD_TRACE) " done"
78 $(END_TRACE)
80 %-prepare:
81 $(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
82 @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
83 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
84 $(MAKE_TRACE); \
85 else \
86 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
87 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
89 $(CMD_TRACE) " done"
90 $(END_TRACE)
92 %-configure: %-prepare
93 $(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
94 @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
95 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
96 $(MAKE_TRACE); \
97 else \
98 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
99 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
101 $(CMD_TRACE) " done"
102 $(END_TRACE)
104 %-compile: %-configure
105 $(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
106 @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
107 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
108 $(MAKE_TRACE); \
109 else \
110 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
111 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
113 $(CMD_TRACE) " done"
114 $(END_TRACE)
116 %-install: %-compile
117 $(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
118 @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
119 $(MAKE) -C $(patsubst %-install,%,$@) install \
120 $(MAKE_TRACE); \
121 else \
122 $(MAKE) -C $(patsubst %-install,%,$@) install \
123 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
125 $(CMD_TRACE) " done"
126 $(END_TRACE)
128 %-final: %-install
129 $(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
130 @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
131 $(CMD_TRACE) " done"
132 $(END_TRACE)
134 %-clean:
135 $(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
136 @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
137 $(CMD_TRACE) " done"
138 $(END_TRACE)