Home Learn Linux Linux Answers Applications Device Driver Makefile in Fedora13
  • 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?


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

    Sample program:

    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_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 jabirali
    4 years ago
    0 1
Similar Questions Found
Questions from category Applications

Upcoming Linux Foundation Courses

  1. LFD312 Developing Applications For Linux
    16 Feb » 20 Feb - Atlanta - GA
  2. LFD331 Developing Linux Device Drivers
    16 Feb » 20 Feb - San Jose - CA
  3. LFS220 Linux System Administration
    16 Feb » 19 Feb - Virtual

View All Upcoming Courses

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