On Mon, 2021-07-05 at 11:33 +0200, Christof Warlich wrote:
> build-stamp:  config.status
>      dh_testdir
>      $(MAKE) $(MAKEFLAGS)
> 
> I have tree questions here:
> 
>  1. As short options show up in $(MAKEFLAGS) without the leading -, am I
>     right to consider the above usage of MAKEFLAGS to be a bug?

Yes.  That makefile is wrong.

>  2. Furthermore, is it true that any (sub)make honors all flags present
>     in MAKEFLAGS anyway?

Yes.  MAKEFLAGS is not intended to be used in recipes at all.  It's a
method for a parent make to communicate to a child make through the
environment, not through the command line.

>  3. Finally, it looks somewhat inconsistent to me (and presumably, also
>     to the maintainer of the elfutils package) that short options in
>     MAKEFLAGS are lacking their leading -, whereas long options (that do
>     not have a short option counterpart) do show up in MAKEFLAGS with
>     their two leading --: Is this just for historic reasons?

Mostly.  Long-ago makefiles would use "-$(MAKEFLAGS)" in their recipes
so this is for backward-compatibility with those makefiles.

However POSIX does require that MAKEFLAGS be allowed to have either
leading hyphen or non-leading hyphen so some of the confusion is
required by the standard.

The correct behavior of makefiles is to never add $(MAKEFLAGS) to the
recipe when invoking a sub-make.  As above, this value is intended to
be passed _through the environment_, not _on the command line_.


Reply via email to