Simple Makefile error:: all nothing need to be done.
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Simple Makefile error:: all nothing need to be done.
Good Day,
Raed this code from the book trying to compile it, But make file doesn't seems to work.
Code:
#include<linux/modules.h>
#include<linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "goodbye world 1. \n");
}
Makefile
Code:
obj−m += hello1.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
Upon running make command:
Quote:
[root@stone-age mod]# make
uname: extra operand `−r'
Try `uname --help' for more information.
uname: extra operand `−r'
Try `uname --help' for more information.
make: Nothing to be done for `all'.
[root@stone-age mod]#
Any one? any ideas?
Thanks.
Last edited by knockout_artist; 11-17-2007 at 11:21 AM.
The problem here is very subtle. It’s because you copied and pasted your Makefile from a badly-created pdf. See this line:
Quote:
Originally Posted by knockout_artist
Code:
make −C /lib/modules/$(shell `uname −r`)/build M=$(PWD) modules
is supposed to be
Code:
make -C /lib/modules/$(shell `uname -r`)/build M=$(PWD) modules
Notice that in the first the argument to uname contains the unicode MINUS SIGN (codepoint U+2212), and in the second it is the ASCII/Unicode HYPHEN-MINUS (codepoint U+002D). The same thing happened to all the hyphens in your Makefile (I see five of them). Additionally, there should be a tab instead of 8 spaces.
Moral of the story: don’t blindly copy and paste from pdf files.
Last edited by osor; 11-18-2007 at 02:28 PM.
Reason: point out that there are five occurrences of the hypen
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
Makefile:
Code:
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
Quote:
[root@stone-age mod]# make
make: Nothing to be done for `all'.
[root@stone-age mod]#
May be I can comile it with one command line.
I remember using __WALL__ kind of command to compile modules.
Thanks.
Last edited by knockout_artist; 11-18-2007 at 09:56 PM.
Again, the make utility uses tabs to interpret the commands for a target. Originally, you had 8 spaces. Now, you have nothing. What you need to do is change this:
Quote:
Originally Posted by knockout_artist
Makefile:
Code:
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
to this
Makefile:
Code:
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
Notice that the commands are preceded by tabstops (Ctrl+I) instead of spaces.
^ OSOR brother, its working now Thank you.
How ever I am using it on RH now.
Tonite I am going to try same code on the machine where trouble started(FC6).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.