use target optimization flags for madwifi tools
[openwrt.git] / package / madwifi / Makefile
1
2 # Copyright (C) 2006 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_VERSION:=0.9.2
14 PKG_RELEASE:=1
15
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17 PKG_SOURCE_URL:=@SF/$(PKG_NAME)
18 PKG_MD5SUM:=a75baacbe07085ddc5cb28e1fb43edbb
19 PKG_CAT:=bzcat
20
21 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
22
23 include $(INCLUDE_DIR)/package.mk
24
25 RATE_CONTROL:=sample
26
27 ifeq ($(ARCH),mips)
28   HAL_TARGET:=mips-be-elf
29 endif
30 ifeq ($(ARCH),mipsel)
31   HAL_TARGET:=mips-le-elf
32 endif
33 ifeq ($(ARCH),i386)
34   HAL_TARGET:=i386-elf
35 endif
36 ifeq ($(ARCH),armeb)
37   HAL_TARGET:=xscale-be-elf
38 endif
39 ifeq ($(ARCH),powerpc)
40   HAL_TARGET:=powerpc-be-elf
41 endif
42
43 BUS:=PCI
44 ifneq ($(CONFIG_LINUX_2_4_AR531X),)
45   BUS:=AHB
46 endif
47 ifneq ($(CONFIG_LINUX_2_6_ARUBA),)
48   BUS:=PCI AHB  # no suitable HAL for AHB yet.
49 endif
50
51 BUS_MODULES:=
52 ifeq ($(findstring AHB,$(BUS)),AHB)
53   BUS_MODULES+=$(PKG_BUILD_DIR)/ath/ath_ahb.$(LINUX_KMOD_SUFFIX)
54 endif
55 ifeq ($(findstring PCI,$(BUS)),PCI)
56   BUS_MODULES+=$(PKG_BUILD_DIR)/ath/ath_pci.$(LINUX_KMOD_SUFFIX)
57 endif
58
59 MADWIFI_AUTOLOAD:= \
60         wlan \
61         wlan_scan_ap \
62         wlan_scan_sta \
63         ath_hal \
64         ath_rate_$(RATE_CONTROL) \
65         wlan_acl \
66         wlan_ccmp \
67         wlan_tkip \
68         wlan_wep \
69         wlan_xauth
70
71 ifeq ($(findstring AHB,$(BUS)),AHB)
72         MADWIFI_AUTOLOAD += ath_ahb
73 endif
74 ifeq ($(findstring PCI,$(BUS)),PCI)
75         MADWIFI_AUTOLOAD += ath_pci
76 endif
77
78 define KernelPackage/madwifi
79   SUBMENU:=Wireless Drivers
80   DEFAULT:=y if LINUX_2_6_BRCM || LINUX_2_6_ARUBA || LINUX_2_4_AR531X || LINUX_2_6_XSCALE, m if ALL
81   TITLE:=Driver for Atheros wireless chipsets
82   DESCRIPTION:=\
83         This package contains a driver for Atheros 802.11a/b/g chipsets.
84   URL:=http://madwifi.org/
85   VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
86   FILES:= \
87                 $(PKG_BUILD_DIR)/ath/ath_hal.$(LINUX_KMOD_SUFFIX) \
88                 $(BUS_MODULES) \
89                 $(PKG_BUILD_DIR)/ath_rate/$(RATE_CONTROL)/ath_rate_$(RATE_CONTROL).$(LINUX_KMOD_SUFFIX) \
90                 $(PKG_BUILD_DIR)/net80211/wlan*.$(LINUX_KMOD_SUFFIX)
91   AUTOLOAD:=$(call AutoLoad,50,$(MADWIFI_AUTOLOAD))
92 endef
93
94 MADWIFI_MAKEOPTS= -C $(PKG_BUILD_DIR) \
95                 PATH="$(TARGET_PATH)" \
96                 ARCH="$(LINUX_KARCH)" \
97                 CROSS_COMPILE="$(TARGET_CROSS)" \
98                 TARGET="$(HAL_TARGET)" \
99                 TOOLPREFIX="$(KERNEL_CROSS)" \
100                 TOOLPATH="$(KERNEL_CROSS)" \
101                 KERNELPATH="$(LINUX_DIR)" \
102                 LDOPTS=" " \
103                 ATH_RATE="ath_rate/$(RATE_CONTROL)" \
104                 DOMULTI=1
105
106 ifeq ($(findstring AHB,$(BUS)),AHB)
107   define Build/Compile/ahb
108         $(MAKE) $(MADWIFI_MAKEOPTS) BUS="AHB" modules
109   endef
110 endif
111
112 ifeq ($(findstring PCI,$(BUS)),PCI)
113   define Build/Compile/pci
114         $(MAKE) $(MADWIFI_MAKEOPTS) BUS="PCI" modules
115   endef
116 endif
117
118 define Build/Compile
119         $(call Build/Compile/ahb)
120         $(call Build/Compile/pci)
121         $(MAKE) $(MADWIFI_MAKEOPTS) \
122                 CFLAGS="$(TARGET_CFLAGS)" \
123                 tools
124 endef
125
126 define Build/InstallDev
127         mkdir -p $(STAGING_DIR)/usr/include/madwifi
128         $(CP) $(PKG_BUILD_DIR)/include $(STAGING_DIR)/usr/include/madwifi/
129         mkdir -p $(STAGING_DIR)/usr/include/madwifi/net80211
130         $(CP) $(PKG_BUILD_DIR)/net80211/*.h $(STAGING_DIR)/usr/include/madwifi/net80211/
131 endef
132
133 define Build/UninstallDev
134         rm -rf  $(STAGING_DIR)/usr/include/madwifi
135 endef
136
137 define KernelPackage/madwifi/install
138         mkdir -p $(1)/etc/init.d
139         mkdir -p $(1)/lib/modules/$(LINUX_VERSION)
140         mkdir -p $(1)/usr/sbin
141         install -m0755 ./files/madwifi.init $(1)/etc/init.d/madwifi
142         $(CP) $(PKG_BUILD_DIR)/tools/{madwifi_multi,80211debug,80211stats,athchans,athctrl,athdebug,athkey,athstats,wlanconfig} $(1)/usr/sbin/
143 endef
144
145 $(eval $(call KernelPackage,madwifi))