2 GMP_URL=https://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER).tar.bz2
3 GMP_TAR=gmp-$(GMP_VER).tar.bz2
5 GMP_SUM=a8109865f2893f1373b0a8ed5ff7429de8db696fc451b1036bd7bdf95bbeffd6
8 MPFR_URL=https://ftp.gnu.org/gnu/mpfr/mpfr-$(MPFR_VER).tar.bz2
9 MPFR_TAR=mpfr-$(MPFR_VER).tar.bz2
10 MPFR_DIR=mpfr-$(MPFR_VER)
11 MPFR_SUM=d3103a80cdad2407ed581f3618c4bed04e0c92d1cf771a65ead662cc397f7775
14 MPC_URL=https://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VER).tar.gz
15 MPC_TAR=mpc-$(MPC_VER).tar.gz
16 MPC_DIR=mpc-$(MPC_VER)
17 MPC_SUM=617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3
20 BINUTILS_URL=https://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS_VER).tar.bz2
21 BINUTILS_TAR=binutils-$(BINUTILS_VER).tar.bz2
22 BINUTILS_DIR=binutils-$(BINUTILS_VER)
23 BINUTILS_PATCHES=local/patches/binutils.patch local/patches/binutils-2.27_fixup.patch
24 BINUTILS_SUM=369737ce51587f92466041a97ab7d2358c6d9e1b6490b3940eb09fb0a9a6ac88
27 GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VER)/gcc-$(GCC_VER).tar.bz2
28 GCC_TAR=gcc-$(GCC_VER).tar.bz2
29 GCC_DIR=gcc-$(GCC_VER)
30 GCC_PATCHES=local/patches/gcc.patch
31 GCC_SUM=9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5
34 TOOLCHAIN_DIR=$(BASEDIR)/toolchain
36 DL_DIR=$(TOOLCHAIN_DIR)/dl
37 BUILD_DIR=$(TOOLCHAIN_DIR)/build
42 # 2: configure arguments
45 mkdir -p $(BUILD_DIR)/$($(1)_DIR)
46 +cd $(BUILD_DIR)/$($(1)_DIR) && \
47 $(DL_DIR)/$($(1)_DIR)/configure \
48 --prefix=$(TOOLCHAIN_DIR)/inst \
54 $(call Common/Compile,GMP, \
55 --disable-shared --enable-static, \
56 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
61 $(call Common/Compile,MPFR, \
62 --disable-shared --enable-static \
63 --with-gmp=$(TOOLCHAIN_DIR)/inst, \
64 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
69 $(call Common/Compile,MPC, \
70 --disable-shared --enable-static \
71 --with-gmp=$(TOOLCHAIN_DIR)/inst \
72 --with-mpfr=$(TOOLCHAIN_DIR)/inst, \
73 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
77 define BINUTILS/Compile
78 $(call Common/Compile,BINUTILS, \
81 $(MAKE) && $(MAKE) -j1 install \
86 $(call Common/Compile,GCC, \
88 --enable-languages=c \
91 --disable-libquadmath \
92 --with-gmp=$(TOOLCHAIN_DIR)/inst \
93 --with-mpfr=$(TOOLCHAIN_DIR)/inst \
94 --with-mpc=$(TOOLCHAIN_DIR)/inst \
96 $(MAKE) && $(MAKE) -j1 install \
101 # 2: dependencies on other packages
103 $(DL_DIR)/$($(1)_TAR):
105 wget -N -P $(DL_DIR) $($(1)_URL)
106 printf "%s %s\n" $($(1)_SUM) $$@ | shasum -a 256 -c
108 $(DL_DIR)/$($(1)_DIR)/.prepared: $(DL_DIR)/$($(1)_TAR)
109 tar -C $(DL_DIR) -x$(if $(findstring bz2,$($(1)_TAR)),j,z)f $(DL_DIR)/$($(1)_TAR)
110 $(if $($(1)_PATCHES), \
111 cat $($(1)_PATCHES) | \
112 patch -p1 -d $(DL_DIR)/$($(1)_DIR))
115 $(1)_DEPENDS = $(foreach pkg,$(2),$(BUILD_DIR)/$($(pkg)_DIR)/.built)
116 $(BUILD_DIR)/$($(1)_DIR)/.built: $(DL_DIR)/$($(1)_DIR)/.prepared $$($(1)_DEPENDS)
117 mkdir -p $(BUILD_DIR)/$($(1)_DIR)
122 rm -rf $(DL_DIR)/$($(1)_DIR)
124 toolchain: $(BUILD_DIR)/$($(1)_DIR)/.built
125 clean-dl: clean-dl-$(1)
126 download: $(DL_DIR)/$($(1)_DIR)/.prepared
130 all: toolchain firmware
132 rm -rf $(TOOLCHAIN_DIR)/build $(TOOLCHAIN_DIR)/inst
138 $(MAKE) -C target_firmware clean
141 +$(MAKE) -C target_firmware
143 .PHONY: all toolchain-clean clean clean-dl download toolchain firmware
145 $(eval $(call Build,GMP))
146 $(eval $(call Build,MPFR,GMP))
147 $(eval $(call Build,MPC,GMP MPFR))
148 $(eval $(call Build,BINUTILS))
149 $(eval $(call Build,GCC,MPC MPFR))