# the ADDIDATAINCLUDE variable may hold the path to the addidata-specific include directory
ifeq ($(ADDIDATAINC),)
# include directory has not been specified. suppose we are located inside the Linux kernel source tree
ADDI_CFLAGS:=-I$(TOPDIR)/include/linux/addidata/ 
else
# use specified location
ADDI_CFLAGS:=-I$(ADDIDATAINC) 
endif

# default CONFIG_APCI1564_MAX_BOARD_NBR if not set
ifeq ($(CONFIG_APCI1564_MAX_BOARD_NBR),)
# include directory has not been specified. suppose we are located inside the Linux kernel source tree
ADDI_CFLAGS+=-DCONFIG_APCI1564_MAX_BOARD_NBR=3
endif

# Each configuration option enables a list of files.
obj-$(CONFIG_APCI1564_IOCTL)	+= apci1564.o

# list of objects that make the module
apci1564-objs := main.o procfs.o fs.o ioctl.o input.o output.o event.o interrupt.o counter.o

# Kernel build flags: ccflags-y and ldflags-y were introduced in 2008 as the
# recommended approach. Some kernel 5.x versions already enforce these flags.
# For compatibility: kernels < 5 use EXTRA_CFLAGS, kernels >= 5 use ccflags-y/ldflags-y
ifeq ($(shell test $(VERSION) -lt 5; echo $$?),0)
EXTRA_CFLAGS+=$(ADDI_CFLAGS)
EXTRA_LDFLAGS+=$(ADDI_LDFLAGS)
else
ccflags-y :=$(ADDI_CFLAGS)
ldflags-y :=$(ADDI_LDFLAGS)
endif

# KERNEL 2.4 ------------------------------------------
ifeq ($(VERSION),2)
ifeq ($(PATCHLEVEL),4)

# The target object and module list name.
O_TARGET	:= driver.o

# Objects that export symbols.
export-objs	:= main.o

# Each configuration option enables a list of files.
obj-$(CONFIG_APCI1564_IOCTL)	+= apci1564.o

# Link rules
apci1564.o: $(apci1564-objs)
	$(LD) -r -o $@ $(apci1564-objs)

# The global Rules.make.
include $(TOPDIR)/Rules.make

endif
endif
	