ifneq (${KERNELRELEASE},)

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

else

# We are being compiled as a module: use the Kernel build system
	KERNEL_SOURCE := /usr/src/linux
        PWD := $(shell pwd)

default: module hello

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


#CC:=gcc
#DEFS:=-D_ENABLE_TILT -D_ENABLE_FORCE 
#CFLAGS:=-Wall -pipe $(DEFS) -g -O9 -Os
#INCLUDES:=-I./src
#LIBS:=-L./lib -lcwiimote -lbluetooth -lm -lsndfile

#all: hello.o wiicontroller.o
#	$(CC) $(CFLAGS) -o hello $^ $(LIBS) $(INCLUDES)

#hello.o: hello.c wiicontroller.h vga_led.h configuration.h
#	$(CC) $(CFLAGS) $(INCLUDES) -c $< 

#wiicontroller.o: wiicontroller.c configuration.h
#	$(CC) $(CFLAGS) $(INCLUDES) -c $< 

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

socfpga.dtb : socfpga.dtb
	dtc -O dtb -o socfpga.dtb socfpga.dts

endif 

