Use default autoconf extension, add some ignore files.
[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 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,dvi,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
57 # Output format targets
58 pdf: $(patsubst %,$(PDFDIR)/%.pdf,$(MAIN_DOCS))
59 dvi: $(patsubst %,$(DVIDIR)/%.dvi,$(MAIN_DOCS))
60 ps: $(patsubst %,$(PSDIR)/%.ps,$(MAIN_DOCS))
61 txt: $(patsubst %,$(TXTDIR)/%.txt,$(MAIN_DOCS))
62 txt-chunks: $(addsuffix -txt-chunks,$(MAIN_DOCS))
63 fo: $(patsubst %,$(FODIR)/%.fo,$(MAIN_DOCS))
64 fo-pdf: $(patsubst %,$(FOPDFDIR)/%.pdf,$(MAIN_DOCS))
65 tex: $(addsuffix .tex,$(MAIN_DOCS))
66 texi: $(patsubst %,$(TEXINFODIR)/%.texi,$(MAIN_DOCS))
67 texiinfo: $(patsubst %,$(TEXINFODIR)/%.info,$(MAIN_DOCS))
68 manpages3: $(patsubst $(MANPAGEDIR3)/%.xml,$(OUTPUTDIR)/manpages-3/%,$(MANPAGES3))
69 pearson: $(PEARSONDIR)/Samba3-HOWTO.xml
70 pearson-verify: $(PEARSONDIR)/Samba3-HOWTO.report.html
71 plucker: $(patsubst %,$(PLUCKERDIR)/%.pdb,$(MAIN_DOCS))
72 htmlman3: $(patsubst $(MANPAGEDIR3)/%.xml,$(HTMLDIR)/manpages-3/%.html,$(MANPAGES3)) $(HTMLDIR)/manpages-3/index.html
73 html-single: $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS))
74 html: $(patsubst %,$(HTMLDIR)/%/index.html,$(MAIN_DOCS)) $(HTMLDIR)/index.html
75 htmlhelp: $(addprefix $(HTMLHELPDIR)/,$(MAIN_DOCS))
76 validate: $(addsuffix -validate,$(MAIN_DOCS))
77
78 # Intermediate docbook docs
79 #
80 $(DOCBOOKDIR)/%.xml: %/index.xml xslt/expand-sambadoc.xsl
81         @echo "Converting Samba-specific tags for $*..."
82         @mkdir -p $(@D)
83         $(XSLTPROC) --stringparam latex.imagebasedir "$*/" --stringparam noreference 1 --xinclude --output $@ xslt/expand-sambadoc.xsl $<
84
85 $(DOCBOOKDIR)/manpages-3/%.xml: $(MANPAGEDIR3)/%.xml xslt/expand-sambadoc.xsl
86         @mkdir -p $(@D)
87         $(XSLTPROC) --xinclude --stringparam noreference 1 --output $@ xslt/expand-sambadoc.xsl $<
88
89 $(DOCBOOKDIR)/manpages-3/index.xml: $(MANPAGES3) xslt/manpage-summary.xsl
90         @mkdir -p $(@D)
91         echo "<article><variablelist>" > $@
92         $(XSLTPROC) xslt/manpage-summary.xsl $(MANPAGES3) >> $@
93         @echo "</variablelist></article>" >> $@
94
95 # HTML docs
96
97 $(HTMLDIR)/index.html: htmldocs.html
98         @mkdir -p $(@D)
99         cp $< $@
100         
101 $(HTMLDIR)/%/index.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/%/samba.css xslt/html-chunk.xsl %-images-html-chunks
102         @mkdir -p $(@D)
103         $(XSLTPROC) --stringparam base.dir "$(HTMLDIR)/$*/" xslt/html-chunk.xsl $<
104
105 # Single large HTML files
106 $(OUTPUTDIR)/%/samba.css: xslt/html/samba.css
107         @mkdir -p $(@D)
108         cp $< $@
109
110 $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS)): $(HTMLDIR)/%.html: %-images-html-single
111
112 $(HTMLDIR)/%.html: $(DOCBOOKDIR)/%.xml $(HTMLDIR)/samba.css xslt/html.xsl 
113         $(XSLTPROC) --output $@ xslt/html.xsl $<
114
115 # Attributions
116 %-attributions.xml: 
117         @echo "Generating attributions file $@ from $*/"
118         $(XSLTPROC) --xinclude -o $@ xslt/generate-attributions.xsl $*/index.xml 
119
120 # Text files
121 $(TXTDIR)/%.txt: $(HTMLDIR)/%.html
122         @mkdir -p $(@D)
123         $(HTML2TEXT) -nobs -style pretty -o $@ $<
124
125 # Tex files
126 %.tex: %/index.xml xslt/latex.xsl
127         @echo "Generating $@..."
128         @mkdir -p $(@D)
129         $(XSLTPROC) $(DB2LATEX_ARGS) --stringparam latex.imagebasedir "$*/" --xinclude --output $@ xslt/latex.xsl $<
130
131 latexfigures: $(LATEX_FIGURES)
132
133 $(PDFDIR)/%.pdf: %.pdf
134         @mkdir -p $(@D)
135         cp $< $@
136
137 %.idx: %.tex latexfigures
138         -$(PDFLATEX) $<
139
140 %.ind: %.idx
141         $(MAKEINDEX) $<
142
143 # Dependency files
144 %.d: $(DOCBOOKDIR)/%.xml xslt/generate-dependencies.xsl
145         @echo "Generating dependency file for $*" 
146         $(XSLTPROC) \
147                 --novalid \
148                 --stringparam txtbasedir "$(TXTDIR)/$*/" \
149                 --stringparam target "$*" \
150                 -o $@ xslt/generate-dependencies.xsl $<
151         @echo "$*-images-latex-dia = \$$(wildcard \$$(addsuffix .dia, \$$($*-images-latex)))" >> $@
152         @echo "$*-images-latex-eps: \$$(addsuffix .eps, \$$($*-images-latex))" >> $@
153         @echo "$*-images-latex-pdf: \$$(patsubst %.dia, %.pdf, \$$($*-images-latex-dia))" >> $@
154         @echo "$*-images-latex-png: \$$(filter-out \$$(patsubst %.dia,%.png,\$$($*-images-latex-dia)), \$$(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 %.pdf: %.tex %.ind latexfigures %-images-latex-png %-images-latex-pdf
181         -$(PDFLATEX) $<
182         $(THUMBPDF) --quiet $*.pdf
183         -$(PDFLATEX) $<
184
185 # DVI files
186 $(DVIDIR)/%.dvi: %.dvi
187         @mkdir -p $(@D)
188         cp $< $@
189
190 %.dvi: %.tex %.idx %-images-latex-eps
191         -$(LATEX) $< 
192
193 %.eps: %.dia
194         $(DIA) -t eps-builtin -e $@ $<
195
196 %.png: %.dia
197         $(DIA) -e $@ $<
198
199 %.pdf: %.eps
200         $(EPSTOPDF) $<
201
202 %.eps: %.png
203         $(PNGTOPNM) $< | $(PNMTOPS) > $@
204
205 # PostScript files
206 $(PSDIR)/%.ps: $(DVIDIR)/%.dvi
207         @mkdir -p $(@D)
208         $(DVIPS) -o $@ $<
209
210 # Fo
211 $(FODIR)/%.fo: $(DOCBOOKDIR)/%.xml
212         @mkdir -p $(@D)
213         $(XSLTPROC) --output $@ xslt/fo.xsl $<
214
215 # PDF thru Fo
216 $(FOPDFDIR)/%.pdf: $(FODIR)/%.fo
217         @mkdir -p $(@D)
218         JAVA_OPTS=-Xmx250m $(FOP) -q -d $< -pdf $@
219
220 $(HTMLHELPDIR)/%: $(DOCBOOKDIR)/%.xml %-images-htmlhelp
221         $(XSLTPROC) --stringparam htmlhelp.chm $*.chm \
222                                 --stringparam manifest.in.base.dir "$@/" \
223                                 --stringparam base.dir "$@/" \
224         http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl $<
225
226 # Plucker docs
227 $(PLUCKERDIR)/%.pdb: $(HTMLDIR)/%.html 
228         @mkdir -p $(@D)
229         $(PLUCKERBUILD) -v -V 2 --stayonhost --zlib-compression -f $* -p $(PLUCKERDIR) file:$< 
230
231 # Texinfo docs
232 $(TEXINFODIR)/%.texi: $(DOCBOOKDIR)/%.xml
233         @mkdir -p $(@D)
234         cd $(@D) && $(DB2TEXI) $(shell pwd)/$<
235
236 $(TEXINFODIR)/%.info: $(TEXINFODIR)/%.texi
237         $(MAKEINFO) --no-validate --force -o $@ "$<"
238
239 # Manpages
240 $(MANPAGEDIR3)/smb.conf.5.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/parameters.global.xml
241
242 $(SMBDOTCONFDOC)/parameters.all.xml: $(wildcard $(SMBDOTCONFDOC)/*/*.xml) $(SMBDOTCONFDOC)/generate-file-list.sh
243         $(SMBDOTCONFDOC)/generate-file-list.sh $(SMBDOTCONFDOC) > $@
244
245 $(SMBDOTCONFDOC)/parameters.global.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
246         @echo "Generating list of global smb.conf options" 
247         $(XSLTPROC) --xinclude --param smb.context "'G'" --output $(SMBDOTCONFDOC)/parameters.global.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
248
249 $(SMBDOTCONFDOC)/parameters.service.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
250         @echo "Generating list of share-mode smb.conf options" 
251         $(XSLTPROC) --xinclude --param smb.context "'S'" --output $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
252
253 $(OUTPUTDIR)/%: $(DOCBOOKDIR)/%.xml xslt/man.xsl
254         @mkdir -p $(@D)
255         $(XSLTPROC) --output $@ xslt/man.xsl $<
256
257 # Individual smb.conf parameters
258 smb.conf-chunks: $(patsubst $(SMBDOTCONFDOC)/%.xml,$(HTMLDIR)/smb.conf/%.html,$(wildcard $(SMBDOTCONFDOC)/*/*.xml))
259         
260 $(HTMLDIR)/smb.conf/%.html: $(SMBDOTCONFDOC)/%.xml
261         @mkdir -p $(@D)
262         $(XSLTPROC) --output $@ xslt/smb.conf-html.xsl $<
263
264 # Pearson compatible XML
265 $(PEARSONDIR)/%.xml: %/index.xml xslt/pearson.xsl
266         @mkdir -p $(@D)
267         $(XSLTPROC) --xinclude --output $@ xslt/sambadoc2pearson.xsl $<
268
269 $(PEARSONDIR)/%.report.html: $(PEARSONDIR)/%.xml
270         @mkdir -p $(@D)
271         -$(XMLLINT) --valid --noout $< 2> $@
272
273 # Validation verification
274 %-validate: %/index.xml
275         cd $(<D) && $(XMLLINT) --xinclude --noent --postvalid --noout $(<F)
276
277 # Find undocumented parameters
278 undocumented: $(SMBDOTCONFDOC)/parameters.all.xml scripts/find_missing_doc.pl scripts/find_missing_manpages.pl
279         $(PERL) scripts/find_missing_doc.pl $(SRCDIR)
280         $(PERL) scripts/find_missing_manpages.pl $(SRCDIR)
281
282 samples: $(DOCBOOKDIR)/Samba3-HOWTO.xml xslt/extract-examples.xsl scripts/indent-smb.conf.pl
283         @mkdir -p $(EXAMPLESDIR)
284         $(XSLTPROC) --xinclude xslt/extract-examples.xsl $< > /dev/null 2> examples/README
285         for I in examples/*.conf; do { ./scripts/indent-smb.conf.pl < $$I > $$I.tmp; mv $$I.tmp $$I; } done
286
287 # Archiving
288 archive: pdf
289         @mkdir -p $(ARCHIVEDIR)
290         cp $(PDFDIR)/Samba3-HOWTO.pdf $(ARCHIVEDIR)/TOSHARG-$(DATETIME).pdf
291         cp $(PDFDIR)/Samba3-ByExample.pdf $(ARCHIVEDIR)/S3bE-$(DATETIME).pdf
292
293 # XSL scripts
294 xslt/html.xsl: xslt/html-common.xsl 
295 xslt/html-chunk.xsl: xslt/html-common.xsl 
296 xslt/latex.xsl: 
297 xslt/expand-sambadoc.xsl: 
298 xslt/generate-attributions.xsl: 
299 xslt/man.xsl:
300 xslt/pearson.xsl:
301
302 distclean clobber: clean
303         rm Makefile.settings config.status config.log configure
304
305 clean: 
306         @echo "Cleaning up..." 
307         rm -rf $(OUTPUTDIR)/* $(DOCBOOKDIR)
308         rm -f $(patsubst %.dia,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
309                         $(patsubst %.dia,%.pdf,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
310                         $(patsubst %.dia,%.eps,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia)))
311         rm -f *.xml *.d *.tpt *.tex *.loc *.toc *.lof *.glo *.idx *.aux
312         rm -f *-images-html*
313         rm -f *-images-latex-* latexfigures
314         rm -f xslt/figures/*pdf
315         rm -f $(SMBDOTCONFDOC)/parameters.*.xml
316         rm -f $(addsuffix .*,$(MAIN_DOCS))
317
318 # Always keep intermediate files if we can
319 .SECONDARY:
320 .PHONY: clean clobber archive release everything all $(TARGETS) latexfigures
321