Hello.

Geoff Clare wrote in
 <20211220133200.GA25606@localhost>:
 |Robert Elz wrote, on 18 Dec 2021:
 |> bsd make (bmake) has a couple of macros (the doc calls what are
 |> macros here variables, but they are the same thing), which default to
 |> being unset, which can be set in the environment or command line,
 |> but which cannot be set in any Makefile, as they alter the interpretation
 |> of makefiles (slightly).  That is, if they are going to be defined, that
 |> needs to have happened before the first makefile line is read.
 |> They are used (expanded) in makefiles quite commonly.
 |> 
 |> For that to work, no rule requiring variables to be always set in the
 |> Makefile before being expanded is possible 
 |
 |No such rule is being proposed.  The error is only allowed if
 |the macro is expanded while unset.  If it is set, it makes no
 |difference how it was set.
 |
 |> The += is effectively shorthand for (not possible in make I think)
 |>  MACRO= ${MACRO} string
 |> an so is effectively expanding the otherwise potentially unset MACRO
 |> before altering it.   Any implementation which generated an error on
 |> an expansion of an unset macro would need to generate an error for
 |> this usage (assuming MACRO was unset previously) as well.
 |
 |Thank you for pointing that out.  We should revisit the proposed
 |changes to allow this error as well.

Now that it starts to affect me.. :)
I do not think the proposal reflects practice.

For example CRUX-Linux has a /etc/pkgmk.conf where people can
define $CFLAGS, $CXXFLAGS, etc., also things like

  export JOBS=$(nproc)
  export MAKEFLAGS="-j $JOBS"

It is processed by the shell before the actual package is build.
I personally set things in my environment, $CFLAGS for example.
These things are picked up by most build processes automatically
ever since i consciously look at that.

        all:
                echo CFLAGS=$(CFLAGS)
->
  echo CFLAGS=-O1 -g
  CFLAGS=-O1 -g

or even

        CFLAGS+=-Weven-more-noise
        all:
                echo CFLAGS=$(CFLAGS)
->
  echo CFLAGS=-O1 -g -Weven-more-noise
  CFLAGS=-O1 -g -Weven-more-noise

This would vanish with the proposal:

  CFLAGS=
        CFLAGS+=-Weven-more-noise
        all:
                echo CFLAGS=$(CFLAGS)
->
  echo CFLAGS=-Weven-more-noise
  CFLAGS=-Weven-more-noise

It even becomes impossible to get the same effect that is used in
the wild, as Robert Elz already said, specifying 'make
CFLAGS="$CFLAGS"' on the command line hard-sets CFLAGS in the
makefile, and the += never comes into play.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

        • Re: [Is... Quentin Rameau via austin-group-l at The Open Group
        • Re: [Is... Paul Smith via austin-group-l at The Open Group
        • Re: [Is... Ukko via austin-group-l at The Open Group
        • Re: [Is... Quentin Rameau via austin-group-l at The Open Group
        • Re: [Is... Quentin Rameau via austin-group-l at The Open Group
        • Re: [Is... Paul Smith via austin-group-l at The Open Group
        • Re: [Is... Oğuz via austin-group-l at The Open Group
        • Re: [Is... Robert Elz via austin-group-l at The Open Group
        • Re: [Is... Quentin Rameau via austin-group-l at The Open Group
        • Re: [Is... Geoff Clare via austin-group-l at The Open Group
        • Re: [Is... Steffen Nurpmeso via austin-group-l at The Open Group
        • Re: [Is... Geoff Clare via austin-group-l at The Open Group
        • Re: [Is... Steffen Nurpmeso via austin-group-l at The Open Group
        • Re: [Is... Geoff Clare via austin-group-l at The Open Group
        • Re: [Is... Paul Smith via austin-group-l at The Open Group
        • Re: [Is... Chet Ramey via austin-group-l at The Open Group
        • Re: [Is... Robert Elz via austin-group-l at The Open Group
    • Re: [Issue 8 dr... Robert Elz via austin-group-l at The Open Group
  • Re: [Issue 8 drafts ... Robert Elz via austin-group-l at The Open Group

Reply via email to