2 GMP_URL=https://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER).tar.bz2
3 GMP_TAR=gmp-$(GMP_VER).tar.bz2
7 MPFR_URL=https://ftp.gnu.org/gnu/mpfr/mpfr-$(MPFR_VER).tar.bz2
8 MPFR_TAR=mpfr-$(MPFR_VER).tar.bz2
9 MPFR_DIR=mpfr-$(MPFR_VER)
12 MPC_URL=https://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VER).tar.gz
13 MPC_TAR=mpc-$(MPC_VER).tar.gz
14 MPC_DIR=mpc-$(MPC_VER)
17 BINUTILS_URL=https://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS_VER).tar.bz2
18 BINUTILS_TAR=binutils-$(BINUTILS_VER).tar.bz2
19 BINUTILS_DIR=binutils-$(BINUTILS_VER)
20 BINUTILS_PATCHES=local/patches/binutils.patch local/patches/binutils-elf32-xtensa-sec_cache.patch
23 GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VER)/gcc-$(GCC_VER).tar.bz2
24 GCC_TAR=gcc-$(GCC_VER).tar.bz2
25 GCC_DIR=gcc-$(GCC_VER)
26 GCC_PATCHES=local/patches/gcc.patch
29 TOOLCHAIN_DIR=$(BASEDIR)/toolchain
31 DL_DIR=$(TOOLCHAIN_DIR)/dl
32 BUILD_DIR=$(TOOLCHAIN_DIR)/build
37 # 2: configure arguments
40 mkdir -p $(BUILD_DIR)/$($(1)_DIR)
41 +cd $(BUILD_DIR)/$($(1)_DIR) && \
42 $(DL_DIR)/$($(1)_DIR)/configure \
43 --prefix=$(TOOLCHAIN_DIR)/inst \
49 $(call Common/Compile,GMP, \
50 --disable-shared --enable-static, \
51 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
56 $(call Common/Compile,MPFR, \
57 --disable-shared --enable-static \
58 --with-gmp=$(TOOLCHAIN_DIR)/inst, \
59 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
64 $(call Common/Compile,MPC, \
65 --disable-shared --enable-static \
66 --with-gmp=$(TOOLCHAIN_DIR)/inst \
67 --with-mpfr=$(TOOLCHAIN_DIR)/inst, \
68 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
72 define BINUTILS/Compile
73 $(call Common/Compile,BINUTILS, \
76 $(MAKE) && $(MAKE) -j1 install \
81 $(call Common/Compile,GCC, \
83 --enable-languages=c \
86 --disable-libquadmath \
87 --with-gmp=$(TOOLCHAIN_DIR)/inst \
88 --with-mpfr=$(TOOLCHAIN_DIR)/inst \
89 --with-mpc=$(TOOLCHAIN_DIR)/inst \
91 $(MAKE) && $(MAKE) -j1 install \
96 # 2: dependencies on other packages
98 $(DL_DIR)/$($(1)_TAR):
100 wget -N -P $(DL_DIR) $($(1)_URL)
102 $(DL_DIR)/$($(1)_DIR)/.prepared: $(DL_DIR)/$($(1)_TAR)
103 tar -C $(DL_DIR) -x$(if $(findstring bz2,$($(1)_TAR)),j,z)f $(DL_DIR)/$($(1)_TAR)
104 $(if $($(1)_PATCHES), \
105 cat $($(1)_PATCHES) | \
106 patch -p1 -d $(DL_DIR)/$($(1)_DIR))
109 $(1)_DEPENDS = $(foreach pkg,$(2),$(BUILD_DIR)/$($(pkg)_DIR)/.built)
110 $(BUILD_DIR)/$($(1)_DIR)/.built: $(DL_DIR)/$($(1)_DIR)/.prepared $$($(1)_DEPENDS)
111 mkdir -p $(BUILD_DIR)/$($(1)_DIR)
116 rm -rf $(DL_DIR)/$($(1)_DIR)
118 toolchain: $(BUILD_DIR)/$($(1)_DIR)/.built
119 clean-dl: clean-dl-$(1)
120 download: $(DL_DIR)/$($(1)_DIR)/.prepared
124 all: toolchain firmware
126 rm -rf $(TOOLCHAIN_DIR)/build $(TOOLCHAIN_DIR)/inst
132 $(MAKE) -C target_firmware clean
135 +$(MAKE) -C target_firmware
137 .PHONY: all toolchain-clean clean clean-dl download toolchain firmware
139 $(eval $(call Build,GMP))
140 $(eval $(call Build,MPFR,GMP))
141 $(eval $(call Build,MPC,GMP MPFR))
142 $(eval $(call Build,BINUTILS))
143 $(eval $(call Build,GCC,MPC MPFR))