[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subdir-objects fails with non-literal _SOURCES

From: Jim Meyering
Subject: subdir-objects fails with non-literal _SOURCES
Date: Tue, 17 Apr 2007 18:18:44 +0200

Some automake-generated code malfunctions when using the combination of
the subdir-objects option and non-literal _SOURCES.  You can demonstrate
by changing automake's tests/pr224.test, replacing this line:

    bar_SOURCES = foo/main.c

with these apparently equivalent ones:

    f = foo
    bar_SOURCES = $f/main.c

The test fails like this:

    Makefile:238: foo/.deps/main.Po: No such file or directory
    make: *** No rule to make target `foo/.deps/main.Po'.  Stop.

The problem is in the code in configure to create each DIR/.deps/FILE.Po
without invoking make.  It tries to run mkdir for each "DIR" part, but
rather than creating Make's expansion, foo/, it creates a literal "$f/".

FYI, the emitted shell code comes from m4/depout.m4.

I found no mention of this limitation in automake's documentation.
The question now is whether simply to document it, and perhaps to change
automake to detect and warn about the problem...  Or to accommodate
this usage.

FYI, the Makefile.am that led to this report
had a long list of *_SOURCES, where each literal name
would have had several components, e.g.,

    dir1 = some/directory
    dir2 = some/other/directory

    bar_SOURCES = \
      $(dir1)/f1.c \
      $(dir1)/f2.c \
      $(dir1)/f3.c \
      $(dir2)/a.c \
      $(dir2)/b.c \
      $(dir2)/c.c \

The immediate workaround is to replace uses of $(dir1), $(dir2)
by their literal expansions -- or to turn off subdir-objects.
Of course, we'd prefer to have it just work.

It is possible to obtain the expanded directory names from that portion
of configure.  Just not as easy. i.e., it requires the use of make.
Here's a partial example, using the modified pr224.test:

  $ (sed '/^include.*DEPDIR/s/^/#/' Makefile; echo '_:;@echo "$f"')|make -f - _

[Of course, the target name, "_", could conflict, so it'd be better
 to use a longer and more distinctive name ]

While "$f" is hard-coded above, you could get all of the unexpanded
directory names via something like this:

  $ sed -n '/^include \(.*\)\/\$(DEPDIR)\/.*/s//address@hidden '\''\1'\''/p' 
        @echo '$f'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]