socat: update to 1.7.3.2
[openadk.git] / toolchain / Makefile
blob2502d3f155b3338769e3b2463426a0b9fa2ec3f0
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_BUILD_COMPILER_LLVM),y)
21 TARGETS:=binutils
22 TARGETS+=llvm
23 COMPILER:=llvm
24 endif
26 ifeq ($(ADK_TARGET_LIB_GLIBC),y)
27 TARGETS+=glibc
28 CLIB:=glibc
29 endif
30 ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
31 TARGETS+=uclibc-ng
32 CLIB:=uclibc-ng
33 endif
34 ifeq ($(ADK_TARGET_LIB_MUSL),y)
35 TARGETS+=musl
36 CLIB:=musl
37 endif
38 ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
39 TARGETS+=newlib
40 CLIB:=newlib
41 endif
43 ifeq ($(ADK_TARGET_BINFMT_FLAT)$(ADK_TARGET_OS_FROSTED),y)
44 TARGETS+=elf2flt
45 ELF2FLT:=elf2flt-install
46 endif
48 ifeq ($(ADK_TOOLCHAIN_WITH_GDB),y)
49 # disable gdb for some architectures
50 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),)
51 TARGETS+=gdb
52 GDB:=gdb-install
53 endif
54 endif
56 ifeq (${ADK_PRELINK},y)
57 TARGETS+=prelink-cross
58 endif
60 DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
61 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
62 FINAL:=$(patsubst %,%-final,$(COMPILER))
63 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
65 install: $(TARGETS_INSTALL)
66 clean: $(TARGETS_CLEAN)
67 download: $(DOWNLOAD)
68 final: $(FINAL)
71 ifeq ($(ADK_BUILD_COMPILER_LLVM),y)
72 $(COMPILER)-configure: binutils-install
73 else
74 $(COMPILER)-configure: binutils-install gmp-install mpfr-install mpc-install
75 endif
77 ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
78 $(CLIB)-install: $(COMPILER)-configure
79 else
80 $(CLIB)-install: $(COMPILER)-configure kernel-headers-configure
81 endif
82 $(COMPILER)-install: $(ELF2FLT) $(CLIB)-install
83 $(COMPILER)-final: $(COMPILER)-install $(GDB)
85 %-download:
86 $(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
87 $(MAKE) -C $(patsubst %-download,%,$@) fetch
88 $(CMD_TRACE) " done"
89 $(END_TRACE)
91 %-prepare:
92 $(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
93 @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
94 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
95 $(MAKE_TRACE); \
96 else \
97 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
98 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
100 $(CMD_TRACE) " done"
101 $(END_TRACE)
103 %-configure: %-prepare
104 $(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
105 @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
106 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
107 $(MAKE_TRACE); \
108 else \
109 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
110 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
112 $(CMD_TRACE) " done"
113 $(END_TRACE)
115 %-compile: %-configure
116 $(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
117 @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
118 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
119 $(MAKE_TRACE); \
120 else \
121 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
122 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
124 $(CMD_TRACE) " done"
125 $(END_TRACE)
127 %-install: %-compile
128 $(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
129 @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
130 $(MAKE) -C $(patsubst %-install,%,$@) install \
131 $(MAKE_TRACE); \
132 else \
133 $(MAKE) -C $(patsubst %-install,%,$@) install \
134 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
136 $(CMD_TRACE) " done"
137 $(END_TRACE)
139 %-final: %-install
140 $(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
141 @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
142 $(CMD_TRACE) " done"
143 $(END_TRACE)
145 %-clean:
146 $(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
147 @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
148 $(CMD_TRACE) " done"
149 $(END_TRACE)