#!/usr/bin/env /bin/bash
#
# Copyright (C) 2006 Intel Corporation
#
# This script checks the current running kernel for appropriate dependencies
# and subsystems (namely, that ieee80211 is installed)
if [ ! "$1" ]; then
    DEST="/lib/modules/$(uname -r)/build"
else
    DEST=$1
fi

function check_installed()
{
	[ -e $DEST/net/ieee80211/Kconfig ] && return 0
	cat <<EOF
The ieee80211 subsystem was not found in your running kernel.  In order to 
patch the kernel to support the driver, you must first patch the kernel
to include the ieee80211 subsystem.

Aborting.
EOF
	return 1
}

function check_radiotap()
{
	grep -q IEEE80211_RADIOTAP $DEST/net/ieee80211/Kconfig && return 0
	cat << EOF
The version of the ieee80211 subsystem you have does not include the
Kconfig option for IEEE80211_RADIOTAP.  Please download a newer version
of the ieee80211 subsystem from http://ieee80211.sf.net and run:

	% make patch_kernel

*or with this driver*, run:

	% make add_radiotap

and then try again with this driver.

Aborting.
EOF
	return 1
}

check_installed && check_radiotap
