Linux.com

Home Learn Linux Linux Answers Applications Device Driver Makefile in Fedora13
Answers
  • Accepted Answer

    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?

    Answered by Jabir Ali Ouassou
    3 years ago
    0 1
Similar Questions Found
Questions from category Applications

Community Answers - Search


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board