Build: Improve rules for building .stdout files
[shapes.git] / doc / build / Makefile.common
blob49db1106828b5a0080c514263fe309811e96154e
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, 2014 Gustaf Hendeby, Henrik Tidefelt
18 CONVERT_FLAGS = -antialias -flatten -background white
20 %.pdf %.stdout: %.shape $(SHEXT_FILES)
21         test -d  $(@D) || ${mkdir_p} $(@D)
22         $(SHAPES) $(SHAPESFLAGS) --in $< --out $*.pdf > $*.stdout0
23         mv $*.stdout0 $*.stdout
25 %_3.pdf %.stdout: %.shape $(SHEXT_FILES)
26         test -d  $(@D) || ${mkdir_p} $(@D)
27         $(SHAPES) $(SHAPESFLAGS) -vs1.3 --in $< --out $*_3.pdf > $*.stdout0
28         mv $*.stdout0 $*.stdout
30 %.stdout: %.blank $(SHEXT_FILES)
31         test -d  $(@D) || ${mkdir_p} $(@D)
32         $(SHAPES) $(SHAPESFLAGS) --in $< > $*.stdout0
33         mv $*.stdout0 $@
35 # Some stupid versions of convert exit with a non-zero value even though the conversion was a success...
36 %_70%.jpg: %.pdf
37         -convert $(CONVERT_FLAGS) -density 100 -resize $(shell echo $@ | ${SED} -e 's!.*_\([^._]*\).jpg!\1!') $< $@
39 %_y_big.jpg: %.pdf
40         -convert $(CONVERT_FLAGS) -density `echo 150 \* 150 / $$(identify $< | sed -e 's!.* [a-zA-Z0-9]\{1,\} \([^x]*\)x\([^ ]*\).*!\2!') | bc` -resize x150 $< $@
42 %_y_small.jpg: %.pdf
43         -convert $(CONVERT_FLAGS) -density `echo 50 \* 150 / $$(identify $< | sed -e 's!.* [a-zA-Z0-9]\{1,\} \([^x]*\)x\([^ ]*\).*!\2!') | bc` -resize x50 $< $@
45 %_x_big.jpg: %.pdf
46         -convert $(CONVERT_FLAGS) -density `echo 150 \* 150 / $$(identify $< | sed -e 's!.* [a-zA-Z0-9]\{1,\} \([^x]*\)x\([^ ]*\).*!\1!') | bc` -resize 150x $< $@
48 %_x_small.jpg: %.pdf
49         -convert $(CONVERT_FLAGS) -density `echo 50 \* 150 / $$(identify $< | sed -e 's!.* [a-zA-Z0-9]\{1,\} \([^x]*\)x\([^ ]*\).*!\1!') | bc` -resize 50x $< $@
51 %.xml : ${partsdir}/%/index.sxml ${formatsdir}/html.xsl ${DEPDIR}/%.ssidep
52         if ${SSI} --in $< ${SSIFLAGS} > $*.Txml; \
53         then \
54                 mv $*.Txml $@; \
55         else \
56                 ${RM} $*.Txml; \
57                 exit 1; \
58         fi
60 ${DEPDIR}/%.ssidep : ${partsdir}/%/index.sxml Makefile
61         test -d  $(@D) || ${mkdir_p} ${@D}
62         if $(SSI) --in $< $(SSIFLAGS) --head $*.xml --deps > \
63           ${DEPDIR}/$*.Tssidep; \
64         then \
65                 ${SED} -e 's!^.*:!nobase_dist_noinst_DATA += $< !' \
66                   ${DEPDIR}/$*.Tssidep > ${DEPDIR}/$*.dist ; \
67           ${SED} -e 's!^!$@ !' ${DEPDIR}/$*.Tssidep > $@ ; \
68                 mv ${DEPDIR}/$*.Tssidep $@; \
69         else \
70                 ${RM} ${DEPDIR}/$*.Tssidep; \
71                 exit 1; \
72         fi
74 if HAVE_SAXON
75 %.html : %.xml ${partsdir}/%/formats/html.xsl ${formatsdir}/html.xsl
76         test -d  ${@D} || ${mkdir_p} ${@D} ; \
77         ( $(SAXON) $< $$( test -f ${partsdir}/$*/formats/html.xsl || \
78           echo '${srcdir}'/ )${partsdir}/$*/formats/html.xsl || exit 1 ) | \
79           ${POSTPROC_HTML} > $*.html
80         if $(SAXON) $@ $$( test -f ${toolsdir}/xhtml-deps/filter.xsl || \
81           echo '${srcdir}'/)${toolsdir}/xhtml-deps/filter.xsl  > \
82           ${DEPDIR}/$*.Thtmldep ; \
83         then \
84                 echo "${htmldepvar} += $$( tr ' ' '\n' < ${DEPDIR}/$*.Thtmldep | sort -u | tr '\n' ' ' )" > ${DEPDIR}/$*.htmldep ; \
85                 ${RM} ${DEPDIR}/$*.Thtmldep ; \
86         else \
87                 ${RM} ${DEPDIR}/$*.Thtmldep ; \
88                 exit 1; \
89         fi
90 endif