summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2014-02-08 16:34:47 (GMT)
committerTony Theodore <tonyt@logyst.com>2014-02-08 16:34:47 (GMT)
commit5a18b2786be138604e82a54f84e131536371781b (patch)
tree22fd3bd693189735604bd683447f9192428061ed
parentb5449a4a2616140c30b1b66816bc839b16e82b4b (diff)
parentc1ad1344399ec3ee81bac467cd89c6438a9b8ed6 (diff)
downloadmxe-5a18b2786be138604e82a54f84e131536371781b.zip
mxe-5a18b2786be138604e82a54f84e131536371781b.tar.gz
mxe-5a18b2786be138604e82a54f84e131536371781b.tar.bz2
Merge pull request #320 from tonytheodore/lookup-pkg-rule
Makefile: refactor lookup of pkg build rules and deps
-rw-r--r--Makefile35
-rw-r--r--src/gcc.mk6
-rw-r--r--src/sdl_rwhttp.mk6
3 files changed, 28 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 5f8e99b..9093c53 100644
--- a/Makefile
+++ b/Makefile
@@ -147,11 +147,15 @@ $(PREFIX)/installed/check-requirements: $(MAKEFILE)
$(call CHECK_REQUIREMENT_VERSION,automake,1\.11\.[3-9]\|1\.[1-9][2-9]\(\.[0-9]\+\)\?)
@touch '$@'
+# define some whitespace variables
define newline
endef
+null :=
+space := $(null) $(null)
+
include $(patsubst %,$(TOP_DIR)/src/%.mk,$(PKGS))
.PHONY: download
@@ -189,9 +193,19 @@ $(1): | $(if $(value $(1)_DEPS), \
endef
$(foreach TARGET,$(MXE_TARGETS),$(eval $(call TARGET_RULE,$(TARGET))))
+# finds a package build rule or deps by truncating the target elements
+# $(call LOOKUP_PKG_RULE, package, [BUILD|DEPS], target)
+# returns variable name for use with $(value)
+LOOKUP_PKG_RULE = $(strip \
+ $(if $(findstring undefined, $(flavor $(1)_$(2)_$(3))),\
+ $(if $(3),\
+ $(call LOOKUP_PKG_RULE,$(1),$(2),$(call merge,.,$(call chop,$(call split,.,$(3))))),\
+ $(1)_$(2)),\
+ $(1)_$(2)_$(3)))
+
define PKG_RULE
.PHONY: download-$(1)
-download-$(1):: $(addprefix download-,$($(1)_DEPS) $($(1)_DEPS_$(3)))
+download-$(1):: $(addprefix download-,$(value $(call LOOKUP_PKG_RULE,$(1),DEPS,$(3))))
if ! $(call CHECK_PKG_ARCHIVE,$(1)); then \
$(call DOWNLOAD_PKG_ARCHIVE,$(1)); \
$(call CHECK_PKG_ARCHIVE,$(1)) || { echo 'Wrong checksum!'; exit 1; }; \
@@ -202,7 +216,7 @@ $(1): $(PREFIX)/$(3)/installed/$(1)
$(PREFIX)/$(3)/installed/$(1): $(TOP_DIR)/src/$(1).mk \
$(wildcard $(TOP_DIR)/src/$(1)-*.patch) \
$(wildcard $(TOP_DIR)/src/$(1)-test*) \
- $(addprefix $(PREFIX)/$(3)/installed/,$($(1)_DEPS) $($(1)_DEPS_$(3))) \
+ $(addprefix $(PREFIX)/$(3)/installed/,$(value $(call LOOKUP_PKG_RULE,$(1),DEPS,$(3)))) \
| $(if $(DONT_CHECK_REQUIREMENTS),,check-requirements) $(3)
@[ -d '$(LOG_DIR)/$(TIMESTAMP)' ] || mkdir -p '$(LOG_DIR)/$(TIMESTAMP)'
@if ! $(call CHECK_PKG_ARCHIVE,$(1)); then \
@@ -220,14 +234,9 @@ $(PREFIX)/$(3)/installed/$(1): $(TOP_DIR)/src/$(1).mk \
exit 1; \
fi; \
fi
- $(if $(or $(value $(1)_BUILD_$(3)),\
- $(and $(value $(1)_BUILD),$(findstring undefined,$(origin $(1)_BUILD_$(3))))),
+ $(if $(value $(call LOOKUP_PKG_RULE,$(1),BUILD,$(3))),
@echo '[build] $(1)',
- $(if $(findstring undefined,$(origin $(1)_BUILD_$(3))),
- @echo '[no-op] $(1)',
- @echo '[exclude] $(1)'
- )
- )
+ @echo '[no-build] $(1)')
@touch '$(LOG_DIR)/$(TIMESTAMP)/$(1)_$(3)'
@[ $(words $(MXE_TARGETS)) == 1 ] || ln -sf '$(TIMESTAMP)/$(1)_$(3)' '$(LOG_DIR)/$(1)_$(3)'
@ln -sf '$(TIMESTAMP)/$(1)_$(3)' '$(LOG_DIR)/$(1)'
@@ -247,15 +256,15 @@ $(PREFIX)/$(3)/installed/$(1): $(TOP_DIR)/src/$(1).mk \
) >> '$(LOG_DIR)/$(TIMESTAMP)/$(1)_$(3)'; \
exit 1; \
fi
- @echo '[done] $(1)'
+ $(if $(value $(call LOOKUP_PKG_RULE,$(1),BUILD,$(3))),
+ @echo '[done] $(1)')
.PHONY: build-only-$(1)_$(3)
build-only-$(1)_$(3): PKG = $(1)
build-only-$(1)_$(3): TARGET = $(3)
build-only-$(1)_$(3): CMAKE_TOOLCHAIN_FILE = $(PREFIX)/$(3)/share/cmake/mxe-conf.cmake
build-only-$(1)_$(3):
- $(if $(or $(value $(1)_BUILD_$(3)),\
- $(and $(value $(1)_BUILD),$(findstring undefined,$(origin $(1)_BUILD_$(3))))),
+ $(if $(value $(call LOOKUP_PKG_RULE,$(1),BUILD,$(3))),
uname -a
git show-branch --list --reflog=1
lsb_release -a 2>/dev/null || sw_vers 2>/dev/null || true
@@ -265,7 +274,7 @@ build-only-$(1)_$(3):
cd '$(2)/$($(1)_SUBDIR)'
$(foreach PKG_PATCH,$(sort $(wildcard $(TOP_DIR)/src/$(1)-*.patch)),
(cd '$(2)/$($(1)_SUBDIR)' && $(PATCH) -p1 -u) < $(PKG_PATCH))
- $$(call $(if $(value $(1)_BUILD_$(3)),$(1)_BUILD_$(3),$(1)_BUILD),$(2)/$($(1)_SUBDIR),$(TOP_DIR)/src/$(1)-test)
+ $$(call $(call LOOKUP_PKG_RULE,$(1),BUILD,$(3)),$(2)/$($(1)_SUBDIR),$(TOP_DIR)/src/$(1)-test)
(du -k -d 0 '$(2)' 2>/dev/null || du -k --max-depth 0 '$(2)') | $(SED) -n 's/^\(\S*\).*/du: \1 KiB/p'
rm -rfv '$(2)'
,)
diff --git a/src/gcc.mk b/src/gcc.mk
index 3b6a23a..209bf51 100644
--- a/src/gcc.mk
+++ b/src/gcc.mk
@@ -11,9 +11,9 @@ $(PKG)_URL := ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_
$(PKG)_URL_2 := ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_DEPS := binutils gcc-cloog gcc-gmp gcc-isl gcc-mpc gcc-mpfr
-$(PKG)_DEPS_i686-pc-mingw32 := mingwrt w32api
-$(PKG)_DEPS_i686-w64-mingw32 := mingw-w64
-$(PKG)_DEPS_x86_64-w64-mingw32 := mingw-w64
+$(PKG)_DEPS_i686-pc-mingw32 := $($(PKG)_DEPS) mingwrt w32api
+$(PKG)_DEPS_i686-w64-mingw32 := $($(PKG)_DEPS) mingw-w64
+$(PKG)_DEPS_x86_64-w64-mingw32 := $($(PKG)_DEPS) mingw-w64
define $(PKG)_UPDATE
$(WGET) -q -O- 'http://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
diff --git a/src/sdl_rwhttp.mk b/src/sdl_rwhttp.mk
index 65abffb..3f98a46 100644
--- a/src/sdl_rwhttp.mk
+++ b/src/sdl_rwhttp.mk
@@ -10,9 +10,9 @@ $(PKG)_FILE := SDL_rwhttp-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := https://github.com/mgerhardy/SDL_rwhttp/releases/download/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
$(PKG)_DEPS := gcc curl
-$(PKG)_DEPS_i686-pc-mingw32 := sdl sdl_net
-$(PKG)_DEPS_i686-w64-mingw32 := sdl2 sdl2_net
-$(PKG)_DEPS_x86_64-w64-mingw32 := sdl2 sdl2_net
+$(PKG)_DEPS_i686-pc-mingw32 := $($(PKG)_DEPS) sdl sdl_net
+$(PKG)_DEPS_i686-w64-mingw32 := $($(PKG)_DEPS) sdl2 sdl2_net
+$(PKG)_DEPS_x86_64-w64-mingw32 := $($(PKG)_DEPS) sdl2 sdl2_net
define $(PKG)_UPDATE
$(WGET) -q -O- 'http://github.com/mgerhardy/SDL_rwhttp/tags' | \