Home:ALL Converter>Makefile for kernel module

Makefile for kernel module

Ask Time:2014-04-21T22:50:47         Author:BMC

Json Formatter

Hi I am trying to write a 'Hello World' kernel module. I wrote the following C code: Module514.c

#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>


MODULE_LICENSE("GPL");
MODULE_AUTHOR("BMC")
MODULE_DESCRIPTION(" My module]")


static int __init module514(void){
    printk(KERN_INFO"Hello World");
    return 0;
    }

static void __exit module514_cleanup(void){
    printk(KERN_INFO"unloaded")
    } 


  module_init(module514);
  module_exit(module514_cleanup);

Then created the following Makefile

obj-m += Module514.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

But when I give make I get the following message.

make: Nothing to be done for `all'.

What am I doing wrong.

Author:BMC,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/23199778/makefile-for-kernel-module
yy