hello.c
/* hello.c */
#include
#include
#include
MODULE_LICENSE("GPL");
MODULE_AUTHOR("tang");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world/n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, hello/n");
}
module_init(hello_init);
module_exit(hello_exit);
----------------------------------------------------------------------------
Makefile
/* Makefile*/
PWD := $(shell pwd)
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
obj-m:=hello.o
all :
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD)
.PHONY : clean
clean :
rm -rf .*.cmd *.mod.c *.o *.ko .tmp_versions
linux下可以make编译,希望对你有帮助!