Fix spelling s/authenticaiton/authentication/
[sfrench/samba-autobuild/.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 export XML_CATALOG_FILES := $(XML_CATALOG_FILES) /etc/xml/catalog  $(shell pwd)/build/catalog.xml
10
11 # Docs to build
12 MAIN_DOCS = $(patsubst %/index.xml,%,$(wildcard */index.xml))
13 MANPAGES = $(sort $(wildcard $(MANPAGEDIR)/*.?.xml))
14
15 # Lists of files to process
16 MANPAGES_PLUCKER = $(patsubst $(MANPAGEDIR)/%.xml,$(PLUCKERDIR)/%.pdb,$(MANPAGES))
17 DBLATEX_OPTIONS = -p xslt/latex.xsl -i xslt/latex
18
19 DATETIME := $(shell date +%Y%m%d%H%M%S)
20
21 XSLTPROC_DEPS = build/catalog.xml build/DTD/samba.build.version
22
23 ifeq ($(PROFILE), Y)
24 XSLTPROC += --profile --load-trace --timing
25 endif
26
27 ifndef OUTPUTDIR
28 Makefile.settings: configure
29         ./configure
30
31 configure: configure.ac
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,ps,manpages,txt,pearson,htmlhelp - Build specific output format"
41         @echo " html - Build multi-file HTML versions"
42         @echo " html-single - Build single-file HTML versions"
43         @echo " htmlman - Build HTML version of manpages"
44         @echo " samples - Extract examples"
45
46 $(PDFDIR)/Samba3-ByExample.pdf $(PSDIR)/Samba3-ByExample.ps $(DOCBOOKDIR)/Samba3-ByExample.xml Samba3-ByExample.tex: $(wildcard Samba3-ByExample/*.xml)
47 $(PDFDIR)/Samba3-HOWTO.pdf $(PSDIR)/Samba3-HOWTO.ps Samba3-HOWTO.tex $(DOCBOOKDIR)/Samba3-HOWTO.xml: $(wildcard Samba3-HOWTO/*.xml) Samba3-HOWTO-attributions.xml
48 Samba3-HOWTO/manpages.xml: $(MANPAGEDIR)/smb.conf.5.xml
49 $(PDFDIR)/Samba3-Developers-Guide.pdf $(PSDIR)/Samba3-Developers-Guide.ps $(DOCBOOKDIR)/Samba3-Developers-Guide.xml Samba3-Developers-Guide.tex: $(wildcard Samba3-Developers-Guide/*.xml) Samba3-Developers-Guide-attributions.xml
50
51 # Pseudo targets 
52 all:: $(TARGETS)
53 everything:: manpages pdf html-single html htmlman txt ps fo htmlhelp pearson
54 release:: manpages htmlman html pdf
55 clean::
56         @echo "Cleaning up..." 
57         rm -rf $(OUTPUTDIR)/* $(DOCBOOKDIR)
58         rm -f *-attributions.xml
59         rm -f $(patsubst %.svg,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
60                         $(patsubst %.svg,%.pdf,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg))) \
61                         $(patsubst %.svg,%.eps,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg))) \
62                         $(patsubst %.svg,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-svg)))
63         rm -f *-attributions.xml *.d *.tpt *.tex *.loc *.toc *.lof *.glo *.idx *.aux
64         rm -f *-images-html*
65         rm -f *-images-latex-* $(LATEX_FIGURES)
66         rm -f xslt/figures/*pdf
67         rm -f $(SMBDOTCONFDOC)/parameters.*.xml
68         rm -f build/catalog.xml
69
70 # Output format targets
71 pdf:: $(patsubst %,$(PDFDIR)/%.pdf,$(MAIN_DOCS))
72 ps:: $(patsubst %,$(PSDIR)/%.ps,$(MAIN_DOCS))
73 txt:: $(patsubst %,$(TXTDIR)/%.txt,$(MAIN_DOCS))
74 tex:: $(addsuffix .tex,$(MAIN_DOCS))
75 texi:: $(patsubst %,$(TEXINFODIR)/%.texi,$(MAIN_DOCS))
76 texiinfo:: $(patsubst %,$(TEXINFODIR)/%.info,$(MAIN_DOCS))
77 manpages:: $(patsubst $(MANPAGEDIR)/%.xml,$(OUTPUTDIR)/manpages/%,$(MANPAGES))
78 pearson:: $(PEARSONDIR)/Samba3-HOWTO.xml
79 pearson-verify:: $(PEARSONDIR)/Samba3-HOWTO.report.html
80 plucker:: $(patsubst %,$(PLUCKERDIR)/%.pdb,$(MAIN_DOCS))
81 htmlman:: $(patsubst $(MANPAGEDIR)/%.xml,$(HTMLDIR)/manpages/%.html,$(MANPAGES)) $(HTMLDIR)/manpages/index.html
82 html-single:: $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS))
83 html:: $(patsubst %,$(HTMLDIR)/%/index.html,$(MAIN_DOCS)) $(HTMLDIR)/index.html
84 htmlhelp:: $(addprefix $(HTMLHELPDIR)/,$(MAIN_DOCS))
85 validate:: $(addsuffix -validate,$(MAIN_DOCS))
86
87 test:: validate
88 check:: validate
89
90 .PHONY: test check validate manpages
91
92 # Intermediate docbook docs
93 #
94 $(DOCBOOKDIR)/%.xml: %/index.xml xslt/expand-sambadoc.xsl $(XSLTPROC_DEPS)
95         @echo "Converting Samba-specific tags for $*..."
96         @mkdir -p $(@D)
97         @$(XSLTPROC) --stringparam latex.imagebasedir "$*/"  --stringparam noreference 0  --xinclude --output $@ xslt/expand-sambadoc.xsl $<
98
99 $(DOCBOOKDIR)/manpages/%.xml: $(MANPAGEDIR)/%.xml xslt/expand-sambadoc.xsl Makefile.settings $(XSLTPROC_DEPS)
100         @mkdir -p $(@D)
101         $(XSLTPROC) --xinclude --stringparam noreference 0 --output $@ xslt/expand-sambadoc.xsl $<
102
103 $(DOCBOOKDIR)/manpages/index.xml: $(MANPAGES) xslt/manpage-summary.xsl $(XSLTPROC_DEPS)
104         @mkdir -p $(@D)
105         echo "<article><variablelist>" > $@
106         $(XSLTPROC) xslt/manpage-summary.xsl $(MANPAGES) >> $@
107         @echo "</variablelist></article>" >> $@
108
109 # HTML docs
110 $(HTMLDIR)/index.html: htmldocs.html
111         @mkdir -p $(@D)
112         cp $< $@
113
114 $(HTMLDIR)/%/index.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/%/samba.css xslt/html-chunk.xsl %-images-html-chunks $(XSLTPROC_DEPS)
115         @mkdir -p $(@D)
116         $(XSLTPROC) --stringparam base.dir "$(HTMLDIR)/$*/" xslt/html-chunk.xsl $<
117
118 # Single large HTML files
119 $(OUTPUTDIR)/%/samba.css: xslt/html/samba.css $(XSLTPROC_DEPS)
120         @mkdir -p $(@D)
121         cp $< $@
122
123 $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS)): $(HTMLDIR)/%.html: %-images-html-single
124
125 $(HTMLDIR)/%.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/samba.css xslt/html.xsl $(XSLTPROC_DEPS)
126         $(XSLTPROC) --output $@ xslt/html.xsl $<
127
128 # Attributions
129 %-attributions.xml: $(XSLTPROC_DEPS)
130         @echo "Generating attributions file $@ from $*/"
131         @cp -f templates/attributions.xml $@
132         @$(XSLTPROC) --xinclude -o $@ xslt/generate-attributions.xsl $*/index.xml 
133
134 # Text files
135 $(TXTDIR)/%.txt: $(HTMLDIR)/%.html
136         @mkdir -p $(@D)
137         $(HTML2TEXT) -nobs -style pretty -o $@ $<
138
139 # Tex files
140 %.tex: %/index.xml xslt/latex.xsl
141         @echo "Generating $@..."
142         @mkdir -p $(@D)
143         @$(DBLATEX) $(DBLATEX_OPTIONS) -t tex -o $@ $<
144
145 # Dependency files
146 %.d: $(DOCBOOKDIR)/%.xml xslt/generate-dependencies.xsl $(XSLTPROC_DEPS)
147         @echo "Generating dependency file for $*" 
148         @$(XSLTPROC) --novalid \
149                 --stringparam txtbasedir "$(TXTDIR)/$*/" \
150                 --stringparam target "$*" \
151                 -o $@ xslt/generate-dependencies.xsl $<
152         @echo "$*-images-latex-svg = \$$(wildcard \$$(addsuffix .svg, \$$($*-images-latex)))" >> $@
153         @echo "$*-images-latex-eps: \$$(addsuffix .eps, \$$($*-images-latex))" >> $@
154         @echo "$*-images-latex-pdf: \$$(patsubst %.svg, %.pdf, \$$($*-images-latex-svg))" >> $@
155         @echo "$*-images-latex-png: \$$(filter-out \$$(patsubst %.svg,%.png,\$$($*-images-latex-svg)), \$$(addsuffix .png, \$$($*-images-latex)))" >> $@
156
157         @echo >> $@
158         @echo "\$$(HTMLDIR)/%: $*/%" >> $@
159         @echo " @mkdir -p \$$(@D)" >> $@
160         @echo " @cp \$$< \$$@" >> $@
161         @echo >> $@
162         @echo "\$$(HTMLDIR)/$*/%: $*/%" >> $@
163         @echo " @mkdir -p \$$(@D)" >> $@
164         @echo " @cp \$$< \$$@" >> $@
165         @echo >> $@
166         @echo "\$$(HTMLHELPDIR)/$*/%: $*/%" >> $@
167         @echo " @mkdir -p \$$(@D)" >> $@
168         @echo " @cp \$$< \$$@" >> $@
169         @echo >> $@
170         @echo "$*-images-html-single: \$$(addprefix \$$(HTMLDIR)/, \$$($*-images-html))" >> $@
171         @echo "$*-images-html-chunks: \$$(addprefix \$$(HTMLDIR)/$*/, \$$($*-images-html))" >> $@
172         @echo "$*-images-htmlhelp: \$$(addprefix \$$(HTMLHELPDIR)/$*/, \$$($*-images-html))" >> $@
173
174 ifdef OUTPUTDIR 
175 ifneq ($(MAKECMDGOALS),clobber)
176 -include $(addsuffix .d,$(MAIN_DOCS))
177 endif
178 endif
179
180 # Adobe PDF files  
181 $(PDFDIR)/%.pdf: %/index.xml $(PDFDIR) xslt/latex.xsl %-images-latex-png %-images-latex-pdf
182         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t pdf -o $@ $<
183
184 # PostScript files
185 $(PSDIR)/%.ps: %/index.xml $(PSDIR) xslt/latex.xsl %-images-latex-eps
186         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t ps -o $@ $<
187
188 %.eps: %.svg
189         $(INKSCAPE) -z -f $(abspath $<) --export-eps=$(abspath $@)
190
191 %.png: %.svg
192         $(INKSCAPE) -z -f $(abspath $<) --export-png=$(abspath $@)
193
194 %.eps: %.png
195         $(PNGTOPNM) $< | $(PNMTOPS) > $@
196
197 %.pdf: %.svg
198         $(INKSCAPE) -z -f $(abspath $<) --export-pdf=$(abspath $@)
199
200 $(HTMLHELPDIR)/%: $(DOCBOOKDIR)/%.xml %-images-htmlhelp $(XSLTPROC_DEPS)
201         $(XSLTPROC) --stringparam htmlhelp.chm $*.chm \
202                                 --stringparam manifest.in.base.dir "$@/" \
203                                 --stringparam base.dir "$@/" \
204         http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl $<
205
206 # Plucker docs
207 $(PLUCKERDIR)/%.pdb: $(HTMLDIR)/%.html 
208         @mkdir -p $(@D)
209         $(PLUCKERBUILD) -v -V 2 --stayonhost --zlib-compression -f $* -p $(PLUCKERDIR) file:$< 
210
211 # Texinfo docs
212 $(TEXINFODIR)/%.texi: $(DOCBOOKDIR)/%.xml
213         @mkdir -p $(@D)
214         cd $(@D) && $(DB2TEXI) $(shell pwd)/$<
215
216 $(TEXINFODIR)/%.info: $(TEXINFODIR)/%.texi
217         $(MAKEINFO) --no-validate --force -o $@ "$<"
218
219 # Manpages
220 $(MANPAGEDIR)/smb.conf.5.xml: parameters
221
222 # The phony parameters target exists in order to always create the
223 # the parameters xml files. Otherwise, when parameters.*.xml does not exist
224 # yet, the parameters are not generated when smb.conf.5.xml is newer than
225 # any smbdotconf/*/*.xml file ...
226 .PHONY: parameters
227
228 parameters: $(SMBDOTCONFDOC)/parameters.all.xml
229
230 $(SMBDOTCONFDOC)/parameters.all.xml: $(wildcard $(SMBDOTCONFDOC)/*/*.xml) $(SMBDOTCONFDOC)/generate-file-list.sh
231         $(SMBDOTCONFDOC)/generate-file-list.sh $(SMBDOTCONFDOC) > $@
232
233 $(OUTPUTDIR):
234         test -d $@ || mkdir $@
235
236 $(OUTPUTDIR)/%: $(DOCBOOKDIR)/%.xml xslt/man.xsl
237         @mkdir -p $(@D)
238         $(XSLTPROC) --output $@ xslt/man.xsl $<
239
240 # Individual smb.conf parameters
241 smb.conf-chunks: $(patsubst $(SMBDOTCONFDOC)/%.xml,$(HTMLDIR)/smb.conf/%.html,$(wildcard $(SMBDOTCONFDOC)/*/*.xml))
242
243 $(HTMLDIR)/smb.conf/%.html: $(SMBDOTCONFDOC)/%.xml
244         @mkdir -p $(@D)
245         $(XSLTPROC) --output $@ xslt/smb.conf-html.xsl $<
246
247 # Pearson compatible XML
248 $(PEARSONDIR)/%.xml: %/index.xml xslt/pearson.xsl
249         @mkdir -p $(@D)
250         $(XSLTPROC) --xinclude --output $@ xslt/sambadoc2pearson.xsl $<
251
252 $(PEARSONDIR)/%.report.html: $(PEARSONDIR)/%.xml
253         @mkdir -p $(@D)
254         -$(XMLLINT) --valid --noout $< 2> $@
255
256 # Validation verification
257 %-validate: %/index.xml
258         cd $(<D) && $(XMLLINT) --xinclude --noent --postvalid --noout $(<F)
259
260 build/catalog.xml: build/catalog.xml.in
261         sed -e "s|@abs_top_srcdir@|`pwd`|g;s|@abs_top_builddir@|`pwd`|g" < build/catalog.xml.in > build/catalog.xml
262
263 samples: $(DOCBOOKDIR)/Samba3-HOWTO.xml xslt/extract-examples.xsl scripts/indent-smb.conf.pl
264         @mkdir -p examples
265         $(XSLTPROC) --xinclude xslt/extract-examples.xsl $< > /dev/null 2> examples/README
266         for I in examples/*.conf; do { ./scripts/indent-smb.conf.pl < $$I > $$I.tmp; mv $$I.tmp $$I; } done
267
268 # Archiving
269 archive: pdf
270         @mkdir -p $(ARCHIVEDIR)
271         cp $(PDFDIR)/Samba3-HOWTO.pdf $(ARCHIVEDIR)/TOSHARG-$(DATETIME).pdf
272         cp $(PDFDIR)/Samba3-ByExample.pdf $(ARCHIVEDIR)/S3bE-$(DATETIME).pdf
273
274 # XSL scripts
275 xslt/html.xsl: xslt/html-common.xsl 
276 xslt/html-chunk.xsl: xslt/html-common.xsl 
277 xslt/latex.xsl: 
278 xslt/expand-sambadoc.xsl: 
279 xslt/generate-attributions.xsl: 
280 xslt/man.xsl:
281 xslt/pearson.xsl:
282
283 distclean clobber:: clean
284         rm -f Makefile.settings config.status config.log
285
286 realdistclean:: distclean
287         rm -f configure
288         rm -rf autom4te.cache
289         rm -rf output
290
291 # Always keep intermediate files if we can
292 .SECONDARY:
293 .PHONY: clean clobber archive release everything all