Makefile and hello.c for driver programming

 

#Makefile

ifneq ($(KERNELRELEASE),)
        obj-m := module.o
        module-objs := file1.o file2.o
#obj-m:=hello.o
else

        KERNELDIR := /lib/modules/$(shell uname -r)/build
        PWD := $(shell pwd)
defualt:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

 

/* hello.c */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>


MODULE_LICENSE("Dual BSD/GPL");



static int hello_init(void)
{
        printk(KERN_ALERT "Hello, world\n");
        return 0;
}

static void hello_exit(void)
{
        printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit)

 

posted @ 2015-04-22 13:10  Kozmers  阅读(160)  评论(0编辑  收藏  举报