主题 : mini2440驱动程序的独立Makefile的问题? 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 27775
精华: 0
发帖: 1
金钱: 5 两
威望: 1 点
综合积分: 2 分
注册时间: 2010-08-31
最后登录: 2010-09-10
楼主  发表于: 2010-08-31 22:41

 mini2440驱动程序的独立Makefile的问题?

我编写一个Hello world的驱动模块,和独立Makefile文件。

Makefile文件内容如下:
module_name = hello_world
ifneq ($(KERNELRELEASE),)
    obj-m := $(module_name).o
else
    KERNELDIR ?= /opt/FriendlyARM/mini2440/linux-2.6.32.2
    PWD := $(shell pwd)
module:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
    @-rm -rf *.o *.mod.o $(module_name).ko *.mod.c
.PHONY: module clean
endif

运行make module编译arm二进制驱动模块时,出现如下错误提示:
make -C /opt/FriendlyARM/mini2440/linux-2.6.32.2 M=/root/Module_test modules
make[1]: Entering directory `/opt/FriendlyARM/mini2440/linux-2.6.32.2'
  CC [M]  /root/Module_test/hello_world.o
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /root/Module_test/hello_world.c:2:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:258:5: warning: "MAX_NR_ZONES" is not defined
include/linux/mmzone.h:260:7: warning: "MAX_NR_ZONES" is not defined
include/linux/mmzone.h:262:7: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /root/Module_test/hello_world.c:2:
include/linux/mmzone.h:300: error: 'MAX_NR_ZONES' undeclared here (not in a function)
make[2]: *** [/root/Module_test/hello_world.o] 错误 1
make[1]: *** [_module_/root/Module_test] 错误 2
make[1]: Leaving directory `/opt/FriendlyARM/mini2440/linux-2.6.32.2'
make: *** [module] 错误 2

开发环境为fedora9(2.6.25-14.fc9.i686),请问出现该编译问题的原因是什么?为什么在mini2440提供的linux-2.6.32.2内核源码中编译就没问题?我应如何调整独立Makefile?