[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12142: automake tries to compile a program when 'foo' and 'foo.cxx'
From: |
Stefano Lattarini |
Subject: |
bug#12142: automake tries to compile a program when 'foo' and 'foo.cxx' exist (though the former is header) |
Date: |
Mon, 06 Aug 2012 09:38:08 +0200 |
tags 12142 notabug
thanks
On 08/05/2012 11:45 AM, Michał Górny wrote:
> autoconf: 2.69
> automake: 1.12.2
> libtool: 2.4.2
>
Also, which version of make are you using?
> Hello,
>
> I was writing a C++ library and I think I hit a pretty ugly bug within
> automake.
>
What you describe below is not an Automake bug, but an unexpected interaction
with the GNU make built-in rules. That is, GNU make contains (among other
stuff) a built-in rule to compile programs from a C++ source files:
<http://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules>
and that is being somehow invoked as an unindented consequence of your
declarations. More details below.
> My library was structured like the following:
>
> - src/foo (the header file),
>
Why not simply using a more usual name like 'foo.h' for 'foo.hxx'?
That would be unlikely to trigger unexpected problems in the first
place ...
> - src/foo.cxx (the code).
>
> These files assemble a library, let's call it libfoo.la.
>
> The problem is that every time I modify src/foo.cxx and call 'make',
> automake
>
No, automake is doing nothing at this point. It's make that does the
building and compiling, using both the instructions given in the
Automake-generated Makefile and its own built-in rules. And it's one
the latter that is wreaking havoc here.
first (correctly) compiles the library, and then mistakenly
> tries to compile and link it into a program src/foo, either effectively
> overwriting or removing my header file, or failing early due to
> missing dependency file.
>
I guess this doesn't happen if you run make with the '--no-builtin-rules'
option. And in fact ...
> What's interesting, 'make' calls not following src/foo.cxx changes work
> correctly; just the one after modifying src/foo.cxx fails.
> I've also prepared a git repository with the simple test case:
>
> git clone https://bitbucket.org/mgorny/automake-cxx-bug.git
> cd automake-cxx-bug
> autoreconf -vi
> ./configure --disable-static
> make # compiles fine
> touch src/foo.cxx
> make # fails
>
... I've tried this out and verified that my diagnosis is correct.
Bottom line: to avoid the issue, either rename the header file (the
sanest thing to do IMO), or ensure make gets always run with the
'--no-builtin-rules' option.
Regards,
Stefano