# Makefile for bcm43xx driver

KVER		:= $(shell uname -r)
KDIR		?= /lib/modules/$(KVER)/build
PWD		:= $(shell pwd)
MODPATH		:= /lib/modules/$(KVER)/kernel/drivers/net/wireless/bcm43xx

# Comment/uncomment to enable/disable debugging
# DEBUG = y

# Comment/uncomment to enable/disable PIO mode, DMA mode is always enabled
# PIO_MODE = y

ifeq ($(DEBUG),y)
DEBUGFS_OBJ = bcm43xx_debugfs.o
EXTRA_CFLAGS += -O2 -DCONFIG_BCM43XX_DEBUG
CONFIG_BCM43XX_DEBUG=y
else
DEBUGFS_OBJ =
EXTRA_CFLAGS += -O2
endif

ifeq ($(PIO_MODE),y)
EXTRA_CFLAGS += -DCONFIG_BCM43XX_PIO -DCONFIG_BCM43XX_DMA -DCONFIG_BCM43XX_DMA_AND_PIO_MODE
PIO_OBJ = bcm43xx_pio.o
else
EXTRA_CFLAGS += -DCONFIG_BCM43XX_DMA -DCONFIG_BCM43XX_DMA_MODE
PIO_OBJ =
endif



ifneq ($(KERNELRELEASE),)
# call from kernel build system

# Handle the case where the options are set in .config, but not here

ifdef CONFIG_BCM43XX_PIO
PIO_OBJ=bcm43xx_pio.o
endif

ifdef CONFIG_BCM43XX_DEBUG
DEBUGFS_OBJ=bcm43xx_debugfs.o
endif

obj-$(CONFIG_BCM43XX) += bcm43xx.o
bcm43xx-objs := bcm43xx_main.o bcm43xx_dma.o $(DEBUGFS_OBJ) \
		bcm43xx_radio.o bcm43xx_phy.o \
		bcm43xx_power.o bcm43xx_wx.o \
		bcm43xx_ethtool.o bcm43xx_leds.o \
		$(PIO_OBJ) bcm43xx_ilt.o \
		bcm43xx_xmit.o bcm43xx_sysfs.o

else

default: modules

modules:
	$(MAKE) -C $(KDIR) M=$(PWD) modules

modules_install: bcm43xx.ko
	install -d $(MODPATH)
	install -m 644 -c bcm43xx.ko $(MODPATH)

modules_uninstall:
	rm -rf $(MODPATH)

endif

clean:
	@rm -rf .tmp_versions
	find . \( -name '*.ko' -o -name '*.o' -o -name '*~' \
		-o -name '.*.cmd' -o -name '*.mod.c' -o -name '*.tar.bz2' -o -name '*.rej' -o -name '*.orig' \)\
		-print | xargs rm -Rf

depend .depend dep:
	$(CC) $(EXTRA_CFLAGS) -M *.c > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif


