PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/config/rules/doc.mak

https://gitlab.com/generic-library/speech-tools
Makefile | 305 lines | 196 code | 48 blank | 61 comment | 10 complexity | 0e56d28489f2aca47e98ab2574b27848 MD5 | raw file
  1. ###########################################################################
  2. ## ##
  3. ## Centre for Speech Technology Research ##
  4. ## University of Edinburgh, UK ##
  5. ## Copyright (c) 1996 ##
  6. ## All Rights Reserved. ##
  7. ## ##
  8. ## Permission is hereby granted, free of charge, to use and distribute ##
  9. ## this software and its documentation without restriction, including ##
  10. ## without limitation the rights to use, copy, modify, merge, publish, ##
  11. ## distribute, sublicense, and/or sell copies of this work, and to ##
  12. ## permit persons to whom this work is furnished to do so, subject to ##
  13. ## the following conditions: ##
  14. ## 1. The code must retain the above copyright notice, this list of ##
  15. ## conditions and the following disclaimer. ##
  16. ## 2. Any modifications must be clearly marked as such. ##
  17. ## 3. Original authors' names are not deleted. ##
  18. ## 4. The authors' names are not used to endorse or promote products ##
  19. ## derived from this software without specific prior written ##
  20. ## permission. ##
  21. ## ##
  22. ## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
  23. ## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
  24. ## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
  25. ## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
  26. ## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
  27. ## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
  28. ## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
  29. ## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
  30. ## THIS SOFTWARE. ##
  31. ## ##
  32. ###########################################################################
  33. ## ##
  34. ## Author: Richard Caley (rjc@cstr.ed.ac.uk) ##
  35. ## -------------------------------------------------------------------- ##
  36. ## Rules for creating documentation. ##
  37. ## ##
  38. ###########################################################################
  39. MANUALS_GEN=manuals_gen
  40. EXAMPLES_GEN=examples_gen
  41. IMAGES_GEN=images_gen
  42. DOCXX_GEN=doc++
  43. HTML_DIR=$(DOCNAME)
  44. ###########################################################################
  45. ## User Visable doc++ rule
  46. # This strange idiom is for expensive operations. something dependednt
  47. # on .doc++_made will make doc++ initially, but then not remake it. It
  48. # will notice if doc++ is remade. Something dependent on doc++ will
  49. # remake it every time. The manual pages and examples are also done
  50. # this way.
  51. .doc++file_list_made :
  52. @if [ ! -f .doc++file_list_made ] ; then $(MAKE) -C $(TOP)/doc --no-print-directory doc++file_list ; fi
  53. doc++file_list : FORCE
  54. @echo "Building doc++ files"
  55. @echo "empty $(TOP)/Doc++Files"
  56. @$(RM) -f $(TOP)/Doc++Files
  57. @$(ECHO_N) > $(TOP)/Doc++Files
  58. ifdef DOCXX_DIRS
  59. @for d in $(DOCXX_DIRS) ; do \
  60. $(MAKE) -C $$d --no-print-directory doc++files ;\
  61. done
  62. endif
  63. @date > .doc++file_list_made
  64. .doc++_made:
  65. @if [ ! -f .doc++_made ] ; then $(MAKE) -C $(TOP)/doc --no-print-directory doc++ ; fi
  66. doc++: FORCE
  67. @$(MAKE) -C $(TOP)/doc --no-print-directory doc++file_list doc++process sane_to_docbook
  68. @date > .doc++_made
  69. doc++process : FORCE
  70. @echo Clear out doc++ directory
  71. @$(subst DIR,$(DOCXX_GEN),$(ENSURE_EMPTY_DIR))
  72. @$(RM) -f .tex_done
  73. ifdef DOCXX_DIRS
  74. @echo DOC++
  75. @$(DOCXX) $(DOCXX_ARGS) -d $(DOCXX_GEN) $(shell sed -e 's/^/$(TOP)\//' $(TOP)/Doc++Files) $(DOCXX_EXTRA_FILES)
  76. @cp -p $(DOCXXIMAGES) $(DOCXX_GEN)
  77. endif
  78. sane_to_docbook: FORCE
  79. @$(ECHO_N) 'Convert to Docbook: '
  80. @$(RM) -f $(DOCXX_GEN)/declare_entities.sgml $(DOCXX_GEN)/include_entities.sgml
  81. ifdef DOCXX_DIRS
  82. @$(MAKE) -C $(TOP)/doc --no-print-directory $(subst sane,db,$(wildcard $(DOCXX_GEN)/*.sane))
  83. endif
  84. @echo " :done"
  85. $(DOCXX_GEN)/%.db: FORCE
  86. @{ \
  87. name=`basename $@ .db` ;\
  88. idname=`echo "docpp-$$name"|sed -e 's/[^a-zA-Z0-9][^a-zA-Z0-9]*/-/g'` ;\
  89. sane="$(DOCXX_GEN)/$$name.sane" ;\
  90. db="$(DOCXX_GEN)/$$name.db" ;\
  91. $(ECHO_N) "$$name " ;\
  92. jade -E 2000 -d $(DSSL_SANE_DB) -t sgml $$sane > $$db 2>>$(DOCXX_GEN)/jade_trace ;\
  93. echo "<!entity $$idname SYSTEM '$$db'>" >&3 ;\
  94. echo "&$$idname;" >&4 ;\
  95. for inc in 2 3 4 ;\
  96. do \
  97. perl -pe '$$inc='$$inc';s%<(/)?sect([0-9]+)%"<".$$1."sect".($$2+$$inc-1)%ge;' $$db > $$db-$$inc ;\
  98. echo "<!entity $$idname-$$inc SYSTEM '$$db-$$inc'>" >&3 ;\
  99. echo "&$$idname-$$inc;" >&4 ;\
  100. done ;\
  101. } 3>>$(DOCXX_GEN)/declare_entities.sgml 4>>$(DOCXX_GEN)/include_entities.sgml
  102. ###########################################################################
  103. ## Create example sections from testsuite code
  104. .examples_made :
  105. @if [ ! -f .examples_made ] ; then $(MAKE) -C $(TOP)/doc --no-print-directory examples ; fi
  106. examples : FORCE
  107. @$(ECHO_N) 'Building examples:'
  108. @$(subst DIR,$(EXAMPLES_GEN),$(ENSURE_EMPTY_DIR))
  109. @$(ECHO_N) '' > $(EXAMPLES_GEN)/declare_entities.sgml
  110. @$(ECHO_N) '' > $(EXAMPLES_GEN)/include_entities.sgml
  111. @for e in $(EXAMPLE_TO_DOCUMENT) XXXX ;\
  112. do \
  113. if [ $$e = XXXX ] ; then break ; fi ;\
  114. $(ECHO_N) " $$e" ;\
  115. sect=$(EXAMPLES_GEN)/$${e}_example_section.sgml ;\
  116. ent=`echo "$${e}examplesection"| tr -dc '[a-z]'` ;\
  117. $(EST_HOME)/bin/cxx_to_docbook -s 1 $(TOP)/testsuite/$${e}_example.cc >$$sect 2>$(EXAMPLES_GEN)/$${e}_trace;\
  118. echo "<!entity $${ent} SYSTEM '$$sect' >" >> $(EXAMPLES_GEN)/declare_entities.sgml ;\
  119. echo "&$${ent};" >> $(EXAMPLES_GEN)/include_entities.sgml ;\
  120. done
  121. @echo " :done"
  122. @date > .examples_made
  123. ###########################################################################
  124. ## Create example sections from mainlines
  125. .manuals_made :
  126. @if [ ! -f .manuals_made ] ; then $(MAKE) -C $(TOP)/doc --no-print-directory manuals ; fi
  127. manuals : FORCE
  128. @$(ECHO_N) 'Building manuals:'
  129. @$(subst DIR,$(MANUALS_GEN),$(ENSURE_EMPTY_DIR))
  130. @$(ECHO_N) '' > $(MANUALS_GEN)/declare_entities.sgml
  131. @$(ECHO_N) '' > $(MANUALS_GEN)/include_entities.sgml
  132. @for m in $(MAIN_TO_DOCUMENT) XXXX ;\
  133. do \
  134. if [ "$$m" = XXXX ] ; then break ; fi ;\
  135. $(ECHO_N) " $$m" ;\
  136. sect="$(MANUALS_GEN)/$${m}_manual_section.sgml" ;\
  137. ent=`echo "$${m}manualsection"| tr -dc '[a-z]'` ;\
  138. $(EST_HOME)/bin/cxx_to_docbook -s 1 \
  139. -special @options '<para>' "$(EST_HOME)/bin/$$m -sgml_options" '</para>' \
  140. -special @synopsis '<para>' "$(EST_HOME)/bin/$$m -sgml_synopsis" '</para>' \
  141. $(TOP)/main/$${m}_main.cc > $$sect 2>$(MANUALS_GEN)/$${m}_trace ;\
  142. echo "<!entity $${ent} SYSTEM '$$sect' >" >> $(MANUALS_GEN)/declare_entities.sgml ;\
  143. echo "&$${ent};" >> $(MANUALS_GEN)/include_entities.sgml ;\
  144. done
  145. @echo " :done"
  146. @date > .manuals_made
  147. ###########################################################################
  148. ## Index building
  149. index.sgml: index_html.jade
  150. @echo 'Creating Index'
  151. $(EST_HOME)/bin/build_docbook_index -m html -t 'INDEX' index_html.jade index.sgml
  152. ensure_index_input:
  153. @if [ ! -f index_html.jade ] ; then echo "CREATING EMPTY INDEX" ; touch index_html.jade ; fi
  154. ###########################################################################
  155. ## Process things through LaTeX into gifs
  156. tex_conversion : .tex_done
  157. @:
  158. .tex_done: tex_stuff.jade
  159. @echo 'Converting LaTeX'
  160. @$(subst DIR,$(HTML_DIR)/$(IMAGES_GEN),$(ENSURE_EMPTY_DIR))
  161. @$(EST_HOME)/bin/tex_to_images -s $(TEX_SCALE) -d $(HTML_DIR) tex_stuff.jade
  162. @date >.tex_done
  163. ensure_tex_input:
  164. @if [ ! -f tex_stuff.jade ] ; then echo "CREATING EMPTY LaTeX input" ; touch tex_stuff.jade ; fi
  165. ###########################################################################
  166. ## Include and exclude file building
  167. INCLUDE_ONLY-full: $(DOCNAME).sgml
  168. @echo "Rebuild INCLUDE_ONLY-full"
  169. @$(RM) -f INCLUDE_ONLY-full INCLUDE_ONLY-min
  170. @{ \
  171. echo "<!--" ;\
  172. echo " .. Change INCLUDE to IGNORE to exclude a section" ;\
  173. echo " -->" ;\
  174. sed -n -e '/.*%\(include-[a-zA-Z0-9]*\);.*/{;s//<!entity % \1 "INCLUDE">/;p;}' $(DOCNAME).sgml ;\
  175. } > INCLUDE_ONLY-full
  176. @sed -e '/INCLUDE/s//IGNORE/' INCLUDE_ONLY-full > INCLUDE_ONLY-min
  177. @chmod -w INCLUDE_ONLY-full INCLUDE_ONLY-min
  178. sections.dtd: $(DOCNAME).sgml
  179. @echo "Rebuild sections.dtd"
  180. @$(RM) -f sections.dtd
  181. @{ \
  182. echo "<!--" ;\
  183. echo " .. Created automagically from $(DOCNAME).sgml" ;\
  184. echo " -->" ;\
  185. sed -n -e '/.*%include-.*&\([a-z0-9]*\)doc;.*/{;s//<!entity \1doc SYSTEM "\1.sgml">/;p;}' $(DOCNAME).sgml ;\
  186. echo '<!entity indexChapter SYSTEM "index.sgml">' ;\
  187. } > sections.dtd
  188. @chmod -w sections.dtd
  189. INCLUDE_ONLY: INCLUDE_ONLY-full
  190. @[ -f INCLUDE_ONLY ] || { cp INCLUDE_ONLY-full INCLUDE_ONLY ; echo INCLUDE_ONLY created from INCLUDE_ONLY-full ; }
  191. @chmod +w INCLUDE_ONLY
  192. copy_requirements: FORCE
  193. ifdef HTML_REQUIREMENTS
  194. @for r in $(HTML_REQUIREMENTS) ;\
  195. do \
  196. $(RM) -rf "$(HTML_DIR)/$$r";\
  197. cp -r "$$r" $(HTML_DIR) ;\
  198. done
  199. endif
  200. ###########################################################################
  201. ## Make sure things get done in the right order
  202. prepare_doc: doc++ manuals examples
  203. @:
  204. prepare_doc_quick: .doc++_made .manuals_made .examples_made
  205. @:
  206. .$(DOCNAME)_html : $(DOCNAME).sgml $(SGMLFILES) INCLUDE_ONLY $(DSSSL) .doc++_made .manuals_made .examples_made index.sgml tex_stuff.jade
  207. .$(DOCNAME)_ps : $(DOCNAME).sgml $(SGMLFILES) INCLUDE_ONLY $(DSSSL) .doc++_made .manuals_made .examples_made
  208. new_doc: INCLUDE_ONLY sections.dtd ensure_index_input ensure_tex_input prepare_doc new_doc_x copy_requirements
  209. new_doc_x:
  210. @i=x; until $(MAKE) -q .$(DOCNAME)_html ;\
  211. do \
  212. if [ "$$i" = xxxx ] ; then break ; fi ;\
  213. i="x$$i"; \
  214. $(MAKE) --no-print-directory .$(DOCNAME)_html ;\
  215. $(MAKE) --no-print-directory tex_conversion ;\
  216. done
  217. new_quick_doc: INCLUDE_ONLY sections.dtd ensure_index_input ensure_tex_input prepare_doc_quick .$(DOCNAME)_html copy_requirements
  218. quick_doc quick_new_doc: new_quick_doc
  219. @:
  220. ###########################################################################
  221. ## Actual Docbook=> output rules
  222. .%_html: %.sgml
  223. sgmltools -b html -s $(DSSSL_HTML) $*.sgml
  224. date > .$*_html
  225. if cmp $(HTML_DIR)/HTML.index index_html.jade ; then : ; else cp $(HTML_DIR)/HTML.index index_html.jade ; fi
  226. if cmp $(HTML_DIR)/TeX.formulae tex_stuff.jade ; then : ; else cp $(HTML_DIR)/TeX.formulae tex_stuff.jade ; fi
  227. .%_ps: %.sgml
  228. sgmltools -b ps $*.sgml
  229. @date > .$*_ps
  230. .%_txt: %.sgml
  231. sgmltools -b txt -s $(DSSSL_HTML) $*.sgml
  232. ###########################################################################
  233. ## Some help with what the targets are.
  234. new_doc_help: FORCE
  235. @echo '\
  236. ;\
  237. ;To do a complete rebuild of the documentation do: \
  238. ; gnumake new_doc ;\
  239. ;\
  240. ;To just remake the documentation without doing all the\
  241. ;analysis of header files and so on, do:\
  242. ; gnumake quick_new_doc\
  243. ;\
  244. ;You can force rebuilding of just some of the supporting \
  245. ;information using the following targets:\
  246. ;\
  247. ; doc++file_list \
  248. ; - Check for new files which doc++ needs to analyse. \
  249. ; doc++ - analysis of headers and conversion to sgml. \
  250. ; manuals - Extraction of manuals from executables. \
  251. ; examples - Extraction of example code. \
  252. ;\
  253. ;For instance, to rebuild the manual pages and then process: \
  254. ; gnumake manuals quick_new_doc \
  255. ;\
  256. ;\
  257. ' | tr ';' '\012'