filelibtool

how to make a library with libtool if there are sources with the same filename in several directories


I'm trying to compile a library using libtool. The problem is that I have several source files with the same filename in several directories. Because of the that, during autoreconf, libtoolize throws errors at me.

Basically, my filesystem layout is as follows:

src/
    Makefile.am
    file.cpp
    dir1/
        file.cpp
        ...
    dir2/
        file.cpp
        ...

The Makefile.am is placed in the src/ directory and is called by the main Makefile.am using SUBDIRS = src. The contents are similar to the following:

libfoo_la_SOURCES =    \
    file.cpp        \
    dir1/file.cpp   \
    dir2/file.cpp   \
    ...

However, when doing autoreconf, I get an error:

src/Makefile.am: object `file.lo' created by `dir1/file.cpp' and `file.cpp'

How to solve that? I presume that I'll have to add a Makefile.am into each of the subdiectories. How to exactly do that? Google did not help to find the solution.


Solution

  • The solution is to create convenience libtool libraries (prefix them noinst so they won't be installed) in each subdirectory and then link them to the final shared library.