Skip to content

Commit

Permalink
Update erlang.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
jj1bdx committed Nov 17, 2014
1 parent 06ccd62 commit 4c9ab31
Showing 1 changed file with 22 additions and 107 deletions.
129 changes: 22 additions & 107 deletions erlang.mk
Expand Up @@ -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
.PHONY: all deps app rel docs tests clean distclean help erlang-mk

ERLANG_MK_VERSION = 1

Expand Down Expand Up @@ -72,6 +72,18 @@ define core_http_get
endef
endif

# Automated update.

ERLANG_MK_BUILD_CONFIG ?= build.config
ERLANG_MK_BUILD_DIR ?= .erlang.mk.build

erlang-mk:
git clone https://github.com/ninenines/erlang.mk $(ERLANG_MK_BUILD_DIR)
if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR); fi
cd $(ERLANG_MK_BUILD_DIR) && make
cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
rm -rf $(ERLANG_MK_BUILD_DIR)

# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
# This file is part of erlang.mk and subject to the terms of the ISC License.

Expand Down Expand Up @@ -108,7 +120,7 @@ deps:: $(ALL_DEPS_DIRS)
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
$(MAKE) -C $$dep ; \
else \
echo "include $(CURDIR)/erlang.mk" | $(MAKE) -f - -C $$dep ; \
echo "include $(CURDIR)/erlang.mk" | ERLC_OPTS=+debug_info $(MAKE) -f - -C $$dep ; \
fi ; \
done

Expand Down Expand Up @@ -176,8 +188,10 @@ pkg-search:
$(error Usage: make pkg-search q=STRING)
endif

ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
distclean-pkg:
$(gen_verbose) rm -f $(PKG_FILE2)
endif

help::
@printf "%s\n" "" \
Expand Down Expand Up @@ -217,8 +231,10 @@ app:: erlc-include ebin/$(PROJECT).app
echo "Empty modules entry not found in $(PROJECT).app.src. Please consult the erlang.mk README for instructions." >&2; \
exit 1; \
fi
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
$(appsrc_verbose) cat src/$(PROJECT).app.src \
| sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
| sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
> ebin/$(PROJECT).app

define compile_erl
Expand Down Expand Up @@ -278,6 +294,7 @@ help::
bs_appsrc = "{application, $(PROJECT), [" \
" {description, \"\"}," \
" {vsn, \"0.1.0\"}," \
" {id, \"git\"}," \
" {modules, []}," \
" {registered, []}," \
" {applications, [" \
Expand All @@ -290,6 +307,7 @@ bs_appsrc = "{application, $(PROJECT), [" \
bs_appsrc_lib = "{application, $(PROJECT), [" \
" {description, \"\"}," \
" {vsn, \"0.1.0\"}," \
" {id, \"git\"}," \
" {modules, []}," \
" {registered, []}," \
" {applications, [" \
Expand Down Expand Up @@ -622,6 +640,7 @@ DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt
export DIALYZER_PLT

PLT_APPS ?=
DIALYZER_DIRS ?= --src -r src
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
-Wunmatched_returns # -Wunderspecs

Expand Down Expand Up @@ -650,33 +669,7 @@ dialyze:
else
dialyze: $(DIALYZER_PLT)
endif
@dialyzer --no_native --src -r src $(DIALYZER_OPTS)

# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
# This file is part of erlang.mk and subject to the terms of the ISC License.

# Verbosity.

dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
dtl_verbose = $(dtl_verbose_$(V))

# Core targets.

define compile_erlydtl
$(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
Compile = fun(F) -> \
Module = list_to_atom( \
string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \
end, \
_ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
init:stop()'
endef

ifneq ($(wildcard src/),)
ebin/$(PROJECT).app:: $(shell find templates -type f -name \*.dtl 2>/dev/null)
$(if $(strip $?),$(call compile_erlydtl,$?))
endif
@dialyzer --no_native $(DIALYZER_DIRS) $(DIALYZER_OPTS)

# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
# This file is part of erlang.mk and subject to the terms of the ISC License.
Expand All @@ -699,81 +692,3 @@ distclean:: distclean-edoc

distclean-edoc:
$(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info

# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
# This file is part of erlang.mk and subject to the terms of the ISC License.

.PHONY: relx-rel distclean-relx-rel distclean-relx

# Configuration.

RELX_CONFIG ?= $(CURDIR)/relx.config

RELX ?= $(CURDIR)/relx
export RELX

RELX_URL ?= https://github.com/erlware/relx/releases/download/v1.0.2/relx
RELX_OPTS ?=
RELX_OUTPUT_DIR ?= _rel

ifeq ($(firstword $(RELX_OPTS)),-o)
RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
else
RELX_OPTS += -o $(RELX_OUTPUT_DIR)
endif

# Core targets.

ifneq ($(wildcard $(RELX_CONFIG)),)
rel:: distclean-relx-rel relx-rel
endif

distclean:: distclean-relx-rel distclean-relx

# Plugin-specific targets.

define relx_fetch
$(call core_http_get,$(RELX),$(RELX_URL))
chmod +x $(RELX)
endef

$(RELX):
@$(call relx_fetch)

relx-rel: $(RELX)
@$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)

distclean-relx-rel:
$(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)

distclean-relx:
$(gen_verbose) rm -rf $(RELX)

# Copyright (c) 2014, M Robert Martin <rob@version2beta.com>
# This file is contributed to erlang.mk and subject to the terms of the ISC License.

.PHONY: shell

# Configuration.

SHELL_PATH ?= -pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin
SHELL_OPTS ?=

ALL_SHELL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(SHELL_DEPS))

# Core targets

help::
@printf "%s\n" "" \
"Shell targets:" \
" shell Run an erlang shell with SHELL_OPTS or reasonable default"

# Plugin-specific targets.

$(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep))))

build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
@for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done

shell: build-shell-deps
$(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS)

0 comments on commit 4c9ab31

Please sign in to comment.