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