add fw_printenv/fw_setenv
[openadk.git] / toolchain / Makefile
blob23f206ee7352bc86e414f0aa0ecabd0c23c68e9f
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, libelf and gmp
7 # 3) build and install minimal gcc c compiler
8 # 4) install kernel-headers
9 # 5) install libc headers
10 # 6) build and install initial static gcc
11 # 7) build and install full libc
12 # 8) build and install full shared gcc
13 # 9) rebuild and install full libc (in case of musl/uclibc)
14 # 10) build and install gdb debugger
16 include $(ADK_TOPDIR)/rules.mk
18 TARGETS:=binutils gmp mpfr mpc libelf gcc
20 ifeq ($(ADK_TARGET_LIB_GLIBC),y)
21 TARGETS+=glibc
22 CLIB:=glibc
23 endif
24 ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
25 TARGETS+=uclibc
26 CLIB:=uclibc
27 endif
28 ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
29 TARGETS+=uclibc-ng
30 CLIB:=uclibc-ng
31 endif
32 ifeq ($(ADK_TARGET_LIB_MUSL),y)
33 TARGETS+=musl
34 CLIB:=musl
35 endif
37 ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
38 TARGETS+=elf2flt
39 ELF2FLT:=elf2flt-install
40 endif
42 # disable gdb for arc and avr32
43 ifeq ($(ADK_TARGET_ARCH_ARC),)
44 TARGETS+=gdb
45 GDB:=gdb-install
46 endif
48 DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
49 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
50 FIXUP:=$(patsubst %,%-fixup,$(CLIB))
51 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
53 install: $(TARGETS_INSTALL)
54 clean: $(TARGETS_CLEAN)
55 download: $(DOWNLOAD)
56 fixup: $(FIXUP)
58 gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
59 $(CLIB)-prepare: gcc-prepare kernel-headers-prepare
60 gcc-configure: $(CLIB)-prepare
61 $(CLIB)-compile: gcc-configure
62 gcc-compile: $(CLIB)-install
63 $(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)
65 %-download:
66 $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
67 $(MAKE) -C $(patsubst %-download,%,$@) fetch
69 %-prepare:
70 $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
71 @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
72 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
73 $(MAKE_TRACE); \
74 else \
75 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
76 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
79 %-configure: %-prepare
80 $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
81 @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
82 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
83 $(MAKE_TRACE); \
84 else \
85 $(MAKE) -C $(patsubst %-configure,%,$@) configure \
86 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
89 %-compile: %-configure
90 $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
91 @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
92 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
93 $(MAKE_TRACE); \
94 else \
95 $(MAKE) -C $(patsubst %-compile,%,$@) compile \
96 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
99 %-install: %-compile
100 $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
101 @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
102 $(MAKE) -C $(patsubst %-install,%,$@) install \
103 $(MAKE_TRACE); \
104 else \
105 $(MAKE) -C $(patsubst %-install,%,$@) install \
106 CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
109 %-fixup: %-install
110 $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
111 @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
113 %-clean:
114 $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
115 @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)