【发布时间】:2017-11-03 20:13:05
【问题描述】:
我正忙着将编译器选项从 Autoconf 导入 Automake。我的一些源文件有Automake per-object flags:
## Makefile.am
librijndael_simd_la_SOURCES = rijndael-simd.cpp
librijndael_simd_la_CXXFLAGS = $(AES_FLAG)
AES_FLAG 需要 IA-32、Aarch32/64 和 Power8 的架构标志。其他平台没有标志。以前,这些标志被硬编码在 Makefile.am 中。
在构建初始 Autotools 支持时,我正在尝试对 Autoconf 中的选项进行硬编码:
# configure.ac
AC_SUBST([GCM_FLAG], [-mssse3 -mpclmul])
AC_SUBST([AES_FLAG], [-msse4.1 -maes])
AC_SUBST([SHA_FLAG], [-msse4.2 -msha])
...
AC_OUTPUT(Makefile)
但结果是:
$ ./configure
...
checking how to run the C++ preprocessor... g++ -E
./configure: line 16195: -mpclmul: command not found
./configure: line 16199: -maes: command not found
./configure: line 16201: -msha: command not found
Autoconf 手册 3.1.2 The Autoconf Language 说要使用双括号([[ 和 ]]):
AC_SUBST([[GCM_FLAG]], [[-mssse3 -mpclmul]])
AC_SUBST([[AES_FLAG]], [[-msse4.1 -maes]])
AC_SUBST([[SHA_FLAG]], [[-msse4.2 -msha]])
结果(我猜这就是大多数人不遵循手册的原因):
$ autoreconf --force --install
...
error: AC_SUBST: `[AES_FLAG]' is not a valid shell variable name
configure.ac:50: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
我相信这是文档,但它没有提供示例或故障排除步骤:7.2 Setting Output Variables。
天真地,我以为会有 1000 多个博客展示如何执行这个简单的任务,但事实并非如此:autoconf pass compiler option to automake。
如何将编译器标志从 Autoconf 传递到 Automake?
【问题讨论】:
-
您能否添加处理 GCM_FLAG 和其他问题的
Makefile.in或Makefile段? -
谢谢@Vicente。我从来没有走那么远(即,足够远到我的
Makefile.am变成Makefile)。 -
只有在极少数情况下才需要或想要双括号。
-
如果我怀疑您发现的解决方案与您想的不一样,那么我强烈建议您提交minimal reproducible example。我认为您开始使用的单括号方法没有任何本质上的错误。
-
只是为了知道发生了什么,您可以在配置文件中显示 16195 附近的行。
标签: autotools autoconf automake compiler-options