c177ba721b882b0557ec3409b143e078e7daa539
[jra/samba/.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,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 tex:: $(addsuffix .tex,$(MAIN_DOCS))
73 texi:: $(patsubst %,$(TEXINFODIR)/%.texi,$(MAIN_DOCS))
74 texiinfo:: $(patsubst %,$(TEXINFODIR)/%.info,$(MAIN_DOCS))
75 manpages3:: $(patsubst $(MANPAGEDIR3)/%.xml,$(OUTPUTDIR)/manpages-3/%,$(MANPAGES3))
76 pearson:: $(PEARSONDIR)/Samba3-HOWTO.xml
77 pearson-verify:: $(PEARSONDIR)/Samba3-HOWTO.report.html
78 plucker:: $(patsubst %,$(PLUCKERDIR)/%.pdb,$(MAIN_DOCS))
79 htmlman3:: $(patsubst $(MANPAGEDIR3)/%.xml,$(HTMLDIR)/manpages-3/%.html,$(MANPAGES3)) $(HTMLDIR)/manpages-3/index.html
80 html-single:: $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS))
81 html:: $(patsubst %,$(HTMLDIR)/%/index.html,$(MAIN_DOCS)) $(HTMLDIR)/index.html
82 htmlhelp:: $(addprefix $(HTMLHELPDIR)/,$(MAIN_DOCS))
83 validate:: $(addsuffix -validate,$(MAIN_DOCS))
84
85 test:: validate
86 check:: validate
87
88 .PHONY: test check validate
89
90 # Intermediate docbook docs
91 #
92 $(DOCBOOKDIR)/%.xml: %/index.xml xslt/expand-sambadoc.xsl
93         @echo "Converting Samba-specific tags for $*..."
94         @mkdir -p $(@D)
95         @$(XSLTPROC) --stringparam latex.imagebasedir "$*/"  --stringparam noreference 0  --xinclude --output $@ xslt/expand-sambadoc.xsl $<
96
97 $(DOCBOOKDIR)/manpages-3/%.xml: $(MANPAGEDIR3)/%.xml xslt/expand-sambadoc.xsl
98         @mkdir -p $(@D)
99         $(XSLTPROC) --xinclude --stringparam noreference 0 --output $@ xslt/expand-sambadoc.xsl $<
100
101 $(DOCBOOKDIR)/manpages-3/index.xml: $(MANPAGES3) xslt/manpage-summary.xsl
102         @mkdir -p $(@D)
103         echo "<article><variablelist>" > $@
104         $(XSLTPROC) xslt/manpage-summary.xsl $(MANPAGES3) >> $@
105         @echo "</variablelist></article>" >> $@
106
107 # HTML docs
108 $(HTMLDIR)/index.html: htmldocs.html
109         @mkdir -p $(@D)
110         cp $< $@
111         
112 $(HTMLDIR)/%/index.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/%/samba.css xslt/html-chunk.xsl %-images-html-chunks
113         @mkdir -p $(@D)
114         $(XSLTPROC) --stringparam base.dir "$(HTMLDIR)/$*/" xslt/html-chunk.xsl $<
115
116 # Single large HTML files
117 $(OUTPUTDIR)/%/samba.css: xslt/html/samba.css
118         @mkdir -p $(@D)
119         cp $< $@
120
121 $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS)): $(HTMLDIR)/%.html: %-images-html-single
122
123 $(HTMLDIR)/%.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/samba.css xslt/html.xsl 
124         $(XSLTPROC) --output $@ xslt/html.xsl $<
125
126 # Attributions
127 %-attributions.xml: 
128         @echo "Generating attributions file $@ from $*/"
129         @cp -f templates/attributions.xml $@
130         @$(XSLTPROC) --xinclude -o $@ xslt/generate-attributions.xsl $*/index.xml 
131
132 # Text files
133 $(TXTDIR)/%.txt: $(HTMLDIR)/%.html
134         @mkdir -p $(@D)
135         $(HTML2TEXT) -nobs -style pretty -o $@ $<
136
137 # Tex files
138 %.tex: %/index.xml xslt/latex.xsl
139         @echo "Generating $@..."
140         @mkdir -p $(@D)
141         @$(DBLATEX) $(DBLATEX_OPTIONS) -t tex -o $@ $<
142
143 # Dependency files
144 %.d: $(DOCBOOKDIR)/%.xml xslt/generate-dependencies.xsl
145         @echo "Generating dependency file for $*" 
146         @$(XSLTPROC) --novalid \
147                 --stringparam txtbasedir "$(TXTDIR)/$*/" \
148                 --stringparam target "$*" \
149                 -o $@ xslt/generate-dependencies.xsl $<
150         @echo "$*-images-latex-svg = \$$(wildcard \$$(addsuffix .svg, \$$($*-images-latex)))" >> $@
151         @echo "$*-images-latex-eps: \$$(addsuffix .eps, \$$($*-images-latex))" >> $@
152         @echo "$*-images-latex-pdf: \$$(patsubst %.svg, %.pdf, \$$($*-images-latex-svg))" >> $@
153         @echo "$*-images-latex-png: \$$(filter-out \$$(patsubst %.svg,%.png,\$$($*-images-latex-svg)), \$$(addsuffix .png, \$$($*-images-latex)))" >> $@
154
155         @echo >> $@
156         @echo "\$$(HTMLDIR)/%: $*/%" >> $@
157         @echo " @mkdir -p \$$(@D)" >> $@
158         @echo " @cp \$$< \$$@" >> $@
159         @echo >> $@
160         @echo "\$$(HTMLDIR)/$*/%: $*/%" >> $@
161         @echo " @mkdir -p \$$(@D)" >> $@
162         @echo " @cp \$$< \$$@" >> $@
163         @echo >> $@
164         @echo "\$$(HTMLHELPDIR)/$*/%: $*/%" >> $@
165         @echo " @mkdir -p \$$(@D)" >> $@
166         @echo " @cp \$$< \$$@" >> $@
167         @echo >> $@
168         @echo "$*-images-html-single: \$$(addprefix \$$(HTMLDIR)/, \$$($*-images-html))" >> $@
169         @echo "$*-images-html-chunks: \$$(addprefix \$$(HTMLDIR)/$*/, \$$($*-images-html))" >> $@
170         @echo "$*-images-htmlhelp: \$$(addprefix \$$(HTMLHELPDIR)/$*/, \$$($*-images-html))" >> $@
171
172 ifdef OUTPUTDIR 
173 ifneq ($(MAKECMDGOALS),clobber)
174 -include $(addsuffix .d,$(MAIN_DOCS))
175 endif
176 endif
177
178 # Adobe PDF files  
179 $(PDFDIR)/%.pdf: %/index.xml $(PDFDIR) xslt/latex.xsl %-images-latex-png %-images-latex-pdf
180         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t pdf -o $@ $<
181
182 # PostScript files
183 $(PSDIR)/%.ps: %/index.xml $(PSDIR) xslt/latex.xsl %-images-latex-eps
184         $(DBLATEX) $(DBLATEX_OPTIONS) -I $*/images -t ps -o $@ $<
185
186 %.eps: %.svg
187         $(INKSCAPE) -z -f $< --export-eps=$@
188
189 %.png: %.svg
190         $(INKSCAPE) -z -f $< --export-png=$@
191
192 %.pdf: %.eps
193         $(EPSTOPDF) $<
194
195 %.eps: %.png
196         $(PNGTOPNM) $< | $(PNMTOPS) > $@
197
198 $(HTMLHELPDIR)/%: $(DOCBOOKDIR)/%.xml %-images-htmlhelp
199         $(XSLTPROC) --stringparam htmlhelp.chm $*.chm \
200                                 --stringparam manifest.in.base.dir "$@/" \
201                                 --stringparam base.dir "$@/" \
202         http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl $<
203
204 # Plucker docs
205 $(PLUCKERDIR)/%.pdb: $(HTMLDIR)/%.html 
206         @mkdir -p $(@D)
207         $(PLUCKERBUILD) -v -V 2 --stayonhost --zlib-compression -f $* -p $(PLUCKERDIR) file:$< 
208
209 # Texinfo docs
210 $(TEXINFODIR)/%.texi: $(DOCBOOKDIR)/%.xml
211         @mkdir -p $(@D)
212         cd $(@D) && $(DB2TEXI) $(shell pwd)/$<
213
214 $(TEXINFODIR)/%.info: $(TEXINFODIR)/%.texi
215         $(MAKEINFO) --no-validate --force -o $@ "$<"
216
217 # Manpages
218 $(MANPAGEDIR3)/smb.conf.5.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/parameters.global.xml
219
220 $(SMBDOTCONFDOC)/parameters.all.xml: $(wildcard $(SMBDOTCONFDOC)/*/*.xml) $(SMBDOTCONFDOC)/generate-file-list.sh
221         $(SMBDOTCONFDOC)/generate-file-list.sh $(SMBDOTCONFDOC) > $@
222
223 $(SMBDOTCONFDOC)/parameters.global.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
224         @echo "Generating list of global smb.conf options" 
225         $(XSLTPROC) --xinclude --param smb.context "'G'" --output $(SMBDOTCONFDOC)/parameters.global.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
226
227 $(SMBDOTCONFDOC)/parameters.service.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
228         @echo "Generating list of share-mode smb.conf options" 
229         $(XSLTPROC) --xinclude --param smb.context "'S'" --output $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
230
231 $(OUTPUTDIR):
232         test -d $@ || mkdir $@
233
234 $(OUTPUTDIR)/%: $(DOCBOOKDIR)/%.xml xslt/man.xsl
235         @mkdir -p $(@D)
236         $(XSLTPROC) --output $@ xslt/man.xsl $<
237
238 # Individual smb.conf parameters
239 smb.conf-chunks: $(patsubst $(SMBDOTCONFDOC)/%.xml,$(HTMLDIR)/smb.conf/%.html,$(wildcard $(SMBDOTCONFDOC)/*/*.xml))
240         
241 $(HTMLDIR)/smb.conf/%.html: $(SMBDOTCONFDOC)/%.xml
242         @mkdir -p $(@D)
243         $(XSLTPROC) --output $@ xslt/smb.conf-html.xsl $<
244
245 # Pearson compatible XML
246 $(PEARSONDIR)/%.xml: %/index.xml xslt/pearson.xsl
247         @mkdir -p $(@D)
248         $(XSLTPROC) --xinclude --output $@ xslt/sambadoc2pearson.xsl $<
249
250 $(PEARSONDIR)/%.report.html: $(PEARSONDIR)/%.xml
251         @mkdir -p $(@D)
252         -$(XMLLINT) --valid --noout $< 2> $@
253
254 # Validation verification
255 %-validate: %/index.xml
256         cd $(<D) && $(XMLLINT) --xinclude --noent --postvalid --noout $(<F)
257
258 # Find undocumented parameters
259 undocumented: $(SMBDOTCONFDOC)/parameters.all.xml scripts/find_missing_doc.pl scripts/find_missing_manpages.pl
260         $(PERL) scripts/find_missing_doc.pl $(SRCDIR)
261         $(PERL) scripts/find_missing_manpages.pl $(SRCDIR)
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
290 # Always keep intermediate files if we can
291 .SECONDARY:
292 .PHONY: clean clobber archive release everything all