Remove all references to svnversion, MadWifi svn is gone
[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 if test -f ${WIRELESS}/Kconfig; then
58         kbuild=2.6
59         kbuildconf=Kconfig
60 else if test -f ${WIRELESS}/Config.in; then
61         kbuild=2.4
62         kbuildconf=Config.in
63 else
64         die "Kernel build system is not supported"
65 fi
66 fi
67
68 echo "Copying top-level files"
69 MADWIFI=${WIRELESS}/madwifi
70 rm -rf ${MADWIFI}
71 mkdir -p ${MADWIFI}
72 cp -f ${SRC}/BuildCaps.inc ${SRC}/release.h ${MADWIFI}
73
74
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')"
78 for f in $FILES; do
79         case $f in
80                 *.mod.c) continue;;
81         esac
82         mkdir -p $(dirname ${MADWIFI}/$f)
83         cp -f ${SRC}/$f ${MADWIFI}/$f
84 done
85
86 echo "Copying makefiles"
87 FILES=$(cd ${SRC} && find . -name Makefile.kernel)
88 for f in $FILES; do
89         cp -f ${SRC}/$f $(dirname ${MADWIFI}/$f)/Makefile
90 done
91
92
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
98 sed -i '$a\
99 obj-$(CONFIG_ATHEROS) += madwifi/
100 /madwifi/d;' ${WIRELESS}/Makefile
101 else
102 cp -f Config.in ${MADWIFI}
103 sed -i '$a\
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
112 fi
113
114
115 echo "Done"