I am trying to add some compilation options in Automake, but none of the approaches work.
Here is my configure.ac
:
AC_INIT(...)
AC_PREREQ([2.59])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.10 foreign -Wall no-define])
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile test/Makefile])
AC_LANG(C++)
AC_OUTPUT
And I have the parent Makefile.am
(in top-level dir):
#AM_CFLAGS = ... # doesn't work
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
SUBDIRS = src test
dist_noinst_SCRIPTS = autogen.sh
and a Makefile.am
for each source dir; src/Makefile
:
include_HEADERS = ...
lib_LIBRARIES = ...
and test/Makefile
:
#AM_CFLAGS = ... # doesn't work
bin_PROGRAMS = myprog #test
myprog_SOURCES = ...
myprog_LDADD = ../src/libmylib.a
#myprog_CFLAGS = ... # Doesn't work either
I tried uncommenting all combinations of commented lines, i.e.:
- add
AM_CFLAGS = ...
to the parentMakefile.am
- this should set the CFLAGS for all affected sources - add
AM_CFLAGS = ...
to other twoMakefile.am
s - add myprog_
CFLAGS = ...
to Makefile.am (this should set CFLAGS when compiling myprog)
but none of these has any effects. Both my program (myprog
) and its library (mylib
) are kept being compiled / linked with some default flags which are something like -DHAVE_CONFIG -g -O2
.
I also tried using INCLUDES
instead of AM_CFLAGS
, but didn't help.
Anybody has some idea what is going on here and how to fix it?