I'm currently working on a C++ project which relies on recursive automake for building.
I want to build a shared library and the Makefile.am
in the src
directory of the library looks like
# ...
# Library name
lib_LTLIBRARIES = libadapter-@[email protected]
# Sources
libadapter_@MY_API_VERSION@_la_SOURCES = \
$(top_builddir)/src/sourceA.cpp \
$(top_builddir)/src/sourceB.cpp
# ...
Since version 1.14, automake issues a warning when the subdir-objects
option is not specified in AM_INIT_AUTOMAKE
in configure.ac
. However, adding the subdir-objects
option seems to break the build process with make
complaining about missing .Plo
files. I already searched the web for people experiencing similar problems but did not find any sensible hint on how to resolve the issue without changing the project to a non-recursive one. Any help is greatly appreciated.
EDIT:
Diving more deeply into the problem, I noted that ./configure
creates a directory literally named $(top_builddir)
below the current source directory of the library, which contains all the required .Plo
files for building the library. In the Makefile
, however, I found that the .Plo
equivalents of my library sources (sourceA.cpp
and sourceB.cpp
in the example) are prefixed by include $(top_builddir)/src/$(DEPDIR)/
and $(top_builddir)
is a variable defined as a relative path (namely, ../../../src/.deps/
). Now it becomes clear why make
can't find the .Plo
files because it searches the wrong directory. This looks like a possible duplicate of bug #16375. Any workarounds?
EDIT 2:
Digging further in the web revealed two more threads which address the issue: #1327 and automake-bug. A known workaround seems to be passing the --disable-dependency-tracking
option to ./configure
. At least for me it works.
ACLOCAL_AMFLAGS
just to set the macro path (-I ...
). TheAM_INIT_AUTOMAKE
options are set byAUTOMAKE_OPTIONS
:1.11 foreign
. That's it. – Internalizetop_srcdir
toabs_top_srcdir
andtop_builddir
toabs_top_builddir
. Hmm... – Internalizetop_builddir
ortop_srcdir
, but this issue seems to be popping up with 1.14.x in a lot of places. – LattieMakefile.am
? – LattieMakefile.am
to my question. – Stellatop_builddir
toabs_top_builddir
but get the same error (missing.Plo
files). – Stella.Plo
files). Do you see any problems in using relative paths? – Stellasubdir-objects
, which broke my build. – InternalizelibMyLib_la_SOURCES=$(top_srcdir)/external/http_parser.c
which failed (it created a directory called top_srcdir). I replaced it with a relative path and it worked:libMyLib_la_SOURCES=../external/http_parser.c
. Also added thesubdir-objects
as advised. – Intake