help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

buggy interaction between MAKEFLAGS += rR and CC ?= my_gcc


From: Britton Kerin
Subject: buggy interaction between MAKEFLAGS += rR and CC ?= my_gcc
Date: Thu, 25 Aug 2016 11:27:52 -0800

MAKEFLAGS += rR still doesn't work as expected:

     $ cat Makefile

     MAKEFLAGS += rR

     CC ?= my_gcc

     debug:
             @echo 'origin of CC:' $(origin CC)
             @echo 'value of CC: ' $(CC)

     %.o: %.c
             $(CC) $< -o $@
     $ touch test.c
     $ make test.o
     test.c -o test.o
     make: test.c: Command not found
     make: *** [Makefile:11: test.o] Error 127
     $ make debug
     origin of CC: undefined
     value of CC:
     $ make -rR debug
     origin of CC: file
     value of CC:  my_gcc
     $ make -rR test.o
     my_gcc test.c -o test.o
     make: my_gcc: Command not found
     make: *** [Makefile:11: test.o] Error 127
     $

So although injecting rR into MAKEFLAGS does have an effect (CC etc. end up
undefined), it doesn't seem to happen in time to have the expected results
on e.g. subsequent conditional assignment.  In the above example, at the
time the conditional assignment happens, Make still considers CC to have
origin default, as can be seen by adding a line like:

      $(info origin of CC: $(origin CC))

 immediately above the conditional assignment line.

If assignment into MAKEFLAGS is going to be supported at all, it should
have exactly the effect that the corresponding command line options have.
In this case, that means CC etc. should be undefined (as with the undefine
directive) from the point rR is injected, not just empty with origin default.
So if when MAKEFLAGS += rR happens and CC has origin default, it should be
undefined.  It it's origin is file or command line or something it should be
left alone.

Britton



reply via email to

[Prev in Thread] Current Thread [Next in Thread]