summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2020-08-29 22:58:58 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2020-08-29 22:58:58 -0400
commitf08649b6aa6c359c0ed5903c5809a8e7dfbf83b0 (patch)
treefa3aac43f720745a93f2db6e21d67961d03223e4
parent2c6ad4d51f5625c30bab0c4ca8a19c2e44c1a7a7 (diff)
downloadmakefile_templates-f08649b6aa6c359c0ed5903c5809a8e7dfbf83b0.tar.gz
makefile_templates-f08649b6aa6c359c0ed5903c5809a8e7dfbf83b0.zip
allow to pass absolute topdir to subdirs targets
-rw-r--r--subdirs.mk9
1 files changed, 9 insertions, 0 deletions
diff --git a/subdirs.mk b/subdirs.mk
index a39b038..b742d75 100644
--- a/subdirs.mk
+++ b/subdirs.mk
@@ -2,6 +2,11 @@
export dir_symbol += -
+USE_ABSOLUTE_TOPDIR ?= 0
+ifneq ($(USE_ABSOLUTE_TOPDIR),0)
+ TOPDIR_FOR_SUBDIR=$(shell pwd)
+endif
+
nullstring :=
space := $(nullstring) # keep it to assign space
@@ -9,6 +14,10 @@ subdirs: $(SUBDIRS)
$(SUBDIRS):
echo $(subst $(space),,$(dir_symbol))'|' $@ $(MAKECMDGOALS)
+ifeq ($(USE_ABSOLUTE_TOPDIR),0)
$(MAKE) -C $@ $(MAKECMDGOALS)
+else
+ TOPDIR="$(TOPDIR_FOR_SUBDIR)" $(MAKE) -C $@ $(MAKECMDGOALS)
+endif
.PHONY: $(SUBDIRS)