#
# Makefile for the Linux Wireless network device drivers.
#
# Original makefile by Peter Johanson
#
# NOTE: This make file can serve as both an external Makefile (launched
#       directly by the user), or as the sub-dir Makefile used by the kernel
# 	build system.

# If CONFIG_IPW2100 isn't set, we'll assume the user has never configured
# their kernel to include this module and set up some defaults.
#
# NOTE: If you have previously added IPW2100 to your kernel and configured it
#       for inclusion, these settings will be overridden by your kernel
#       configuration.
ifndef CONFIG_IPW2100
EXTERNAL_BUILD=y
CONFIG_IPW2100=m
CONFIG_IPW2200=m
CONFIG_IPW_DEBUG=y

# If you are not interested in using monitor mode, simply comment out:
#
# NOTE:  If you have problems compiling due to IW_MODE_MONITOR not being
#        defined then you need to update the wireless extension version
#	 installed in your kernel, or comment this line out.
CONFIG_IPW2100_MONITOR=y

endif

# We have to add drivers/net/wireless until ieee802_11.h is in the default
# include path
EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/wireless

ifeq ($(CONFIG_IPW_DEBUG),y)
	EXTRA_CFLAGS += -g -Wa,-adhlms=$@.lst
endif


list-m :=
list-$(CONFIG_IPW2100) += ipw2100

ifeq ($(CONFIG_USERMODE),)
ifeq ($(CONFIG_NET_WIRELESS),y)
obj-$(CONFIG_IPW2100) += ipw2100.o
obj-$(CONFIG_IPW2100) += ipw2200.o
endif
endif

ifndef ($(CONFIG_IEEE80211))
CONFIG_IEEE80211=$(CONFIG_IPW2100)
CONFIG_IEEE80211_DEBUG=y

# If you do not want any encryption/decryptoin code in the driver, comment out
# this line:
CONFIG_IEEE80211_CRYPT=$(CONFIG_IEEE80211)

# If you want to build WPA support, uncomment this line:
CONFIG_IEEE80211_WPA=$(CONFIG_IEEE80211_CRYPT)

endif

list-$(CONFIG_IEEE80211) += ieee80211
list-$(CONFIG_IEEE80211_CRYPT) += ieee80211_crypt
list-$(CONFIG_IEEE80211_CRYPT) += ieee80211_crypt_wep
list-$(CONFIG_IEEE80211_WPA) += ieee80211_crypt_ccmp
list-$(CONFIG_IEEE80211_WPA) += ieee80211_crypt_tkip

obj-$(CONFIG_IEEE80211) += ieee80211.o
obj-$(CONFIG_IEEE80211_CRYPT) += ieee80211_crypt.o
obj-$(CONFIG_IEEE80211_CRYPT) += ieee80211_crypt_wep.o
obj-$(CONFIG_IEEE80211_WPA) += ieee80211_crypt_ccmp.o
obj-$(CONFIG_IEEE80211_WPA) += ieee80211_crypt_tkip.o
ieee80211-objs := \
	ieee80211_module.o \
	ieee80211_tx.o \
	ieee80211_rx.o \
	ieee80211_wx.o

#
# If you receive a compile message about multiple definitions of
# CONFIG_IPW_DEBUG, then you have
# likely previously included the IPW2100 into the full kernel build, and
# these definitions are now being set up by the kernel build system.
#
# To correct this, remove any CONFIG_{IPW,IEEE80211}* lines from
# $(KSRC)/.config and $(KSRC)/include/linux/autoconf.h
#

EXTRA_CFLAGS += -DCONFIG_PM

ifeq ($(EXTERNAL_BUILD),y)
ifdef CONFIG_IPW_DEBUG
EXTRA_CFLAGS += -DCONFIG_IPW_DEBUG=$(CONFIG_IPW_DEBUG)
endif
ifdef CONFIG_IPW2100_MONITOR
EXTRA_CFLAGS += -DCONFIG_IPW2100_MONITOR=$(CONFIG_IPW2100_MONITOR)
endif
ifdef CONFIG_IEEE80211_DEBUG
EXTRA_CFLAGS += -DCONFIG_IEEE80211_DEBUG=$(CONFIG_IEEE80211_DEBUG)
endif
ifdef CONFIG_IEEE80211_CRYPT
EXTRA_CFLAGS += -DCONFIG_IEEE80211_CRYPT=$(CONFIG_IEEE80211_CRYPT)
ifdef CONFIG_IEEE80211_WPA
EXTRA_CFLAGS += -DCONFIG_IEEE80211_WPA=$(CONFIG_IEEE80211_WPA)
EXTRA_CFLAGS += -DCONFIG_IEEE80211_CRYPT_TKIP=$(CONFIG_IEEE80211_WPA)
EXTRA_CFLAGS += -DCONFIG_IEEE80211_CRYPT_CCMP=$(CONFIG_IEEE80211_WPA)
endif
endif
endif

# Here we begin the portion that is executed if the user invoked this Makefile
# directly.

KERNEL_SOURCE ?= /lib/modules/$(shell uname -r)/build

all: modules

modules modules_install clean:
	$(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(shell pwd) $@

install: modules_install




.PHONY: TAGS tags

RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
define all-sources
	( find . $(RCS_FIND_IGNORE) -name '*.[chS]' -print )
endef

TAGS:
	$(all-sources) | etags -
tags:
	rm -f $@
	CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
	$(all-sources) | xargs ctags $$CTAGSF -a

