ifneq ($(KERNELRELEASE),)
#call from kernel build system

foobar-objs := foo_1.o foo_2.o

obj-m := foobar.o

else

KERNELDIR ?= /YOUR/KERNEL/SOURCE/PATH
PWD := $(shell pwd)

modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

clean:
        rm -rf *.o *~ core .depend .*.cmd .*.o.d *.ko *.mod.c .tmp_versions