Makefile 2.5 KB

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