Subject: Re: bug#19961: check-local is kind of like check-hook

From: Peter Johansson <[email-masked]>
Date: Mon, 02 Mar 2015 09:18:25 +1000

On 02/28/2015 02:07 AM, Shahbaz Youssefi wrote:
> Hi,
>
> The -local and -hook targets are generally used like this:
>
> X: X-local
>      # stuff to do X
>      $(MAKE) X-hook
>
> That is, X-local is run first, then the automake generated rules do X
> and then X-hook is called.
>
> With check-local, the generated Makefile.in looks like this:
>
> check-am: all-am
>      $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local
>
> Now as far as the documentation is concerned, this is valid:
>
>> With the -local targets, there is no particular guarantee of execution order; typically, they are run early, but with parallel make, there is no way to be sure of that.
> However, even with not-parallel make, check-local executes after the tests.
>
> To align this with the other -local rules, why not generate it like this?
>
> check-am: all-am check-local
>      $(MAKE) $(AM_MAKEFLAGS) check-TESTS

I think it would be a mistake to change this rule. Some projects might 
rely on the fact that 'check-local' depends on 'all-am' and 
'check-local' might e.g. run some of the programs built within 'all-am'.

>
> The reason I actually have a problem with the current method is that
> it is impossible to perform an action before the check. In my
> particular case, my test scripts use test kernel modules. Of course,
> automake doesn't have a target like check_KERNELMODULE for example to
> automatically build the kernel module before running the tests. So
> ideally what I could do is to build the kernel module in check-local.
> The way the Makefile.in's are currently generated, this is impossible.
>
> In my case, I had to use all-local to build the test kernel modules,
> even if the user is not interested in make check, which is annoying in
> the least.

With my Automake the rule looks like:

check-am: all-am
     $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) $(check_DATA)
     $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local

so you could move your check_kernelmodule into check_DATA with something 
like (untested)

check_DATA = kernelmodule.timestamp

kernelmodule.timestamp:
     @echo "*******************************************"
     @echo "*******************************************"
     @echo "I want this to be called before the check"
     @echo "*******************************************"
     @echo "*******************************************"

Cheers,
Peter

-- 
Peter Johansson