home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / gnome-doc-utils / gnome-doc-utils.make next >
Encoding:
Text File  |  2006-08-07  |  23.7 KB  |  701 lines

  1. # gnome-doc-utils.make - make magic for building documentation
  2. # Copyright (C) 2004-2005 Shaun McCance <shaunm@gnome.org>
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software Foundation,
  16. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. #
  18. # As a special exception to the GNU General Public License, if you
  19. # distribute this file as part of a program that contains a
  20. # configuration script generated by Autoconf, you may include it under
  21. # the same distribution terms that you use for the rest of that program.
  22.  
  23. ################################################################################
  24. ## @@ Generating Header Files
  25.  
  26. ## @ DOC_H_FILE
  27. ## The name of the header file to generate
  28. DOC_H_FILE ?=
  29.  
  30. ## @ DOC_H_DOCS
  31. ## The input DocBook files for generating the header file
  32. DOC_H_DOCS ?=
  33.  
  34. $(DOC_H_FILE): $(DOC_H_DOCS);
  35.     @rm -f $@.tmp; touch $@.tmp;
  36.     echo 'const gchar* documentation_credits[] = {' >> $@.tmp
  37.     list='$(DOC_H_DOCS)'; for doc in $$list; do \
  38.       xmlpath="`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`:$(srcdir)/`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`"; \
  39.       if ! test -f "$$doc"; then doc="$(srcdir)/$$doc"; fi; \
  40.       xsltproc --path "$$xmlpath" $(_credits) $$doc; \
  41.     done | sort | uniq \
  42.       | awk 'BEGIN{s=""}{n=split($$0,w,"<");if(s!=""&&s!=substr(w[1],1,length(w[1])-1)){print s};if(n>1){print $$0;s=""}else{s=$$0}};END{if(s!=""){print s}}' \
  43.       | sed -e 's/\\/\\\\/' -e 's/"/\\"/' -e 's/\(.*\)/\t"\1",/' >> $@.tmp
  44.     echo '    NULL' >> $@.tmp
  45.     echo '};' >> $@.tmp
  46.     echo >> $@.tmp
  47.     list='$(DOC_H_DOCS)'; for doc in $$list; do \
  48.       xmlpath="`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`:$(srcdir)/`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`"; \
  49.       if ! test -f "$$doc"; then doc="$(srcdir)/$$doc"; fi; \
  50.       docid=`echo "$$doc" | sed -e 's/.*\/\([^/]*\)\.xml/\1/' \
  51.         | sed -e 's/[^a-zA-Z_]/_/g' | tr 'a-z' 'A-Z'`; \
  52.       echo $$xmlpath; \
  53.       ids=`xsltproc --xinclude --path "$$xmlpath" $(_ids) $$doc`; \
  54.       for id in $$ids; do \
  55.         echo '#define HELP_'`echo $$docid`'_'`echo $$id \
  56.           | sed -e 's/[^a-zA-Z_]/_/g' | tr 'a-z' 'A-Z'`' "'$$id'"' >> $@.tmp; \
  57.       done; \
  58.       echo >> $@.tmp; \
  59.     done;
  60.     cp $@.tmp $@ && rm -f $@.tmp
  61.  
  62. .PHONY: dist-doc-header
  63. dist-doc-header: $(DOC_H_FILE)
  64.     @if test -f "$(DOC_H_FILE)"; then d=; else d="$(srcdir)/"; fi; \
  65.     echo "$(INSTALL_DATA) $${d}$(DOC_H_FILE) $(distdir)/$(DOC_H_FILE)"; \
  66.     $(INSTALL_DATA) "$${d}$(DOC_H_FILE)" "$(distdir)/$(DOC_H_FILE)";
  67.  
  68. doc-dist-hook: $(if $(DOC_H_FILE),dist-doc-header)
  69.  
  70. .PHONY: clean-doc-header
  71. _clean_doc_header = $(if $(DOC_H_FILE),clean-doc-header)
  72. clean-local: $(_clean_doc_header)
  73. distclean-local: $(_clean_doc_header)
  74. mostlyclean-local: $(_clean_doc_header)
  75. maintainer-clean-local: $(_clean_doc_header)
  76. clean-doc-header:
  77.     rm -f $(DOC_H_FILE)
  78.  
  79. all: $(DOC_H_FILE)
  80.  
  81.  
  82. ################################################################################
  83. ## @@ Generating Documentation Files
  84.  
  85. ## @ DOC_MODULE
  86. ## The name of the document being built
  87. DOC_MODULE ?=
  88.  
  89. ## @ DOC_ENTITIES
  90. ## Files included with a SYSTEM entity
  91. DOC_ENTITIES ?=
  92.  
  93. ## @ DOC_INCLUDES
  94. ## Files included with XInclude
  95. DOC_INCLUDES ?=
  96.  
  97. ## @ DOC_FIGURES
  98. ## Figures and other external data
  99. DOC_FIGURES ?=
  100.  
  101. ## @ DOC_FORMATS
  102. ## The default formats to be built and installed
  103. DOC_FORMATS ?= docbook
  104. _DOC_REAL_FORMATS = $(if $(DOC_USER_FORMATS),$(DOC_USER_FORMATS),$(DOC_FORMATS))
  105.  
  106. ## @ DOC_LINGUAS
  107. ## The languages this document is translated into
  108. DOC_LINGUAS ?=
  109. _DOC_REAL_LINGUAS = $(if $(filter environment,$(origin LINGUAS)),        \
  110.     $(filter $(LINGUAS),$(DOC_LINGUAS)),                    \
  111.     $(DOC_LINGUAS))
  112.  
  113. ## @ RNGDOC_DIRS
  114. ## The directories containing RNG files to be documented with rngdoc
  115. RNGDOC_DIRS ?=
  116.  
  117. ## @ XSLDOC_DIRS
  118. ## The directories containing XSLT files to be documented with xsldoc
  119. XSLDOC_DIRS ?=
  120.  
  121.  
  122. ################################################################################
  123. ## Variables for Bootstrapping
  124.  
  125. _xml2po ?= `which xml2po`
  126.  
  127. _db2html ?= `$(PKG_CONFIG) --variable db2html gnome-doc-utils`
  128. _db2omf  ?= `$(PKG_CONFIG) --variable db2omf gnome-doc-utils`
  129. _rngdoc  ?= `$(PKG_CONFIG) --variable rngdoc gnome-doc-utils`
  130. _xsldoc  ?= `$(PKG_CONFIG) --variable xsldoc gnome-doc-utils`
  131. _chunks  ?= `$(PKG_CONFIG) --variable xmldir gnome-doc-utils`/gnome/xslt/docbook/utils/chunks.xsl
  132. _credits ?= `$(PKG_CONFIG) --variable xmldir gnome-doc-utils`/gnome/xslt/docbook/utils/credits.xsl
  133. _ids ?= `$(PKG_CONFIG) --variable xmldir gnome-doc-utils`/gnome/xslt/docbook/utils/ids.xsl
  134.  
  135. _sklocalstatedir ?= `scrollkeeper-config --pkglocalstatedir`
  136.  
  137.  
  138. ################################################################################
  139. ## @@ Rules for rngdoc
  140.  
  141. rngdoc_args =                                    \
  142.     --stringparam rngdoc.id                            \
  143.     $(shell echo $(basename $(notdir $(1))) | sed -e 's/[^A-Za-z0-9_-]/_/g')\
  144.     $(_rngdoc) $(filter %/$(basename $(notdir $(1))).rng,$(_RNGDOC_RNGS))
  145.  
  146. ## @ _RNGDOC_RNGS
  147. ## The actual RNG files for which to generate documentation with rngdoc
  148. _RNGDOC_RNGS = $(sort $(patsubst ./%, %, $(foreach dir,$(RNGDOC_DIRS),        \
  149.     $(wildcard $(dir)/*.rng) $(wildcard $(srcdir)/$(dir)/*.rng))))
  150.  
  151. ## @ _RNGDOC_C_DOCS
  152. ## The generated rngdoc documentation in the C locale
  153. _RNGDOC_C_DOCS = $(foreach rng,$(_RNGDOC_RNGS), C/$(basename $(notdir $(rng))).xml)
  154.  
  155. # FIXME: Fix the dependancies
  156. $(_RNGDOC_C_DOCS) : $(_RNGDOC_RNGS)
  157.     if ! test -d $(dir $@); then mkdir $(dir $@); fi;
  158.     xsltproc $(call rngdoc_args,$@,$<) | xmllint --c14n - > $@.tmp && \
  159.       cp $@.tmp $@ && rm -f $@.tmp
  160.  
  161. .PHONY: rngdoc
  162. rngdoc: $(_RNGDOC_C_DOCS)
  163.  
  164.  
  165. ################################################################################
  166. ## @@ Rules for xsldoc
  167.  
  168. # FIXME: _XSLDOC_XSLS is getting dupes with relative/absolute in some
  169. # cases.  Right now, I'm just taking the first, but that's just a bad
  170. # work-around.  Fix the real problem.
  171. xsldoc_args =                                    \
  172.     --stringparam xsldoc.id                            \
  173.     $(shell echo $(basename $(notdir $(1))) | sed -e 's/[^A-Za-z0-9_-]/_/g')\
  174.     $(_xsldoc)                                \
  175.     $(word 1,$(filter %/$(basename $(notdir $(1))).xsl,$(_XSLDOC_XSLS)))
  176.  
  177. ## @ _XSLDOC_XSLS
  178. ## The actual XSLT files for which to generate documentation with xsldoc
  179. _XSLDOC_XSLS = $(sort $(patsubst ./%, %, $(foreach dir,$(XSLDOC_DIRS),        \
  180.     $(wildcard $(dir)/*.xsl) $(wildcard $(srcdir)/$(dir)/*.xsl))))
  181.  
  182. ## @ _XSLDOC_C_DOCS
  183. ## The generated xsldoc documentation in the C locale
  184. _XSLDOC_C_DOCS = $(foreach xsl,$(_XSLDOC_XSLS), C/$(basename $(notdir $(xsl))).xml)
  185.  
  186. # FIXME: Fix the dependancies
  187. $(_XSLDOC_C_DOCS) : $(_XSLDOC_XSLS)
  188.     if ! test -d $(dir $@); then mkdir $(dir $@); fi;
  189.     xsltproc $(call xsldoc_args,$@,$<) | xmllint --c14n - > $@.tmp && \
  190.       cp $@.tmp $@ && rm -f $@.tmp
  191.  
  192. .PHONY: xsldoc
  193. xsldoc: $(_XSLDOC_C_DOCS)
  194.  
  195.  
  196. ################################################################################
  197. ## @@ Rules for OMF Files
  198.  
  199. db2omf_args =                                    \
  200.     --stringparam db2omf.basename $(DOC_MODULE)                \
  201.     --stringparam db2omf.format $(3)                    \
  202.     --stringparam db2omf.dtd                        \
  203.     $(shell xmllint --format $(2) | grep -h PUBLIC | head -n 1         \
  204.         | sed -e 's/.*PUBLIC \(\"[^\"]*\"\).*/\1/')            \
  205.     --stringparam db2omf.lang $(notdir $(patsubst %/$(notdir $(2)),%,$(2)))    \
  206.     --stringparam db2omf.omf_dir "$(OMF_DIR)"                \
  207.     --stringparam db2omf.help_dir "$(HELP_DIR)"                \
  208.     --stringparam db2omf.omf_in "`pwd`/$(_DOC_OMF_IN)"            \
  209.     $(_db2omf) $(2)
  210.  
  211. ## @ _DOC_OMF_IN
  212. ## The OMF input file
  213. _DOC_OMF_IN = $(if $(DOC_MODULE),$(wildcard $(srcdir)/$(DOC_MODULE).omf.in))
  214.  
  215. ## @ _DOC_OMF_DB
  216. ## The OMF files for DocBook output
  217. _DOC_OMF_DB = $(if $(_DOC_OMF_IN),                        \
  218.     $(foreach lc,C $(_DOC_REAL_LINGUAS),$(DOC_MODULE)-$(lc).omf))
  219.  
  220. $(_DOC_OMF_DB) : $(_DOC_OMF_IN)
  221. $(_DOC_OMF_DB) : $(DOC_MODULE)-%.omf : %/$(DOC_MODULE).xml
  222.     xsltproc -o $@ $(call db2omf_args,$@,$<,'docbook')
  223.  
  224. ## @ _DOC_OMF_HTML
  225. ## The OMF files for HTML output
  226. _DOC_OMF_HTML = $(if $(_DOC_OMF_IN),                        \
  227.     $(foreach lc,C $(_DOC_REAL_LINGUAS),$(DOC_MODULE)-html-$(lc).omf))
  228.  
  229. $(_DOC_OMF_HTML) : $(_DOC_OMF_IN)
  230. $(_DOC_OMF_HTML) : $(DOC_MODULE)-html-%.omf : %/$(DOC_MODULE).xml
  231.     xsltproc -o $@ $(call db2omf_args,$@,$<,'xhtml')
  232.  
  233. ## @ _DOC_OMF_ALL
  234. ## All OMF output files to be built
  235. # FIXME
  236. _DOC_OMF_ALL =                                    \
  237.     $(if $(filter docbook,$(_DOC_REAL_FORMATS)),$(_DOC_OMF_DB))        \
  238.     $(if $(filter html HTML,$(_DOC_REAL_FORMATS)),$(_DOC_OMF_HTML))
  239.  
  240. .PHONY: omf
  241. omf: $(_DOC_OMF_ALL)
  242.  
  243.  
  244. ################################################################################
  245. ## @@ Rules for .cvsignore Files
  246.  
  247. ## @ _CVSIGNORE_TOP
  248. ## The .cvsignore file in the top directory
  249. _CVSIGNORE_TOP = $(if $(DOC_MODULE), .cvsignore)
  250.  
  251. ## @ _CVSIGNORE_C
  252. ## The .cvsignore file in the C directory
  253. _CVSIGNORE_C = $(if $(DOC_MODULE), C/.cvsignore)
  254.  
  255. ## @ _CVSIGNORE_LC
  256. ## The .cvsignore files in other locale directories
  257. _CVSIGNORE_LC = $(if $(DOC_MODULE),$(foreach lc,$(_DOC_REAL_LINGUAS),$(lc)/.cvsignore))
  258.  
  259. ## @ _CVSIGNORE_TOP_FILES
  260. ## The list of files to be listed in the top-level .cvsignore file
  261. _CVSIGNORE_TOP_FILES = $(_DOC_OMF_ALL) $(_DOC_DSK_ALL)
  262.  
  263. ## @ _CVSIGNORE_C_FILES
  264. ## The list of files to be listed in the .cvsignore file in the C directory
  265. _CVSIGNORE_C_FILES = $(_RNGDOC_C_DOCS) $(_XSLDOC_C_DOCS)
  266.  
  267. ## @ _CVSIGNORE_C_FILES
  268. ## The list of files to be listed in the .cvsignore files in other
  269. ## locale directories
  270. _CVSIGNORE_LC_FILES = $(_DOC_LC_DOCS)
  271.  
  272. $(_CVSIGNORE_TOP) : $(_CVSIGNORE_TOP_FILES)
  273.     if ! test -f $@; then touch $@; fi
  274.     cat $@ > $@.tmp
  275.     list='$^'; for file in $$list; do \
  276.       echo $$file >> $@.tmp; \
  277.     done
  278.     cat $@.tmp | sort | uniq > $@
  279.     rm $@.tmp
  280.  
  281. $(_CVSIGNORE_C) : $(_CVSIGNORE_C_FILES)
  282.     if ! test -f $@; then touch $@; fi
  283.     cat $@ > $@.tmp
  284.     list='$^'; for file in $$list; do \
  285.       echo $$file | sed -e 's/.*\///' >> $@.tmp; \
  286.     done
  287.     cat $@.tmp | sort | uniq > $@
  288.     rm $@.tmp
  289.  
  290. $(_CVSIGNORE_LC) : $(_CVSIGNORE_LC_FILES)
  291.     if ! test -f $@; then touch $@; fi
  292.     cat $@ > $@.tmp
  293.     list='$(wildcard $(_CVSIGNORE_LC_FILES),$(dir $@)/*)'; \
  294.     for file in $$list; do \
  295.       echo $$file | sed -e 's/.*\///' >> $@.tmp; \
  296.     done
  297.     cat $@.tmp | sort | uniq > $@
  298.     rm $@.tmp
  299.  
  300. .PHONY: cvsignore
  301. cvsignore: $(_CVSIGNORE_TOP) $(_CVSIGNROE_C) $(_CVSIGNORE_LC)
  302.  
  303.  
  304. ################################################################################
  305. ## @@ C Locale Documents
  306.  
  307. ## @ _DOC_C_MODULE
  308. ## The top-level documentation file in the C locale
  309. _DOC_C_MODULE = $(if $(DOC_MODULE),C/$(DOC_MODULE).xml)
  310.  
  311. ## @ _DOC_C_ENTITIES
  312. ## Files included with a SYSTEM entity in the C locale
  313. _DOC_C_ENTITIES = $(foreach ent,$(DOC_ENTITIES),C/$(ent))
  314.  
  315. ## @ _DOC_C_XINCLUDES
  316. ## Files included with XInclude in the C locale
  317. _DOC_C_INCLUDES = $(foreach inc,$(DOC_INCLUDES),C/$(inc))
  318.  
  319. ## @ _DOC_C_DOCS
  320. ## All documentation files in the C locale
  321. _DOC_C_DOCS =                                \
  322.     $(_DOC_C_ENTITIES)    $(_DOC_C_INCLUDES)            \
  323.     $(_RNGDOC_C_DOCS)    $(_XSLDOC_C_DOCS)            \
  324.     $(_DOC_C_MODULE)
  325.  
  326. ## @ _DOC_C_DOCS_NOENT
  327. ## All documentation files in the C locale,
  328. ## except files included with a SYSTEM entity
  329. _DOC_C_DOCS_NOENT =                            \
  330.     $(_DOC_C_MODULE)    $(_DOC_C_INCLUDES)            \
  331.     $(_RNGDOC_C_DOCS)    $(_XSLDOC_C_DOCS)
  332.  
  333. ## @ _DOC_C_FIGURES
  334. ## All figures and other external data in the C locale
  335. _DOC_C_FIGURES = $(if $(DOC_FIGURES),                    \
  336.     $(foreach fig,$(DOC_FIGURES),C/$(fig)),                \
  337.     $(patsubst $(srcdir)/%,%,$(wildcard $(srcdir)/C/figures/*.png)))
  338.  
  339. ## @ _DOC_C_HTML
  340. ## All HTML documentation in the C locale
  341. # FIXME: probably have to shell escape to determine the file names
  342. _DOC_C_HTML = $(foreach f,                        \
  343.     $(shell xsltproc --xinclude                     \
  344.       --stringparam db.chunk.basename "$(DOC_MODULE)"        \
  345.       $(_chunks) "C/$(DOC_MODULE).xml"),                \
  346.     C/$(f).xhtml)
  347.  
  348. ###############################################################################
  349. ## @@ Other Locale Documentation
  350.  
  351. ## @ _DOC_POFILES
  352. ## The .po files used for translating the document
  353. _DOC_POFILES = $(if $(DOC_MODULE),                        \
  354.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(lc)/$(lc).po))
  355.  
  356. .PHONY: po
  357. po: $(_DOC_POFILES)
  358.  
  359. ## @ _DOC_LC_MODULES
  360. ## The top-level documentation files in all other locales
  361. _DOC_LC_MODULES = $(if $(DOC_MODULE),                        \
  362.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(lc)/$(DOC_MODULE).xml))
  363.  
  364. ## @ _DOC_LC_XINCLUDES
  365. ## Files included with XInclude in all other locales
  366. _DOC_LC_INCLUDES =                                \
  367.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach inc,$(_DOC_C_INCLUDES),    \
  368.         $(lc)/$(notdir $(inc)) ))
  369.  
  370. ## @ _RNGDOC_LC_DOCS
  371. ## The generated rngdoc documentation in all other locales
  372. _RNGDOC_LC_DOCS =                                \
  373.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach doc,$(_RNGDOC_C_DOCS),    \
  374.         $(lc)/$(notdir $(doc)) ))
  375.  
  376. ## @ _XSLDOC_LC_DOCS
  377. ## The generated xsldoc documentation in all other locales
  378. _XSLDOC_LC_DOCS =                                \
  379.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach doc,$(_XSLDOC_C_DOCS),    \
  380.         $(lc)/$(notdir $(doc)) ))
  381.  
  382. ## @ _DOC_LC_HTML
  383. ## All HTML documentation in all other locales
  384. # FIXME: probably have to shell escape to determine the file names
  385. _DOC_LC_HTML =                                    \
  386.     $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach doc,$(_DOC_C_HTML),        \
  387.         $(lc)/$(notdir $(doc)) ))
  388.  
  389. ## @ _DOC_LC_DOCS
  390. ## All documentation files in all other locales
  391. _DOC_LC_DOCS =                                    \
  392.     $(_DOC_LC_MODULES)    $(_DOC_LC_INCLUDES)                \
  393.     $(_RNGDOC_LC_DOCS)    $(_XSLDOC_LC_DOCS)                \
  394.     $(if $(filter html HTML,$(_DOC_REAL_FORMATS)),$(_DOC_LC_HTML))
  395.  
  396. ## @ _DOC_LC_FIGURES
  397. ## All figures and other external data in all other locales
  398. _DOC_LC_FIGURES = $(foreach lc,$(_DOC_REAL_LINGUAS),                \
  399.     $(patsubst C/%,$(lc)/%,$(_DOC_C_FIGURES)) )
  400.  
  401. _DOC_SRC_FIGURES =                                \
  402.     $(foreach fig,$(_DOC_C_FIGURES), $(foreach lc,C $(_DOC_REAL_LINGUAS),    \
  403.         $(wildcard $(srcdir)/$(lc)/$(patsubst C/%,%,$(fig))) ))
  404.  
  405. $(_DOC_POFILES):
  406.     @if ! test -d $(dir $@); then \
  407.       echo "mkdir $(dir $@)"; \
  408.       mkdir "$(dir $@)"; \
  409.     fi
  410.     @if test ! -f $@ -a -f $(srcdir)/$@; then \
  411.       echo "cp $(srcdir)/$@ $@"; \
  412.       cp "$(srcdir)/$@" "$@"; \
  413.     fi;
  414.     @docs=; \
  415.     list='$(_DOC_C_DOCS_NOENT)'; for doc in $$list; do \
  416.       if test -f $$doc; then \
  417.         docs="$$docs ../$$doc"; \
  418.       else \
  419.         docs="$$docs ../$(srcdir)/$$doc"; \
  420.       fi; \
  421.     done; \
  422.     if ! test -f $@; then \
  423.       echo "(cd $(dir $@) && \
  424.         $(_xml2po) -e $$docs > $(notdir $@).tmp && \
  425.         cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp)"; \
  426.       (cd $(dir $@) && \
  427.         $(_xml2po) -e $$docs > $(notdir $@).tmp && \
  428.         cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp); \
  429.     else \
  430.       echo "(cd $(dir $@) && \
  431.         $(_xml2po) -e -u $(notdir $@) $$docs)"; \
  432.       (cd $(dir $@) && \
  433.         $(_xml2po) -e -u $(notdir $@) $$docs); \
  434.     fi
  435.  
  436. # FIXME: fix the dependancy
  437. # FIXME: hook xml2po up
  438. $(_DOC_LC_DOCS) : $(_DOC_POFILES)
  439. $(_DOC_LC_DOCS) : $(_DOC_C_DOCS)
  440.     if ! test -d $(dir $@); then mkdir $(dir $@); fi
  441.     case "$(srcdir)" in /*) sd="$(srcdir)";; *) sd="../$(srcdir)";;    esac; \
  442.     if [ -f "C/$(notdir $@)" ]; then d="../"; else d="$$sd/"; fi; \
  443.     (cd $(dir $@) && \
  444.       $(_xml2po) -e -p \
  445.         "$${d}$(dir $@)$(patsubst %/$(notdir $@),%,$@).po" \
  446.         "$${d}C/$(notdir $@)" > $(notdir $@).tmp && \
  447.         cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp)
  448.  
  449. ## @ _DOC_POT
  450. ## A pot file
  451. _DOC_POT = $(if $(DOC_MODULE),$(DOC_MODULE).pot)
  452. .PHONY: pot
  453. pot: $(_DOC_POT)
  454. $(_DOC_POT): $(_DOC_C_DOCS_NOENT)
  455.     $(_xml2po) -e -o $@ $^
  456.  
  457.  
  458. ################################################################################
  459. ## @@ All Documentation
  460.  
  461. ## @ _DOC_HTML_ALL
  462. ## All HTML documentation, only if it's built
  463. _DOC_HTML_ALL = $(if $(filter html HTML,$(_DOC_REAL_FORMATS)), \
  464.     $(_DOC_C_HTML) $(_DOC_LC_HTML))
  465.  
  466. _DOC_HTML_TOPS = $(foreach lc,C $(_DOC_REAL_LINGUAS),$(lc)/$(DOC_MODULE).xhtml)
  467.  
  468. $(_DOC_HTML_TOPS): $(_DOC_C_DOCS) $(_DOC_LC_DOCS)
  469.     xsltproc -o $@ --xinclude --param db.chunk.chunk_top "false()" --stringparam db.chunk.basename "$(DOC_MODULE)" --stringparam db.chunk.extension ".xhtml" $(_db2html) $(patsubst %.xhtml,%.xml,$@)
  470.  
  471.  
  472. ################################################################################
  473.  
  474. if ENABLE_SK
  475. _ENABLE_SK = true
  476. else
  477. _ENABLE_SK = false
  478. endif
  479.  
  480. all:                            \
  481.     $(_DOC_C_DOCS)        $(_DOC_LC_DOCS)        \
  482.     $(_DOC_OMF_ALL)        $(_DOC_DSK_ALL)        \
  483.     $(_DOC_HTML_ALL)    $(_DOC_POFILES)
  484.  
  485.  
  486. .PHONY: clean-doc-rngdoc clean-doc-xsldoc clean-doc-omf clean-doc-dsk clean-doc-lc clean-doc-dir
  487.  
  488. clean-doc-rngdoc: ; rm -f $(_RNGDOC_C_DOCS) $(_RNGDOC_LC_DOCS)
  489. clean-doc-xsldoc: ; rm -f $(_XSLDOC_C_DOCS) $(_XSLDOC_LC_DOCS)
  490. clean-doc-omf: ; rm -f $(_DOC_OMF_DB) $(_DOC_OMF_HTML)
  491. clean-doc-dsk: ; rm -f $(_DOC_DSK_DB) $(_DOC_DSK_HTML)
  492. clean-doc-lc:
  493.     rm -f $(_DOC_LC_DOCS)
  494.     @list='$(_DOC_POFILES)'; for po in $$list; do \
  495.       if ! test "$$po" -ef "$(srcdir)/$$po"; then \
  496.         echo "rm -f $$po"; \
  497.         rm -f "$$po"; \
  498.       fi; \
  499.     done
  500.     @for lc in C $(_DOC_REAL_LINGUAS); do \
  501.       if test -f "$$lc/.xml2po.mo"; then \
  502.         echo "rm -f $$lc/.xml2po.mo"; \
  503.         rm -f "$$lc/.xml2po.mo"; \
  504.       fi; \
  505.     done
  506. clean-doc-dir:
  507.     @for lc in C $(_DOC_REAL_LINGUAS); do \
  508.       for dir in `find $$lc -depth -type d`; do \
  509.         if ! test $$dir -ef $(srcdir)/$$dir; then \
  510.           echo "rmdir $$dir"; \
  511.           rmdir "$$dir"; \
  512.        fi; \
  513.       done; \
  514.     done
  515.  
  516. _clean_rngdoc = $(if $(RNGDOC_DIRS),clean-doc-rngdoc)
  517. _clean_xsldoc = $(if $(XSLDOC_DIRS),clean-doc-xsldoc)
  518. _clean_omf = $(if $(_DOC_OMF_IN),clean-doc-omf)
  519. _clean_dsk = $(if $(_DOC_DSK_IN),clean-doc-dsk)
  520. _clean_lc  = $(if $(_DOC_REAL_LINGUAS),clean-doc-lc)
  521. _clean_dir = $(if $(DOC_MODULE),clean-doc-dir)
  522.  
  523. clean-local:                        \
  524.     $(_clean_rngdoc)    $(_clean_xsldoc)    \
  525.     $(_clean_omf)        $(_clean_dsk)        \
  526.     $(_clean_lc)        $(_clean_dir)
  527. distclean-local:                    \
  528.     $(_clean_rngdoc)    $(_clean_xsldoc)    \
  529.     $(_clean_omf)        $(_clean_dsk)        \
  530.     $(_clean_lc)        $(_clean_dir)
  531. mostlyclean-local:                    \
  532.     $(_clean_rngdoc)    $(_clean_xsldoc)    \
  533.     $(_clean_omf)        $(_clean_dsk)        \
  534.     $(_clean_lc)        $(_clean_dir)
  535. maintainer-clean-local:                    \
  536.     $(_clean_rngdoc)    $(_clean_xsldoc)    \
  537.     $(_clean_omf)        $(_clean_dsk)        \
  538.     $(_clean_lc)        $(_clean_dir)
  539.  
  540.  
  541. .PHONY: dist-doc-docs dist-doc-figs dist-doc-omf dist-doc-dsk
  542. doc-dist-hook:                     \
  543.     $(if $(DOC_MODULE),dist-doc-docs)    \
  544.     $(if $(_DOC_C_FIGURES),dist-doc-figs)    \
  545.     $(if $(_DOC_OMF_IN),dist-doc-omf)
  546. #    $(if $(_DOC_DSK_IN),dist-doc-dsk)
  547.  
  548. dist-doc-docs: $(_DOC_C_DOCS) $(_DOC_LC_DOCS) $(_DOC_POFILES)
  549.     @for lc in C $(_DOC_REAL_LINGUAS); do \
  550.       echo " $(mkinstalldirs) $(distdir)/$$lc"; \
  551.       $(mkinstalldirs) "$(distdir)/$$lc"; \
  552.     done
  553.     @list='$(_DOC_C_DOCS) $(_DOC_LC_DOCS) $(_DOC_POFILES)'; \
  554.     for doc in $$list; do \
  555.       if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \
  556.       echo "$(INSTALL_DATA) $$d$$doc $(distdir)/$$doc"; \
  557.       $(INSTALL_DATA) "$$d$$doc" "$(distdir)/$$doc"; \
  558.     done
  559.  
  560. dist-doc-figs: $(_DOC_SRC_FIGURES)
  561.     @list='$(_DOC_C_FIGURES) $(_DOC_LC_FIGURES)'; \
  562.     for fig in $$list; do \
  563.       if test -f "$$fig"; then d=; else d="$(srcdir)/"; fi; \
  564.       if test -f "$$d$$fig"; then \
  565.         figdir=`echo $$fig | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \
  566.         if ! test -d "$(distdir)/$$figdir"; then \
  567.           echo "$(mkinstalldirs) $(distdir)/$$figdir"; \
  568.           $(mkinstalldirs) "$(distdir)/$$figdir"; \
  569.         fi; \
  570.         echo "$(INSTALL_DATA) $$d$$fig $(distdir)/$$fig"; \
  571.         $(INSTALL_DATA) "$$d$$fig" "$(distdir)/$$fig"; \
  572.       fi; \
  573.     done;
  574.  
  575. dist-doc-omf:
  576.     @if test -f "$(_DOC_OMF_IN)"; then d=; else d="$(srcdir)/"; fi; \
  577.     echo "$(INSTALL_DATA) $$d$(_DOC_OMF_IN) $(distdir)/$(notdir $(_DOC_OMF_IN))"; \
  578.     $(INSTALL_DATA) "$$d$(_DOC_OMF_IN)" "$(distdir)/$(notdir $(_DOC_OMF_IN))"
  579.  
  580. dist-doc-dsk:
  581.     @if test -f "$(_DOC_DSK_IN)"; then d=; else d="$(srcdir)/"; fi; \
  582.     echo "$(INSTALL_DATA) $$d$(_DOC_DSK_IN) $(distdir)/$(notdir $(_DOC_DSK_IN))"; \
  583.     $(INSTALL_DATA) "$$d$(_DOC_DSK_IN)" "$(distdir)/$(notdir $(_DOC_DSK_IN))"
  584.  
  585.  
  586. .PHONY: check-doc-docs check-doc-omf
  587. check:                            \
  588.     $(if $(DOC_MODULE),check-doc-docs)        \
  589.     $(if $(_DOC_OMF_IN),check-doc-omf)
  590.  
  591. check-doc-docs: $(_DOC_C_DOCS) $(_DOC_LC_DOCS)
  592.     @for lc in C $(_DOC_REAL_LINGUAS); do \
  593.       if test -f "$$lc"; \
  594.         then d=; \
  595.         xmlpath="$$lc"; \
  596.       else \
  597.         d="$(srcdir)/"; \
  598.         xmlpath="$$lc:$(srcdir)/$$lc"; \
  599.       fi; \
  600.       echo "xmllint --noout --noent --path $$xmlpath --xinclude --postvalid $$d$$lc/$(DOC_MODULE).xml"; \
  601.       xmllint --noout --noent --path "$$xmlpath" --xinclude --postvalid "$$d$$lc/$(DOC_MODULE).xml"; \
  602.     done
  603.  
  604. check-doc-omf: $(_DOC_OMF_ALL)
  605.     @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \
  606.       echo "xmllint --noout --dtdvalid 'http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd' $$omf"; \
  607.       xmllint --noout --dtdvalid 'http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd' $$omf; \
  608.     done
  609.  
  610.  
  611. .PHONY: install-doc-docs install-doc-html install-doc-figs install-doc-omf install-doc-dsk
  612. install-data-local:                    \
  613.     $(if $(DOC_MODULE),install-doc-docs)        \
  614.     $(if $(_DOC_HTML_ALL),install-doc-html)        \
  615.     $(if $(_DOC_C_FIGURES),install-doc-figs)    \
  616.     $(if $(_DOC_OMF_IN),install-doc-omf)
  617. #    $(if $(_DOC_DSK_IN),install-doc-dsk)
  618.  
  619. install-doc-docs:
  620.     @for lc in C $(_DOC_REAL_LINGUAS); do \
  621.       echo "$(mkinstalldirs) $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$lc"; \
  622.       $(mkinstalldirs) $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$lc; \
  623.     done
  624.     @list='$(_DOC_C_DOCS) $(_DOC_LC_DOCS)'; for doc in $$list; do \
  625.       if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \
  626.       echo "$(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$doc"; \
  627.       $(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$doc; \
  628.     done
  629.  
  630. install-doc-figs:
  631.     @list='$(patsubst C/%,%,$(_DOC_C_FIGURES))'; for fig in $$list; do \
  632.       for lc in C $(_DOC_REAL_LINGUAS); do \
  633.         if test -f "$$lc/$$fig"; then \
  634.           figfile="$$lc/$$fig"; \
  635.         elif test -f "$(srcdir)/$$lc/$$fig"; then \
  636.           figfile="$(srcdir)/$$lc/$$fig"; \
  637.         elif test -f "C/$$fig"; then \
  638.           figfile="C/$$fig"; \
  639.         else \
  640.           figfile="$(srcdir)/C/$$fig"; \
  641.         fi; \
  642.         figdir="$$lc/"`echo $$fig | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \
  643.         figdir="$(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$figdir"; \
  644.         if ! test -d "$$figdir"; then \
  645.           echo "$(mkinstalldirs) $$figdir"; \
  646.           $(mkinstalldirs) "$$figdir"; \
  647.         fi; \
  648.         figbase=`echo $$fig | sed -e 's/^.*\///'`; \
  649.         echo "$(INSTALL_DATA) $$figfile $$figdir$$figbase"; \
  650.         $(INSTALL_DATA) "$$figfile" "$$figdir$$figbase"; \
  651.       done; \
  652.     done
  653.  
  654. install-doc-html:
  655.     echo install-html
  656.  
  657. install-doc-omf:
  658.     $(mkinstalldirs) $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)
  659.     @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \
  660.       echo "$(INSTALL_DATA) $$omf $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf"; \
  661.       $(INSTALL_DATA) $$omf $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf; \
  662.     done
  663.     @if test "x$(_ENABLE_SK)" = "xtrue"; then \
  664.       echo "scrollkeeper-update -p $(DESTDIR)$(_sklocalstatedir) -o $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)"; \
  665.       scrollkeeper-update -p "$(DESTDIR)$(_sklocalstatedir)" -o "$(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)"; \
  666.     fi;
  667.  
  668. install-doc-dsk:
  669.     echo install-dsk
  670.  
  671.  
  672. .PHONY: uninstall-doc-docs uninstall-doc-html uninstall-doc-figs uninstall-doc-omf uninstall-doc-dsk
  673. uninstall-local:                    \
  674.     $(if $(DOC_MODULE),uninstall-doc-docs)        \
  675.     $(if $(_DOC_HTML_ALL),uninstall-doc-html)    \
  676.     $(if $(_DOC_C_FIGURES),uninstall-doc-figs)    \
  677.     $(if $(_DOC_OMF_IN),uninstall-doc-omf)
  678. #    $(if $(_DOC_DSK_IN),uninstall-doc-dsk)
  679.  
  680. uninstall-doc-docs:
  681.     @list='$(_DOC_C_DOCS) $(_DOC_LC_DOCS)'; for doc in $$list; do \
  682.       echo " rm -f $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$doc"; \
  683.       rm -f "$(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$doc"; \
  684.     done
  685.  
  686. uninstall-doc-figs:
  687.     @list='$(_DOC_C_FIGURES) $(_DOC_LC_FIGURES)'; for fig in $$list; do \
  688.       echo "rm -f $(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$fig"; \
  689.       rm -f "$(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$fig"; \
  690.     done;
  691.  
  692. uninstall-doc-omf:
  693.     @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \
  694.       if test "x$(_ENABLE_SK)" == "xtrue"; then \
  695.         echo "scrollkeeper-uninstall -p $(_sklocalstatedir) $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf"; \
  696.         scrollkeeper-uninstall -p "$(_sklocalstatedir)" "$(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf"; \
  697.       fi; \
  698.       echo "rm -f $(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf"; \
  699.       rm -f "$(DESTDIR)$(OMF_DIR)/$(DOC_MODULE)/$$omf"; \
  700.     done
  701.