# This is the Makefile used by the Linux kernel build system

ifndef NOCHECK

ifneq ($(VERSION).$(PATCHLEVEL),2.6)
$(error Only Linux 2.6.x is supported)
endif

ifneq (,$(filter $(SUBLEVEL),0 1 2 3 4 5 6 7 8 9 10 11))
$(error This kernel is too old and not supported)
endif

ifneq (,$(filter $(SUBLEVEL),12 13))
$(warning This kernel is quite old - spectrum_cs will not be compiled)
NO_SPECTRUM_CS = 1
KERNEL_PCMCIA = 1
COMPAT_HEADERS = 1
endif

ifneq (,$(filter $(SUBLEVEL),14 15 16))
KERNEL_PCMCIA = 1
COMPAT_HEADERS = 1
endif

ifneq (,$(filter $(SUBLEVEL),17))
COMPAT_HEADERS = 1
endif

ifndef CONFIG_MODULES
$(error Module support is not enabled)
endif

ifndef CONFIG_NET_RADIO
$(error Wireless extensions are not enabled)
endif

ifdef CONFIG_HERMES
$(error This driver is already enabled in the kernel)
endif

endif

tmp-m := hermes.o orinoco.o
tmp-y :=

tmp-$(CONFIG_PPC_PMAC) += airport.o

tmp-$(CONFIG_PCI) += orinoco_nortel.o orinoco_pci.o orinoco_plx.o orinoco_tmd.o

tmp-$(CONFIG_PCMCIA) += orinoco_cs.o

ifdef KERNEL_PCMCIA
orinoco_cs-objs = orinoco_cs_kernel.o
spectrum_cs-objs = spectrum_cs_kernel.o

quiet_cmd_copy = COPY    kernel $(<F) to $(@F)
      cmd_copy = cp -f $< $@

$(obj)/orinoco_cs_kernel.c: drivers/net/wireless/orinoco_cs.c FORCE
	$(call if_changed,copy)

$(obj)/spectrum_cs_kernel.c: drivers/net/wireless/spectrum_cs.c FORCE
	$(call if_changed,copy)
endif

ifdef COMPAT_HEADERS
EXTRA_CFLAGS += -include $(obj)/compat.h -I$(obj)
endif

extra-y = orinoco_cs_kernel.c spectrum_cs_kernel.c

ifdef CONFIG_FW_LOADER
ifndef NO_SPECTRUM_CS
tmp-$(CONFIG_PCMCIA) += spectrum_cs.o
endif
endif

# Force all objects to be modules
obj-m := $(tmp-y) $(tmp-m)
