I want to know how to set default compiler/linker/etc. flags if I use Autoconf/Automake combo.
For example, the default compiler flag is "-O2 -g" if I don't set anything. I can just override it with something else, for example if I want to debug:
./configure 'CXXFLAGS=-O0 -g'
But I find the default configuration stupid because if I enable optimization, debugging will become impossible. So the default flags should either be "-O2" or "-O0 -g", if I run configure
without arguments. How do I do it?
Edit: I tried the following solutions:
- Put
progname_CXXFLAGS=whatever
to Makefile.am. It doesn't work, because it adds the flags to the default flags instead of replacing them. - Put
CXXFLAGS=whatever
into configure.ac. This works, but then I can't override it later.