madwifi: add patch for building all modules (except for the HAL) into a single module...
[openwrt/svn-archive/archive.git] / package / madwifi / Makefile
1 #
2 # Copyright (C) 2006-2009 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10
11 PKG_NAME:=madwifi
12
13 ifneq ($(CONFIG_MADWIFI_UPSTREAM),)
14 PKG_VERSION:=0.9.4
15 PKG_RELEASE:=2
16
17 PKG_SOURCE:=madwifi-$(PKG_VERSION).tar.gz
18 PKG_SOURCE_URL:=@SF/madwifi
19 PKG_MD5SUM:=399d20de8d855a59f20058857c2178ad
20
21 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/madwifi-$(PKG_VERSION)
22
23 PATCH_DIR=./patches-upstream
24 else
25 # PKG_BRANCH:=madwifi-dfs
26 PKG_REV:=3314
27 PKG_VERSION:=r$(PKG_REV)
28 PKG_RELEASE:=2
29
30 PKG_SOURCE_PROTO:=svn
31 PKG_SOURCE_VERSION:=$(PKG_REV)
32 PKG_SOURCE_SUBDIR:=$(if $(PKG_BRANCH),$(PKG_BRANCH),madwifi-trunk)-$(PKG_VERSION)
33 PKG_SOURCE_URL:=http://madwifi-project.org/svn/madwifi/$(if $(PKG_BRANCH),branches/$(PKG_BRANCH),trunk)
34 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
35
36 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(if $(PKG_BRANCH),$(PKG_BRANCH),madwifi-trunk)-$(PKG_VERSION)
37
38 PATCH_DIR=./patches
39 endif
40
41 HAL_VERSION:=20090508
42 HAL_FILE:=ath_hal-$(HAL_VERSION).tgz
43 HAL_MD5SUM:=4ab7ae8bdb96c0be388c98bf8f92d5ca
44
45 PKG_BUILD_DEPENDS:=wprobe
46
47 include $(INCLUDE_DIR)/package.mk
48
49 ifdef CONFIG_MADWIFI_COMPRESSION
50 COMPRESSION:=1
51 else
52 COMPRESSION:=0
53 endif
54
55 define Download/hal
56 FILE:=$(HAL_FILE)
57 URL:=http://mirror2.openwrt.org/sources
58 MD5SUM:=$(HAL_MD5SUM)
59 endef
60 $(eval $(call Download,hal))
61
62
63 ifneq ($(CONFIG_TARGET_atheros),)
64 BUS:=AHB
65 else
66 ifneq ($(CONFIG_PCI_SUPPORT),)
67 BUS:=PCI
68 endif
69 endif
70
71 ifneq ($(CONFIG_CPU_MIPS32_R2),)
72 ifeq ($(ARCH),mips)
73 HAL_TARGET:=mips32r2-be-elf
74 endif
75 ifeq ($(ARCH),mipsel)
76 HAL_TARGET:=mips32r2-le-elf
77 endif
78 else
79 ifeq ($(ARCH),mips)
80 HAL_TARGET:=$(if $(CONFIG_MADWIFI_UPSTREAM),mips-be-elf,mips32-be-elf)
81 endif
82 ifeq ($(ARCH),mipsel)
83 HAL_TARGET:=$(if $(CONFIG_MADWIFI_UPSTREAM),mips-le-elf,mips32-le-elf)
84 endif
85 endif
86 ifeq ($(ARCH),i386)
87 HAL_TARGET:=i386-elf
88 endif
89 ifeq ($(ARCH),i686)
90 HAL_TARGET:=i386-elf
91 endif
92 ifeq ($(BOARD),ixp4xx)
93 HAL_TARGET:=xscale-be-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
94 endif
95 ifeq ($(BOARD),iop32x)
96 HAL_TARGET:=xscale-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
97 endif
98 ifeq ($(BOARD),orion)
99 HAL_TARGET:=xscale-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
100 endif
101 ifeq ($(ARCH),powerpc)
102 HAL_TARGET:=powerpc-be-elf
103 endif
104 ifeq ($(BOARD),gemini)
105 HAL_TARGET:=armv4-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
106 endif
107 ifneq ($(CONFIG_TARGET_atheros),)
108 HAL_TARGET:=wisoc
109 endif
110
111 ifdef CONFIG_MADWIFI_RCA_MINSTREL
112 RATE_CONTROL:=minstrel
113 endif
114
115 ifdef CONFIG_MADWIFI_RCA_ONOE
116 RATE_CONTROL:=onoe
117 endif
118
119 ifdef CONFIG_MADWIFI_RCA_AMRR
120 RATE_CONTROL:=amrr
121 endif
122
123 ifdef CONFIG_MADWIFI_RCA_SAMPLERATE
124 RATE_CONTROL:=sample
125 endif
126
127 ifneq ($(CONFIG_MADWIFI_SINGLE_MODULE),)
128 MADWIFI_FILES:= $(PKG_BUILD_DIR)/ath_hal/ath_hal.$(LINUX_KMOD_SUFFIX)
129 else
130 MADWIFI_FILES:= \
131 $(PKG_BUILD_DIR)/net80211/wlan.$(LINUX_KMOD_SUFFIX) \
132 $(PKG_BUILD_DIR)/net80211/wlan_scan_ap.$(LINUX_KMOD_SUFFIX) \
133 $(PKG_BUILD_DIR)/net80211/wlan_scan_sta.$(LINUX_KMOD_SUFFIX) \
134 $(PKG_BUILD_DIR)/ath_hal/ath_hal.$(LINUX_KMOD_SUFFIX) \
135 $(PKG_BUILD_DIR)/ath_rate/$(RATE_CONTROL)/ath_rate_$(RATE_CONTROL).$(LINUX_KMOD_SUFFIX) \
136 $(PKG_BUILD_DIR)/net80211/wlan_acl.$(LINUX_KMOD_SUFFIX) \
137 $(PKG_BUILD_DIR)/net80211/wlan_ccmp.$(LINUX_KMOD_SUFFIX) \
138 $(PKG_BUILD_DIR)/net80211/wlan_tkip.$(LINUX_KMOD_SUFFIX) \
139 $(PKG_BUILD_DIR)/net80211/wlan_wep.$(LINUX_KMOD_SUFFIX) \
140 $(PKG_BUILD_DIR)/net80211/wlan_xauth.$(LINUX_KMOD_SUFFIX)
141 endif
142
143 ifneq ($(CONFIG_MADWIFI_SINGLE_MODULE),)
144 MADWIFI_AUTOLOAD:= ath_hal
145 else
146 MADWIFI_AUTOLOAD:= \
147 wlan \
148 wlan_scan_ap \
149 wlan_scan_sta \
150 ath_hal \
151 ath_rate_$(RATE_CONTROL) \
152 wlan_acl \
153 wlan_ccmp \
154 wlan_tkip \
155 wlan_wep \
156 wlan_xauth
157 endif
158
159 ifeq ($(findstring AHB,$(BUS)),AHB)
160 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_ahb.$(LINUX_KMOD_SUFFIX)
161 MADWIFI_AUTOLOAD+= ath_ahb
162 endif
163 ifeq ($(findstring PCI,$(BUS)),PCI)
164 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_pci.$(LINUX_KMOD_SUFFIX)
165 MADWIFI_AUTOLOAD+= ath_pci
166 endif
167
168 MADWIFI_APPLETS:=80211stats athchans athkey athstats wlanconfig ath_info
169 ifdef CONFIG_MADWIFI_DEBUG
170 MADWIFI_APPLETS += athdebug 80211debug
171 endif
172 ifndef CONFIG_MADWIFI_UPSTREAM
173 MADWIFI_APPLETS += madwifi_multi
174 endif
175
176 define KernelPackage/madwifi
177 SUBMENU:=Wireless Drivers
178 TITLE:=Driver for Atheros wireless chipsets
179 URL:=http://madwifi-project.org/
180 DEPENDS:=+wireless-tools @PCI_SUPPORT||TARGET_atheros @!TARGET_avr32 @!TARGET_etrax @LINUX_2_6
181 FILES:=$(MADWIFI_FILES)
182 AUTOLOAD:=$(call AutoLoad,50,$(MADWIFI_AUTOLOAD))
183 endef
184
185 define KernelPackage/madwifi/description
186 This package contains a driver for Atheros 802.11a/b/g chipsets.
187 endef
188
189 define KernelPackage/madwifi/config
190 source "$(SOURCE)/Config.in"
191 endef
192
193 MADWIFI_INC = \
194 -I$(PKG_BUILD_DIR) \
195 -I$(PKG_BUILD_DIR)/include \
196 -I$(PKG_BUILD_DIR)/hal \
197 -I$(PKG_BUILD_DIR)/ath \
198 -I$(PKG_BUILD_DIR)/ath_hal \
199 -I$(PKG_BUILD_DIR)/net80211 \
200 -I$(STAGING_DIR)/usr/include/wprobe \
201 -include $(PKG_BUILD_DIR)/include/compat.h
202
203 MAKE_ARGS:= \
204 PATH="$(TARGET_PATH)" \
205 ARCH="$(LINUX_KARCH)" \
206 ARCH-y="$(LINUX_KARCH)" \
207 CROSS_COMPILE="$(TARGET_CROSS)" \
208 TARGET="$(HAL_TARGET)" \
209 TOOLPREFIX="$(KERNEL_CROSS)" \
210 TOOLPATH="$(KERNEL_CROSS)" \
211 KERNELPATH="$(LINUX_DIR)" \
212 LDOPTS="--no-warn-mismatch " \
213 ATH_RATE="$(RATE_CONTROL)" \
214 ATH_CAP_SUPERG_COMP="$(COMPRESSION)" \
215 DO_MULTI=1 \
216 SINGLE_MODULE=$(if $(CONFIG_MADWIFI_SINGLE_MODULE),1) \
217 INCS="$(MADWIFI_INC)" \
218 $(if $(CONFIG_MADWIFI_DEBUG),,DEBUG=) WARNINGS="-Wno-unused"
219
220 MAKE_VARS:= \
221 COPTS="-DATH_REVERSE_ENGINEERING=1" \
222
223 ifeq ($(CONFIG_MADWIFI_UPSTREAM),)
224 define Build/Prepare/HAL
225 rm -rf $(PKG_BUILD_DIR)/tmp
226 mkdir -p $(PKG_BUILD_DIR)/tmp
227 tar xvzf $(DL_DIR)/$(HAL_FILE) -C $(PKG_BUILD_DIR)/tmp
228 $(CP) $(PKG_BUILD_DIR)/tmp/ath_hal*/* $(PKG_BUILD_DIR)/hal/
229 rm -rf $(PKG_BUILD_DIR)/tmp
230 endef
231 endif
232
233 define Build/Prepare
234 $(call Build/Prepare/Default)
235 $(call Build/Prepare/HAL)
236 # patch cflags
237 $(SED) 's, -E[LB],,' \
238 -e 's, -mips2,,' \
239 -e 's, -mapcs-32,,' \
240 -e 's, -mlong-calls,,' \
241 $(PKG_BUILD_DIR)/hal/public/*.inc
242 $(SED) 's,march=armv4,march=armv5te,' \
243 $(PKG_BUILD_DIR)/hal/public/xscale*.inc
244 endef
245
246 ifeq ($(findstring AHB,$(BUS)),AHB)
247 define Build/Compile/ahb
248 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="AHB" modules
249 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
250 endef
251 endif
252
253 ifeq ($(findstring PCI,$(BUS)),PCI)
254 define Build/Compile/pci
255 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="PCI" modules
256 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
257 endef
258 endif
259
260 define Build/Configure
261 $(SED) 's,-E[LB] ,,g' $(PKG_BUILD_DIR)/hal/public/*.inc
262 endef
263
264 define Build/Compile
265 $(call Build/Compile/ahb)
266 $(call Build/Compile/pci)
267 endef
268
269 define Build/InstallDev
270 mkdir -p $(1)/usr/include/madwifi
271 $(CP) $(PKG_BUILD_DIR)/include $(1)/usr/include/madwifi/
272 mkdir -p $(1)/usr/include/madwifi/net80211
273 $(CP) $(PKG_BUILD_DIR)/net80211/*.h $(1)/usr/include/madwifi/net80211/
274 endef
275
276 define KernelPackage/madwifi/install
277 $(INSTALL_DIR) $(1)/usr/sbin
278 $(CP) ./files/* $(1)/
279 $(CP) $(foreach applet,$(MADWIFI_APPLETS),$(PKG_BUILD_DIR)/tools/$(applet)) $(1)/usr/sbin/
280 endef
281
282 $(eval $(call KernelPackage,madwifi))