Makefile.doc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #
  2. # $Id$
  3. #
  4. #
  5. # The name of the index file (the one which will be built by default
  6. # without specifying a target
  7. #
  8. DOCUMENTS ?= index
  9. #
  10. # The root of the document tree, this is used to determine the directory
  11. # of auxiliary files. The variable should be overwritten by per-directory
  12. # Makefiles
  13. #
  14. ROOT_DIR ?= ../../..
  15. #
  16. # Output directory where files produced by XSL stylesheets should be stored,
  17. # by default we output to the same directory, documents that are chunked may
  18. # choose to override this to write all chunks in a subdirectory instead
  19. #
  20. OUTPUT_DIR ?= .
  21. #
  22. # Stylesheet used to generate dependencies from XML files
  23. #
  24. DEP_XSL ?= $(ROOT_DIR)/doc/stylesheets/dep.xsl
  25. #
  26. # Default stylesheet used to generate XHTML
  27. #
  28. XHTML_XSL ?= $(ROOT_DIR)/doc/stylesheets/xhtml.xsl
  29. #
  30. # Default stylesheet used to generate Drupal HTML without html headers
  31. #
  32. DRUPAL_XSL ?= $(ROOT_DIR)/doc/stylesheets/drupal.xsl
  33. #
  34. # Default stylesheet used to generate HTML
  35. #
  36. HTML_XSL ?= $(ROOT_DIR)/doc/stylesheets/html.chunked.xsl
  37. #
  38. # Stylesheet used to generate plain text documents,
  39. # this is usually the one used for xhtml
  40. #
  41. TXT_XSL ?= $(ROOT_DIR)/doc/stylesheets/txt.xsl
  42. #
  43. # Stylesheet used to generate FO (Formatted Objects)
  44. # This is used by PDF generators
  45. #
  46. FO_XSL ?= $(ROOT_DIR)/doc/stylesheets/fo.xsl
  47. #
  48. # Disable document validation by default
  49. #
  50. VALIDATE ?= 0
  51. CATALOG=$(ROOT_DIR)/doc/catalog.xml
  52. LYNX ?= lynx
  53. DIA ?= dia
  54. XSLTPROC ?= xsltproc
  55. XMLLINT ?= /usr/bin/xmllint
  56. XEP ?= /usr/bin/xep
  57. LYNX_FLAGS ?= -nolist
  58. DIA_ARGS ?=
  59. XSLTPROC_FLAGS ?=
  60. XMLLINT_FLAGS ?= --xinclude --postvalid --noout
  61. XEP_FLAGS ?=
  62. ifeq ($(VALIDATE), 0)
  63. override XSLTPROC_FLAGS := $(XSLTPROC_FLAGS) --novalid
  64. endif
  65. alldep = Makefile $(ROOT_DIR)/Makefile.doc $(DEP_XSL) $(EXTRA_DEPS)
  66. all: xhtml
  67. xml_files = $(addsuffix .xml, $(DOCUMENTS))
  68. dep_files = $(addsuffix .d, $(DOCUMENTS))
  69. xhtml_files = $(addsuffix .xhtml, $(DOCUMENTS))
  70. html_files = $(addsuffix .html, $(DOCUMENTS))
  71. txt_files = $(addsuffix .txt, $(DOCUMENTS))
  72. pdf_files = $(addsuffix .pdf, $(DOCUMENTS))
  73. xhtml: $(xhtml_files)
  74. html: $(html_files)
  75. txt: $(txt_files)
  76. pdf: $(pdf_files)
  77. drupal: override HTML_XSL := $(DRUPAL_XSL)
  78. drupal: $(html_files)
  79. %.xhtml: %.xml %.d $(alldep) $(XHTML_XSL)
  80. XML_CATALOG_FILES=$(CATALOG) $(XSLTPROC) $(XSLTPROC_FLAGS) \
  81. --xinclude \
  82. --stringparam base.dir "$(OUTPUT_DIR)/" \
  83. --stringparam root.filename "$(basename $<)" \
  84. --stringparam html.ext ".xhtml" \
  85. $(XHTML_XSL) $<
  86. %.html: %.xml %.d $(alldep) $(HTML_XSL)
  87. XML_CATALOG_FILES=$(CATALOG) $(XSLTPROC) $(XSLTPROC_FLAGS) \
  88. --xinclude \
  89. --stringparam base.dir "$(OUTPUT_DIR)/" \
  90. --stringparam root.filename "$(basename $<)" \
  91. --stringparam html.ext ".html" \
  92. --stringparam html.stylesheet ser.css \
  93. $(HTML_XSL) $<
  94. %.fo: %.xml $(alldep) $(FO_XSL)
  95. XML_CATALOG_FILES=$(CATALOG) $(XSLTPROC) $(XSLTPROC_FLAGS) \
  96. --xinclude \
  97. -o $@ $(FO_XSL) $<
  98. %.pdf: %.fo %.d $(alldep)
  99. $(XEP) $(XEP_FLAGS) -fo $< -pdf $@
  100. %.txt: %.xml %.d $(alldep)
  101. XML_CATALOG_FILES=$(CATALOG) $(XSLTPROC) $(XSLTPROC_FLAGS) \
  102. --xinclude \
  103. $(TXT_XSL) $< | $(LYNX) $(LYNX_FLAGS) -stdin -dump > $@
  104. %.png: %.dia $(alldep)
  105. $(DIA) $(DIA_ARGS) -t png -e $@ $<
  106. %.d: %.xml $(alldep)
  107. $(XSLTPROC) $(XSLTPROC_FLAGS) \
  108. --nonet \
  109. --novalid \
  110. --stringparam output "$@" \
  111. $(DEP_XSL) $<
  112. .PHONY: check
  113. check: $(xml_files)
  114. XML_CATALOG_FILES=$(CATALOG) $(XMLLINT) $(XMLLINT_FLAGS) $<
  115. .PHONY: clean
  116. clean:
  117. @rm -f $(txt_files)
  118. @rm -f $(xhtml_files)
  119. @rm -f $(pdf_files)
  120. @rm -f $(html_files)
  121. .PHONY: proper realclean distclean
  122. proper realclean distclean: clean
  123. @rm -f $(dep_files) *~
  124. ifeq (,$(MAKECMDGOALS))
  125. include $(dep_files)
  126. endif
  127. ifneq (,$(filter-out clean proper realclean distclean check, $(MAKECMDGOALS)))
  128. include $(dep_files)
  129. endif