2 GMP_URL=http://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER).tar.bz2
3 GMP_TAR=gmp-$(GMP_VER).tar.bz2
7 MPFR_URL=http://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=http://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=http://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
23 GCC_URL=http://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, \
75 $(MAKE) && $(MAKE) -j1 install \
80 $(call Common/Compile,GCC, \
82 --enable-languages=c \
85 --disable-libquadmath \
86 --with-gmp=$(TOOLCHAIN_DIR)/inst \
87 --with-mpfr=$(TOOLCHAIN_DIR)/inst \
88 --with-mpc=$(TOOLCHAIN_DIR)/inst \
90 $(MAKE) && $(MAKE) -j1 install \
95 # 2: dependencies on other packages
97 $(DL_DIR)/$($(1)_TAR):
99 wget -N -P $(DL_DIR) $($(1)_URL)
101 $(DL_DIR)/$($(1)_DIR)/.prepared: $(DL_DIR)/$($(1)_TAR)
102 tar -C $(DL_DIR) -x$(if $(findstring bz2,$($(1)_TAR)),j,z)f $(DL_DIR)/$($(1)_TAR)
103 $(if $($(1)_PATCHES), \
104 cat $($(1)_PATCHES) | \
105 patch -p1 -d $(DL_DIR)/$($(1)_DIR))
108 $(1)_DEPENDS = $(foreach pkg,$(2),$(BUILD_DIR)/$($(pkg)_DIR)/.built)
109 $(BUILD_DIR)/$($(1)_DIR)/.built: $(DL_DIR)/$($(1)_DIR)/.prepared $$($(1)_DEPENDS)
110 mkdir -p $(BUILD_DIR)/$($(1)_DIR)
115 rm -rf $(DL_DIR)/$($(1)_DIR)
117 toolchain: $(BUILD_DIR)/$($(1)_DIR)/.built
118 clean-dl: clean-dl-$(1)
119 download: $(DL_DIR)/$($(1)_DIR)/.prepared
123 all: toolchain firmware
125 rm -rf $(TOOLCHAIN_DIR)/build $(TOOLCHAIN_DIR)/inst
131 $(MAKE) -C target_firmware clean
134 +$(MAKE) -C target_firmware
136 .PHONY: all toolchain-clean clean clean-dl download toolchain firmware
138 $(eval $(call Build,GMP))
139 $(eval $(call Build,MPFR,GMP))
140 $(eval $(call Build,MPC,GMP MPFR))
141 $(eval $(call Build,BINUTILS))
142 $(eval $(call Build,GCC,MPC MPFR))