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