Automake: AM_CFLAGS has no effect
- It looks like you're compiling C++, in which case the variable to use is
AM_CXXFLAGS
. - Setting
AM_CXXFLAGS
should be in theMakefile.am
that declares things you're actually compiling (i.e.,bin_PROGRAMS
,lib_LTLIBRARIES
, ...). - If you're repeating yourself, don't forget automake supports an
include
statement. - Recursive make considered harmful. Modern automake supports
subdir-objects
. If oneMakefile.am
gets out of hand, useinclude
statements. - The modern way to turn on libtool is
LT_INIT
, notAC_PROG_LIBTOOL
. AC_LANG(C++)
doesn't do anything at point ofconfigure.ac
. It sets the language to use when running configure tests. Besides,AC_LANG_PUSH
andAC_LANG_POP
are smarter ways of doing that.- Why are you assigning to
ACLOCAL_AMFLAGS
like that?
I tried adding AM_CFLAGS
to the parent Makefile.am as suggested, which didn't work. When I added it to the relevant Makefile.am, it ended introducing two conflicting -g
options as shown below:
libtool: link: gcc -std=gnu99 -g -O0 -g -O2 -Wl -pthread ...
The correct way to disable optimization is to add CFLAGS = -g -O0
to the Makefile.am where it's needed. Try deleting Makefile.in and Makefile (no extension) if the change doesn't take effect for some reason.
Here's the correct linker directive:
libtool: link: gcc -std=gnu99 -g -O0 -Wl -pthread ...