9

This is a "Hello.c" module and "Makefile". After executing make from the woking directory I get the following message:

make: Nothing to be done for `all'.

This is the "Hello.c" file:

#include <linux/module.h>    // included for all kernel modules
#include <linux/kernel.h>    // included for KERN_INFO
#include <linux/init.h>      // included for __init and __exit macros

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");

static int __init hello_init(void) {
  printk(KERN_INFO "Hello world!\n");
  return 0;    // Non-zero return means that the module couldn't be
}

static void __exit hello_cleanup(void) {
    printk(KERN_INFO "Cleaning up module.\n");
}   

module_init(hello_init); 
module_exit(hello_cleanup);

And "Makefile":

obj-m += hello.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

I tried all suggestions and I got this in the terminal:

root@stupid-HP:/home/stupid/cpz/module$ pwd
/home/stupid/cpz/module
root@stupid-HP:/home/stupid/cpz/module$ ls
hello.c  Makefile
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ make clean
make: Nothing to be done for `clean'.
root@stupid-HP:/home/stupid/cpz/module$ make clean all
make: Nothing to be done for `clean'.
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ ls
hello.c  Makefile
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ vi hello.c  # modified again
root@stupid-HP:/home/stupid/cpz/module$ make clean
make: Nothing to be done for `clean'.
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.
набиячлэвэли
  • 4,099
  • 4
  • 29
  • 40
user55111
  • 322
  • 1
  • 3
  • 12
  • i checked,there is no other makefile in current working dir.only two files hello.c and makefile. (thanks for reply) – user55111 Oct 02 '15 at 08:32
  • If your program is built, the compiler will not be invoked. You have to modify your source file or remove the compiler output to get a now compiler run. This is time stamp based. – usr1234567 Oct 02 '15 at 08:37
  • 1
    It might just mean that `hello.o` is up to date. You can run `make clean all` and see if you get the message again. – BlackDwarf Oct 02 '15 at 08:37
  • 2
    make sure that `make -C ...` is indented with a TAB (not spaces) – sergej Oct 02 '15 at 08:39
  • Try running "make clean" first and then "make". – Sreeyesh Sreedharan Oct 02 '15 at 08:43
  • i'm trying to build this module. is there any other procedures to building module ? how compile hello.c without using make . – user55111 Oct 02 '15 at 10:31
  • @PraveenSH: `how compile hello.c without using make?` - With same files instead of `make` call use this one: `make -C /lib/modules/\`uname -r\`/build M=\`pwd\` modules`. – Tsyvarev Oct 02 '15 at 11:34
  • 1
    @sergej thank you.. as you told I removed spaces in Makefile and i replaced with TAB. Now its working and iam able to use insmod . – user55111 Oct 02 '15 at 11:44

6 Answers6

33
  1. make clean and then make again
  2. check for spaces and tabs as per make file format
  3. Verify the Path of the kernel libraries
Dilip Kumar
  • 1,736
  • 11
  • 22
10

Make works on the base of time stamps. If you alter some of your source files Make compile them and built the image accordingly. If you do not change source file then compiler has nothing to do with your project. make does not work like gcc to compile every time whether new build is needed or not. This is one of many advantages of using make for your project.

incompetent
  • 1,715
  • 18
  • 29
7

You should remove space in your Makefile. In makefile, only use tab.

I tested your code again, and it works with tab

Hoang Pham
  • 136
  • 1
  • 4
2

Compiler is simply telling you that your code was already compiled and there are no changes in your code (it is up to date), then it does not compile. Is a builtin feature of compilers, if there are no changes in source code file, compilers do not waste time.

Use make clean before to make or modify Hello.c and Build your project.

LPs
  • 16,045
  • 8
  • 30
  • 61
1

Try : make clean to delete the executable file (./a.out) and try to compile it again! You may have something change in some fuction and make can't see it

sofronas
  • 21
  • 5
1

Just in case someone encounters the same problem as me:

Eclipse fails to build correctly when one of your folders has the same name as the executable. If this is the case, no matter what you do, you will always get the "nothing to be done" message. The solution is to rename either the folder or executable. Details can be found here.

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185