Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # See LICENSE for licensing information.
  2. PROJECT = cowboy
  3. RANCH_VSN = 0.6.0
  4. ERLC_OPTS = -Werror +debug_info +warn_export_all # +bin_opt_info +warn_missing_spec
  5. DEPS_DIR ?= $(CURDIR)/deps
  6. export DEPS_DIR
  7. # Makefile tweaks.
  8. V ?= 0
  9. appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src;
  10. appsrc_verbose = $(appsrc_verbose_$(V))
  11. erlc_verbose_0 = @echo " ERLC " $(?F);
  12. erlc_verbose = $(erlc_verbose_$(V))
  13. gen_verbose_0 = @echo " GEN " $@;
  14. gen_verbose = $(gen_verbose_$(V))
  15. .PHONY: all clean-all app clean deps clean-deps docs clean-docs tests autobahn build-plt dialyze
  16. # Application.
  17. all: deps app
  18. clean-all: clean clean-deps clean-docs
  19. $(gen_verbose) rm -rf .$(PROJECT).plt $(DEPS_DIR) logs
  20. MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')
  21. app: ebin/$(PROJECT).app
  22. $(appsrc_verbose) cat src/$(PROJECT).app.src \
  23. | sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
  24. > ebin/$(PROJECT).app
  25. ebin/$(PROJECT).app: src/*.erl
  26. @mkdir -p ebin/
  27. $(erlc_verbose) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ \
  28. src/$(PROJECT)_middleware.erl $?
  29. clean:
  30. $(gen_verbose) rm -rf ebin/ test/*.beam erl_crash.dump
  31. # Dependencies.
  32. $(DEPS_DIR)/ranch:
  33. @mkdir -p $(DEPS_DIR)
  34. git clone -n -- https://github.com/extend/ranch.git $(DEPS_DIR)/ranch
  35. cd $(DEPS_DIR)/ranch ; git checkout -q $(RANCH_VSN)
  36. deps: $(DEPS_DIR)/ranch
  37. @$(MAKE) -C $(DEPS_DIR)/ranch
  38. clean-deps:
  39. -@$(MAKE) -C $(DEPS_DIR)/ranch clean
  40. # Documentation.
  41. docs: clean-docs
  42. $(gen_verbose) erl -noshell \
  43. -eval 'edoc:application($(PROJECT), ".", []), init:stop().'
  44. clean-docs:
  45. $(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info
  46. # Tests.
  47. CT_RUN = ct_run \
  48. -pa ebin $(DEPS_DIR)/*/ebin \
  49. -dir test \
  50. -logdir logs \
  51. -cover test/cover.spec
  52. tests: ERLC_OPTS += -DTEST=1
  53. tests: clean clean-deps deps app
  54. @mkdir -p logs/
  55. @$(CT_RUN) -suite eunit_SUITE http_SUITE ws_SUITE
  56. autobahn: clean clean-deps deps app
  57. @mkdir -p logs/
  58. @$(CT_RUN) -suite autobahn_SUITE
  59. # Dialyzer.
  60. build-plt: deps app
  61. @dialyzer --build_plt --output_plt .$(PROJECT).plt \
  62. --apps erts kernel stdlib crypto public_key ssl $(DEPS_DIR)/ranch
  63. dialyze:
  64. @dialyzer --src src --plt .$(PROJECT).plt --no_native \
  65. -Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs