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=f51c99cb114deb21a60075ffb494c1a210eb9d7cb729ed042ddb7de9534451ea
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=c05e3f02d09e0e9019384cdd58e0f19c64e6db1fd6f5ecf77b4b1c61ca253acc
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=6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e
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-2.34_fixup.patch local/patches/binutils.patch
24 BINUTILS_SUM=89f010078b6cf69c23c27897d686055ab89b198dddf819efb0a4f2c38a0b36e6
27 GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VER)/gcc-$(GCC_VER).tar.gz
28 GCC_TAR=gcc-$(GCC_VER).tar.gz
29 GCC_DIR=gcc-$(GCC_VER)
30 GCC_PATCHES=local/patches/gcc.patch
31 GCC_SUM=a931a750d6feadacbeecb321d73925cd5ebb6dfa7eff0802984af3aef63759f4
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))