如何解决autoconf配置在交叉编译时获取主机编译器HOSTCC / CC_FOR_BUILD
交叉编译时应如何获取主机编译器(例如gcc
,但可能会有所不同)
./configure --host aarch64-suse-linux CROSS_COMPILE="aarch64-suse-linux-"
我在config.log
中得到了变量:
build='x86_64-pc-linux-gnu'
build_cpu='x86_64'
但是我无法从中获得类似$HOSTCC
的东西。
我知道,当我省略--build
the default is --build=$(config.guess)
时。但是无论指定它还是使用默认值都不能帮助我找到编译器。
另外,自动工具似乎不支持
- https://lists.gnu.org/archive/html/automake/2011-04/msg00017.html
- What is the sense of the word "host" in 'HOSTCC' and ./configure --host?
仅供参考,我需要在LTP中添加一些编译时帮助工具,这些工具使用automake and autoconf,but otherwise have somehow custom build system,而不使用Makefile.am
。因此CC=$(CC_FOR_BUILD)
之类的东西不可用:(。
也许无法(使用某些脚本)从$build
变量中检测到它,我不得不要求用户定义它:
HOSTCC=${HOSTCC-cc}
解决方法
也许使用AC_ARG_VAR
:
configure.ac
:
AC_ARG_VAR(HOSTCC,[The C compiler on the host])
test -z "$HOSTCC" && HOSTCC='$(CC)'
Makefile.in
:
HOSTCC = @HOSTCC@
信用:Gforth项目:configure.ac
Makefile.in
。
我将代替test -z "$HOSTCC" && HOSTCC='$(CC)'
中的configure.ac
,将其添加到Makefile.in
中:
build := @build@
host := @host@
ifeq ($(strip $(HOSTCC)),)
# native build,respect CC
ifeq ($(build),$(host))
HOSTCC := $(CC)
else
# cross compilation
HOSTCC := cc
endif
endif
但如果开箱即用地支持HOSTCC
或CC_FOR_BUILD
,那就太好了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。