1 ### These are all generic; we set all the variables we need
3 # intermediary build path
6 BUILDIMAGESDIR = $(BUILDDIR)/images
9 # right now, we only allow .png and .fig as source
10 # we might add more later if we feel the need
12 # PNG's can be source or built from .fig
13 PNG = $(strip $(PNG_SRC) $(FIG_SRC:.fig=.png))
14 # EPS .ps files can be built from .png or .fig
15 EPS = $(strip $(FIG_SRC:.fig=.ps) $(PNG_SRC:.png=.ps))
16 # PDF .pdf files can be built from .png or .fig
17 PDF = $(strip $(FIG_SRC:.fig=.pdf) $(PNG_SRC:.png=.pdf))
19 # where we expect to find images during building, whether by copying
20 # or by generating them
21 PNG_BUILT = $(foreach file, $(PNG), $(BUILDIMAGESDIR)/$(file))
22 EPS_BUILT = $(foreach file, $(EPS), $(BUILDIMAGESDIR)/$(file))
23 PDF_BUILT = $(foreach file, $(PDF), $(BUILDIMAGESDIR)/$(file))
25 SRC = $(XML) $(PNG_SRC) $(FIG_SRC) $(CSS) $(EXTRA_SRC)
30 ### generate all documentation by default
31 # hook in html generation
34 # can we generate HTML ?
37 HTML_TARGET = html/index.html
44 # can we generate PS ?
52 # can we generate PDF ?
61 @echo "outputting some useful debug information"
65 @echo "Source image files:"
66 @echo "PNG_SRC: '$(PNG_SRC)'"
67 @echo "FIG_SRC: '$(FIG_SRC)'"
68 @echo "All used image files:"
72 @echo "All used image files in their built path:"
73 @echo "PNG_BUILT: '$(PNG_BUILT)'"
74 @echo "EPS_BUILT: '$(EPS_BUILT)'"
75 @echo "PDF_BUILT: '$(PDF_BUILT)'"
76 @echo "End result products:"
77 @echo "HTML_DAT: '$(HTML_DAT)'"
78 @echo "PS_DAT: '$(PS_DAT)'"
79 @echo "PDF_DAT: '$(PDF_DAT)'"
81 # a rule to copy all of the source for docs into $(builddir)/build
82 $(BUILDDIR)/$(MAIN): $(XML) $(CSS) $(EXTRA_SRC)
83 @-mkdir -p $(BUILDDIR)
84 @if test "x$(EXTRA_SRC)" != "x"; then for a in $(EXTRA_SRC); do cp $(srcdir)/$$a $(BUILDDIR); done; fi
85 @for a in $(XML); do cp $(srcdir)/$$a $(BUILDDIR); done
86 @for a in $(CSS); do cp $(srcdir)/$$a $(BUILDDIR); done
87 @cp ../version.entities $(BUILDDIR)
88 @cp $(top_srcdir)/docs/url.entities $(BUILDDIR)
90 # we should switch to xsltproc
91 # docbook2html aka jade can't add the encoding easily to the html meta
92 # jw -f docbook -b html -d pwg.dsl -o ../html -V '%use-id-as-filename%' $(MAIN)
93 # this is a startng point
94 # xsltproc --nonet /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl pwg.xml
96 html/index.html: $(BUILDDIR)/$(MAIN) $(PNG_BUILT) $(FIG_SRC)
98 @echo "*** Generating HTML output ***"
100 @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities
101 @cd $(BUILDDIR) && docbook2html -o ../html -V '%use-id-as-filename%' $(MAIN)
102 @test "x$(CSS)" != "x" && \
103 echo "Copying .css files: $(CSS)" && \
104 cp $(srcdir)/$(CSS) html
105 @test "x$(PNG)" != "x" && \
106 echo "Copying .png images: $(PNG_BUILT)" && \
107 mkdir -p html/images && \
108 cp $(PNG_BUILT) html/images || true
110 $(DOC).ps: $(BUILDDIR)/$(MAIN) $(EPS_BUILT) $(PNG_SRC) $(FIG_SRC)
112 @echo "*** Generating PS output ***"
113 @cp -f $(srcdir)/../image-eps $(BUILDDIR)/image.entities
114 cd $(BUILDDIR) && docbook2ps -o .. $(MAIN)
115 # export LC_PAPER=$(PAPER_LOCALE) && cd $(BUILDDIR) && xmlto ps -o .. $(MAIN)
117 $(DOC).pdf: $(DOC).ps
119 @echo "*** Generating PDF output ***"
122 #$(DOC).pdf: $(MAIN) $(PDF) $(FIG_SRC)
123 # @echo "*** Generating PDF output ***"
124 # @cp -f $(srcdir)/../image-pdf image.entities
125 # @export LC_PAPER=$(PAPER_LOCALE) && xmlto pdf $(MAIN)
129 -$(RM) -r $(BUILDDIR)
137 # copy png from source dir png
138 $(BUILDIMAGESDIR)/%.png: $(srcdir)/%.png
139 @echo "Copying $< to $@"
140 @mkdir -p $(BUILDIMAGESDIR)
143 $(BUILDIMAGESDIR)/%.png: %.fig
144 @echo "Generating $@ from $<"
145 @mkdir -p $(BUILDIMAGESDIR)
148 # make ps(EPS) from fig
149 $(BUILDIMAGESDIR)/%.ps: %.fig
150 @echo "Generating $@ from $<"
151 @mkdir -p $(BUILDIMAGESDIR)
155 $(BUILDIMAGESDIR)/%.pdf: %.fig
156 @echo "Generating $@ from $<"
157 @mkdir -p $(BUILDIMAGESDIR)
161 $(BUILDIMAGESDIR)/%.pdf: %.png
162 @echo "Generating $@ from $<"
163 @mkdir -p $(BUILDIMAGESDIR)
164 @cat $< | pngtopnm | pnmtops -noturn 2> /dev/null | epstopdf --filter --outfile $@ 2> /dev/null
166 # make ps(EPS) from png
167 $(BUILDIMAGESDIR)/%.ps: %.png
168 @echo "Generating $@ from $<"
169 @mkdir -p $(BUILDIMAGESDIR)
170 @cat $< | pngtopnm | pnmtops -noturn > $@ 2> /dev/null
172 # make sure xml validates properly
173 check-local: $(BUILDDIR)/$(MAIN)
174 @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities
175 cd $(BUILDDIR) && xmllint -noout -valid $(MAIN)