erlydtl.mk 774 B

12345678910111213141516171819202122232425
  1. # Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. # Verbosity.
  4. dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
  5. dtl_verbose = $(dtl_verbose_$(V))
  6. # Core targets.
  7. define compile_erlydtl
  8. $(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
  9. Compile = fun(F) -> \
  10. Module = list_to_atom( \
  11. string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
  12. erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \
  13. end, \
  14. _ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
  15. init:stop()'
  16. endef
  17. ifneq ($(wildcard src/),)
  18. ebin/$(PROJECT).app:: $(shell find templates -type f -name \*.dtl 2>/dev/null)
  19. $(if $(strip $?),$(call compile_erlydtl,$?))
  20. endif