Is it possible to compile a kernel module without a makefile and if so, how?
No, that is not possible because the kernel Makefile that you have to use to compile a module has to call another Makefile defining
The usual Makefile for an out of tree module loks like that:
ifneq ($(KERNELRELEASE),) obj-m := mymodule.o else KDIR := /lib/modules/`uname -r`/build all: $(MAKE) -C $(KDIR) M=$$PWD endif
The first time it is called,
KERNELRELEASE is not defined, it will then call the kernel Makefile with the
Finally, the kernel Makefile will use
M, finding and calling the module Makefile again, this time with
KERNELRELEASE defined and obj-m will get filled. The module will then be compiled.