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