aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core.mk24
-rw-r--r--core/deps.mk40
-rw-r--r--core/docs.mk15
-rw-r--r--core/test.mk2
4 files changed, 55 insertions, 26 deletions
diff --git a/core/core.mk b/core/core.mk
index fdef354..5cb0b54 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -12,7 +12,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.PHONY: all deps app rel docs tests clean distclean help erlang-mk
+.PHONY: all deps app rel docs install-docs tests check clean distclean help erlang-mk
ERLANG_MK_VERSION = 1
@@ -46,6 +46,8 @@ all:: deps
rel::
@echo -n
+check:: clean app tests
+
clean:: clean-crashdump
clean-crashdump:
@@ -63,15 +65,17 @@ help::
"Usage: [V=1] make [-jNUM] [target]" \
"" \
"Core targets:" \
- " all Run deps, app and rel targets in that order" \
- " deps Fetch dependencies (if needed) and compile them" \
- " app Compile the project" \
- " rel Build a release for this project, if applicable" \
- " docs Build the documentation for this project" \
- " tests Run the tests for this project" \
- " clean Delete temporary and output files from most targets" \
- " distclean Delete all temporary and output files" \
- " help Display this help and exit" \
+ " all Run deps, app and rel targets in that order" \
+ " deps Fetch dependencies (if needed) and compile them" \
+ " app Compile the project" \
+ " rel Build a release for this project, if applicable" \
+ " docs Build the documentation for this project" \
+ " install-docs Install the man pages for this project" \
+ " tests Run the tests for this project" \
+ " check Compile and run all tests and analysis for this project" \
+ " clean Delete temporary and output files from most targets" \
+ " distclean Delete all temporary and output files" \
+ " help Display this help and exit" \
"" \
"The target clean only removes files that are commonly removed." \
"Dependencies and releases are left untouched." \
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
diff --git a/core/docs.mk b/core/docs.mk
new file mode 100644
index 0000000..9637d32
--- /dev/null
+++ b/core/docs.mk
@@ -0,0 +1,15 @@
+# Copyright (c) 2015, Viktor Söderqvist <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: docs-deps
+
+# Configuration.
+
+ALL_DOC_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DOC_DEPS))
+
+# Targets.
+
+$(foreach dep,$(DOC_DEPS),$(eval $(call dep_target,$(dep))))
+
+doc-deps: $(ALL_DOC_DEPS_DIRS)
+ @for dep in $(ALL_DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
diff --git a/core/test.mk b/core/test.mk
index c1a25ba..385ec85 100644
--- a/core/test.mk
+++ b/core/test.mk
@@ -5,7 +5,7 @@
# Configuration.
-TEST_DIR ?= test
+TEST_DIR ?= $(CURDIR)/test
ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))