多个文件的Makefile

内核编译和嵌入式产品的设计与开发
回复
wbo4958
帖子: 4
注册时间: 2009-07-31 19:46

多个文件的Makefile

#1

帖子 wbo4958 » 2010-06-05 11:28

今天早上起来写一个HELLO的驱动程序,在一个文件里时,运行是显示是正确的,
把它拆到两个文件中去后就 用 dmesg | tail 就没有显示了,这是怎么回事呢,跪求解答

//////////////////////////////////////////////////////////hello.c////////////////////////////////////////////////////////////////////////////////////
#include<linux/init.h>
#include<linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("snail");
MODULE_VERSION("V1.0");

static int __init hello_init(void)
{
print_hello(); /* print.c里的函数*/
printk(KERN_ALERT "hello snail\n");

return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_ALERT "good bye snail\n");
}

module_init(hello_init);
module_exit(hello_exit);


/////////////////////////////////////////////////////////////////////print.c////////////////////////////////////////////////////////////////////////////////
#include<linux/module.h>
#include<linux/init.h>

void print_hello(void)
{
int i=10;
printk(KERN_ALERT "hello snail bo bo haha!%d\n",i);
}


/////////////////////////////////////////////////////////////////////////////Makefile///////////////////////////////////////////////////////////////////////////////////////
ifneq ($(KERNELRELEASE),)
hello-objs:= print.o
obj-m:=hello.o

else
KERNELDIR ?=/lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)

modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -fr *.o *.ko *symvers *.mod.c *.order *.markers
echo "ok ,clean over!"

endif
附件
hello.tar.gz
里面是所有的文件,
(692 Bytes) 已下载 33 次
wbo4958
帖子: 4
注册时间: 2009-07-31 19:46

Re: 多个文件的Makefile

#2

帖子 wbo4958 » 2010-06-05 12:56

顶起来
回复