 ifneq (${KERNELRELEASE},)

# # KERNELRELEASE defined: we are being compiled as part of the Kernel
         obj-m := dpu.o


 else # We are being compiled as a module: use the Kernel build system

#if we are cross compiling from the host use its kernel and don't compile the test program
ifeq ($(CROSS_COMPILE),)
KERNEL_SOURCE := /usr/src/linux
default: module
else
KERNEL_SOURCE := /export/board01/root/usr/src/linux_for_host
default: module
endif

PWD := $(shell pwd)

module:
	${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules

hello: hello.c
	gcc -o hello hello.c -lpthread -DDEBUG


clean:
	${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
	${RM} *~

endif

# obj-m := fifo0.o

# all: check
#        make -C $(KSRC) M=`pwd`  

# check:
# ifeq ($(KSRC),)
#        $(error 'Path to kernel in env variable KSRC not found. Exiting')
# endif
# .PHONY: check

# clean: check
#        $(MAKE) -C $(KSRC) M=`pwd` clean

# help: check
#        $(MAKE) -C $(KSRC) M=`pwd` help

# .PHONY: hello clean help
