ifneq (${KERNELRELEASE},)

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

else

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

	KERNEL_SOURCE := /usr/src/linux-headers-$(shell uname -r)
        PWD := $(shell pwd)

default: main

#module:
#	${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
main: controller.o bomberman.o main.o
	gcc -o main controller.o bomberman.o main.o -lusb-1.0 -lpthread
main.o: main.c
	gcc -o main.o -c main.c -lusb-1.0 -lpthread
bomberman.o: bomberman.c 
	gcc -o bomberman.o -c bomberman.c -lusb-1.0 -lpthread
controller.o: controller.c
	gcc -o controller.o -c controller.c -lusb-1.0 -lpthread
clean:
	${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
	rm *.o
TARFILES = Makefile README hello.h vga.c software_moving.c
TARFILE = lab3-sw.tar.gz
.PHONY : tar
tar : $(TARFILE)

$(TARFILE) : $(TARFILES)
	tar zcfC $(TARFILE) .. $(TARFILES:%=lab3-sw/%)
endif 
