Chinaunix

标题: makefile 驱动程序出问题 [打印本页]

作者: lq003112    时间: 2010-05-04 08:49
标题: makefile 驱动程序出问题
本帖最后由 lq003112 于 2010-05-04 08:59 编辑

昨天写了一个GPIO口的驱动程序,Makefile了一下
就出现了一串报警信息,我的makefile文件是这样的:
ifneq ($(KERNELRELEASE),)
        obj-m:=button.o              /*驱动程序是button.c在这里目标文件就命名为button.o*/
else
        KERNELDIR ?=/home/Lee/linux-2.6.12/          /*这个是解压后的linux内核源码包的地址*/
        PWD:= $(shell pwd)
default:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
        rm –rf *.o *.mod.c *.mod.o
endif

button.c和Makefile文件都放在了/home/Lee/FIRST文件夹内,arm-linux-gcc放在了
/home/Lee/usr/local/arm/3.4.1/bin/下面,
执行make后,就出现了如下的错误提示:

make -C /home/Lee/linux-2.6.12/ M=/home/Lee/FIRST modules
make[1]: /usr/local/arm/3.4.1/bin/arm-linux-gcc:命令未找到
make[1]: Entering directory `/home/Lee/linux-2.6.12'
scripts/Makefile.build:195: 目标“/home/Lee/FIRST/button.c”不匹配目标模式
  CC [M]  /home/Lee/FIRST/button.c
/bin/sh: /usr/local/arm/3.4.1/bin/arm-linux-gcc: 没有那个文件或目录
make[2]: *** [/home/Lee/FIRST/button.c] 错误 1
make[1]: *** [_module_/home/Lee/FIRST] 错误 2
make[1]: Leaving directory `/home/Lee/linux-2.6.12'
make: *** [default] 错误 2

请大家帮忙分析一下是什么原因呢?
作者: T-Bagwell    时间: 2010-05-04 10:04
需要指定一下交叉编译工具链的路径
或者把你的交叉编译工具链copy到他需要的路径下
作者: lq003112    时间: 2010-05-04 10:39
回复 2# T-Bagwell


    我修改了makefile文件,麻烦您给看一下这样写对不对
ifneq ($(KERNELRELEASE),)
        obj-m:=button.o
        export PATH=$(PATH):/home/Lee/usr/local/arm/3.4.1/bin/                         /*这个是交叉编译器的安装路径*/
else
        KERNELDIR ?=/home/Lee/linux-2.6.12/
        PWD:= $(shell pwd)
default:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
        rm –rf *.o *.mod.c *.mod.o
endif
作者: T-Bagwell    时间: 2010-05-04 10:49
你还是把交叉编译环境弄到/usr/local下吧
按照他的要求弄吧
这样稳妥点




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2