as31: Add .gitignore file to keep autogenerated files out of git
[linux-libre-firmware.git] / carl9170fw / toolchain / Makefile
1 BINUTILS_VER=2.23.1
2 BINUTILS_TAR=binutils-$(BINUTILS_VER).tar.bz2
3 BINUTILS_URL="http://mirrors.kernel.org/gnu/binutils/$(BINUTILS_TAR)"
4
5 NEWLIB_VER=2.0.0
6 NEWLIB_TAR=newlib-$(NEWLIB_VER).tar.gz
7 NEWLIB_URL="ftp://sourceware.org/pub/newlib/$(NEWLIB_TAR)"
8
9 GCC_VER=4.8.2
10 GCC_TAR=gcc-$(GCC_VER).tar.bz2
11 GCC_URL="http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VER)/$(GCC_TAR)"
12
13 MPFR_VER=3.1.2
14 MPFR_TAR=mpfr-$(MPFR_VER).tar.gz
15 MPFR_URL="http://ftpmirror.gnu.org/gnu/mpfr/$(MPFR_TAR)"
16
17 GMP_VER=5.1.3
18 GMP_TAR=gmp-$(GMP_VER).tar.gz
19 GMP_URL="http://ftpmirror.gnu.org/gnu/gmp/$(GMP_TAR)"
20
21 MPC_VER=1.0.1
22 MPC_TAR=mpc-$(MPC_VER).tar.gz
23 MPC_URL="http://ftpmirror.gnu.org/gnu/mpc/$(MPC_TAR)"
24
25 JOBS?=$(shell grep -c ^processor /proc/cpuinfo)
26
27 BASEDIR=$(shell pwd)
28
29 define checksum
30 @if grep -q '  $(subst .,\.,$(1))$$' SHA256SUMS; then                   \
31         grep '  $(subst .,\.,$(1))$$' SHA256SUMS | sha256sum -c || rm $(1);     \
32 else                                                                    \
33         echo "WARNING: no checksum defined for $(1)";                   \
34 fi
35 endef
36
37 all: clean gcc
38
39 src/$(MPFR_TAR):
40         wget -P "$(BASEDIR)/src" $(MPFR_URL)
41         $(call checksum,$@)
42
43 src/$(GMP_TAR):
44         wget -P "$(BASEDIR)/src" $(GMP_URL)
45         $(call checksum,$@)
46
47 src/$(MPC_TAR):
48         wget -P "$(BASEDIR)/src" $(MPC_URL)
49         $(call checksum,$@)
50
51 src/$(BINUTILS_TAR):
52         wget -P "$(BASEDIR)/src" $(BINUTILS_URL)
53         $(call checksum,$@)
54
55 src/$(NEWLIB_TAR):
56         wget -P "$(BASEDIR)/src" $(NEWLIB_URL)
57         $(call checksum,$@)
58
59 src/$(GCC_TAR):
60         wget -P "$(BASEDIR)/src" $(GCC_URL)
61         $(call checksum,$@)
62
63 src/mpfr-$(MPFR_VER): src/$(MPFR_TAR)
64         tar -C "$(BASEDIR)/src" -xf $<
65
66 src/gmp-$(GMP_VER): src/$(GMP_TAR)
67         tar -C "$(BASEDIR)/src" -xf $<
68
69 src/mpc-$(MPC_VER): src/$(MPC_TAR)
70         tar -C "$(BASEDIR)/src" -xf $<
71
72 src/binutils-$(BINUTILS_VER): src/$(BINUTILS_TAR)
73         tar -C "$(BASEDIR)/src" -xf $<
74
75 src/newlib-$(NEWLIB_VER): src/$(NEWLIB_TAR)
76         tar -C "$(BASEDIR)/src" -xf $<
77
78 src/gcc-$(GCC_VER): src/$(GCC_TAR) src/newlib-$(NEWLIB_VER)
79         tar -C "$(BASEDIR)/src" -xf $<
80         ln -s $(BASEDIR)/src/newlib-$(NEWLIB_VER)/newlib $@
81         ln -s $(BASEDIR)/src/newlib-$(NEWLIB_VER)/libgloss $@
82
83 binutils: src/binutils-$(BINUTILS_VER)
84         mkdir -p "$(BASEDIR)/build/binutils"
85         cd "$(BASEDIR)/build/binutils"; \
86         $(BASEDIR)/$</configure --target=sh-elf --prefix=$(BASEDIR)/inst; \
87         $(MAKE) -j$(JOBS); \
88         $(MAKE) install
89
90 gcc: src/gcc-$(GCC_VER) src/mpc-$(MPC_VER) src/gmp-$(GMP_VER) src/mpfr-$(MPFR_VER) binutils
91         cd "$(BASEDIR)/src/gcc-$(GCC_VER)"; \
92         ln -s ../gmp-$(GMP_VER) gmp; \
93         ln -s ../mpfr-$(MPFR_VER) mpfr; \
94         ln -s ../mpc-$(MPC_VER) mpc
95         mkdir -p "$(BASEDIR)/build/gcc"
96         cd "$(BASEDIR)/build/gcc"; \
97         $(BASEDIR)/$</configure --target=sh-elf --prefix=$(BASEDIR)/inst -enable-languages=c --without-pkgversion --with-newlib; \
98         $(MAKE) -j$(JOBS); \
99         $(MAKE) install
100
101 clean:
102         rm -rf "$(BASEDIR)/build" "$(BASEDIR)/inst"
103         
104 distclean: clean
105         rm -rf "$(BASEDIR)/src"