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