Kshine0 2014-03-19
makefile
#include <linux/kernel.h>
#include <linux/module.h> //on pc you should use "tail -f /var/log/messages " to see the result static int __init mini6410_hello_module_init(void) { printk("Hello, Mini6410 module is installed !\n"); return 0; } static void __exit mini6410_hello_module_cleanup(void) { printk("Good-bye, Mini6410 module was removed!\n"); } module_init(mini6410_hello_module_init); module_exit(mini6410_hello_module_cleanup); MODULE_LICENSE("GPL");
pc
### the ko name should be the same as the C file
### this is for gcc on PC obj-m:=mykotest.o mymodule-objs:=module KDIR:=/lib/modules/2.6.27.5-117.fc10.i686/build/ MAKE:=make default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules clean: rm -rf *.o *.~ *.ko Module.* *.mod.* modules.*
arm
### the ko name should be the same as the C file ### this is for arm-linux-gcc on ARM A=ar ARCH=arm CC=arm-linux-gcc obj-m :=mykotest.o mymodule-objs:=module KDIR :=/opt/linux-3.0.8/ PWD :=$(shell pwd) MAKE :=make all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules clean: rm -rf *.o *~ *.ko *mod*