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