Hi Paul,

On Tue, Jul 16, 2024 at 12:52:05PM GMT, Paul Smith wrote:
> On Tue, 2024-07-16 at 17:53 +0200, Alejandro Colomar wrote:
> > And now I say:  If CC is not set in the Makefile (I didn't) nor in
> > the
> > environment (I didn't either), set it to foo.
> > > 
> > >   $(info $(CC))
> > 
> > I expect this should print "foo".
> > 
> > >   alx@debian:~/tmp/make$ make
> > >   cc
> > 
> > But it prints the builtin value "cc".  Why?
> 
> A default setting is still a setting: the CC variable is set to a
> value.  The ?= only sets the variable if it's not already set, at all,
> so your assignment has no effect.

I used the following:

< <
< <       alx@debian:~/tmp/make$ env | grep CC
< <       QT_ACCESSIBILITY=1
< <       alx@debian:~/tmp/make$ cat GNUmakefile
< <       GNUMAKEFLAGS += --no-builtin-rules
< <       GNUMAKEFLAGS += --no-builtin-variables
< 
< I expect the line above to drop any builtin setting of $(CC).

> 
> You could disable all the built-in variables by running "make -R" or,
> if you have a sufficiently modern version of GNU Make,

How much modern should it be?  I'm using 4.4.1; I thought that one
already had that fixed.  What's the minimum version I should use?

I'll also add some warning in the makefile if I detect an old version of
make(1):

ifneq (4.4.2, $(shell printf "4.4.2\n$(MAKE_VERSION)" | sort -V | head -n1))
$(warning make(1) >= 4.4.2 is necessary.  You may find issues with 
$(MAKE_VERSION).)
endif

(assuming it was 4.4.2 the one that added support for that.)

> buy adding to
> MAKEFLAGS in your makefile:
> 
>     MAKEFLAGS += -R

That's what I tried (via GNUMAKEFLAGS).

> 
> This will disable _all_ the built-in variables... I don't know if
> that's a problem.

No, that's indeed what I want.

Cheers,
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature

Reply via email to