1

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

Community
  • 1
  • 1

3 Answers3

1

This works for me:

configure.ac

...
AC_SUBST([AM_CXXFLAGS], ["-Wall -Werror"])
...
ldav1s
  • 15,885
  • 2
  • 53
  • 56
1

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.

Community
  • 1
  • 1
0

Set them in Makefile.am instead:

AM_CXXFLAGS = -Wall -Werror
ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Thank you for the answer, but is there absolutely no way of setting it in the `configure.ac` file ? –  Sep 20 '14 at 10:04