-define Package/kmod-madwifi
- SECTION:=drivers
- CATEGORY:=Drivers
- DEFAULT:=y if LINUX_2_6_BRCM || LINUX_2_6_ARUBA || LINUX_2_4_AR531X || LINUX_2_6_XSCALE, m if ALL
- TITLE:=Driver for Atheros wireless chipsets
- DESCRIPTION:=Driver for Atheros 802.11a/b/g chipsets
- URL:=http://madwifi.org/
- VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
+MAKE_ARGS:= \
+ PATH="$(TARGET_PATH)" \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ TARGET="$(HAL_TARGET)" \
+ TOOLPREFIX="$(KERNEL_CROSS)" \
+ TOOLPATH="$(KERNEL_CROSS)" \
+ KERNELPATH="$(LINUX_DIR)" \
+ LDOPTS="--no-warn-mismatch " \
+ ATH_RATE="ath_rate/$(RATE_CONTROL)" \
+ DO_MULTI=1
+
+ifneq ($(CONFIG_MADWIFI_TESTING),)
+ MAKE_ARGS += $(if $(CONFIG_MADWIFI_DEBUG),,ATH_DEBUG=)
+else
+ MAKE_ARGS += $(if $(CONFIG_MADWIFI_DEBUG),,DEBUG=) WARNINGS="-Wno-unused"
+endif
+
+MAKE_VARS:= \
+ COPTS="-DCONFIG_ATHEROS_RATE_DEFAULT='\"$(RATE_CONTROL)\"' -DATH_REVERSE_ENGINEERING=1" \
+
+ifeq ($(CONFIG_MADWIFI_UPSTREAM),)
+ HALFILE:=$(lastword $(sort $(wildcard ./ath_hal-*.tgz)))
+endif
+
+ifneq ($(HALFILE),)
+ define Build/Prepare/HAL
+ rm -rf $(PKG_BUILD_DIR)/tmp
+ mkdir -p $(PKG_BUILD_DIR)/tmp
+ tar xvzf $(HALFILE) -C $(PKG_BUILD_DIR)/tmp
+ $(CP) $(PKG_BUILD_DIR)/tmp/ath_hal*/* $(PKG_BUILD_DIR)/hal/
+ rm -rf $(PKG_BUILD_DIR)/tmp
+ endef
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(call Build/Prepare/HAL)
+ # patch cflags
+ $(SED) 's, -E[LB],,' \
+ -e 's, -mips2,,' \
+ -e 's, -mapcs-32,,' \
+ $(PKG_BUILD_DIR)/hal/public/*.inc
+ $(SED) 's,march=armv4,march=armv5te,' \
+ $(PKG_BUILD_DIR)/hal/public/xscale*.inc