aboutsummaryrefslogtreecommitdiffstats
path: root/core/deps.mk
diff options
context:
space:
mode:
Diffstat (limited to 'core/deps.mk')
-rw-r--r--core/deps.mk40
1 files changed, 25 insertions, 15 deletions
diff --git a/core/deps.mk b/core/deps.mk
index 74bc30b..1115a97 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -30,14 +30,20 @@ export PKG_FILE2
PKG_FILE_URL ?= https://raw.githubusercontent.com/ninenines/erlang.mk/master/packages.v2.tsv
+# Verbosity.
+
+dep_verbose_0 = @echo " DEP " $(1);
+dep_verbose = $(dep_verbose_$(V))
+
# Core targets.
deps:: $(ALL_DEPS_DIRS)
@for dep in $(ALL_DEPS_DIRS) ; do \
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
- $(MAKE) -C $$dep ; \
+ $(MAKE) -C $$dep || exit $$? ; \
else \
- echo "include $(CURDIR)/erlang.mk" | ERLC_OPTS=+debug_info $(MAKE) -f - -C $$dep ; \
+ echo "ERROR: No makefile to build dependency $$dep. Consider adding it to AUTOPATCH." ; \
+ exit 1 ; \
fi ; \
done
@@ -49,7 +55,8 @@ define dep_autopatch
$(ERL) -eval " \
DepDir = \"$(DEPS_DIR)/$(1)/\", \
fun() -> \
- {ok, Conf} = file:consult(DepDir ++ \"rebar.config\"), \
+ {ok, Conf} = case file:consult(DepDir ++ \"rebar.config\") of \
+ {error, enoent} -> {ok, []}; Res -> Res end, \
File = case lists:keyfind(deps, 1, Conf) of false -> []; {_, Deps} -> \
[begin {Method, Repo, Commit} = case Repos of \
{git, R} -> {git, R, master}; \
@@ -60,7 +67,12 @@ fun() -> \
io_lib:format(\"DEPS += ~s\ndep_~s = ~s ~s ~s~n\", [Name, Name, Method, Repo, Commit]) \
end || {Name, _, Repos} <- Deps] \
end, \
- ok = file:write_file(\"$(DEPS_DIR)/$(1)/Makefile\", [\"ERLC_OPTS = +debug_info\n\n\", File, \"\ninclude erlang.mk\"]) \
+ First = case lists:keyfind(erl_first_files, 1, Conf) of false -> []; {_, Files} -> \
+ Names = [[\" \", begin \"lre.\" ++ R = lists:reverse(F), lists:reverse(R) end] \
+ || \"src/\" ++ F <- Files], \
+ io_lib:format(\"COMPILE_FIRST +=~s\n\", [Names]) \
+ end, \
+ ok = file:write_file(\"$(DEPS_DIR)/$(1)/Makefile\", [\"ERLC_OPTS = +debug_info\n\n\", File, First, \"\ninclude erlang.mk\"]) \
end(), \
AppSrcOut = \"$(DEPS_DIR)/$(1)/src/$(1).app.src\", \
AppSrcIn = case filelib:is_regular(AppSrcOut) of false -> \"$(DEPS_DIR)/$(1)/ebin/$(1).app\"; true -> AppSrcOut end, \
@@ -82,13 +94,15 @@ endif
define dep_fetch
if [ "$$$$VS" = "git" ]; then \
- git clone -n -- $$$$REPO $(DEPS_DIR)/$(1); \
+ git clone -q -n -- $$$$REPO $(DEPS_DIR)/$(1); \
cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
elif [ "$$$$VS" = "hg" ]; then \
- hg clone -U $$$$REPO $(DEPS_DIR)/$(1); \
+ hg clone -q -U $$$$REPO $(DEPS_DIR)/$(1); \
cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
elif [ "$$$$VS" = "svn" ]; then \
- svn checkout $$$$REPO $(DEPS_DIR)/$(1); \
+ svn checkout -q $$$$REPO $(DEPS_DIR)/$(1); \
+ elif [ "$$$$VS" = "cp" ]; then \
+ cp -R $$$$REPO $(DEPS_DIR)/$(1); \
else \
echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
exit 78; \
@@ -100,25 +114,21 @@ $(DEPS_DIR)/$(1):
@mkdir -p $(DEPS_DIR)
ifeq (,$(dep_$(1)))
@if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
- @DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
+ $(dep_verbose) DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
$(call dep_fetch,$(1))
else
- @VS=$(word 1,$(dep_$(1))); \
+ $(dep_verbose) VS=$(word 1,$(dep_$(1))); \
REPO=$(word 2,$(dep_$(1))); \
COMMIT=$(word 3,$(dep_$(1))); \
$(call dep_fetch,$(1))
endif
ifneq ($(filter $(1),$(AUTOPATCH)),)
- $(call dep_autopatch_verbose,$(1)) if [ -f $(DEPS_DIR)/$(1)/rebar.config ]; then \
+ $(call dep_autopatch_verbose,$(1)) \
$(call dep_autopatch,$(1)); \
- cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk; \
- elif [ ! -f $(DEPS_DIR)/$(1)/Makefile ]; then \
- echo "ERLC_OPTS = +debug_info\ninclude erlang.mk" > $(DEPS_DIR)/$(1)/Makefile; \
- cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk; \
- fi
+ cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk
endif
endef