Linux 交叉编译 module 范本

2014-11-24 08:57:06 ? 作者: ? 浏览: 0

hello.c


#include
#include
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);


交叉编译Makefile


obj-m := hello.o
KDIR := /home/lah/linux-2.6.31
PWD := $(shell pwd)
CROSS_ARCH := ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
default:
$(MAKE) $(CROSS_ARCH) -C $(KDIR) M=$(PWD) modules
clean:
rm -rf *.cmd *.o *.mod.c


直接编译,非交叉编译Makefile


obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules


-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: