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

BCMTGT=tg3

# PREFIX may be set by the RPM build to set the effective root.
PREFIX=

# 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.
		$(error Cannot find linux source)

	else

		# It worked!
		BCMLINSRC := $(BCMTESTDIR)

	endif

else

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

endif


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



BCM_FLAGS := $(BCM_NETDUMP_CFLAG)


# 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 := $(BCMTGT).o

EXTRA_CFLAGS = $(BCM_FLAGS)

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

else

obj-m := $(BCMTGT).o

include $(TOPDIR)/Rules.make

endif
