[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MAKEFLAGS
From: |
Oleksandr Gavenko |
Subject: |
Re: MAKEFLAGS |
Date: |
Thu, 22 Nov 2012 19:41:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
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 /
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
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'
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...
--
Best regards!
- MAKEFLAGS, Warlich, Christof, 2012/11/21
- Re: MAKEFLAGS,
Oleksandr Gavenko <=