Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am just trying to learn how to driver modules for Linux Kernel. I followed Linux Device drivers 3rd edition book and started my work. I created a sample program and makefile. Please find my makefile contents below.

obj-m += testModule.o
make -C /lib/modules/3.2.36/build M=$(PWD) modules

I saved this makefile in my home directory. Whenever I am trying to execute this file using


command I am getting

make: *** No targets.  Stop

error. Can someone please help me?

Thanks in advance.

share|improve this question

closed as off topic by Gilles, vonbrand, n0pe, Renan, warl0ck Apr 4 '13 at 8:57

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

So, that two-line block is your Makefile? Try putting a line that says all: or my_program: or foo: (the : is critical) immediately before the line that says make -C /lib/modules/3.2.36/build M=$(PWD) modules, and make sure that that line (the make -C ... line) is indented by a tab. – Scott Jan 30 '13 at 1:36
I tried! It worked!! Thank you so much Scott. Since it is my first linux dirver, I did silly mistakes. I apologize. Thank you so much for your help. – Rengasami Ramanujam Jan 30 '13 at 1:46
There is another problem in the makefile. The make inside the makefile is going on recursion it is not picking my linux source tree makefile. – Rengasami Ramanujam Jan 30 '13 at 2:00
This question should belong on stack overflow – BenjiWiebe Jan 30 '13 at 3:37
@Rengasami: D’oh! I missed that. Recursion in Makefiles is not necessarily bad, but you’re probably better off avoiding it. // @Benji: I disagree. It could have been asked on Stack Overflow or Super User, but it’s in scope for Unix and Linux. – Scott Jan 30 '13 at 23:45

That make -C command should be separated,


obj-m += testModule.o

    make -C /lib/modules/`uname -r`/build SUBDIRS=$(PWD) modules
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.