[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
The -e option confuses the $(origin ) ?
From: |
Masahiro Yamada |
Subject: |
The -e option confuses the $(origin ) ? |
Date: |
Mon, 13 Sep 2021 16:28:52 +0900 |
Hi.
I have a question about the -e option.
'man make' shows this:
-e, --environment-overrides
Give variables taken from the environment precedence over vari‐
ables from makefiles.
But, as a side-effect, the result of $(origin ) is changed.
I am not sure whether it is intended or not.
Test code
=======
masahiro@oscar:~/workspace/foo$ cat Makefile
$(warning the origin of FOO is: $(origin FOO))
$(warning the value of FOO is: $(FOO))
all:
$(MAKE) -e -f Makefile.sub1 FOO=1
masahiro@oscar:~/workspace/foo$ cat Makefile.sub1
$(warning the origin of FOO is: $(origin FOO))
$(warning the value of FOO is: $(FOO))
all:
$(MAKE) -f Makefile.sub2
masahiro@oscar:~/workspace/foo$ cat Makefile.sub2
$(warning the origin of FOO is: $(origin FOO))
$(warning the value of FOO is: $(FOO))
all:
@:
Result
=====
masahiro@oscar:~/workspace/foo$ export FOO=2
masahiro@oscar:~/workspace/foo$ make
Makefile:1: the origin of FOO is: environment
Makefile:2: the value of FOO is: 2
make -e -f Makefile.sub1 FOO=1
make[1]: Entering directory '/home/masahiro/workspace/foo'
Makefile.sub1:1: the origin of FOO is: command line
Makefile.sub1:2: the value of FOO is: 1
make -f Makefile.sub2
make[2]: Entering directory '/home/masahiro/workspace/foo'
Makefile.sub2:1: the origin of FOO is: environment
Makefile.sub2:2: the value of FOO is: 1
make[2]: Leaving directory '/home/masahiro/workspace/foo'
make[1]: Leaving directory '/home/masahiro/workspace/foo'
I think the log from Makefile.sub2 is strange:
Makefile.sub2:1: the origin of FOO is: environment
Makefile.sub2:2: the value of FOO is: 1
Apparently, FOO=1 was specified in the command line.
--
Best Regards
Masahiro Yamada
- The -e option confuses the $(origin ) ?,
Masahiro Yamada <=