Welcome 微信登录

首页 / 操作系统 / Linux / Linux 交叉编译 module 范本

hello.c#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("DUal BSD/GPL");static int hello_init(void)
{
 printk(KERN_ALERT "Hello,world ");
 return 0;
}static void hello_exit(void)
{
  printk(KERN_ALERT "Goodbye, cruel world ");
}module_init(hello_init);
module_exit(hello_exit);交叉编译Makefileobj-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直接编译,非交叉编译Makefileobj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
 $(MAKE) -C $(KDIR) M=$(PWD) modules