diff options
author | Tony Theodore <tonyt@logyst.com> | 2014-02-12 04:25:26 (GMT) |
---|---|---|
committer | Tony Theodore <tonyt@logyst.com> | 2014-02-12 05:00:21 (GMT) |
commit | 723241e08527aa5209d5b57ad417423596feda1a (patch) | |
tree | 8390efb070e40deb12e122282b1b72ec90615c9f /Makefile | |
parent | 5bf7353ebb83f04adcdfe54339ebbf7321218d2d (diff) | |
download | mxe-723241e08527aa5209d5b57ad417423596feda1a.zip mxe-723241e08527aa5209d5b57ad417423596feda1a.tar.gz mxe-723241e08527aa5209d5b57ad417423596feda1a.tar.bz2 |
Makefile: speedup LOOKUP_PKG_RULE function
Use gmsl `memoize` function and associative arrays to cache results
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -215,17 +215,30 @@ $(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, [BUILD|DEPS], target) +# $(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 merge,.,$(call chop,$(call split,.,$(3)))),$(or $(4),$(call uc,$(word 2,$(subst ., ,$(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)),\ + $(call LOOKUP_PKG_RULE,$(1),$(2),$(4),,$(5)),\ + $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(5),$(1)_$(2))\ $(1)_$(2))),\ - $(1)_$(2)_$(3))) + $(call set,LOOKUP_PKG_RULE_,$(1)_$(2)_$(or $(5),$(3)),$(1)_$(2)_$(3))\ + $(1)_$(2)_$(3)))) define PKG_RULE .PHONY: download-$(1) |