커널 2.6 버전의 Makefile
KERNELDIR = /lib/modules/$(shell uname -r)/build
obj-m = hellomodule.o
KDIR :=/lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
obj-m = hellomodule.o
KDIR :=/lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.ko
rm -rf *.mod.*
rm -rf .*.cmd
rm -rf *.o
커널 2.6 버전의 module파일
hellomodule.c
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
static int __init init_hello(void);
static void __exit exit_hello(void);
static int __init init_hello(void){
printk("Module init\n");
printk("Hello Linux Module! \n");
return 0;
}
static void __exit exit_hello(void){
printk("Module Cleand up!\n");
}
module_init( init_hello );
module_exit( exit_hello );
MODULE_LICENSE("GPL");
#include <linux/kernel.h>
#include <linux/module.h>
static int __init init_hello(void);
static void __exit exit_hello(void);
static int __init init_hello(void){
printk("Module init\n");
printk("Hello Linux Module! \n");
return 0;
}
static void __exit exit_hello(void){
printk("Module Cleand up!\n");
}
module_init( init_hello );
module_exit( exit_hello );
MODULE_LICENSE("GPL");