summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2013-08-20 15:18:34 (GMT)
committerTony Theodore <tonyt@logyst.com>2013-08-20 15:18:34 (GMT)
commit143ae3c63f875af9b07b4eb7590d90214145ea7a (patch)
tree9b8aefaf59bb618d9b8e853943e3f3bd1b3b5172 /Makefile
parent6e81b7a64370cdfacde4a9c7ecc99d8cffcfc44e (diff)
downloadmxe-143ae3c63f875af9b07b4eb7590d90214145ea7a.zip
mxe-143ae3c63f875af9b07b4eb7590d90214145ea7a.tar.gz
mxe-143ae3c63f875af9b07b4eb7590d90214145ea7a.tar.bz2
Makefile and docs: add EXCLUDE_PKGS and show*deps* functionality
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile61
1 files changed, 60 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index f68e790..daf2b69 100644
--- a/Makefile
+++ b/Makefile
@@ -99,7 +99,7 @@ else
endif
.PHONY: all
-all: $(PKGS)
+all: all-filtered
.PHONY: check-requirements
define CHECK_REQUIREMENT
@@ -261,6 +261,65 @@ $(foreach TARGET,$(MXE_TARGETS), \
$(foreach PKG,$(PKGS), \
$(eval $(call PKG_RULE,$(PKG),$(call TMP_DIR,$(PKG)),$(TARGET)))))
+# convenience set-like functions for unique lists
+SET_APPEND = \
+ $(eval $(1) := $(sort $($(1)) $(2)))
+
+SET_CLEAR = \
+ $(eval $(1) := )
+
+# WALK functions accept a list of pkgs and/or wildcards
+WALK_UPSTREAM = \
+ $(strip \
+ $(foreach PKG,$(filter $(1),$(PKGS)),\
+ $(foreach DEP,$($(PKG)_DEPS) $(foreach TARGET,$(MXE_TARGETS),$($(PKG)_DEPS_$(TARGET))),\
+ $(if $(filter-out $(PKGS_VISITED),$(DEP)),\
+ $(call SET_APPEND,PKGS_VISITED,$(DEP))\
+ $(call WALK_UPSTREAM,$(DEP))\
+ $(DEP)))))
+
+# not really walking downstream - that seems to be quadratic, so take
+# a linear approach and filter the fully expanded upstream for each pkg
+WALK_DOWNSTREAM = \
+ $(strip \
+ $(foreach PKG,$(PKGS),\
+ $(call SET_CLEAR,PKGS_VISITED)\
+ $(eval $(PKG)_DEPS_ALL := $(call WALK_UPSTREAM,$(PKG))))\
+ $(foreach PKG,$(PKGS),\
+ $(if $(filter $(1),$($(PKG)_DEPS_ALL)),$(PKG))))
+
+# EXCLUDE_PKGS can be a list of pkgs and/or wildcards
+RECURSIVELY_EXCLUDED_PKGS = \
+ $(sort \
+ $(filter $(EXCLUDE_PKGS),$(PKGS))\
+ $(call SET_CLEAR,PKGS_VISITED)\
+ $(call WALK_DOWNSTREAM,$(EXCLUDE_PKGS)))
+
+.PHONY: all-filtered
+all-filtered: $(filter-out $(call RECURSIVELY_EXCLUDED_PKGS),$(PKGS))
+
+# print a list of upstream dependencies and downstream dependents
+show-deps-%:
+ $(call SET_CLEAR,PKGS_VISITED)
+ $(info $* upstream dependencies:$(newline)\
+ $(call WALK_UPSTREAM,$*)\
+ $(newline)$(newline)$* downstream dependents:$(newline)\
+ $(call WALK_DOWNSTREAM,$*))
+ @echo
+
+# show upstream dependencies and downstream dependents separately
+# suitable for usage in shell with: `make show-downstream-deps-foo`
+# @echo -n suppresses the "Nothing to be done" without an eol
+show-downstream-deps-%:
+ $(call SET_CLEAR,PKGS_VISITED)
+ $(info $(call WALK_DOWNSTREAM,$*))
+ @echo -n
+
+show-upstream-deps-%:
+ $(call SET_CLEAR,PKGS_VISITED)\
+ $(info $(call WALK_UPSTREAM,$*))
+ @echo -n
+
.PHONY: clean
clean:
rm -rf $(call TMP_DIR,*) $(PREFIX)/*