summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-11-20 12:37:30 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-11-20 12:37:30 -0500
commit3331afbb26380088c0a6cc5b301a093a96235475 (patch)
tree8e2473bf84ce80aa0c147b2dda14788a224dc00b /Makefile
parent1f403348acb7c3f5c92494f75d2590166420ef71 (diff)
Makefile: add rest and merge functions, use them to simplify a bit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile16
1 files changed, 10 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 6584fe0..16a5605 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ all: package
_main = $(_$(func)_main)
_hash = _memoized_$(_$(func)_hash)
-memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(wordlist 2,$(words $($(_hash))),$($(_hash)))
+memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))
# utilities ####################################################################
@@ -61,6 +61,10 @@ file2 = $(foreach file,$2,$(call _file2_memo,$1,$(file)))
specs_for = $(strip $(foreach t,$1,$(filter $t|%,$(if $2,$2,$(specs)))))
+# These are equivalent to the same functions in GSML
+rest = $(wordlist 2,$(words $1),$1)
+merge = $(firstword $2)$(if $(call rest,$2),$1$(call merge,$1,$(call rest,$2)))
+
# configuration ################################################################
# Load conf/sources.mk
@@ -74,9 +78,9 @@ export bindir := $(shell $(CAT) conf/bindir.txt)
# Post-processing for conf/sources.mk
packages := $(filter-out _%,$(variables))
-packages_specific=$(filter $(patsubst rules/%/Makefile,%,$(wildcard rules/*/Makefile)),$(packages))
-packages_stub =$(foreach package,$(packages),$(if $(filter stub,$(call name2,type,$(package))),$(package)))
-packages_generic =$(filter-out $(packages_specific) $(packages_stub),$(packages))
+packages_specific := $(filter $(patsubst rules/%/Makefile,%,$(wildcard rules/*/Makefile)),$(packages))
+packages_stub := $(foreach package,$(packages),$(if $(filter stub,$(call name2,type,$(package))),$(package)))
+packages_generic := $(filter-out $(packages_specific) $(packages_stub),$(packages))
specs := $(foreach variable,$(variables),$(if $(findstring |,$($(variable))),$($(variable))))
tarbombs := $(addprefix build/extract/,$(call spec2,base,$(_tarbombs)))
@@ -213,10 +217,10 @@ package: PHONY $(addprefix build/packages/,$(packages))
_dirs2jars = $(if $1,$(shell $(FIND) $1 -name '*.jar'))
_deps2jars = $(filter %.jar,$1) $(call _dirs2jars,$(filter build/packages/%,$1))
-deps2classpath = $(shell $(ECHO) $(abspath $(call _deps2jars,$1)) $(CLASSPATH) | $(SED) 'y/ /:/')
+deps2classpath = $(call merge,:,$(abspath $(call _deps2jars,$1)) $(CLASSPATH))
_deps2bindirs = $(if $1,$(sort $(shell $(FIND) $1 -type f -executable -printf '%h\n' 2>/dev/null)))
-deps2path = $(shell $(ECHO) $(abspath $(call _deps2bindirs,$(filter build/packages/%,$1))) $(PATH) | $(SED) 'y/ /:/')
+deps2path = $(call merge,:,$(abspath $(call _deps2bindirs,$(filter build/packages/%,$1))) $(PATH))
recurse = \
PATH='$(call deps2path,$^)' \