No rule to make target "syscall_32.tbl"
08 February 2014

The beginning

I recently got into kernel module programming along with my friend Rohit. We were following the tutorial here and we stumbled upon an error.

The Error

When running sudo make, we got :

anshul@aiice:~/modules$ sudo make
make -C /lib/modules/3.12.0-031200-generic/build M= modules
make[1]: Entering directory `/usr/src/linux-headers-3.12.0-031200-generic'
make[2]: *** No rule to make target `/usr/src/linux-headers-3.12.0-031200-generic/
arch/x86/syscalls/syscall_32.tbl', needed by `
arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h'.  Stop.
make[1]: *** [archheaders] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.12.0-031200-generic'
make: *** [all] Error 2

This is the Makefile we were using as given on the tutorial :

obj-m += hello-1.o
all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

The Reason

At last we had to look the output ourselves.
You can notice that M is getting no value. (See M= in the first output line of make.)

That means M=$(PWD) in the Makefile is wrong. It would have worked if PWD had been defined in the shell beforehand. But this is not so, we need to replace it with something that returns the present working directory (PWD).

The Solution

That can be done perfectly with $(shell pwd). So just replace M=$(PWD) with M=$(shell pwd) in the Makefile.

Worked perfectly for me. Hope it saves some time for you.

Thanks for reading. Do comment.