3

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

make

command I am getting

make: *** No targets.  Stop

error. Can someone please help me?

Thanks in advance.

5
  • 4
    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
3

That make -C command should be separated,

i.e

obj-m += testModule.o

default:
    make -C /lib/modules/`uname -r`/build SUBDIRS=$(PWD) modules

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