aboutsummaryrefslogtreecommitdiffstats
path: root/erlang.mk
diff options
context:
space:
mode:
Diffstat (limited to 'erlang.mk')
-rw-r--r--erlang.mk34
1 files changed, 27 insertions, 7 deletions
diff --git a/erlang.mk b/erlang.mk
index 8a27f67..8df7ee2 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -19,9 +19,12 @@ V ?= 0
appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src;
appsrc_verbose = $(appsrc_verbose_$(V))
-erlc_verbose_0 = @echo " ERLC " $(?F);
+erlc_verbose_0 = @echo " ERLC " $(filter-out %.dtl,$(?F));
erlc_verbose = $(erlc_verbose_$(V))
+dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
+dtl_verbose = $(dtl_verbose_$(V))
+
gen_verbose_0 = @echo " GEN " $@;
gen_verbose = $(gen_verbose_$(V))
@@ -48,18 +51,35 @@ all: deps app
clean-all: clean clean-deps clean-docs
$(gen_verbose) rm -rf .$(PROJECT).plt $(DEPS_DIR) logs
-MODULES = $(shell ls src/*.erl $(wildcard src/*.core) \
- | sed 's/src\///;s/\.core/,/;s/\.erl/,/' | sed '$$s/.$$//')
-
app: ebin/$(PROJECT).app
+ $(eval MODULES := $(shell ls ebin/*.beam \
+ | sed 's/ebin\///;s/\.beam/,/' | sed '$$s/.$$//'))
$(appsrc_verbose) cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> ebin/$(PROJECT).app
-ebin/$(PROJECT).app: src/*.erl $(wildcard src/*.core)
- @mkdir -p ebin/
+define compile_erl =
$(erlc_verbose) ERL_LIBS=deps erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ \
- $(COMPILE_FIRST_PATHS) $?
+ $(COMPILE_FIRST_PATHS) $(1)
+endef
+
+define compile_dtl =
+ $(dtl_verbose) erl -noshell -pa ebin/ deps/erlydtl/ebin/ -eval ' \
+ Compile = fun(F) -> \
+ Module = list_to_atom( \
+ string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
+ erlydtl_compiler:compile(F, Module, [{out_dir, "ebin/"}]) \
+ end, \
+ _ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
+ init:stop()'
+endef
+
+ebin/$(PROJECT).app: src/*.erl $(wildcard src/*.core) $(wildcard templates/*.dtl)
+ @mkdir -p ebin/
+ $(if $(strip $(filter-out %.dtl,$?)), \
+ $(call compile_erl,$(filter-out %.dtl,$?)))
+ $(if $(strip $(filter %.dtl,$?)), \
+ $(call compile_dtl,$(filter %.dtl,$?)))
clean:
$(gen_verbose) rm -rf ebin/ test/*.beam erl_crash.dump