3 # Shell script to integrate madwifi sources into a Linux
4 # source tree so it can be built statically. Typically this
5 # is done to simplify debugging with tools like kgdb.
12 echo "FATAL ERROR: $1" >&2
17 KERNEL_VERSION=$(uname -r)
21 else if test -e /lib/modules/${KERNEL_VERSION}/source; then
22 KERNEL_PATH="/lib/modules/${KERNEL_VERSION}/source"
23 else if test -e /lib/modules/${KERNEL_VERSION}/build; then
24 KERNEL_PATH="/lib/modules/${KERNEL_VERSION}/build"
26 die "Cannot guess kernel source location"
31 test -d ${KERNEL_PATH} || die "No kernel directory ${KERNEL_PATH}"
39 # Location of various pieces. These mimic what is in Makefile.inc
40 # and can be overridden from the environment.
42 SRC_HAL=${HAL:-${SRC}/ath_hal}
43 test -d ${SRC_HAL} || die "No ath_hal directory ${SRC_HAL}"
44 SRC_NET80211=${WLAN:-${SRC}/net80211}
45 test -d ${SRC_NET80211} || die "No net80211 directory ${SRC_NET80211}"
46 SRC_ATH=${ATH:-${SRC}/ath}
47 test -d ${SRC_ATH} || die "No ath directory ${SRC_ATH}"
48 SRC_ATH_RATE=${SRC}/ath_rate
49 test -d ${SRC_ATH_RATE} ||
50 die "No rate control algorithm directory ${SRC_ATH_RATE}"
51 SRC_COMPAT=${SRC}/include
52 test -d ${SRC_COMPAT} || die "No compat directory ${SRC_COMPAT}"
54 WIRELESS=${KERNEL_PATH}/drivers/net/wireless
55 test -d ${WIRELESS} || die "No wireless directory ${WIRELESS}"
57 if test -f ${WIRELESS}/Kconfig; then
60 else if test -f ${WIRELESS}/Config.in; then
64 die "Kernel build system is not supported"
68 echo "Copying top-level files"
69 MADWIFI=${WIRELESS}/madwifi
72 cp -f ${SRC}/BuildCaps.inc ${SRC}/release.h ${MADWIFI}
75 echo "Copying source files"
76 FILES=$(cd ${SRC} && find ath ath_hal ath_rate include net80211 -name '*.[ch]')
77 FILES="$FILES $(cd ${SRC} && find ath_hal -name '*.ini')"
82 mkdir -p $(dirname ${MADWIFI}/$f)
83 cp -f ${SRC}/$f ${MADWIFI}/$f
86 echo "Copying makefiles"
87 FILES=$(cd ${SRC} && find . -name Makefile.kernel)
89 cp -f ${SRC}/$f $(dirname ${MADWIFI}/$f)/Makefile
93 echo "Patching the build system"
94 if test "$kbuild" = 2.6; then
95 cp -f Kconfig ${MADWIFI}
96 sed -i '/madwifi/d;/^endmenu/i\
97 source "drivers/net/wireless/madwifi/Kconfig"' ${WIRELESS}/Kconfig
99 obj-$(CONFIG_ATHEROS) += madwifi/
100 /madwifi/d;' ${WIRELESS}/Makefile
102 cp -f Config.in ${MADWIFI}
104 source drivers/net/wireless/madwifi/Config.in
105 /madwifi/d' ${WIRELESS}/Config.in
106 sed -i '/madwifi/d;/include/i\
107 subdir-$(CONFIG_ATHEROS) += madwifi\
108 obj-$(CONFIG_ATHEROS) += madwifi/madwifi.o' ${WIRELESS}/Makefile
109 DST_DOC=${KERNEL_PATH}/Documentation
110 grep -q 'CONFIG_ATHEROS' ${DST_DOC}/Configure.help || \
111 PATCH ${DST_DOC}/Configure.help Configure.help.patch