# 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/ -I$(TOPDIR)/drivers/addidata/apci_eeprom/
else
# use specified location
ADDI_CFLAGS:=-I$(ADDIDATAINC) -I$(ADDIDATAINC)/../../../drivers/addidata/apci_eeprom/
endif

#TODO
#ADDI_CFLAGS+=-D_ADDI_NO_WIN32_COMPAT

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

# list of objects that make the module
apci3200-objs := main.o fs.o procfs.o ioctl.o interrupt.o vtable.o init.o dig-inputs.o dig-outputs.o ana-inputs.o ana-inputs-kapi.o cjc.o eeprom.o scan.o scan-kapi.o utility-kapi.o event.o ../apci_eeprom/s5920.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)
else
ccflags-y :=$(ADDI_CFLAGS)
endif

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

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

# Objects that export symbols.
export-objs	:= main.o scan-kapi.o interrupt.o utility-kapi.o

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

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

endif
endif
