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