Question

I have a little problem with automake to handle the subdirectories when installing headers.

Here is roughly the project hierarchy that I have:

foo/
  foo-bin/
    Makefile.am
    ...
  foo-tests/
    Makefile.am
    ...
  foo-lib/
    Makefile.am
    include/
      foo/
        header1.h
        subdir/
          header2.h
    src/
      file1.cpp

Nothing too fancy, there is a root directory containing the configure.ac, and 3 subdirectories for the shared library, the main binary, and the tests.

The interesting part here is foo-lib/. It contains the library that the binary and tests link to.

Since I want to be able to generate the configure files out of the source tree, I've settled to use $top_srcdir-relative path in my Makefile.am.

Here is what it looks like:

libfoo_la_SOURCES = \
  $(top_srcdir)/foo-lib/src/file1.cpp

pkginclude_HEADERS = \
  $(top_srcdir)/foo-lib/include/foo/header1.h \
  $(top_srcdir)/foo-lib/include/foo/subdir/header2.h

Without these $top_srcdir-relative path, I have problems when I try to use the foo-lib from foo-bin, or when I try to generate the project out of the source tree.

Now the problem: when installing these headers, they end up being flattened! That is, I end up with:

$prefix/include/foo/header1.h
$prefix/include/foo/header2.h

While I was expecting:

$prefix/include/foo/header1.h
$prefix/include/foo/subdir/header2.h

So I assume that is what nobase_ is supposed to achieve, but since the path I use are not relative to the Makefile.am, but to $top_srcdir, I end up with the whole $top_srcdir path being copied:

$prefix/include/foo-lib/include/foo/header1.h
$prefix/include/foo-lib/include/foo/subdir/header2.h

which is clearly not what is expected.

Any thoughts and advises on this are greatly appreciated :) If you need access to the real Makefile.am files, instead of the canonical examples, the project is here:

https://github.com/NewbiZ/crashburn

Était-ce utile?

La solution

This:

pkginclude_HEADERS = \
$(top_srcdir)/foo-lib/include/foo/header1.h \
$(top_srcdir)/foo-lib/include/foo/subdir/header2.h

tells the install to place the headers above in $(pkgincludedir), so flattened is how you told them to be.

What you could do is:

myincludesubdir=$(pkgincludedir)/subdir

pkginclude_HEADERS = $(top_srcdir)/foo-lib/include/foo/header1.h
myincludesub_HEADERS = $(top_srcdir)/foo-lib/include/foo/subdir/header2.h

This should install header1.h to $(pkgincludedir) and header2.h to $(myincludesubdir) aka $(pkgincludedir)/subdir.

I wouldn't use nobase_ in this case. The results you got using it don't look unexpected or erroneous to me.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top