

#Choose a platform. This section will be removed in the final
#distribution.
#CHIPSET = -DDMA_L
CHIPSET = -DEDMA_W

#Choose a Kernel Version by uncommenting the appropriate kernel 
#version line below.
#KERNEL_VERSION = -DDMA_2_4
KERNEL_VERSION = -DDMA_2_6

ifeq ($(KERNEL_VERSION), -DDMA_2_4)
	CFLAGS = -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -O2 -Wall
	INCLUDE = -I. -I/usr/src/linux-2.4/include
endif

CFLAGS += $(CHIPSET) $(KERNEL_VERSION) -DCONFIG_HIGHMEM64G

#######################BEGIN 2.4###########################
# The following section is applicable to building the 
# EDMA driver for the 2.4 kernel only.
# The target to build the driver for 2.4 is 'all_2_4'.
#
# Uncomment the target and macro definitions (lines
# that do not begin with a "#COMMENT:") to build for 2.4.
#

#COMMENT: Make the test application and EDMA Driver
all_2_4:
	gcc -c $(CFLAGS) $(INCLUDE) dma.c
#	@make testapp

#Delete object files.
clean:
	rm -f *.o *.ko core.* test_app

#COMMENT: Make the test application and EDMA Driver with ICC
all_icc:
	icc -c -w $(CFLAGS) $(INCLUDE) dma.c
	icpc $(APPFLAGS) $(TEST_FILES)
	icpc -o test_app $(TEST_OBJS)

##########################END 2.4###########################


##########################BEGIN 2.6#########################
MOD := dma
DOBJ := dma.o
obj-m := $(DOBJ)
KVER := $(shell uname -r)
PWD := $(shell pwd)
KBUILD_SRC ?= /lib/modules/$(KVER)/build

insert: 
	insmod $(MOD).ko
remove: 
	rmmod $(MOD)

all_2_6:
	$(MAKE) V=1 -C $(KBUILD_SRC) SUBDIRS=$(PWD) modules
	@echo "Built - " $(DOBJ)

##########################END 2.6###########################
