Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # See LICENSE for licensing information.
  2. PROJECT = cowboy
  3. # Options.
  4. ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \
  5. +warn_shadow_vars +warn_obsolete_guard +warn_missing_spec
  6. COMPILE_FIRST = cowboy_middleware cowboy_sub_protocol
  7. CT_OPTS += -pa test -ct_hooks cowboy_ct_hook []
  8. PLT_APPS = crypto public_key ssl
  9. # Dependencies.
  10. DEPS = cowlib ranch
  11. TEST_DEPS = ct_helper gun
  12. dep_ct_helper = git https://github.com/extend/ct_helper.git master
  13. # Standard targets.
  14. include erlang.mk
  15. # Documentation.
  16. dep_ezdoc = git https://github.com/ninenines/ezdoc master
  17. $(eval $(call dep_target,ezdoc))
  18. build-doc-deps: $(DEPS_DIR)/ezdoc
  19. $(MAKE) -C $(DEPS_DIR)/ezdoc
  20. define ezdoc_script
  21. io:format("Building manual~n"),
  22. [begin
  23. AST = ezdoc:parse_file(F),
  24. BF = filename:rootname(filename:basename(F)),
  25. io:format(" ~s~n", [BF]),
  26. file:write_file("doc/markdown/manual/" ++ BF ++ ".md", ezdoc_markdown:export(AST)),
  27. case BF of
  28. "cowboy" ++ _ when BF =/= "cowboy_app" ->
  29. file:write_file("doc/man3/" ++ BF ++ ".3", ezdoc_man:export(3, AST));
  30. _ when BF =/= "index" ->
  31. file:write_file("doc/man7/" ++ BF ++ ".7", ezdoc_man:export(7, AST));
  32. _ ->
  33. ok
  34. end
  35. end || F <- filelib:wildcard("doc/src/manual/*.ezdoc")],
  36. io:format("Building guide~n"),
  37. [begin
  38. AST = ezdoc:parse_file(F),
  39. BF = filename:rootname(filename:basename(F)),
  40. io:format(" ~s~n", [BF]),
  41. file:write_file("doc/markdown/guide/" ++ BF ++ ".md", ezdoc_markdown:export(AST))
  42. end || F <- filelib:wildcard("doc/src/guide/*.ezdoc")],
  43. io:format("Done.~n"),
  44. init:stop().
  45. endef
  46. export ezdoc_script
  47. docs:: clean-docs build-doc-deps
  48. @mkdir -p doc/man3 doc/man7 doc/markdown/guide doc/markdown/manual
  49. $(gen_verbose) erl -noinput -pa ebin deps/ezdoc/ebin -eval "$$ezdoc_script"
  50. @gzip doc/man3/*.3 doc/man7/*.7
  51. @cp doc/src/guide/*.png doc/markdown/guide
  52. clean-docs:
  53. $(gen_verbose) rm -rf doc/man3 doc/man7 doc/markdown
  54. MAN_INSTALL_PATH ?= /usr/local/share/man
  55. install-docs:
  56. mkdir -p $(MAN_INSTALL_PATH)/man3/ $(MAN_INSTALL_PATH)/man7/
  57. install -g 0 -o 0 -m 0644 doc/man3/*.gz $(MAN_INSTALL_PATH)/man3/
  58. install -g 0 -o 0 -m 0644 doc/man7/*.gz $(MAN_INSTALL_PATH)/man7/