[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MAKEFLAGS
From: |
Christof Warlich |
Subject: |
Re: MAKEFLAGS |
Date: |
Fri, 23 Nov 2012 10:26:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 |
Am 22.11.2012 18:41, schrieb Oleksandr Gavenko:
On 2012-11-21, Warlich, Christof wrote:
But with the following Makefile, the --include-dir or -I flags are ignored in
MAKEFLAGS (and in MFLAGS):
$(info MAKEFLAGS=$(MAKEFLAGS))
$(info MLAGS=$(MFLAGS))
all: ;
$ make --include-dir=/home -ks -I /
MAKEFLAGS=sk
MLAGS=-sk
Is there any way to get access to the include path from within my Makefile?
I found that it update your example with:
all: ; echo $(MAKEFLAGS)
it print '$(MAKEFLAGS)' from command:
$ make -I subdir:
MAKEFLAGS=sk sk
MLAGS=-sk
skI /home -I /
Ok, that's interesting: Being evaluated from within a recipe, MAKEFLAGS
is set to the right value, while $(info $(MAKEFLAGS)) only shows some flags.
I'd really like to know if this is intended behaviour.
Also I develop such examples:
**Makefile**
include test.mk
all:
echo hello "$(MAKEFLAGS)"
$(MAKE) -C subproj
**subproj/Makefile**
include test.mk
all:
echo hello again "$(MAKEFLAGS)"
**subdir/test.mk**
$(info Found by $(MAKEFILE_LIST)!!)
See how it work:
$ make -I subdir/
Found by Makefile subdir/test.mk!!
echo hello "I subdir/"
hello I subdir/
make -C subproj
make[1]: Entering directory `/home/user/devel/tmp/mk/subproj'
Makefile:2: test.mk: No such file or directory
make[1]: *** No rule to make target `test.mk'. Stop.
make[1]: Leaving directory `/home/user/devel/tmp/mk/subproj'
make: *** [all] Error 2
I think it is ok here that the submake doesn't find the included file,
since the include path being passed is just "subdir", while the incude
file is located in "../subdir" when seen from the submake's working
directory, which is "subproj".
But if I call with *full* path all OK:
$ make -I $PWD/subdir/
Found by Makefile /home/user/devel/tmp/mk/subdir/test.mk!!
echo hello "I /home/user/devel/tmp/mk/subdir/"
hello I /home/user/devel/tmp/mk/subdir/
make -C subproj
Found by Makefile /home/user/devel/tmp/mk/subdir/test.mk!!
make[1]: Entering directory `/home/user/devel/tmp/mk/subproj'
echo hello again "wI /home/user/devel/tmp/mk/subdir/"
hello again wI /home/user/devel/tmp/mk/subdir/
make[1]: Leaving directory `/home/user/devel/tmp/mk/subproj'
Again, a very enlightening example: So the flags are also properly
passed down to the submake. Thus, the problem only seems
to be with $(info $(MAKEFLAGS)) only showing some flags.
I recommend implement own inclusion mechanics:
**Makefile**
dirs := a b/c non-existent
MK_DIRS := $(foreach dir,$(dirs),$(realpath $(dir)))
$(info $(MK_DIRS))
files := a.mk c.mk
MK_FILES := $(foreach file,$(files),$(foreach dir,$(dirs),$(wildcard
$(dir)/$(file))))
$(info $(MK_FILES))
include $(MK_FILES)
**a/a.mk**
$(info "$(lastword $(MAKEFILE_LIST))" was included)
**b/c/c.mk**
$(info "$(lastword $(MAKEFILE_LIST))" was included)
Full working example clone at:
https://sourceforge.net/u/gavenkoa/exp/ci/tip/tree/make/include-dirs/
If you run:
$ make
/home/user/devel/my-devel/exp/make/include-dirs/a
/home/user/devel/my-devel/exp/make/include-dirs/b/c
a/a.mk b/c/c.mk
"a/a.mk" was included
"b/c/c.mk" was included
make: *** No targets. Stop.
Hope this help to you. Any suggestion welcome to help-make...
Yes, that helped a lot. Many thanks!
- MAKEFLAGS, Warlich, Christof, 2012/11/21
- Re: MAKEFLAGS, Oleksandr Gavenko, 2012/11/22
- Re: MAKEFLAGS,
Christof Warlich <=