Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ASCIIDOC := asciidoc
  2. A2X := a2x
  3. ASCIIDOC_FLAGS := -a toc -d manpage -a revnumber=$(VERSION)
  4. A2X_FLAGS := -d manpage -a revnumber=$(VERSION)
  5. ASCIIDOC_SOURCES := \
  6. doc/cenv.9.txt \
  7. doc/init.9.txt \
  8. doc/intro.9.txt \
  9. doc/style.9.txt \
  10. doc/xbuild.9.txt
  11. ASCIIDOC_MANDOCS := $(patsubst %.9.txt,%.9,$(ASCIIDOC_SOURCES))
  12. ASCIIDOC_HTMLDOCS := $(patsubst %.9.txt,%.9.html,$(ASCIIDOC_SOURCES))
  13. define DOC_HELP
  14. @printf '* mandocs - Build man pages\n'
  15. @printf '* htmldocs - Build HTML man pages\n'
  16. endef
  17. define DOC_INSTALL_HELP
  18. @printf ' install-mandocs - Install man pages\n'
  19. @printf ' install-htmldocs - Install HTML man pages\n'
  20. endef
  21. # Expose intermediate DocBook files for correct parallel builds.
  22. %.9.xml: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
  23. $(call xbuild_action_mkdir,$@)
  24. $(Q)$(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -o $@ $<
  25. %.9: %.9.xml doc/asciidoc.conf $(ALL_MAKEFILES)
  26. $(call xbuild_action,MAN,$@) \
  27. $(A2X) $(A2X_FLAGS) -f manpage $<
  28. %.9.html: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
  29. $(call xbuild_action,HTML,$@) \
  30. $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b html5 -o $@ $<
  31. .PHONY: mandocs
  32. mandocs: $(ASCIIDOC_MANDOCS)
  33. .PHONY: htmldocs
  34. htmldocs: $(ASCIIDOC_HTMLDOCS)
  35. .PHONY: docs
  36. docs: mandocs htmldocs
  37. define mandocs_install_targets
  38. $(foreach manpage,$(notdir $(ASCIIDOC_MANDOCS)),$(manpage)_man_install)
  39. endef
  40. %_man_install: doc/%
  41. install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/man/man9/$*
  42. .PHONY: install-mandocs
  43. install-mandocs: $(mandocs_install_targets)
  44. .PHONY: install-htmldocs
  45. install-htmldocs: $(htmldocs_install_targets)
  46. define htmldocs_install_targets
  47. $(foreach htmlpage,$(notdir $(ASCIIDOC_HTMLDOCS)),$(htmlpage)_html_install)
  48. endef
  49. %_html_install: doc/%
  50. install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/doc/x15/$*
  51. .PHONY: install-docs
  52. install-docs: install-mandocs install-htmldocs
  53. define clean_docs
  54. $(Q)rm -f $(ASCIIDOC_MANDOCS) \
  55. $(ASCIIDOC_HTMLDOCS)
  56. endef
  57. .PHONY: clean-docs
  58. clean-docs:
  59. $(call clean_docs)
  60. .PHONY: distclean-docs
  61. distclean-docs: clean-docs