Subject: bug#9625: Overriding `check:' target

From: Stefano Lattarini <[email-masked]>
Date: Wed, 28 Sep 2011 11:06:29 +0200

[Adding bug-automake]

Reference:
 <http://lists.gnu.org/archive/html/automake/2011-09/msg00028.html>

Hi Jordi, thanks for the report.

On Tuesday 27 September 2011, Jordi Gutiérrez wrote:
> (Please cc: me as I'm not subscribed to the list)
> 
> This may be a little frivolous, but in GNU Octave's top-level
> Makefile.am, we override the check: target:
>
Ah yes, you've hitten a known bug/limitation that I had already
encoutered, but the lamentably forgotten about (sorry!).

>     http://hg.savannah.gnu.org/hgweb/octave/file/1bfca2bbea8b/Makefile.am#l106
> 
> However, in the generated Makefile, this produces a warning:
> 
>     Makefile:2354: warning: overriding commands for target `check'
>     Makefile:1948: warning: ignoring old commands for target `check'
> 
> because the generated Makefile contains these lines:
> 
>     ## Standard target
>     check: $(BUILT_SOURCES)
>        $(MAKE) $(AM_MAKEFLAGS) check-recursive
>
JFTR, If I understand things correctly, this hackish recipe is really
required to ensure that $(BUILT_SOURCES) are effectively built not
only before the `check' target, but also before all its "built-in"
dependencies (`check-local', `check-am' and `check-recusrsive', mostly).

>     ## Overriden target
>     check: all
>        $(MAKE) -C test check
Just a question: why this overriding?   If the `test' directory is
listed in SUBDIRS, the automake-generated `check' target will take
care of automatically recursing into `test' anyway.  Or am I missing
something about Octave's source tree setup?

> I would like to silence that warning.
>
If you can, I suggest you to just drop the `check:' overriding, and let
Automake handle the recusrions automatically.  If you can't do so, I'll
take a better look to see if we can work out another solution.

> It clutters my compilation
> buffer when I'm in Emacs and want to quickly jump to the first error
> or warning with C-x `. It would suffice if I could make the check:
> target empty. Can you please explain under what conditions the check:
> target actually has a script involved?
>
You mean a "recipe involved" here, right?  If yes, that happens iff the
BUILT_SOURCES variable is defined.

> I tried making a minimal
> example of my own with Automake, and it produced something like this:
> 
>     ...
>     check: check-recursive
>     all-am: Makefile config.h
>     ...
> 
> i.e. an empty target. So I can override check: without getting a
> warning.
>
In truth, automake is *not* letting you override it; you are "just"
adding additional dependencies and a recipe to it -- but make finds
this legitimate of course, so it won't complain.

> When does this happen? When is the check: target empty
> and when does it actually have a command in there?
> 
Automake should provide a recipe to the `check' target iff the
`BUILT_SOURCES' variable is defined.

HTH,
  Stefano