Reputation:
I am quite new with using autotools and I am still learning.
So, as stated in the title of my topic I would like to know how to set compilation flags.
I know there already has been a topic on this but it didn't solve my problem :
I used :
...
AC_SUBST([AM_CXXFLAGS], [-Wall -Werror])
...
but unfortunately, when using ./configure
I get:
...
./configure: line 3436: -Wall: command not found
...
and as a result it produces Makefiles but with no targets
Thank you in advance for any help
Upvotes: 1
Views: 357
Reputation:
The answer provided by Idav1s works for me as well because
AC_SUBST([FOO], [BAR QUUX])
expands to the following shell code:
FOO=BAR QUUX
which runs QUUX with the FOO environment variable set to BAR. In your case, this means AM_CXXFLAGS
is set to -Wall
, and -Werror
is executed. Why you're seeing -Wall
executed instead is unknown to me... For me, the error happened on line 2802:
configure: line 2802: error: -Werror not found
So I opened the configure
script, and what I found was the AM_CXXFLAGS=-Wall -Werror
on line 2802. Changing it to ['-Wall -Werror']
in configure.ac fixed things for me.
The Autotools build system is quite portable, and it makes cross-compilation easier than some build systems (e.g. Cmake requires a toolchain file with special variables set). I wouldn't suggest switching build systems just yet as a solution to such a simple problem.
Upvotes: 1
Reputation: 16315
This works for me:
configure.ac
...
AC_SUBST([AM_CXXFLAGS], ["-Wall -Werror"])
...
Upvotes: 1