Merge branch 'master' into radar
[carl9170fw.git] / 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.0
10 GCC_TAR=gcc-$(GCC_VER).tar.bz2
11 GCC_URL="http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VER)/$(GCC_TAR)"
12
13 BASEDIR=$(shell pwd)
14
15 define checksum
16 @if grep -q '  $(subst .,\.,$(1))$$' SHA256SUMS; then                   \
17         grep '  $(subst .,\.,$(1))$$' SHA256SUMS | sha256sum -c;        \
18 else                                                                    \
19         echo "WARNING: no checksum defined for $(1)";                   \
20 fi
21 endef
22
23 all: gcc
24
25 src/$(BINUTILS_TAR):
26         wget -P src $(BINUTILS_URL)
27         $(call checksum,$@)
28
29 src/$(NEWLIB_TAR):
30         wget -P src $(NEWLIB_URL)
31         $(call checksum,$@)
32
33 src/$(GCC_TAR):
34         wget -P src $(GCC_URL)
35         $(call checksum,$@)
36
37 src/binutils-$(BINUTILS_VER): src/$(BINUTILS_TAR)
38         tar -C src -xf $<
39
40 src/newlib-$(NEWLIB_VER): src/$(NEWLIB_TAR)
41         tar -C src -xf $<
42
43 src/gcc-$(GCC_VER): src/$(GCC_TAR) src/newlib-$(NEWLIB_VER)
44         tar -C src -xf $<
45         ln -s $(BASEDIR)/src/newlib-$(NEWLIB_VER)/newlib $@
46         ln -s $(BASEDIR)/src/newlib-$(NEWLIB_VER)/libgloss $@
47
48 binutils: src/binutils-$(BINUTILS_VER)
49         mkdir -p build/binutils
50         cd build/binutils; \
51         $(BASEDIR)/$</configure --target=sh-elf --prefix=$(BASEDIR)/inst; \
52         $(MAKE) -j3; \
53         $(MAKE) install
54
55 gcc: src/gcc-$(GCC_VER) binutils
56         mkdir -p build/gcc
57         cd build/gcc; \
58         $(BASEDIR)/$</configure --target=sh-elf --prefix=$(BASEDIR)/inst -enable-languages=c --without-pkgversion --with-newlib; \
59         $(MAKE) -j3; \
60         $(MAKE) install
61
62 clean:
63         rm -rf build inst
64
65 distclean: clean
66         rm -rf src