0

I am learning Linux module programming. I work on Ubuntu 12.04. I made a module, namely start.c, and saved it in home/documents/module_prog.

Then I made the following makefile (I am not acquainted with makefiles so I just did what the tutorial told me to):

obj-m += start.o

KDIR = /usr/src/linux-headers-3.2.0-31-generic-pae

all:
    make -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
    rm -rf *.o *.ko *.mod.* *.symvers *.order

But, now when I type make in the terminal, a message is displayed which says

  make: Nothing to be done for `all'.

Please tell me what is wrong?

2
  • 2
    Do you have a file called all in your working directory?
    – Carl Norum
    Sep 23, 2012 at 22:13
  • Since you're on Linux, what happens if you use make -B? This assumes everything is out of date and should execute the command, even if you have a file or directory called all. Sep 24, 2012 at 0:38

1 Answer 1

3

Make sure that the commands for a make target are intended with a tab, not spaces. I.e.

all:
<tab>make -C $(KDIR) SUBDIRS=$(PWD) modules

Otherwise the all target will be empty, and thus nothing is to be done.

5
  • 1
    Missing the tab would be invalid makefile syntax, and should generate a "missing separator" error, rather than what the OP is seeing.
    – Carl Norum
    Sep 23, 2012 at 22:14
  • If I copy the above Makefile into my Ubuntu 12.04 installation, it complains about missing separator on line 9 (the clean). If I fix that but leave the spaces in line 6, there are no errors but exactly the message avinash mentioned.
    – dseifert
    Sep 23, 2012 at 22:17
  • Sounds like you're on the right track then. I'm surprised it lets you get away with that.
    – Carl Norum
    Sep 23, 2012 at 22:19
  • 1
    It probably considers the SUBDIRS=$(PWD) part as an assignment. At least if you remove the = you get the warning.
    – dseifert
    Sep 23, 2012 at 22:23
  • 1
    Rather astonishingly, if you add $(info $(origin make -C $(KDIR) SUBDIRS)) to the makefile, you'll see that a variable of that name has indeed been assigned to. Sep 24, 2012 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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