rename patches-r3776 to patches-testing
[openwrt/svn-archive/archive.git] / package / madwifi / Makefile
1 #
2 # Copyright (C) 2006-2008 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 PKG_NAME:=madwifi
13 PKG_REV:=$(if $(CONFIG_MADWIFI_TESTING),3776,3314)
14 PKG_VERSION:=r$(PKG_REV)
15 # PKG_BRANCH:=madwifi-dfs
16 PKG_RELEASE:=1
17
18 PKG_SOURCE_PROTO:=svn
19 PKG_SOURCE_VERSION:=$(PKG_REV)
20 PKG_SOURCE_SUBDIR:=$(if $(PKG_BRANCH),$(PKG_BRANCH),madwifi-trunk)-$(PKG_VERSION)
21 PKG_SOURCE_URL:=http://svn.madwifi.org/madwifi/$(if $(PKG_BRANCH),branches/$(PKG_BRANCH),trunk)
22 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
23
24 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(if $(PKG_BRANCH),$(PKG_BRANCH),madwifi-trunk)-$(PKG_VERSION)
25
26 PATCH_DIR=$(if $(CONFIG_MADWIFI_TESTING),./patches-testing,./patches)
27
28 include $(INCLUDE_DIR)/package.mk
29
30 ifneq ($(CONFIG_TARGET_atheros),)
31 BUS:=AHB
32 else
33 ifneq ($(CONFIG_PCI_SUPPORT),)
34 BUS:=PCI
35 endif
36 endif
37
38 # XXX: remove this check later when we have PCI support properly detected on all targets
39 ifneq ($(CONFIG_TARGET_ar7)$(CONFIG_TARGET_uml),)
40 BUS:=
41 endif
42
43 ifeq ($(ARCH),mips)
44 HAL_TARGET:=mips-be-elf
45 endif
46 ifeq ($(ARCH),mipsel)
47 HAL_TARGET:=mips-le-elf
48 endif
49 ifeq ($(ARCH),i386)
50 HAL_TARGET:=i386-elf
51 endif
52 ifeq ($(ARCH),i686)
53 HAL_TARGET:=i386-elf
54 endif
55 ifeq ($(BOARD),ixp4xx)
56 HAL_TARGET:=xscale-be-elf
57 endif
58 ifeq ($(BOARD),iop32x)
59 HAL_TARGET:=xscale-le-elf
60 endif
61 ifeq ($(BOARD),orion)
62 HAL_TARGET:=xscale-le-elf
63 endif
64 ifeq ($(ARCH),powerpc)
65 HAL_TARGET:=powerpc-be-elf
66 endif
67 ifeq ($(BOARD),storm)
68 HAL_TARGET:=armv4-le-elf
69 endif
70 ifneq ($(CONFIG_TARGET_atheros),)
71 HAL_TARGET:=wisoc
72 endif
73
74 ifdef CONFIG_MADWIFI_RCA_MINSTREL
75 RATE_CONTROL:=minstrel
76 endif
77
78 ifdef CONFIG_MADWIFI_RCA_ONOE
79 RATE_CONTROL:=onoe
80 endif
81
82 ifdef CONFIG_MADWIFI_RCA_AMRR
83 RATE_CONTROL:=amrr
84 endif
85
86 ifdef CONFIG_MADWIFI_RCA_SAMPLERATE
87 RATE_CONTROL:=sample
88 endif
89
90 MADWIFI_FILES:= \
91 $(PKG_BUILD_DIR)/net80211/wlan.$(LINUX_KMOD_SUFFIX) \
92 $(PKG_BUILD_DIR)/net80211/wlan_scan_ap.$(LINUX_KMOD_SUFFIX) \
93 $(PKG_BUILD_DIR)/net80211/wlan_scan_sta.$(LINUX_KMOD_SUFFIX) \
94 $(PKG_BUILD_DIR)/ath_hal/ath_hal.$(LINUX_KMOD_SUFFIX) \
95 $(PKG_BUILD_DIR)/ath_rate/$(RATE_CONTROL)/ath_rate_$(RATE_CONTROL).$(LINUX_KMOD_SUFFIX) \
96 $(PKG_BUILD_DIR)/net80211/wlan_acl.$(LINUX_KMOD_SUFFIX) \
97 $(PKG_BUILD_DIR)/net80211/wlan_ccmp.$(LINUX_KMOD_SUFFIX) \
98 $(PKG_BUILD_DIR)/net80211/wlan_tkip.$(LINUX_KMOD_SUFFIX) \
99 $(PKG_BUILD_DIR)/net80211/wlan_wep.$(LINUX_KMOD_SUFFIX) \
100 $(PKG_BUILD_DIR)/net80211/wlan_xauth.$(LINUX_KMOD_SUFFIX) \
101
102 MADWIFI_AUTOLOAD:= \
103 wlan \
104 wlan_scan_ap \
105 wlan_scan_sta \
106 ath_hal \
107 ath_rate_$(RATE_CONTROL) \
108 wlan_acl \
109 wlan_ccmp \
110 wlan_tkip \
111 wlan_wep \
112 wlan_xauth \
113
114 ifeq ($(findstring AHB,$(BUS)),AHB)
115 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_ahb.$(LINUX_KMOD_SUFFIX)
116 MADWIFI_AUTOLOAD+= ath_ahb
117 endif
118 ifeq ($(findstring PCI,$(BUS)),PCI)
119 MADWIFI_FILES+= $(PKG_BUILD_DIR)/ath/ath_pci.$(LINUX_KMOD_SUFFIX)
120 MADWIFI_AUTOLOAD+= ath_pci
121 endif
122
123 MADWIFI_APPLETS:=80211stats,athchans,athctrl,athkey,athstats,wlanconfig,$(if $(CONFIG_MADWIFI_TESTING),ath_info/)ath_info
124 ifdef CONFIG_MADWIFI_DEBUG
125 MADWIFI_APPLETS:=$(strip $(MADWIFI_APPLETS)),athdebug,80211debug
126 endif
127
128
129 define KernelPackage/madwifi
130 SUBMENU:=Wireless Drivers
131 TITLE:=Driver for Atheros wireless chipsets
132 URL:=http://madwifi.org/
133 DEPENDS:=+wireless-tools @PCI_SUPPORT||TARGET_atheros @!TARGET_ar7 @!TARGET_avr32 @!TARGET_etrax @!TARGET_uml
134 FILES:=$(MADWIFI_FILES)
135 AUTOLOAD:=$(call AutoLoad,50,$(MADWIFI_AUTOLOAD))
136 endef
137
138 define KernelPackage/madwifi/description
139 This package contains a driver for Atheros 802.11a/b/g chipsets.
140 endef
141
142 define KernelPackage/madwifi/config
143 source "$(SOURCE)/Config.in"
144 endef
145
146 MAKE_ARGS:= \
147 PATH="$(TARGET_PATH)" \
148 ARCH="$(LINUX_KARCH)" \
149 CROSS_COMPILE="$(TARGET_CROSS)" \
150 TARGET="$(HAL_TARGET)" \
151 TOOLPREFIX="$(KERNEL_CROSS)" \
152 TOOLPATH="$(KERNEL_CROSS)" \
153 KERNELPATH="$(LINUX_DIR)" \
154 LDOPTS="--no-warn-mismatch " \
155 ATH_RATE="ath_rate/$(RATE_CONTROL)" \
156 DO_MULTI=1
157
158 ifneq ($(CONFIG_MADWIFI_TESTING),)
159 MAKE_ARGS += $(if $(CONFIG_MADWIFI_DEBUG),,ATH_DEBUG=)
160 else
161 MAKE_ARGS += $(if $(CONFIG_MADWIFI_DEBUG),,DEBUG=) WARNINGS="-Wno-unused"
162 endif
163
164 MAKE_VARS:= \
165 COPTS="-DCONFIG_ATHEROS_RATE_DEFAULT='\"$(RATE_CONTROL)\"' -DATH_REVERSE_ENGINEERING=1" \
166
167 HALFILE:=$(lastword $(sort $(wildcard ./ath_hal-*.tgz)))
168 ifneq ($(HALFILE),)
169 define Build/Prepare
170 $(call Build/Prepare/Default)
171 rm -rf $(PKG_BUILD_DIR)/tmp
172 mkdir -p $(PKG_BUILD_DIR)/tmp
173 tar xvzf $(HALFILE) -C $(PKG_BUILD_DIR)/tmp
174 $(CP) $(PKG_BUILD_DIR)/tmp/ath_hal*/* $(PKG_BUILD_DIR)/hal/
175 rm -rf $(PKG_BUILD_DIR)/tmp
176 # patch cflags
177 $(SED) 's, -E[LB],,' \
178 -e 's, -mips2,,' \
179 -e 's, -mapcs-32,,' \
180 $(PKG_BUILD_DIR)/hal/public/*.inc
181 $(SED) 's,march=armv4,march=armv5te,' \
182 $(PKG_BUILD_DIR)/hal/public/xscale*.inc
183 endef
184 endif
185
186 ifeq ($(findstring AHB,$(BUS)),AHB)
187 define Build/Compile/ahb
188 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="AHB" modules
189 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
190 endef
191 endif
192
193 ifeq ($(findstring PCI,$(BUS)),PCI)
194 define Build/Compile/pci
195 $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) BUS="PCI" modules
196 $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS) CFLAGS="$(TARGET_CFLAGS)" tools
197 endef
198 endif
199
200 define Build/Configure
201 $(SED) 's,-E[LB] ,,g' $(PKG_BUILD_DIR)/hal/public/*.inc
202 endef
203
204 define Build/Compile
205 $(call Build/Compile/ahb)
206 $(call Build/Compile/pci)
207 endef
208
209 define Build/InstallDev
210 mkdir -p $(1)/usr/include/madwifi
211 $(CP) $(PKG_BUILD_DIR)/include $(1)/usr/include/madwifi/
212 mkdir -p $(1)/usr/include/madwifi/net80211
213 $(CP) $(PKG_BUILD_DIR)/net80211/*.h $(1)/usr/include/madwifi/net80211/
214 endef
215
216 define KernelPackage/madwifi/install
217 $(INSTALL_DIR) $(1)/lib/wifi
218 $(INSTALL_DATA) ./files/lib/wifi/madwifi.sh $(1)/lib/wifi
219 $(INSTALL_DIR) $(1)/usr/sbin
220 $(CP) $(PKG_BUILD_DIR)/tools/{madwifi_multi,$(MADWIFI_APPLETS)} $(1)/usr/sbin/
221 endef
222
223 $(eval $(call KernelPackage,madwifi))