Remove struct ath_ahb_softc, it's pointless for supported kernels
[madwifi/.git] / patch-kernel / install.sh
1 #! /bin/sh
2 #
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.
6 #
7
8 set -e
9
10 die()
11 {
12         echo "FATAL ERROR: $1" >&2
13         exit 1
14 }
15
16 SRC=..
17 KERNEL_VERSION=$(uname -r)
18
19 if test -n "$1"; then
20         KERNEL_PATH="$1"
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"
25 else
26         die "Cannot guess kernel source location"
27 fi
28 fi
29 fi
30
31 test -d ${KERNEL_PATH} || die "No kernel directory ${KERNEL_PATH}"
32
33 PATCH()
34 {
35         patch -N $1 < $2
36 }
37
38 #
39 # Location of various pieces.  These mimic what is in Makefile.inc
40 # and can be overridden from the environment.
41 #
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}"
53
54 WIRELESS=${KERNEL_PATH}/drivers/net/wireless
55 test -d ${WIRELESS} || die "No wireless directory ${WIRELESS}"
56
57 echo "Copying top-level files"
58 MADWIFI=${WIRELESS}/madwifi
59 rm -rf ${MADWIFI}
60 mkdir -p ${MADWIFI}
61 cp -f ${SRC}/BuildCaps.inc ${SRC}/release.h ${MADWIFI}
62
63
64 echo "Copying source files"
65 FILES=$(cd ${SRC} && find ath ath_hal ath_rate include net80211 -name '*.[ch]')
66 FILES="$FILES $(cd ${SRC} && find ath_hal -name '*.ini')"
67 for f in $FILES; do
68         case $f in
69                 *.mod.c) continue;;
70         esac
71         mkdir -p $(dirname ${MADWIFI}/$f)
72         cp -f ${SRC}/$f ${MADWIFI}/$f
73 done
74
75 echo "Copying makefiles"
76 FILES=$(cd ${SRC} && find . -name Makefile.kernel)
77 for f in $FILES; do
78         cp -f ${SRC}/$f $(dirname ${MADWIFI}/$f)/Makefile
79 done
80
81
82 echo "Patching the build system"
83 cp -f Kconfig ${MADWIFI}
84 sed -i '/madwifi/d;/^endmenu/i\
85 source "drivers/net/wireless/madwifi/Kconfig"' ${WIRELESS}/Kconfig
86 sed -i '$a\
87 obj-$(CONFIG_ATHEROS) += madwifi/
88 /madwifi/d;' ${WIRELESS}/Makefile
89
90 echo "Done"