931c8bcc01794d6dd89b0da095a4f1bb28043fd6
[linux-libre-firmware.git] / ath9k_htc / Makefile
1 GMP_VER=5.0.5
2 GMP_URL=https://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=https://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=https://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=https://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 local/patches/binutils-elf32-xtensa-sec_cache.patch
21
22 GCC_VER=4.7.4
23 GCC_URL=https://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                 --disable-werror, \
76                 $(MAKE) && $(MAKE) -j1 install \
77         )
78 endef
79
80 define GCC/Compile
81         $(call Common/Compile,GCC, \
82                 --target=$(TARGET) \
83                 --enable-languages=c \
84                 --disable-libssp \
85                 --disable-shared \
86                 --disable-libquadmath \
87                 --with-gmp=$(TOOLCHAIN_DIR)/inst \
88                 --with-mpfr=$(TOOLCHAIN_DIR)/inst \
89                 --with-mpc=$(TOOLCHAIN_DIR)/inst \
90                 --with-newlib, \
91                 $(MAKE) && $(MAKE) -j1 install \
92         )
93 endef
94
95 # 1: package name
96 # 2: dependencies on other packages
97 define Build
98 $(DL_DIR)/$($(1)_TAR):
99         mkdir -p $(DL_DIR)
100         wget -N -P $(DL_DIR) $($(1)_URL)
101
102 $(DL_DIR)/$($(1)_DIR)/.prepared: $(DL_DIR)/$($(1)_TAR)
103         tar -C $(DL_DIR) -x$(if $(findstring bz2,$($(1)_TAR)),j,z)f $(DL_DIR)/$($(1)_TAR)
104         $(if $($(1)_PATCHES), \
105                 cat $($(1)_PATCHES) | \
106                 patch -p1 -d $(DL_DIR)/$($(1)_DIR))
107         touch $$@
108
109 $(1)_DEPENDS = $(foreach pkg,$(2),$(BUILD_DIR)/$($(pkg)_DIR)/.built)
110 $(BUILD_DIR)/$($(1)_DIR)/.built: $(DL_DIR)/$($(1)_DIR)/.prepared $$($(1)_DEPENDS)
111         mkdir -p $(BUILD_DIR)/$($(1)_DIR)
112         $($(1)/Compile)
113         touch $$@
114
115 clean-dl-$(1):
116         rm -rf $(DL_DIR)/$($(1)_DIR)
117
118 toolchain: $(BUILD_DIR)/$($(1)_DIR)/.built
119 clean-dl: clean-dl-$(1)
120 download: $(DL_DIR)/$($(1)_DIR)/.prepared
121
122 endef
123
124 all: toolchain firmware
125 toolchain-clean:
126         rm -rf $(TOOLCHAIN_DIR)/build $(TOOLCHAIN_DIR)/inst
127 clean-dl:
128 download:
129 toolchain:
130
131 clean:
132         $(MAKE) -C target_firmware clean
133
134 firmware: toolchain
135         +$(MAKE) -C target_firmware
136
137 .PHONY: all toolchain-clean clean clean-dl download toolchain firmware
138
139 $(eval $(call Build,GMP))
140 $(eval $(call Build,MPFR,GMP))
141 $(eval $(call Build,MPC,GMP MPFR))
142 $(eval $(call Build,BINUTILS))
143 $(eval $(call Build,GCC,MPC MPFR))