remove ar5416SetMulticastFilter
[librecmc/open-ath9k-htc-firmware.git] / Makefile
1 GMP_VER=5.0.5
2 GMP_URL=http://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER).tar.bz2
3 GMP_TAR=gmp-$(GMP_VER).tar.bz2
4 GMP_DIR=gmp-$(GMP_VER)
5
6 MPFR_VER=3.1.1
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)
10
11 MPC_VER=1.0.1
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)
15
16 BINUTILS_VER=2.23.1
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
21
22 GCC_VER=4.7.2
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
27
28 BASEDIR=$(shell pwd)
29 TOOLCHAIN_DIR=$(BASEDIR)/toolchain
30 TARGET=xtensa-elf
31 DL_DIR=$(TOOLCHAIN_DIR)/dl
32 BUILD_DIR=$(TOOLCHAIN_DIR)/build
33
34 all: toolchain
35
36 # 1: package name
37 # 2: configure arguments
38 # 3: make command
39 define Common/Compile
40         mkdir -p $(BUILD_DIR)/$($(1)_DIR)
41         +cd $(BUILD_DIR)/$($(1)_DIR) && \
42         $(DL_DIR)/$($(1)_DIR)/configure \
43                 --prefix=$(TOOLCHAIN_DIR)/inst \
44                 $(2) && \
45         $(3)
46 endef
47
48 define GMP/Compile
49         $(call Common/Compile,GMP, \
50                 --disable-shared --enable-static, \
51                 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
52         )
53 endef
54
55 define MPFR/Compile
56         $(call Common/Compile,MPFR, \
57                 --disable-shared --enable-static \
58                 --with-gmp=$(TOOLCHAIN_DIR)/inst, \
59                 $(MAKE) && $(MAKE) check && $(MAKE) -j1 install \
60         )
61 endef
62
63 define MPC/Compile
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 \
69         )
70 endef
71
72 define BINUTILS/Compile
73         $(call Common/Compile,BINUTILS, \
74                 --target=$(TARGET), \
75                 $(MAKE) && $(MAKE) -j1 install \
76         )
77 endef
78
79 define GCC/Compile
80         $(call Common/Compile,GCC, \
81                 --target=$(TARGET) \
82                 --enable-languages=c \
83                 --disable-libssp \
84                 --disable-shared \
85                 --disable-libquadmath \
86                 --with-gmp=$(TOOLCHAIN_DIR)/inst \
87                 --with-mpfr=$(TOOLCHAIN_DIR)/inst \
88                 --with-mpc=$(TOOLCHAIN_DIR)/inst \
89                 --with-newlib, \
90                 $(MAKE) && $(MAKE) -j1 install \
91         )
92 endef
93
94 # 1: package name
95 # 2: dependencies on other packages
96 define Build
97 $(DL_DIR)/$($(1)_TAR):
98         mkdir -p $(DL_DIR)
99         wget -N -P $(DL_DIR) $($(1)_URL)
100
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))
106         touch $$@
107
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)
111         $($(1)/Compile)
112         touch $$@
113
114 clean-dl-$(1):
115         rm -rf $(DL_DIR)/$($(1)_DIR)
116
117 toolchain: $(BUILD_DIR)/$($(1)_DIR)/.built
118 clean-dl: clean-dl-$(1)
119 download: $(DL_DIR)/$($(1)_DIR)/.prepared
120
121 endef
122
123 all: toolchain firmware
124 toolchain-clean:
125         rm -rf $(TOOLCHAIN_DIR)/build $(TOOLCHAIN_DIR)/inst
126 clean-dl:
127 download:
128 toolchain:
129
130 clean:
131         $(MAKE) -C target_firmware clean
132
133 firmware: toolchain
134         +$(MAKE) -C target_firmware
135
136 .PHONY: all toolchain-clean clean clean-dl download toolchain firmware
137
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))