Ammend merge: Misc stuff
[shapes.git] / doc / build / html / Makefile.am
blob128c79f2ac43e72ef2b91f1049ccc5cc304414dd
1 # This file is part of Shapes.
3 # Shapes is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # any later version.
8 # Shapes is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Shapes.  If not, see <http://www.gnu.org/licenses/>.
16 # Copyright 2008, 2010, 2013 Gustaf Hendeby
18 docdir=../..
19 partsdir=${docdir}/parts
20 extensionsdir=${partsdir}/extensions
21 namespacedir=${partsdir}/namespace
22 guidesdir=${partsdir}/guides
23 formatsdir=${partsdir}/formats
24 # Note: stylesdir must not be relative, or cyclic dependencies will result!
25 stylesdir=${top_srcdir}/doc/styles
26 toolsdir=${docdir}/tools
27 imagesdir=${docdir}/images
29 POSTPROC_HTML=${top_builddir}/doc/tools/postproc/postproc-html
31 SAXON = @SAXON@
33 SHAPES = $(top_builddir)/source/shapes
34 SHAPESFLAGS = --warn=error --resources=no \
35               --fontmetricspath ${top_srcdir}/resources/fontmetrics \
36               --needpath ${top_srcdir}/resources/extensions \
37               --tp=no \
38               --tmpdir "/tmp/shapes.${USER}" --tmp*=yes
41 include ../Makefile.goalscheck
43 # In combination with ../Makefile.goalscheck, this how we include a file only if the make goal does not match *clean*:
44 include $(if $(findstring clean,$(MAKECMDGOALS)),,${top_builddir}/source/SHAPES-VERSION-FILE)
46 DATE_PATTERN='[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
47 VERSION_PATTERN='[0-9]\{1,\}\(\.[0-9]\{1,\}\)*\(-[a-z0-9]\{1,\}\)*'
48 SSI=${top_builddir}/doc/tools/ssi/ssipp
49 # Setting BUILDDIR=^ means that paths will be relative to the current working
50 # directory.
51 SSIFLAGS=-dEXAMPLES=example/ -dBASE= -dBUILDDIR=^/ $(MORE_SSIFLAGS)
52 SSIFLAGS_SUBTOPIC=-dEXAMPLES=example/ -dBASE=../ -dBUILDDIR=^/ \
53                      $(MORE_SSIFLAGS) -I${srcdir}
54 MORE_SSIFLAGS=-dMODIFICATION_DATE=$(shell echo ${VERSION_DATE} | \
55              ${SED} -e 's!.*\('${DATE_PATTERN}'\).*!\1!' | \
56              grep -e ${DATE_PATTERN} 2> /dev/null || echo --- ) \
57                -dSHAPES_VERSION=$(shell echo ${VERSION_NUMBER} | \
58              ${SED} -e 's![^0-9]*\('${VERSION_PATTERN}'\).*!\1!' | \
59              grep -e ${VERSION_PATTERN} 2> /dev/null || echo ?.?.? ) \
60                -dHTML_DOC_DIR=$(htmldir) -I${srcdir}
62 SHEXT_LIST=doc/blockdraw-tutorial-tut-prefs.shext doc/winding-rule-paths.shext
63 SHEXT_FILES=$(addprefix example/, $(SHEXT_LIST))
65 EXTRA_html_FILES = \
66   algo-tol.html namespace-index.html edit.html install.html \
67   man.html state-types.html structure.html syntax.html types.html \
68   tutorial.html interactive.html index.html \
69   $(addprefix namespace/, \
70     Shapes.html \
71     Shapes-Data.html \
72     Shapes-Data-Type.html \
73     Shapes-Debug.html \
74     Shapes-Geometry.html \
75     Shapes-Geometry3D.html \
76     Shapes-Graphics.html \
77     Shapes-Graphics-PDF.html \
78     Shapes-Graphics-Tag.html \
79     Shapes-Graphics3D.html \
80     Shapes-IO.html \
81     Shapes-Layout.html \
82     Shapes-Numeric.html \
83     Shapes-Numeric-Constant.html \
84     Shapes-Numeric-Math.html \
85     Shapes-Numeric-Random.html \
86     Shapes-String.html \
87     Shapes-Text.html \
88     Shapes-Text-Font.html \
89     Shapes-Traits.html \
90     Shapes-Traits-BW.html \
91     Shapes-Traits-Blend.html \
92     Shapes-Traits-Cap.html \
93     Shapes-Traits-Device.html \
94     Shapes-Traits-Join.html \
95     Shapes-Traits-Light.html \
96     Shapes-Traits-RGB.html \
97     Applications.html \
98     Applications-Blockdraw.html \
99   ) \
100   $(addprefix extensions/, \
101     Applications-Blockdraw-blockdraw.html \
102     Applications-Blockdraw-bondgraph.html \
103     Shapes-Control-cond.html \
104     Shapes-Data-seq-support.html \
105     Shapes-Geometry-circle.html \
106     Shapes-Geometry-linkpaths.html \
107     Shapes-Geometry-pathmapping.html \
108     Shapes-Geometry3D-circle.html \
109     Shapes-Graphics-arrowheads.html \
110     Shapes-Graphics-metapostarrow.html \
111     Shapes-Graphics-shapesarrow.html \
112     Shapes-Graphics3D-arrowheads.html \
113     Shapes-Graphics3D-metapostarrow.html \
114     Shapes-Layout-basic-layout.html \
115     Shapes-Layout-centering-X.html \
116     Shapes-Layout-shiftoff.html \
117     Shapes-Numeric-Constant-constants.html \
118   ) \
119   $(addprefix guides/, \
120     paths.html 3D.html text.html graphs.html hierarchical.html index.html)
122 nobase_dist_html_DATA = shapes.css toc-miss.html
123 EXTRA_nobase_dist_html = ${html_FILES}
125 nobase_dist_noinst_DATA = ${extensionsdir}/formats/html.xsl \
126                    ${namespacedir}/formats/html.xsl \
127                    ${guidesdir}/formats/html.xsl \
128                    $(addprefix ${formatsdir}/, \
129                       examplecode-html.xsl html.xsl language-elements-html.xsl \
130                       man.xsl plain-book-html.xsl) \
131                    ${partsdir}/namespace-toc/formats/toc.xsl \
132                    $(foreach part,\
133                      $(addprefix ${partsdir}/, \
134                        algo-tol namespace-index edit man state-types \
135                          structure syntax tutorial interactive types index),\
136                      $(part)/formats/html.xsl $(wildcard $(part)/formats/*-html.xsl)) \
137                    $(patsubst ${srcdir}/%,%,\
138                      $(foreach part,\
139                        $(addprefix ${srcdir}/${partsdir}/, \
140                          algo-tol namespace-index edit man state-types \
141                            structure syntax tutorial interactive types index),\
142                        $(part)/formats/html.xsl $(wildcard $(part)/formats/*-html.xsl))) \
143                    $(SHEXT_FILES)
145 EXTRA_DATA=${EXTRA_nobase_dist_html}
147 html_FILES=${EXTRA_html_FILES}
148 nobase_dist_html_DATA+=${EXTRA_nobase_dist_html}
150 EXTRA_DIST=${nobase_dist_html_DATA}
152 # Temporary solution for putting the SF logo on each page:
153 ADD-SF: $(html_FILES)
154         -for i in $(html_FILES); do \
155     echo "Putting SF logo in " $$i; \
156     ex -sC $$i < insert-SF-logo.ex; \
157   done
159 extensions/%.xml : ${extensionsdir}/%.sxml ${DEPDIR}/extensions/%.ssidep
160         test -d $(@D) || ${mkdir_p} $(@D)
161         if ${SSI} --in $< ${SSIFLAGS_SUBTOPIC} > extensions/$*.Txml; \
162   then \
163     mv extensions/$*.Txml $@; \
164   else \
165     ${RM} extensions/$*.Txml; \
166     exit 1; \
167   fi
169 guides/%.xml : ${guidesdir}/%.sxml ${DEPDIR}/guides/%.ssidep
170         test -d $(@D) || ${mkdir_p} $(@D)
171         if ${SSI} --in $< ${SSIFLAGS_SUBTOPIC} > guides/$*.Txml; \
172   then \
173     mv guides/$*.Txml $@; \
174   else \
175     ${RM} guides/$*.Txml; \
176     exit 1; \
177   fi
179 ${DEPDIR}/extensions/%.ssidep : ${extensionsdir}/%.sxml Makefile
180         test -d $(@D) || ${mkdir_p} ${@D}
181         if $(SSI) --in $< $(SSIFLAGS_SUBTOPIC) --head extensions/$*.xml \
182     --deps > ${DEPDIR}/extensions/$*.Tssidep; \
183   then \
184     ${SED} -e 's!^.*:!nobase_dist_noinst_DATA += $< !' \
185       ${DEPDIR}/extensions/$*.Tssidep > ${DEPDIR}/extensions/$*.dist ; \
186     ${SED} -e 's!^!$@ !' ${DEPDIR}/extensions/$*.Tssidep > $@ ; \
187     mv ${DEPDIR}/extensions/$*.Tssidep $@; \
188   else \
189     ${RM} ${DEPDIR}/extensions/$*.Tssidep; \
190     exit 1; \
191   fi
193 namespace/%.xml : ${namespacedir}/%.sxml ${DEPDIR}/namespace/%.ssidep
194         test -d $(@D) || ${mkdir_p} $(@D)
195         if ${SSI} --in $< ${SSIFLAGS_SUBTOPIC} > namespace/$*.Txml; \
196   then \
197     mv namespace/$*.Txml $@; \
198   else \
199     ${RM} namespace/$*.Txml; \
200     exit 1; \
201   fi
203 ${DEPDIR}/namespace/%.ssidep : ${namespacedir}/%.sxml Makefile
204         test -d $(@D) || ${mkdir_p} ${@D}
205         if $(SSI) --in $< $(SSIFLAGS_SUBTOPIC) --head namespace/$*.xml \
206     --deps > ${DEPDIR}/namespace/$*.Tssidep; \
207   then \
208     ${SED} -e 's!^.*:!nobase_dist_noinst_DATA += $< !' \
209       ${DEPDIR}/namespace/$*.Tssidep > ${DEPDIR}/namespace/$*.dist ; \
210     ${SED} -e 's!^!$@ !' ${DEPDIR}/namespace/$*.Tssidep > $@ ; \
211     mv ${DEPDIR}/namespace/$*.Tssidep $@; \
212   else \
213     ${RM} ${DEPDIR}/namespace/$*.Tssidep; \
214     exit 1; \
215   fi
217 ${DEPDIR}/guides/%.ssidep : ${guidesdir}/%.sxml Makefile
218         test -d $(@D) || ${mkdir_p} ${@D}
219         if $(SSI) --in $< $(SSIFLAGS_SUBTOPIC) --head guides/$*.xml \
220     --deps > ${DEPDIR}/guides/$*.Tssidep; \
221   then \
222     ${SED} -e 's!^.*:!nobase_dist_noinst_DATA += $< !' \
223       ${DEPDIR}/guides/$*.Tssidep > ${DEPDIR}/guides/$*.dist ; \
224     ${SED} -e 's!^!$@ !' ${DEPDIR}/guides/$*.Tssidep > $@ ; \
225     mv ${DEPDIR}/guides/$*.Tssidep $@; \
226   else \
227     ${RM} ${DEPDIR}/guides/$*.Tssidep; \
228     exit 1; \
229   fi
231 # WARNING!
232 # Dependencies such as extensions/../dynamic.html will cause
233 # dynamic.html to be built as if it was the extension ../dynamic.html,
234 # which will produce the wrong result.  Therefore, we make an
235 # attempt at removing collapsable parts from the dependencies.
236 if HAVE_SAXON
238 extensions/%.html : extensions/%.xml ${extensionsdir}/formats/html.xsl \
239                     ${formatsdir}/html.xsl
240         test -d ${@D} || ${mkdir_p} ${@D} ; \
241   ( $(SAXON) $< $$( test -f ${extensionsdir}/formats/html.xsl || \
242     echo '${srcdir}'/ )${extensionsdir}/formats/html.xsl || exit 1 ) | \
243     ${POSTPROC_HTML} > $@
244         if $(SAXON) $@ $$( test -f ${toolsdir}/xhtml-deps/filter.xsl || \
245     echo '${srcdir}'/)${toolsdir}/xhtml-deps/filter.xsl > \
246     ${DEPDIR}/extensions/$*.Thtmldep ; \
247   then \
248     echo "nobase_dist_html_DATA += $$( ${SED} -e 's!\([^ ]\{1,\}\)!extensions/\1!g' < ${DEPDIR}/extensions/$*.Thtmldep | ${SED} -e 's![^/ ]\{1,\}/\.\./!!g' | tr ' ' '\n' | sort -u | tr '\n' ' ' )" > ${DEPDIR}/extensions/$*.htmldep ; \
249     ${RM} ${DEPDIR}/extensions/$*.Thtmldep ; \
250   else \
251     ${RM} ${DEPDIR}/extensions/$*.Thtmldep ; \
252     exit 1; \
253   fi
255 namespace/%.html : namespace/%.xml ${namespacedir}/formats/html.xsl \
256                     ${formatsdir}/html.xsl
257         test -d ${@D} || ${mkdir_p} ${@D} ; \
258   ( $(SAXON) $< $$( test -f ${namespacedir}/formats/html.xsl || \
259     echo '${srcdir}'/ )${namespacedir}/formats/html.xsl || exit 1 ) | \
260     ${POSTPROC_HTML} > $@
261         if $(SAXON) $@ $$( test -f ${toolsdir}/xhtml-deps/filter.xsl || \
262     echo '${srcdir}'/)${toolsdir}/xhtml-deps/filter.xsl > \
263      ${DEPDIR}/namespace/$*.Thtmldep ; \
264   then \
265     echo "nobase_dist_html_DATA += $$( ${SED} -e 's!\([^ ]\{1,\}\)!namespace/\1!g' < ${DEPDIR}/namespace/$*.Thtmldep | ${SED} -e 's![^/ ]\{1,\}/\.\./!!g' | tr ' ' '\n' | sort -u | tr '\n' ' ' )" > ${DEPDIR}/namespace/$*.htmldep ; \
266     ${RM} ${DEPDIR}/namespace/$*.Thtmldep ; \
267   else \
268     ${RM} ${DEPDIR}/namespace/$*.Thtmldep ; \
269     exit 1; \
270   fi
272 guides/%.html : guides/%.xml ${guidesdir}/formats/html.xsl \
273                     ${formatsdir}/html.xsl
274         test -d ${@D} || ${mkdir_p} ${@D} ; \
275   ( $(SAXON) $< $$( test -f ${guidesdir}/formats/html.xsl || \
276     echo '${srcdir}'/ )${guidesdir}/formats/html.xsl || exit 1 ) | \
277     ${POSTPROC_HTML} > $@
278         if $(SAXON) $@ $$( test -f ${toolsdir}/xhtml-deps/filter.xsl || \
279     echo '${srcdir}'/)${toolsdir}/xhtml-deps/filter.xsl > \
280     ${DEPDIR}/guides/$*.Thtmldep ; \
281   then \
282     echo "nobase_dist_html_DATA += $$( ${SED} -e 's!\([^ ]\{1,\}\)!guides/\1!g' < ${DEPDIR}/guides/$*.Thtmldep | ${SED} -e 's![^/ ]\{1,\}/\.\./!!g' | tr ' ' '\n' | sort -u | tr '\n' ' ' )" > ${DEPDIR}/guides/$*.htmldep ; \
283     ${RM} ${DEPDIR}/guides/$*.Thtmldep ; \
284   else \
285     ${RM} ${DEPDIR}/guides/$*.Thtmldep ; \
286     exit 1; \
287   fi
289 endif # HAVE_SAXON
291 %.css : ${stylesdir}/html/%.css
292         test -d $(@D) || ${mkdir_p} $(@D)
293         ${INSTALL_DATA} $< $@
295 toc-miss.html : ${partsdir}/namespace-toc/toc-miss.html
296         test -d $(@D) || ${mkdir_p} $(@D)
297         ${INSTALL_DATA} $< $@
299 img/% : ${imagesdir}/%
300         test -d $(@D) || ${mkdir_p} $(@D)
301         ${INSTALL_DATA} $< $@
303 img/%-www.jpg : img/%.png
304         convert $(CONVERT_FLAGS) -scale 30% $< $@
306 example/%.shape : ${top_srcdir}/examples/%.shape
307         test -d $(@D) || ${mkdir_p} $(@D)
308         ${INSTALL_DATA} $< $@
310 example/%.blank : ${top_srcdir}/examples/%.blank
311         test -d $(@D) || ${mkdir_p} $(@D)
312         ${INSTALL_DATA} $< $@
314 example/%.shext : ${top_srcdir}/examples/%.shext
315         test -d $(@D) || ${mkdir_p} $(@D)
316         ${INSTALL_DATA} $< $@
318 %.htmldep : %.ssidep
319         @touch $@
321 .PRECIOUS : $(addprefix ${DEPDIR}/, $(html_FILES:.html=.ssidep) \
322                                     $(html_FILES:.html=.htmldep) \
323                                     $(html_FILES:.html=.dist)) \
324             $(html_FILES:.html=.xml)
326 clean-local :
327         -find . \( -name "*~" -o -name "*.html" -o -name "*.xml" \) -exec ${RM} {} \;
328         -test -d ${DEPDIR} && find ${DEPDIR} -type f -exec ${RM} {} \;
330 distclean-local :
331         -find . -type f -exec ${RM} {} \;
333 # In combination with ../Makefile.goalscheck, this how we include a file only if the make goal does not match *clean*:
334 include $(if $(findstring clean,$(MAKECMDGOALS)),,$(addprefix ${DEPDIR}/, $(html_FILES:.html=.ssidep)))
336 -include $(addprefix ${DEPDIR}/, $(html_FILES:.html=.htmldep))
337 -include $(addprefix ${DEPDIR}/, $(html_FILES:.html=.dist))
339 # When including ../Makefile.common, we must first set up htmldepvar.
340 htmldepvar=nobase_dist_html_DATA
341 include ../Makefile.common
343 html-local : ${nobase_dist_html_DATA} ${nobase_dist_noinst_DATA} FORCE
344 dist-hook : all-local
345 all-local : html-local
346         ${MAKE} html-local
348 FORCE :