LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2011, 01:41 PM   #1
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 9

Rep: Reputation: 0
Building the simple module fails. -No rule to make target `−C'. Stop


Here is my sample Hello world program.

****************Hello.c**************

#define MODULE
#include<linux/module.h>
#include<linux/kernel.h>


int init_module(void) {
printk("<1> Hello World \n");
return 0;
}

void cleanup_module(void)
{
printk("<1> Goodbuy World \n");
}

make file for that.

*********************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

When I do make This is what I see.


make −C /lib/modules/3.0.0-12-generic/build M= modules
make[1]: Entering directory `/home/suneel/Samples'
make[1]: *** No rule to make target `−C'. Stop.
make[1]: Leaving directory `/home/suneel/Samples'
make: *** [all] Error 2


Please suggest some solution.

Last edited by wallwaters; 10-30-2011 at 12:38 PM.
 
Old 10-29-2011, 05:04 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Please post your code (and Makefile) within CODE tags; that way, the text maintains its proper indentation.

As for the issue you are having, use PWD instead of pwd, and be careful with your hyphens (it would appear that the one you are using is not the proper format).

Here's what the Makefile should look like:
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

Last edited by dwhitney67; 10-29-2011 at 05:06 PM.
 
Old 10-30-2011, 12:43 PM   #3
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks for the reply. I do not see any difference in using PWD or pwd. Present Working Directory has been resolved successfully.

In the build result you see PWD.

make[1]: Entering directory `/home/suneel/Samples'

I tried both ways(pwd and PWD) still same issue.

Any other suggestion?

Thanks
 
Old 10-30-2011, 12:59 PM   #4
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
I think it was the problem with hyphen, seems to be it was converted to minus. I have fixed that in the make file. But still build was not successful.

Quote:
make -C /lib/modules/3.0.0-12-generic/build M=/home/suneel/Samples modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-12-generic'
Building modules, stage 2.
MODPOST 0 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic'
Any suggestions after this?
 
Old 10-30-2011, 01:51 PM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Hello.c is not the same as hello.c. Conversely, Hello.o is not the same as hello.o.

The following source code and Makefile work successfully; copy/paste for your needs:

hello.c:
Code:
#include <linux/module.h>      // Needed by all modules

#define DRIVER_AUTHOR "Your Name <yourname@isp.com>"
#define DRIVER_DESC   "A Hello World kernel module."

MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);            /* Who wrote this module? */
MODULE_DESCRIPTION(DRIVER_DESC);         /* What does this module do */


static int __init hello_world( void )
{
  printk("hello world\n");
  return 0;
}

static void __exit goodbye_world( void )
{
  printk("goodbye world\n");
}

module_init( hello_world );
module_exit( goodbye_world );
Makefile:
Code:
obj-m := hello.o        # Module Name is hello.c

KDIR  := /lib/modules/$(shell uname -r)/build

all:
        $(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
        $(MAKE) -C $(KDIR) M=$(PWD) clean
I'm not sure how you got $(pwd) to work; perhaps you have an environment variable with the name of 'pwd'. Most system I have worked with, define it as 'PWD'.
 
  


Reply



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
*** No rule to make target `modules'. Stop. Help heffo_j Linux - Hardware 7 06-05-2011 11:44 AM
No rule to make target `menuconfig'. Stop skaj Linux - Kernel 1 02-11-2011 04:52 AM
about how change user password for Postfix−Cyrus−Web−cyradm−HOWTO comdaze Linux - Software 1 03-16-2007 12:05 AM
Belkin Wirless G RTL8185L make[1]: *** No rule to make target `Makefile'. Stop. SilverRock Linux - Wireless Networking 2 02-11-2007 07:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:07 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
Open Source Consulting | Domain Registration