madwifi: the openwrt build system usually has a better idea of what the target arch...
[openwrt.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:=http://downloads.sourceforge.net/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://svn.madwifi.org/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 define Download/hal
50 FILE:=$(HAL_FILE)
51 URL:=http://mirror2.openwrt.org/sources
52 MD5SUM:=$(HAL_MD5SUM)
53 endef
54 $(eval $(call Download,hal))
55
56
57 ifneq ($(CONFIG_TARGET_atheros),)
58 BUS:=AHB
59 else
60 ifneq ($(CONFIG_PCI_SUPPORT),)
61 BUS:=PCI
62 endif
63 endif
64
65 ifneq ($(CONFIG_CPU_MIPS32_R2),)
66 ifeq ($(ARCH),mips)
67 HAL_TARGET:=mips32r2-be-elf
68 endif
69 ifeq ($(ARCH),mipsel)
70 HAL_TARGET:=mips32r2-le-elf
71 endif
72 else
73 ifeq ($(ARCH),mips)
74 HAL_TARGET:=$(if $(CONFIG_MADWIFI_UPSTREAM),mips-be-elf,mips32-be-elf)
75 endif
76 ifeq ($(ARCH),mipsel)
77 HAL_TARGET:=$(if $(CONFIG_MADWIFI_UPSTREAM),mips-le-elf,mips32-le-elf)
78 endif
79 endif
80 ifeq ($(ARCH),i386)
81 HAL_TARGET:=i386-elf
82 endif
83 ifeq ($(ARCH),i686)
84 HAL_TARGET:=i386-elf
85 endif
86 ifeq ($(BOARD),ixp4xx)
87 HAL_TARGET:=xscale-be-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
88 endif
89 ifeq ($(BOARD),iop32x)
90 HAL_TARGET:=xscale-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
91 endif
92 ifeq ($(BOARD),orion)
93 HAL_TARGET:=xscale-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
94 endif
95 ifeq ($(ARCH),powerpc)
96 HAL_TARGET:=powerpc-be-elf
97 endif
98 ifeq ($(BOARD),storm)
99 HAL_TARGET:=armv4-le-elf$(if $(CONFIG_EABI_SUPPORT),gnueabi)
100 endif
101 ifneq ($(CONFIG_TARGET_atheros),)
102 HAL_TARGET:=wisoc
103 endif
104
105 ifdef CONFIG_MADWIFI_RCA_MINSTREL
106 RATE_CONTROL:=minstrel
107 endif
108
109 ifdef CONFIG_MADWIFI_RCA_ONOE
110 RATE_CONTROL:=onoe
111 endif
112
113 ifdef CONFIG_MADWIFI_RCA_AMRR
114 RATE_CONTROL:=amrr
115 endif
116
117 ifdef CONFIG_MADWIFI_RCA_SAMPLERATE
118 RATE_CONTROL:=sample
119 endif
120
121 MADWIFI_FILES:= \
122 $(PKG_BUILD_DIR)/net80211/wlan.$(LINUX_KMOD_SUFFIX) \
123 $(PKG_BUILD_DIR)/net80211/wlan_scan_ap.$(LINUX_KMOD_SUFFIX) \
124 $(PKG_BUILD_DIR)/net80211/wlan_scan_sta.$(LINUX_KMOD_SUFFIX) \
125 $(PKG_BUILD_DIR)/ath_hal/ath_hal.$(LINUX_KMOD_SUFFIX) \
126 $(PKG_BUILD_DIR)/ath_rate/$(RATE_CONTROL)/ath_rate_$(RATE_CONTROL).$(LINUX_KMOD_SUFFIX) \
127 $(PKG_BUILD_DIR)/net80211/wlan_acl.$(LINUX_KMOD_SUFFIX) \
128 $(PKG_BUILD_DIR)/net80211/wlan_ccmp.$(LINUX_KMOD_SUFFIX) \
129 $(PKG_BUILD_DIR)/net80211/wlan_tkip.$(LINUX_KMOD_SUFFIX) \
130 $(PKG_BUILD_DIR)/net80211/wlan_wep.$(LINUX_KMOD_SUFFIX) \
131 $(PKG_BUILD_DIR)/net80211/wlan_xauth.$(LINUX_KMOD_SUFFIX) \
132
133 MADWIFI_AUTOLOAD:= \
134 wlan \
135 wlan_scan_ap \
136 wlan_scan_sta \
137 ath_hal \
138 ath_rate_$(RATE_CONTROL) \
139 wlan_acl \
140 wlan_ccmp \
141 wlan_tkip \
142 wlan_wep \
143 wlan_xauth \
144
145 ifeq ($(findstring AHB,$(BUS)),AHB)
146 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_ahb.$(LINUX_KMOD_SUFFIX)
147 MADWIFI_AUTOLOAD+= ath_ahb
148 endif
149 ifeq ($(findstring PCI,$(BUS)),PCI)
150 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_pci.$(LINUX_KMOD_SUFFIX)
151 MADWIFI_AUTOLOAD+= ath_pci
152 endif
153
154 MADWIFI_APPLETS:=80211stats athchans athkey athstats wlanconfig ath_info
155 ifdef CONFIG_MADWIFI_DEBUG
156 MADWIFI_APPLETS += athdebug 80211debug
157 endif
158 ifndef CONFIG_MADWIFI_UPSTREAM
159 MADWIFI_APPLETS += madwifi_multi
160 endif
161
162 define KernelPackage/madwifi
163 SUBMENU:=Wireless Drivers
164 TITLE:=Driver for Atheros wireless chipsets
165 URL:=http://madwifi.org/
166 DEPENDS:=+wireless-tools @PCI_SUPPORT||TARGET_atheros @!TARGET_avr32 @!TARGET_etrax @LINUX_2_6
167 FILES:=$(MADWIFI_FILES)
168 AUTOLOAD:=$(call AutoLoad,50,$(MADWIFI_AUTOLOAD))
169 endef
170
171 define KernelPackage/madwifi/description
172 This package contains a driver for Atheros 802.11a/b/g chipsets.
173 endef
174
175 define KernelPackage/madwifi/config
176 source "$(SOURCE)/Config.in"
177 endef
178
179 MADWIFI_INC = \
180 -I$(PKG_BUILD_DIR) \
181 -I$(PKG_BUILD_DIR)/include \
182 -I$(PKG_BUILD_DIR)/hal \
183 -I$(PKG_BUILD_DIR)/ath \
184 -I$(PKG_BUILD_DIR)/ath_hal \
185 -I$(PKG_BUILD_DIR)/net80211 \
186 -I$(STAGING_DIR)/usr/include/wprobe \
187 -include $(PKG_BUILD_DIR)/include/compat.h
188
189 MAKE_ARGS:= \
190 PATH="$(TARGET_PATH)" \
191 ARCH="$(LINUX_KARCH)" \
192 ARCH-y="$(LINUX_KARCH)" \
193 CROSS_COMPILE="$(TARGET_CROSS)" \
194 TARGET="$(HAL_TARGET)" \
195 TOOLPREFIX="$(KERNEL_CROSS)" \
196 TOOLPATH="$(KERNEL_CROSS)" \
197 KERNELPATH="$(LINUX_DIR)" \
198 LDOPTS="--no-warn-mismatch " \
199 ATH_RATE="ath_rate/$(RATE_CONTROL)" \
200 DO_MULTI=1 \
201 INCS="$(MADWIFI_INC)" \
202 $(if $(CONFIG_MADWIFI_DEBUG),,DEBUG=) WARNINGS="-Wno-unused"
203
204 MAKE_VARS:= \
205 COPTS="-DCONFIG_ATHEROS_RATE_DEFAULT='\"$(RATE_CONTROL)\"' -DATH_REVERSE_ENGINEERING=1" \
206
207 ifeq ($(CONFIG_MADWIFI_UPSTREAM),)
208 define Build/Prepare/HAL
209 rm -rf $(PKG_BUILD_DIR)/tmp
210 mkdir -p $(PKG_BUILD_DIR)/tmp
211 tar xvzf $(DL_DIR)/$(HAL_FILE) -C $(PKG_BUILD_DIR)/tmp
212 $(CP) $(PKG_BUILD_DIR)/tmp/ath_hal*/* $(PKG_BUILD_DIR)/hal/
213 rm -rf $(PKG_BUILD_DIR)/tmp
214 endef
215 endif
216
217 define Build/Prepare
218 $(call Build/Prepare/Default)
219 $(call Build/Prepare/HAL)
220 # patch cflags
221 $(SED) 's, -E[LB],,' \
222 -e 's, -mips2,,' \
223 -e 's, -mapcs-32,,' \
224 $(PKG_BUILD_DIR)/hal/public/*.inc
225 $(SED) 's,march=armv4,march=armv5te,' \
226 $(PKG_BUILD_DIR)/hal/public/xscale*.inc
227 endef
228
229 ifeq ($(findstring AHB,$(BUS)),AHB)
230 define Build/Compile/ahb
231 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="AHB" modules
232 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
233 endef
234 endif
235
236 ifeq ($(findstring PCI,$(BUS)),PCI)
237 define Build/Compile/pci
238 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="PCI" modules
239 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
240 endef
241 endif
242
243 define Build/Configure
244 $(SED) 's,-E[LB] ,,g' $(PKG_BUILD_DIR)/hal/public/*.inc
245 endef
246
247 define Build/Compile
248 $(call Build/Compile/ahb)
249 $(call Build/Compile/pci)
250 endef
251
252 define Build/InstallDev
253 mkdir -p $(1)/usr/include/madwifi
254 $(CP) $(PKG_BUILD_DIR)/include $(1)/usr/include/madwifi/
255 mkdir -p $(1)/usr/include/madwifi/net80211
256 $(CP) $(PKG_BUILD_DIR)/net80211/*.h $(1)/usr/include/madwifi/net80211/
257 endef
258
259 define KernelPackage/madwifi/install
260 $(INSTALL_DIR) $(1)/usr/sbin
261 $(CP) ./files/* $(1)/
262 $(CP) $(foreach applet,$(MADWIFI_APPLETS),$(PKG_BUILD_DIR)/tools/$(applet)) $(1)/usr/sbin/
263 endef
264
265 $(eval $(call KernelPackage,madwifi))
This page took 0.062341 seconds and 5 git commands to generate.