#
# Makefile for linux/drivers/net/bcm
#

# Verify our required files are in the provided linux source directory.
ifeq ($(shell cd $(BCMEXTSRCDIR)/include/linux; if [ `ls kernel.h netdevice.h 2>/dev/null | wc -l` = 2 ]; then echo "pass"; fi),)

	# Nope.  Perhaps DKMS gave us the "build" directory by mistake.
	# If so, check for a "source" directory nearby.
	BCMTESTDIR := $(shell cd $(BCMEXTSRCDIR)/../source; pwd)
	ifeq ($(shell cd $(BCMTESTDIR)/include/linux; if [ `ls kernel.h netdevice.h 2> /dev/null | wc -l` = 2 ]; then echo "pass"; fi),)

		# Force a hard failure if no source.
		echo "Cannot find linux source"

	else

		# It worked!
		BCMLINSRC := $(BCMTESTDIR)

	endif

else

	# Yes!  Assign it.
	BCMLINSRC := $(BCMEXTSRCDIR)

endif


ifneq ($(shell grep netdump_mode $(BCMLINSRC)/include/linux/kernel.h > /dev/null 2>&1 && echo rh),)
	EXTRA_CFLAGS = -DRED_HAT_LINUX_KERNEL
endif

ifeq ($(shell grep netif_poll_disable $(BCMLINSRC)/include/linux/netdevice.h > /dev/null 2>&1 && echo newnetif),)
	EXTRA_CFLAGS += -DOLD_NETIF
endif


# Check if 2.4 kernel or 2.5+ kernel.
BCM_KVER:=$(shell echo $(KERNELRELEASE) | cut -c1-3 | sed 's/2\.[56]/2\.6/')

ifeq ($(BCM_KVER), 2.6)

obj-m := tg3.o

default:
	make -C $(BCMEXTSRCDIR) SUBDIRS=$(SUBDIRS) modules

else

obj-m := tg3.o

include $(TOPDIR)/Rules.make

endif
