1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
- # This file is part of erlang.mk and subject to the terms of the ISC License.
- # Configuration.
- DTL_FULL_PATH ?= 0
- DTL_PATH ?= templates/
- DTL_SUFFIX ?= _dtl
- # Verbosity.
- dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
- dtl_verbose = $(dtl_verbose_$(V))
- # Core targets.
- define erlydtl_compile.erl
- [begin
- Module0 = case $(DTL_FULL_PATH) of
- 0 ->
- filename:basename(F, ".dtl");
- 1 ->
- "$(DTL_PATH)" ++ F2 = filename:rootname(F, ".dtl"),
- re:replace(F2, "/", "_", [{return, list}, global])
- end,
- Module = list_to_atom(string:to_lower(Module0) ++ "$(DTL_SUFFIX)"),
- case erlydtl:compile(F, Module, [{out_dir, "ebin/"}, return_errors, {doc_root, "templates"}]) of
- ok -> ok;
- {ok, _} -> ok
- end
- end || F <- string:tokens("$(1)", " ")],
- halt().
- endef
- ifneq ($(wildcard src/),)
- DTL_FILES = $(sort $(call core_find,$(DTL_PATH),*.dtl))
- DTL_ERL_FILES = $(addprefix src/,$(patsubst %.dtl,%_dtl.erl,$(notdir $(DTL_FILES))))
- ERL_FILES += $(DTL_ERL_FILES)
- ebin/$(PROJECT).app:: $(DTL_FILES)
- $(if $(strip $?),\
- $(dtl_verbose) $(call erlang,$(call erlydtl_compile.erl,$?,-pa ebin/ $(DEPS_DIR)/erlydtl/ebin/)))
- endif
|