diff --git a/Makefile b/Makefile index 01bb9ad0..3c8a034f 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,31 @@ else } >'$(PWD)/settings.mk') endif +# cache some target string manipulation functions +# `memoize` and `uc` from gmsl +_CHOP_TARGET = $(call merge,.,$(call chop,$(call split,.,$(1)))) +CHOP_TARGET = $(call memoize,_CHOP_TARGET,$(1)) +_UC_LIB_TYPE = $(call uc,$(word 2,$(subst ., ,$(1)))) +UC_LIB_TYPE = $(call memoize,_UC_LIB_TYPE,$(1)) + +# finds a package build rule or deps by truncating the target elements +# $(call LOOKUP_PKG_RULE, package, rule type ie. BUILD|DEPS|FILE, target,[lib type, original target to cache]) +# returns variable name for use with $(value) +# +# caches result with gmsl associative arrays (`get` and `set` functions) +# since `memoize` only works with single argument +LOOKUP_PKG_RULE = $(strip \ + $(or $(call get,LOOKUP_PKG_RULE_,$(1)_$(2)_$(or $(5),$(3))),\ + $(if $(findstring undefined, $(flavor $(1)_$(2)_$(3))),\ + $(if $(3),\ + $(call LOOKUP_PKG_RULE,$(1),$(2),$(call CHOP_TARGET,$(3)),$(or $(4),$(call UC_LIB_TYPE,$(3))),$(or $(5),$(3))),\ + $(if $(4),\ + $(call LOOKUP_PKG_RULE,$(1),$(2),$(4),,$(5)),\ + $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(5),$(1)_$(2))\ + $(1)_$(2))),\ + $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(or $(5),$(3)),$(1)_$(2)_$(3))\ + $(1)_$(2)_$(3)))) + .PHONY: all all: all-filtered @@ -237,31 +262,6 @@ $(1): | $(if $(value $(1)_DEPS), \ endef $(foreach TARGET,$(MXE_TARGETS),$(eval $(call TARGET_RULE,$(TARGET)))) -# cache some target string manipulation functions -# `memoize` and `uc` from gmsl -_CHOP_TARGET = $(call merge,.,$(call chop,$(call split,.,$(1)))) -CHOP_TARGET = $(call memoize,_CHOP_TARGET,$(1)) -_UC_LIB_TYPE = $(call uc,$(word 2,$(subst ., ,$(1)))) -UC_LIB_TYPE = $(call memoize,_UC_LIB_TYPE,$(1)) - -# finds a package build rule or deps by truncating the target elements -# $(call LOOKUP_PKG_RULE, package, rule type ie. BUILD|DEPS|FILE, target,[lib type, original target to cache]) -# returns variable name for use with $(value) -# -# caches result with gmsl associative arrays (`get` and `set` functions) -# since `memoize` only works with single argument -LOOKUP_PKG_RULE = $(strip \ - $(or $(call get,LOOKUP_PKG_RULE_,$(1)_$(2)_$(or $(5),$(3))),\ - $(if $(findstring undefined, $(flavor $(1)_$(2)_$(3))),\ - $(if $(3),\ - $(call LOOKUP_PKG_RULE,$(1),$(2),$(call CHOP_TARGET,$(3)),$(or $(4),$(call UC_LIB_TYPE,$(3))),$(or $(5),$(3))),\ - $(if $(4),\ - $(call LOOKUP_PKG_RULE,$(1),$(2),$(4),,$(5)),\ - $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(5),$(1)_$(2))\ - $(1)_$(2))),\ - $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(or $(5),$(3)),$(1)_$(2)_$(3))\ - $(1)_$(2)_$(3)))) - define PKG_RULE .PHONY: download-$(1) download-$(1):: $(addprefix download-,$(value $(call LOOKUP_PKG_RULE,$(1),DEPS,$(3))))