Use system-provided dblatex to build the docs rather than included
[ira/wip.git] / docs-xml / Makefile
1 #################################################################
2 # Makefile for Samba Documentation
3 # Authors:      
4 #               James Moore <jmoore@php.net>
5 #               Gerald Carter <jerry@samba.org>
6 #               Jelmer Vernooij <jelmer@samba.org>
7 include Makefile.settings
8
9 # Docs to build
10 MAIN_DOCS = $(patsubst %/index.xml,%,$(wildcard */index.xml))
11 MANPAGES3 = $(wildcard $(MANPAGEDIR3)/*.?.xml)
12 export TEXINPUTS=xslt/latex:.:
13
14 # Lists of files to process
15 LATEX_FIGURES = xslt/figures/caution.pdf xslt/figures/important.pdf xslt/figures/note.pdf xslt/figures/tip.pdf xslt/figures/warning.pdf
16 MANPAGES_PLUCKER = $(patsubst $(MANPAGEDIR3)/%.xml,$(PLUCKERDIR)/%.pdb,$(MANPAGES3))
17 DBLATEX_OPTIONS = -p xslt/latex.xsl -i xslt/latex
18
19 DATETIME := $(shell date +%Y%m%d%H%M%S)
20
21 ifeq ($(PROFILE), Y)
22 XSLTPROC += --profile --load-trace --timing
23 endif
24
25 ifndef OUTPUTDIR
26 Makefile.settings: configure
27         @echo Makefile.settings not present, trying to run configure...
28         ./configure
29
30 configure: configure.ac
31         @echo configure not present, trying to regenerate it...
32         autoreconf
33 endif
34
35 help: 
36         @echo "Supported make targets:"
37         @echo " release - Build the docs needed for a Samba release"
38         @echo " all - Build all docs that can be build using the utilities found by configure"
39         @echo " everything - Build all of the above"
40         @echo " pdf,tex,dvi,ps,manpages3,txt,pearson,fo,htmlhelp - Build specific output format"
41         @echo " html - Build multi-file HTML versions"
42         @echo " html-single - Build single-file HTML versions"
43         @echo " htmlman3 - Build HTML version of manpages"
44         @echo " undocumented - Output list of undocumented smb.conf options"
45         @echo " samples - Extract examples"
46
47 $(DOCBOOKDIR)/Samba3-ByExample.xml: $(filter-out Samba3-ByExample/index.xml,$(wildcard Samba3-ByExample/*.xml))
48 $(DOCBOOKDIR)/Samba3-HOWTO.xml: $(filter-out Samba3-HOWTO/index.xml,$(wildcard Samba3-HOWTO/*.xml)) Samba3-HOWTO-attributions.xml
49 Samba3-HOWTO/manpages.xml: $(MANPAGEDIR3)/smb.conf.5.xml
50 $(DOCBOOKDIR)/Samba3-Developers-Guide.xml: $(filter-out Samba3-Developers-Guide/index.xml,$(wildcard Samba3-Developers-Guide/*.xml)) Samba3-Developers-Guide-attributions.xml
51 $(DOCBOOKDIR)/Samba4-HOWTO.xml: $(filter-out Samba4-HOWTO/index.xml,$(wildcard Samba4-HOWTO/*.xml)) Samba4-HOWTO-attributions.xml
52
53 # Pseudo targets 
54 all:: $(TARGETS)
55 everything:: manpages3 pdf html-single html htmlman3 txt ps fo htmlhelp pearson 
56 release:: manpages3 htmlman3 html pdf 
57 clean::
58         @echo "Cleaning up..." 
59         rm -rf $(OUTPUTDIR)/* $(DOCBOOKDIR)
60         rm -f $(patsubst %.svg,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
61                         $(patsubst %.svg,%.pdf,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg))) \
62                         $(patsubst %.svg,%.eps,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg))) \
63                         $(patsubst %.svg,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg)))
64         rm -f *-attributions.xml *.d *.tpt *.tex *.loc *.toc *.lof *.glo *.idx *.aux
65         rm -f *-images-html*
66         rm -f *-images-latex-* $(LATEX_FIGURES)
67         rm -f xslt/figures/*pdf
68         rm -f $(SMBDOTCONFDOC)/parameters.*.xml
69         rm -f $(addsuffix .*,$(MAIN_DOCS))
70         rm -f build/catalog.xml
71
72 # Output format targets
73 pdf:: $(patsubst %,$(PDFDIR)/%.pdf,$(MAIN_DOCS))
74 dvi:: $(patsubst %,$(DVIDIR)/%.dvi,$(MAIN_DOCS))
75 ps:: $(patsubst %,$(PSDIR)/%.ps,$(MAIN_DOCS))
76 txt:: $(patsubst %,$(TXTDIR)/%.txt,$(MAIN_DOCS))
77 txt-chunks:: $(addsuffix -txt-chunks,$(MAIN_DOCS))
78 fo:: $(patsubst %,$(FODIR)/%.fo,$(MAIN_DOCS))
79 fo-pdf:: $(patsubst %,$(FOPDFDIR)/%.pdf,$(MAIN_DOCS))
80 tex:: $(addsuffix .tex,$(MAIN_DOCS))
81 texi:: $(patsubst %,$(TEXINFODIR)/%.texi,$(MAIN_DOCS))
82 texiinfo:: $(patsubst %,$(TEXINFODIR)/%.info,$(MAIN_DOCS))
83 manpages3:: $(patsubst $(MANPAGEDIR3)/%.xml,$(OUTPUTDIR)/manpages-3/%,$(MANPAGES3))
84 pearson:: $(PEARSONDIR)/Samba3-HOWTO.xml
85 pearson-verify:: $(PEARSONDIR)/Samba3-HOWTO.report.html
86 plucker:: $(patsubst %,$(PLUCKERDIR)/%.pdb,$(MAIN_DOCS))
87 htmlman3:: $(patsubst $(MANPAGEDIR3)/%.xml,$(HTMLDIR)/manpages-3/%.html,$(MANPAGES3)) $(HTMLDIR)/manpages-3/index.html
88 html-single:: $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS))
89 html:: $(patsubst %,$(HTMLDIR)/%/index.html,$(MAIN_DOCS)) $(HTMLDIR)/index.html
90 htmlhelp:: $(addprefix $(HTMLHELPDIR)/,$(MAIN_DOCS))
91 validate:: $(addsuffix -validate,$(MAIN_DOCS))
92
93 test:: validate
94 check:: validate
95
96 .PHONY: test check validate
97
98 # Intermediate docbook docs
99 #
100 $(DOCBOOKDIR)/%.xml: %/index.xml xslt/expand-sambadoc.xsl
101         @echo "Converting Samba-specific tags for $*..."
102         @mkdir -p $(@D)
103         @$(XSLTPROC) --stringparam latex.imagebasedir "$*/"  --stringparam noreference 0  --xinclude --output $@ xslt/expand-sambadoc.xsl $<
104
105 $(DOCBOOKDIR)/manpages-3/%.xml: $(MANPAGEDIR3)/%.xml xslt/expand-sambadoc.xsl
106         @mkdir -p $(@D)
107         $(XSLTPROC) --xinclude --stringparam noreference 0 --output $@ xslt/expand-sambadoc.xsl $<
108
109 $(DOCBOOKDIR)/manpages-3/index.xml: $(MANPAGES3) xslt/manpage-summary.xsl
110         @mkdir -p $(@D)
111         echo "<article><variablelist>" > $@
112         $(XSLTPROC) xslt/manpage-summary.xsl $(MANPAGES3) >> $@
113         @echo "</variablelist></article>" >> $@
114
115 # HTML docs
116 $(HTMLDIR)/index.html: htmldocs.html
117         @mkdir -p $(@D)
118         cp $< $@
119         
120 $(HTMLDIR)/%/index.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/%/samba.css xslt/html-chunk.xsl %-images-html-chunks
121         @mkdir -p $(@D)
122         $(XSLTPROC) --stringparam base.dir "$(HTMLDIR)/$*/" xslt/html-chunk.xsl $<
123
124 # Single large HTML files
125 $(OUTPUTDIR)/%/samba.css: xslt/html/samba.css
126         @mkdir -p $(@D)
127         cp $< $@
128
129 $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS)): $(HTMLDIR)/%.html: %-images-html-single
130
131 $(HTMLDIR)/%.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/samba.css xslt/html.xsl 
132         $(XSLTPROC) --output $@ xslt/html.xsl $<
133
134 # Attributions
135 %-attributions.xml: 
136         @echo "Generating attributions file $@ from $*/"
137         @cp -f templates/attributions.xml $@
138         @$(XSLTPROC) --xinclude -o $@ xslt/generate-attributions.xsl $*/index.xml 
139
140 # Text files
141 $(TXTDIR)/%.txt: $(HTMLDIR)/%.html
142         @mkdir -p $(@D)
143         $(HTML2TEXT) -nobs -style pretty -o $@ $<
144
145 # Tex files
146 %.tex: %/index.xml xslt/latex.xsl
147         @echo "Generating $@..."
148         @mkdir -p $(@D)
149         @$(DBLATEX) $(DBLATEX_OPTIONS) -t tex -o $@ $<
150
151 $(PDFDIR)/%.pdf: %.pdf
152         @mkdir -p $(@D)
153         cp $< $@
154
155 # Dependency files
156 %.d: $(DOCBOOKDIR)/%.xml xslt/generate-dependencies.xsl
157         @echo "Generating dependency file for $*" 
158         @$(XSLTPROC) --novalid \
159                 --stringparam txtbasedir "$(TXTDIR)/$*/" \
160                 --stringparam target "$*" \
161                 -o $@ xslt/generate-dependencies.xsl $<
162         @echo "$*-images-latex-svg = \$$(wildcard \$$(addsuffix .svg, \$$($*-images-latex)))" >> $@
163         @echo "$*-images-latex-eps: \$$(addsuffix .eps, \$$($*-images-latex))" >> $@
164         @echo "$*-images-latex-pdf: \$$(patsubst %.svg, %.pdf, \$$($*-images-latex-svg))" >> $@
165         @echo "$*-images-latex-png: \$$(filter-out \$$(patsubst %.svg,%.png,\$$($*-images-latex-svg)), \$$(addsuffix .png, \$$($*-images-latex)))" >> $@
166
167         @echo >> $@
168         @echo "\$$(HTMLDIR)/%: $*/%" >> $@
169         @echo " @mkdir -p \$$(@D)" >> $@
170         @echo " @cp \$$< \$$@" >> $@
171         @echo >> $@
172         @echo "\$$(HTMLDIR)/$*/%: $*/%" >> $@
173         @echo " @mkdir -p \$$(@D)" >> $@
174         @echo " @cp \$$< \$$@" >> $@
175         @echo >> $@
176         @echo "\$$(HTMLHELPDIR)/$*/%: $*/%" >> $@
177         @echo " @mkdir -p \$$(@D)" >> $@
178         @echo " @cp \$$< \$$@" >> $@
179         @echo >> $@
180         @echo "$*-images-html-single: \$$(addprefix \$$(HTMLDIR)/, \$$($*-images-html))" >> $@
181         @echo "$*-images-html-chunks: \$$(addprefix \$$(HTMLDIR)/$*/, \$$($*-images-html))" >> $@
182         @echo "$*-images-htmlhelp: \$$(addprefix \$$(HTMLHELPDIR)/$*/, \$$($*-images-html))" >> $@
183
184 ifdef OUTPUTDIR 
185 ifneq ($(MAKECMDGOALS),clobber)
186 -include $(addsuffix .d,$(MAIN_DOCS))
187 endif
188 endif
189
190 # Adobe PDF files  
191 %.pdf: %/index.xml xslt/latex.xsl
192         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t pdf -o $@ $<
193
194 # DVI files
195 $(DVIDIR)/%.dvi: %.dvi
196         @mkdir -p $(@D)
197         cp $< $@
198
199 %.dvi: %/index.xml xslt/latex.xsl
200         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t dvi -o $@ $<
201
202 %.eps: %.svg
203         $(INKSCAPE) -z -f $< --export-eps=$@
204
205 %.png: %.svg
206         $(INKSCAPE) -z -f $< --export-png=$@
207
208 #%.pdf: %.svg
209 #       $(INKSCAPE) -z -f $< --export-pdf=$@
210
211 %.pdf: %.eps
212         $(EPSTOPDF) $<
213
214 %.eps: %.png
215         $(PNGTOPNM) $< | $(PNMTOPS) > $@
216
217 # PostScript files
218 $(PSDIR)/%.ps: $(DVIDIR)/%.dvi
219         @mkdir -p $(@D)
220         $(DVIPS) -o $@ $<
221
222 # Fo
223 $(FODIR)/%.fo: $(DOCBOOKDIR)/%.xml
224         @mkdir -p $(@D)
225         $(XSLTPROC) --output $@ xslt/fo.xsl $<
226
227 # PDF thru Fo
228 $(FOPDFDIR)/%.pdf: $(FODIR)/%.fo
229         @mkdir -p $(@D)
230         JAVA_OPTS=-Xmx250m $(FOP) -q -d $< -pdf $@
231
232 $(HTMLHELPDIR)/%: $(DOCBOOKDIR)/%.xml %-images-htmlhelp
233         $(XSLTPROC) --stringparam htmlhelp.chm $*.chm \
234                                 --stringparam manifest.in.base.dir "$@/" \
235                                 --stringparam base.dir "$@/" \
236         http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl $<
237
238 # Plucker docs
239 $(PLUCKERDIR)/%.pdb: $(HTMLDIR)/%.html 
240         @mkdir -p $(@D)
241         $(PLUCKERBUILD) -v -V 2 --stayonhost --zlib-compression -f $* -p $(PLUCKERDIR) file:$< 
242
243 # Texinfo docs
244 $(TEXINFODIR)/%.texi: $(DOCBOOKDIR)/%.xml
245         @mkdir -p $(@D)
246         cd $(@D) && $(DB2TEXI) $(shell pwd)/$<
247
248 $(TEXINFODIR)/%.info: $(TEXINFODIR)/%.texi
249         $(MAKEINFO) --no-validate --force -o $@ "$<"
250
251 # Manpages
252 $(MANPAGEDIR3)/smb.conf.5.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/parameters.global.xml
253
254 $(SMBDOTCONFDOC)/parameters.all.xml: $(wildcard $(SMBDOTCONFDOC)/*/*.xml) $(SMBDOTCONFDOC)/generate-file-list.sh
255         $(SMBDOTCONFDOC)/generate-file-list.sh $(SMBDOTCONFDOC) > $@
256
257 $(SMBDOTCONFDOC)/parameters.global.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
258         @echo "Generating list of global smb.conf options" 
259         $(XSLTPROC) --xinclude --param smb.context "'G'" --output $(SMBDOTCONFDOC)/parameters.global.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
260
261 $(SMBDOTCONFDOC)/parameters.service.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
262         @echo "Generating list of share-mode smb.conf options" 
263         $(XSLTPROC) --xinclude --param smb.context "'S'" --output $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
264
265 $(OUTPUTDIR)/%: $(DOCBOOKDIR)/%.xml xslt/man.xsl
266         @mkdir -p $(@D)
267         $(XSLTPROC) --output $@ xslt/man.xsl $<
268
269 # Individual smb.conf parameters
270 smb.conf-chunks: $(patsubst $(SMBDOTCONFDOC)/%.xml,$(HTMLDIR)/smb.conf/%.html,$(wildcard $(SMBDOTCONFDOC)/*/*.xml))
271         
272 $(HTMLDIR)/smb.conf/%.html: $(SMBDOTCONFDOC)/%.xml
273         @mkdir -p $(@D)
274         $(XSLTPROC) --output $@ xslt/smb.conf-html.xsl $<
275
276 # Pearson compatible XML
277 $(PEARSONDIR)/%.xml: %/index.xml xslt/pearson.xsl
278         @mkdir -p $(@D)
279         $(XSLTPROC) --xinclude --output $@ xslt/sambadoc2pearson.xsl $<
280
281 $(PEARSONDIR)/%.report.html: $(PEARSONDIR)/%.xml
282         @mkdir -p $(@D)
283         -$(XMLLINT) --valid --noout $< 2> $@
284
285 # Validation verification
286 %-validate: %/index.xml
287         cd $(<D) && $(XMLLINT) --xinclude --noent --postvalid --noout $(<F)
288
289 # Find undocumented parameters
290 undocumented: $(SMBDOTCONFDOC)/parameters.all.xml scripts/find_missing_doc.pl scripts/find_missing_manpages.pl
291         $(PERL) scripts/find_missing_doc.pl $(SRCDIR)
292         $(PERL) scripts/find_missing_manpages.pl $(SRCDIR)
293
294 samples: $(DOCBOOKDIR)/Samba3-HOWTO.xml xslt/extract-examples.xsl scripts/indent-smb.conf.pl
295         @mkdir -p examples
296         $(XSLTPROC) --xinclude xslt/extract-examples.xsl $< > /dev/null 2> examples/README
297         for I in examples/*.conf; do { ./scripts/indent-smb.conf.pl < $$I > $$I.tmp; mv $$I.tmp $$I; } done
298
299 # Archiving
300 archive: pdf
301         @mkdir -p $(ARCHIVEDIR)
302         cp $(PDFDIR)/Samba3-HOWTO.pdf $(ARCHIVEDIR)/TOSHARG-$(DATETIME).pdf
303         cp $(PDFDIR)/Samba3-ByExample.pdf $(ARCHIVEDIR)/S3bE-$(DATETIME).pdf
304
305 # XSL scripts
306 xslt/html.xsl: xslt/html-common.xsl 
307 xslt/html-chunk.xsl: xslt/html-common.xsl 
308 xslt/latex.xsl: 
309 xslt/expand-sambadoc.xsl: 
310 xslt/generate-attributions.xsl: 
311 xslt/man.xsl:
312 xslt/pearson.xsl:
313
314 distclean clobber:: clean
315         rm -f Makefile.settings config.status config.log
316
317 realdistclean:: distclean
318         rm -f configure
319         rm -rf autom4te.cache
320
321 # Always keep intermediate files if we can
322 .SECONDARY:
323 .PHONY: clean clobber archive release everything all