LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 11-17-2007, 12:18 PM   #1
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Rep: Reputation: 33
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 12:21 PM.
 
Old 11-17-2007, 12:32 PM   #2
theriddle
Member
 
Registered: Jun 2007
Distribution: Gentoo
Posts: 172

Rep: Reputation: 30
Try
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
or maybe
Code:
obj−m += hello1.o
all:
        make −C /lib/modules/`uname −r`/build M=$(PWD) modules
clean:
        make −C /lib/modules/`uname −r`/build M=$(PWD) clean
 
Old 11-18-2007, 03:43 AM   #3
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
^ didn't work.
Make acts like as It doesn't see file hello.c in directory.
Can some post a working code for hello world kernel module + make file.

Thanks.
 
Old 11-18-2007, 03:24 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
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 View Post
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 03:28 PM. Reason: point out that there are five occurrences of the hypen
 
Old 11-18-2007, 03:30 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Iíve colored them for you:
Quote:
Originally Posted by knockout_artist View Post
Makefile
Code:
objm += 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
 
Old 11-18-2007, 10:53 PM   #6
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
hello.c
Code:
 
#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 10:56 PM.
 
Old 11-19-2007, 12:03 AM   #7
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
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 View Post
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.
 
1 members found this post helpful.
Old 11-19-2007, 03:08 PM   #8
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
^ 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).

Thank you very much once again.
 
Old 06-22-2009, 01:12 PM   #9
kimjoys
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
Please help

nevermind

Last edited by kimjoys; 06-22-2009 at 04:54 PM. Reason: Question Answered
 
Old 10-23-2009, 05:28 AM   #10
sailorbob
LQ Newbie
 
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
Wow, thanks! This was driving me insane. The next thing I was going to do would be to rm the makefile and type it in by hand.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Makefile help sharathkv25 Programming 3 02-21-2007 04:19 AM
Makefile error nesta Programming 2 02-07-2007 06:53 AM
Makefile problems/Simple kernel module smoothdogg00 Linux - Kernel 1 10-28-2006 05:16 PM
What is wrong with this simple rule in makefile? George2 Programming 6 05-03-2006 02:53 AM
Problem with a simple makefile julz_51 Programming 1 11-12-2005 01:57 AM


All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration