You write that you're using:
AM_CXXFLAGS = -Iinclude
This is incorrect; -I
arguments should be placed in the AM_CPPFLAGS
(C preprocessor) variable, because it is the preprocessor that evaluates #include
macros.
문제
I recently migrated a few projects from vanilla make to automake. Although I am not the biggest fan of the GNU autotools, they solve many problems quite nicely. (No I do not want recommendations on other builds systems.)
The project layout is quite standard, I basically have one folder include that contains the public headers and one folder src that contains the sources and private headers. Since I am using C++ the sources need to include the public headers.
The basic solution is to use AM_CXXFLAGS, like so:
AM_CXXFLAGS = -Iinclude
But I am working allot on MinGW-W64 and MSys. To make the mingw behave like a POSIX environment, that is include from /usr/include
and /usr/local/include
, I define the variables CPPFLAGS
, CFLAGS
and CXXFLAGS
appropriately.
CPPFLAGS is not a mistake, it is for the preprocessor, configure needs this or it will complain.
Now once the library is "installed" in the system and continue developing, I get the problem that the headers are pulled from /usr/local/include
instead of the local folder. The problem is that the AM_CXXFLAGS
gets appended to the CXXFLAGS
and thus the local folder is later in the search order than the system folder.
With vanilla make the solution way easy, when extending CXXFLAGS
you preceded the include directive, like so:
CXXFLAGS := -Iinclude $(CXXFLAGS) -g -Wall
This obviously also works with automake, except it needs to be CPPFLAGS
, since libtool takes that into account. But automake rightfully complains that CPPFLAGS
is being overwritten. Is there a correct way to do this, or do I need to live with the warning forever? (Restructuring the project layout, being the only other solution.)
해결책
You write that you're using:
AM_CXXFLAGS = -Iinclude
This is incorrect; -I
arguments should be placed in the AM_CPPFLAGS
(C preprocessor) variable, because it is the preprocessor that evaluates #include
macros.