March 13, 2011

Device Driver Makefile in Fedora13

hai all, Am trying to write a simple device driver program. My Makefile code is, [size=50]" obj-m := first.o PWD := $(shell pwd) KERNELSRC := $(shell pwd) KERNELDIR := $(/lib/modules/$(shell uname -r)/modules/include default: $ -C $(KERNELDIR) M=$(PWD)[/size[/size[[ O=$(KERNELSRC)module" and my sample program is, " #include #include #include static int _init my_init(void) { printk(KERN_INFO,"Dude u installed your test driver "); return 0; } static int _exit my_exit(void) { printk(KERN_INFO,"Dude u Un-installed your test driver "); return 0; } module_init(my_init); module_exit(my_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("\n First Linux Driver\n") " I am getting the following error for make command make -C M=/home/bondGoddard/audacious/LFY_DD/class2 O=/home/bondGoddard/audacious/LFY_DD/class2module make: *** M=/home/bondGoddard/audacious/LFY_DD/class2: No such file or directory. Stop. make: *** [default] Error 2 What it means? That dir is present in the location, dont know, why its saying that the concern dir is not present. thank you,

That submission became kind of garbled, and hard to read. Here, I tried to...

That submission became kind of garbled, and hard to read. Here, I tried to clean it up for you - is this somewhat what you attempted to post?

Makefile:

obj-m := first.o
PWD := $(shell pwd)
KERNELSRC :=
$(shell pwd)
KERNELDIR := $(/lib/modules/$(shell uname -r)/modules/include
default: ${MAKE} -C $(KERNELDIR)
M=$(PWD)
O=$(KERNELSRC)module

Sample program:

#include
#include
#include
static int _init my_init(void)
{
printk(KERN_INFO,"Dude u installed your test driver ");
return 0;
}
static int _exit my_exit(void)
{
printk(KERN_INFO,"Dude u Un-installed your test driver ");
return 0;
}
module_init(my_init);
module_exit(my_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("\n First Linux Driver\n")

Executed command:make -C M=/home/bondGoddard/audacious/LFY_DD/class2 O=/home/bondGoddard/audacious/LFY_DD/class2module

Error message:make: *** M=/home/bondGoddard/audacious/LFY_DD/class2: No such file or directory. Stop. make: ***

There seems to be something lacking though, e.g. there are include-statements that don't refer to anything specific. It would be helpful if you could open a new question with cleaner formatting of all the file contents, so that we can reproduce your error locally and look for it.

I'll attempt to answer it anyway though. I think you might have gotten the syntax a bit wrong - but I'm no expert on makefiles, so you may well be using alternative but legal syntax. Could you try using a makefile like this instead:

obj-m = first.o
PWD = $(shell pwd)
KERNELSRC = $(shell pwd)
KERNELDIR = $(/lib/modules/$(shell uname -r)/modules/include

default:
@${MAKE} -C $(KERNELDIR) M=$(PWD) O=$(KERNELSRC)module

By the way, is it really correct that KERNELSRC should point to the current working directory? And is it correct to use O=$(KERNELSRC)module, not O=$(KERNELSRC)/module?

Like  (0 likes)
Click Here!