From 3f8688e0d0526b74993d64a166e9ba8559c687e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 15 May 2017 14:37:40 +0200 Subject: Make autopatch of Erlang.mk projects less obtrusive We do not touch the erlang.mk file anymore. We only patch the Makefile to include the top-level Erlang.mk by changing the 'include erlang.mk' line to look for ERLANG_MK_FILENAME if it is defined. The modified Makefile can be committed safely. --- core/core.mk | 1 + core/deps-tools.mk | 2 +- core/deps.mk | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/core.mk b/core/core.mk index 10fe0a0..278e20f 100644 --- a/core/core.mk +++ b/core/core.mk @@ -15,6 +15,7 @@ .PHONY: all app apps deps search rel relup docs install-docs check tests clean distclean help erlang-mk ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST))) +export ERLANG_MK_FILENAME ERLANG_MK_VERSION = rolling diff --git a/core/deps-tools.mk b/core/deps-tools.mk index de1cc2b..1ad9274 100644 --- a/core/deps-tools.mk +++ b/core/deps-tools.mk @@ -74,7 +74,7 @@ endif $(verbose) set -e; for dep in $^ ; do \ if ! grep -qs ^$$dep$$ $(ERLANG_MK_RECURSIVE_TMP_LIST); then \ echo $$dep >> $(ERLANG_MK_RECURSIVE_TMP_LIST); \ - if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk)$$" \ + if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk|.*ERLANG_MK_FILENAME.*)$$" \ $$dep/GNUmakefile $$dep/makefile $$dep/Makefile; then \ $(MAKE) -C $$dep fetch-deps \ IS_DEP=1 \ diff --git a/core/deps.mk b/core/deps.mk index 719691a..2777af5 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -164,11 +164,15 @@ define dep_autopatch_noop printf "noop:\n" > $(DEPS_DIR)/$(1)/Makefile endef -# Overwrite erlang.mk with the current file by default. +# Replace "include erlang.mk" with a line that will load the parent Erlang.mk +# if given. Do it for all 3 possible Makefile file names. ifeq ($(NO_AUTOPATCH_ERLANG_MK),) define dep_autopatch_erlang_mk - echo "include $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(DEPS_DIR)/app)/erlang.mk" \ - > $(DEPS_DIR)/$1/erlang.mk + $t for f in Makefile makefile GNUmakefile; do \ + if [ -f $(DEPS_DIR)/$1/$$f ]; then \ + sed -i.bak s/'include *erlang.mk'/'include $$(if $$(ERLANG_MK_FILENAME),$$(ERLANG_MK_FILENAME),erlang.mk)'/ $(DEPS_DIR)/$1/$$f; \ + fi \ + done endef else define dep_autopatch_erlang_mk @@ -411,7 +415,7 @@ define dep_autopatch_rebar.erl end, [PortSpec(S) || S <- PortSpecs] end, - Write("\ninclude $(call core_relpath,$(dir $(ERLANG_MK_FILENAME)),$(DEPS_DIR)/app)/erlang.mk"), + Write("\ninclude $$\(if $$\(ERLANG_MK_FILENAME),$$\(ERLANG_MK_FILENAME),erlang.mk)"), RunPlugin = fun(Plugin, Step) -> case erlang:function_exported(Plugin, Step, 2) of false -> ok; -- cgit v1.2.3