Am Die, 2003-01-28 um 13.22 schrieb Markus Werle:
> Hi!
>
> In my Makefile.am I have e.g. the following lines
>
> COMMON_SOURCES = src/lib/common.C
>
> foo_SOURCES = ${COMMON_SOURCES} src/foo/main.C
> bar_SOURCES = ${COMMON_SOURCES} src/bar/main.C
>
> So I have a name clash for main.o, which makes automake unhappy.
Yes, you have source tree layout problem ;)
> The only resolution I found was to prefix the bar object files
> using the following trick
>
> bar_CXXFLAGS = $(AM_CXXFLAGS)
>
> the problem with this approach is that now common.C
> will get built twice (which is not what I want here).
One work-around: Make a static lib from it.
> I could for sure put common.C into a shared lib and link to that one,
> but I dislike that solution for several other reasons.
A static lib would be sufficient.
> I would prefer to have the possibility to tell
> automake to put foo_OBJECTS into a separate directory,
> perhaps like this:
>
> foo_OBJDIR = foo_obj
>
> Is this feature already available?
Not quite, but
AM_INIT_AUTOMAKE([subdir-objects])
might be helpful.
Another work-around would be to implement a deep Makefile.am-hierarchy,
with two independent Makefile.ams, one for foo and one for bar.
[Now you've got a glimpse of an idea, why I don't share the "Deep
Makefiles are evil"-idea, many persons on this list hang on to.]
Ralf