Everything else aside, there's a profound difference between MAKEFLAGS=-r
and MAKEFLAGS+=-r. The latter is far less destabilizing. And
yes, GNUMAKEFLAGS is definitely better for this use.

On Mon, Jul 17, 2023 at 5:45 AM Bruno Haible <br...@clisp.org> wrote:

> Dmitry Goncharov wrote:
> > Once the makefile author knows the makefile does not need built-in
> > rules, they should add MAKEFLAGS=-r in the makefile and
> > this will do a good service to all their users.
>
> The premise "does not need built-in rules" is likely true for most
> Makefiles
> generated by GNU Automake, because
>   - GNU Automake generates its own rules already,
>   - Whenever rules are executed that don't obey the variables listed in
> [1],
>     such as CPPFLAGS, it is a bug that the package's user should rightfully
>     report.
>
> So I wondered whether I should add this variable definition in the
> Makefile.am
> files of my GNU packages. But then I read this in the documentation [2]:
>
>   "you should be sure not to include any options that will drastically
>    affect the actions of make"
>
> and
>
>   "It’s best to use GNUMAKEFLAGS only with flags which won’t materially
>    change the behavior of your makefiles."
>
> and this on stackoverflow [3]:
>
>   "You shouldn't set MAKEFLAGS at all. ...
>    MAKEFLAGS is intended, really, to be an internal implementation passing
>    arguments from a parent make to a child make. It's not intended,
>    generally, to be modified by a makefile."
>
> and this in Oracle's documentation [4]:
>
>   "Do not define MAKEFLAGS in your makefiles."
>
> And finally, MAKEFLAGS is not even mentioned in the main index of the GNU
> Make
> documentation [5], and only regarding "recursion" in the Variables index
> [6].
>
> > The manual should lead by example.
>
> Yes, I agree. But if the example contradicts all the advice given in the
> rest
> of the manual and elsewhere, I will certainly not use it in my Makefiles.
>
> Also, what the example did not tell me: If a Makefile uses MAKEFLAGS=-r and
> the Makefile in a subdirectory needs built-in rules, will the MAKEFLAGS=-r
> setting propagate to the subdirectory? In other words, is it a good idea
> to use MAKEFLAGS=-r in Makefiles that recurse to other Makefiles (and that
> are maintained independently)?
>
> Bruno
>
> [1]
> https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Preset-Output-Variables.html
> [2]
> https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html
> [3] https://stackoverflow.com/questions/19611004/
> [4] https://docs.oracle.com/cd/E19504-01/802-5880/make-65/index.html
> [5]
> https://www.gnu.org/software/make/manual/html_node/Concept-Index.html#Concept-Index_cp_letter-M
> [6]
> https://www.gnu.org/software/make/manual/html_node/Name-Index.html#Name-Index_fn_letter-M
>
>
>
>
>

Reply via email to