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