aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-29 15:03:34 +0200
committerLoïc Hoguin <[email protected]>2015-09-29 15:03:34 +0200
commitfe5c42fb818acf9ad6ca6589ea182dfbfbaa5427 (patch)
tree5ca924e351e7cb325e179be273febe52ab7f1208 /core
parent41ea5e7fe740625899cd9553f5d9faf25cf5425a (diff)
downloaderlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.tar.gz
erlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.tar.bz2
erlang.mk-fe5c42fb818acf9ad6ca6589ea182dfbfbaa5427.zip
Add support for APPS_DIR
This changes adds Rebar-like "apps/" functionality. From this commit onward, Erlang.mk supports 4 types of repositories: - Repo with an Erlang app at root level + deps/ - Repo with an Erlang app at root level + apps/ deps/ - Repo with no app at root level + deps/ - Repo with no app at root level + apps/ deps/ Example usage: - make new-app in=webchat - make new t=gen_server n=my_chat in=webchat - make Replace new-app with new-lib to create an OTP library instead of an OTP application.
Diffstat (limited to 'core')
-rw-r--r--core/core.mk3
-rw-r--r--core/deps.mk45
-rw-r--r--core/erlc.mk4
3 files changed, 44 insertions, 8 deletions
diff --git a/core/core.mk b/core/core.mk
index 34aad7b..1d0012d 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -181,6 +181,9 @@ core_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,
# @todo On Windows: $(shell dir /B $(1)); make sure to handle when no file exists.
core_ls = $(filter-out $(1),$(shell echo $(1)))
+# @todo Use a solution that does not require using perl.
+core_relpath = $(shell perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' $1 $2)
+
# Automated update.
ERLANG_MK_REPO ?= https://github.com/ninenines/erlang.mk
diff --git a/core/deps.mk b/core/deps.mk
index 814e7db..6a14114 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -1,26 +1,34 @@
# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: distclean-deps distclean-pkg
+.PHONY: distclean-deps
# Configuration.
+ifdef OTP_DEPS
+$(warning The variable OTP_DEPS is deprecated in favor of LOCAL_DEPS.)
+endif
+
IGNORE_DEPS ?=
export IGNORE_DEPS
+APPS_DIR ?= $(CURDIR)/apps
+export APPS_DIR
+
DEPS_DIR ?= $(CURDIR)/deps
export DEPS_DIR
REBAR_DEPS_DIR = $(DEPS_DIR)
export REBAR_DEPS_DIR
+ALL_APPS_DIRS = $(if $(wildcard $(APPS_DIR)/),$(filter-out $(APPS_DIR),$(shell find $(APPS_DIR) -maxdepth 1 -type d)))
ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(filter-out $(IGNORE_DEPS),$(BUILD_DEPS) $(DEPS)))
-ifeq ($(filter $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
+ifeq ($(filter $(APPS_DIR) $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
ifeq ($(ERL_LIBS),)
- ERL_LIBS = $(DEPS_DIR)
+ ERL_LIBS = $(APPS_DIR):$(DEPS_DIR)
else
- ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)
+ ERL_LIBS := $(ERL_LIBS):$(APPS_DIR):$(DEPS_DIR)
endif
endif
export ERL_LIBS
@@ -36,6 +44,11 @@ ifneq ($(SKIP_DEPS),)
deps::
else
deps:: $(ALL_DEPS_DIRS)
+ifndef IS_APP
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep IS_APP=1 || exit $$?; \
+ done
+endif
ifneq ($(IS_DEP),1)
$(verbose) rm -f $(ERLANG_MK_TMP)/deps.log
endif
@@ -55,8 +68,6 @@ endif
done
endif
-distclean:: distclean-deps distclean-pkg
-
# Deps related targets.
# @todo rename GNUmakefile and makefile into Makefile first, if they exist
@@ -538,6 +549,10 @@ dep_commit = $(if $(dep_$(1)_commit),$(dep_$(1)_commit),$(if $(dep_$(1)),$(word
define dep_target
$(DEPS_DIR)/$(1):
+ $(verbose) if test -d $(APPS_DIR)/$1; then \
+ echo "Error: Dependency $1 conflicts with application found in $(APPS_DIR)/$1."; \
+ exit 17; \
+ fi
$(verbose) mkdir -p $(DEPS_DIR)
$(dep_verbose) $(call dep_fetch_$(strip $(call dep_fetch,$(1))),$(1))
$(verbose) if [ -f $(DEPS_DIR)/$(1)/configure.ac -o -f $(DEPS_DIR)/$(1)/configure.in ]; then \
@@ -572,6 +587,24 @@ endef
$(foreach dep,$(BUILD_DEPS) $(DEPS),$(eval $(call dep_target,$(dep))))
+ifndef IS_APP
+clean:: clean-apps
+
+clean-apps:
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep clean IS_APP=1 || exit $$?; \
+ done
+
+distclean:: distclean-apps
+
+distclean-apps:
+ $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
+ $(MAKE) -C $$dep distclean IS_APP=1 || exit $$?; \
+ done
+endif
+
+distclean:: distclean-deps
+
distclean-deps:
$(gen_verbose) rm -rf $(DEPS_DIR)
diff --git a/core/erlc.mk b/core/erlc.mk
index fbba7ae..7ca24bb 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -60,7 +60,7 @@ define app_file
$(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, []},
- {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]}
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS))]}
]}.
endef
else
@@ -71,7 +71,7 @@ define app_file
$(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, [$(call comma_list,$(PROJECT)_sup $(PROJECT_REGISTERED))]},
- {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]},
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS))]},
{mod, {$(PROJECT)_app, []}}
]}.
endef