编译内核时,Makefile是从哪里调用到GCC工具的?
[root@rw stblinux-2.6.12-5.0]# make
/bin/sh: mipsel-linux-gcc: command not found
make: mipsel-linux-gcc: Command not found
mkdir -p include/linux/
awk -f /home/will/BCM97452/stblinux-2.6.12-5.0/scripts/dwarfh.awk /home/will/BCM97452/stblinux-2.6.12-5.0/include/linux/dwarf2.h > include/linux/dwarf2-defs.h
CHK include/linux/version.h
UPD include/linux/version.h
SYMLINK include/asm -> include/asm-mips
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/split-include
HOSTCC scripts/basic/docproc
SHIPPED scripts/kconfig/zconf.tab.h
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/kxgettext.o
HOSTCC scripts/kconfig/mconf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/mips/Kconfig
#
# using defaults found in .config
#
SPLIT include/linux/autoconf.h -> include/config/*
CC scripts/mod/empty.o
/bin/sh: mipsel-linux-gcc: command not found
make[2]: *** [scripts/mod/empty.o] Error 127
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
以上编译出错的原因是PATH的问题。
但我想弄清楚编译内核时,Makefile是从哪里调用到mipsel-linux-gcc的,我用find -type f|xargs grep -n "mipsel-linux-gcc"找不到相关信息
请大家研究一下。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
顶层的Makefile太大,贴一部分吧
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk
GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod
KALLSYMS = scripts/kallsyms
PERL = perl
CHECK = sparse
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__
MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS)
LDFLAGS_MODULE = -r
CFLAGS_KERNEL =
AFLAGS_KERNEL =
从这个顶层Makefile里找不到跟mipsel-linux-gcc相关的内容,可能它调用到了,但是是怎么调用到的还看不清。
CC = $(CROSS_COMPILE)gcc
终于弄明白了!
顶层Makefile读取.config配置文件,按其配置会调用到子目录arch/mips/Makefile,其中有:
ifdef CONFIG_CPU_LITTLE_ENDIAN
32bit-tool-prefix = mipsel-linux-
64bit-tool-prefix = mips64el-linux-
32bit-bfd = elf32-tradlittlemips
64bit-bfd = elf64-tradlittlemips
32bit-emul = elf32ltsmip
64bit-emul = elf64ltsmip
else
32bit-tool-prefix = mips-linux-
64bit-tool-prefix = mips64-linux-
32bit-bfd = elf32-tradbigmips
64bit-bfd = elf64-tradbigmips
32bit-emul = elf32btsmip
64bit-emul = elf64btsmip
endif
ifdef CONFIG_MIPS32
gcc-abi = 32
tool-prefix = $(32bit-tool-prefix)
UTS_MACHINE := mips
endif
ifdef CONFIG_MIPS64
gcc-abi = 64
tool-prefix = $(64bit-tool-prefix)
UTS_MACHINE := mips64
endif
而顶层的CROSS_COMPILE ?=
所以变量让arch/mips/Makefile按照配置赋值为mipsel-linux-gcc
正印证了那句话"Makefile的一切行为都按照.config的配置和kbuild的架构来进行"。哈哈,今天又进步了!!
恭喜恭喜
什么都是一步一步来的。其实对于编程来说,理论重要,但是各个操作方法与函数却需要我们死记硬背才的。
什么是kbuild的架构?
我觉得就是Makefile一个文件而已
Makefile贴一下吧, 里面一般会定义编译器的变量.