Reputation: 102386
I'm having a heck of a time getting compiler options from Autoconf into Automake. Some of my source files have Automake per-object flags:
## Makefile.am
librijndael_simd_la_SOURCES = rijndael-simd.cpp
librijndael_simd_la_CXXFLAGS = $(AES_FLAG)
AES_FLAG
needs architectural flags for IA-32, Aarch32/64 and Power8. Other platforms don't get a flag. Formerly, the flags were hard-coded in Makefile.am
.
I am trying to hard-code the options in Autoconf as I am building out initial Autotools support:
# 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)
But it results in:
$ ./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
The Autoconf manual, 3.1.2 The Autoconf Language, says to use double brackets ([[
and ]]
):
AC_SUBST([[GCM_FLAG]], [[-mssse3 -mpclmul]])
AC_SUBST([[AES_FLAG]], [[-msse4.1 -maes]])
AC_SUBST([[SHA_FLAG]], [[-msse4.2 -msha]])
It results in (I guess this is why most people don't follow the manual):
$ 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
I believe this is the documentation, but it does not provide examples or troubleshooting steps: 7.2 Setting Output Variables.
Naively, I thought there would be 1000's of blogs showing how to perform this simple task, but it does not appear so: autoconf pass compiler option to automake.
How does one pass compiler flags from Autoconf to Automake?
Upvotes: 3
Views: 2250
Reputation: 1583
It looks that your configuration is correct. There might be a newline or any other character in your Makefile.am
or configure.ac
file which is screwing up your building system.
I advise to see the generate Makefile
. You can do a grep -nC5 AES_FLAG Makefile
to see how it looks like. That might give us some hints.
Upvotes: 2