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