#!/bin/bash
#
# This script will look for the ieee80211 subsystem on the system.
# The specific location of the subsystem's include files differs 
# based on how the user has installed the ieee80211 subsystem.
#
# For in-tree versions, the ieee80211 headers are in:
#   TARGET/include/net/
# For out-of-tree version, the ieee80211 headers are in:
#   TARGET/net/
# The purpose of finding the subsystem is two fold --
# First it is to determine what directory to provide as an added
# include directive to the compiler (-I).  Second it is to
# provide a path to look for the ieee80211 module version information
# specified via MODVERDIR.
#
# To that end, the routine returns two paths -- the include path and
# the path in which the include directory was found.
#
function find {
	for i in $@; do
	    PATH=${i%/}/

	    [ -e "${PATH}net/ieee80211.h" ] && {
		echo "${PATH}" "${PATH}"
		return 0
	    }

	    [ -e "${PATH}include/net/ieee80211.h" ] && {
		echo "${PATH}include/" "${PATH}"
		return 0
	    }
	done

	echo "$@"
	return 1
}

find $@
