Fix Samba documentation build for manpages
[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 clean:
57         @echo "Cleaning up..." 
58         rm -rf $(OUTPUTDIR)/* $(DOCBOOKDIR)
59         rm -f $(patsubst %.dia,%.png,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
60                         $(patsubst %.dia,%.pdf,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia))) \
61                         $(patsubst %.dia,%.eps,$(foreach DOC,$(MAIN_DOCS),$($(DOC)-images-latex-dia)))
62         rm -f *.xml *.d *.tpt *.tex *.loc *.toc *.lof *.glo *.idx *.aux
63         rm -f *-images-html*
64         rm -f *-images-latex-* latexfigures
65         rm -f xslt/figures/*pdf
66         rm -f $(SMBDOTCONFDOC)/parameters.*.xml
67         rm -f $(addsuffix .*,$(MAIN_DOCS))
68
69 # Output format targets
70 pdf: $(patsubst %,$(PDFDIR)/%.pdf,$(MAIN_DOCS))
71 dvi: $(patsubst %,$(DVIDIR)/%.dvi,$(MAIN_DOCS))
72 ps: $(patsubst %,$(PSDIR)/%.ps,$(MAIN_DOCS))
73 txt: $(patsubst %,$(TXTDIR)/%.txt,$(MAIN_DOCS))
74 txt-chunks: $(addsuffix -txt-chunks,$(MAIN_DOCS))
75 fo: $(patsubst %,$(FODIR)/%.fo,$(MAIN_DOCS))
76 fo-pdf: $(patsubst %,$(FOPDFDIR)/%.pdf,$(MAIN_DOCS))
77 tex: $(addsuffix .tex,$(MAIN_DOCS))
78 texi: $(patsubst %,$(TEXINFODIR)/%.texi,$(MAIN_DOCS))
79 texiinfo: $(patsubst %,$(TEXINFODIR)/%.info,$(MAIN_DOCS))
80 manpages3: $(patsubst $(MANPAGEDIR3)/%.xml,$(OUTPUTDIR)/manpages-3/%,$(MANPAGES3))
81 pearson: $(PEARSONDIR)/Samba3-HOWTO.xml
82 pearson-verify: $(PEARSONDIR)/Samba3-HOWTO.report.html
83 plucker: $(patsubst %,$(PLUCKERDIR)/%.pdb,$(MAIN_DOCS))
84 htmlman3: $(patsubst $(MANPAGEDIR3)/%.xml,$(HTMLDIR)/manpages-3/%.html,$(MANPAGES3)) $(HTMLDIR)/manpages-3/index.html
85 html-single: $(patsubst %,$(HTMLDIR)/%.html,$(MAIN_DOCS))
86 html: $(patsubst %,$(HTMLDIR)/%/index.html,$(MAIN_DOCS)) $(HTMLDIR)/index.html
87 htmlhelp: $(addprefix $(HTMLHELPDIR)/,$(MAIN_DOCS))
88 validate: $(addsuffix -validate,$(MAIN_DOCS))
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 1 --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 1 --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
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         $(XSLTPROC) $(DB2LATEX_ARGS) --stringparam latex.imagebasedir "$*/" --xinclude --output $@ xslt/latex.xsl $<
143
144 latexfigures: $(LATEX_FIGURES)
145
146 $(PDFDIR)/%.pdf: %.pdf
147         @mkdir -p $(@D)
148         cp $< $@
149
150 %.idx: %.tex latexfigures
151         -$(PDFLATEX) $<
152
153 %.ind: %.idx
154         $(MAKEINDEX) $<
155
156 # Dependency files
157 %.d: $(DOCBOOKDIR)/%.xml xslt/generate-dependencies.xsl
158         @echo "Generating dependency file for $*" 
159         $(XSLTPROC) \
160                 --novalid \
161                 --stringparam txtbasedir "$(TXTDIR)/$*/" \
162                 --stringparam target "$*" \
163                 -o $@ xslt/generate-dependencies.xsl $<
164         @echo "$*-images-latex-dia = \$$(wildcard \$$(addsuffix .dia, \$$($*-images-latex)))" >> $@
165         @echo "$*-images-latex-eps: \$$(addsuffix .eps, \$$($*-images-latex))" >> $@
166         @echo "$*-images-latex-pdf: \$$(patsubst %.dia, %.pdf, \$$($*-images-latex-dia))" >> $@
167         @echo "$*-images-latex-png: \$$(filter-out \$$(patsubst %.dia,%.png,\$$($*-images-latex-dia)), \$$(addsuffix .png, \$$($*-images-latex)))" >> $@
168
169         @echo >> $@
170         @echo "\$$(HTMLDIR)/%: $*/%" >> $@
171         @echo " @mkdir -p \$$(@D)" >> $@
172         @echo " @cp \$$< \$$@" >> $@
173         @echo >> $@
174         @echo "\$$(HTMLDIR)/$*/%: $*/%" >> $@
175         @echo " @mkdir -p \$$(@D)" >> $@
176         @echo " @cp \$$< \$$@" >> $@
177         @echo >> $@
178         @echo "\$$(HTMLHELPDIR)/$*/%: $*/%" >> $@
179         @echo " @mkdir -p \$$(@D)" >> $@
180         @echo " @cp \$$< \$$@" >> $@
181         @echo >> $@
182         @echo "$*-images-html-single: \$$(addprefix \$$(HTMLDIR)/, \$$($*-images-html))" >> $@
183         @echo "$*-images-html-chunks: \$$(addprefix \$$(HTMLDIR)/$*/, \$$($*-images-html))" >> $@
184         @echo "$*-images-htmlhelp: \$$(addprefix \$$(HTMLHELPDIR)/$*/, \$$($*-images-html))" >> $@
185
186 ifdef OUTPUTDIR 
187 ifneq ($(MAKECMDGOALS),clobber)
188 -include $(addsuffix .d,$(MAIN_DOCS))
189 endif
190 endif
191
192 # Adobe PDF files
193 %.pdf: %.tex %.ind latexfigures %-images-latex-png %-images-latex-pdf
194         -$(PDFLATEX) $<
195         $(THUMBPDF) --quiet $*.pdf
196         -$(PDFLATEX) $<
197
198 # DVI files
199 $(DVIDIR)/%.dvi: %.dvi
200         @mkdir -p $(@D)
201         cp $< $@
202
203 %.dvi: %.tex %.idx %-images-latex-eps
204         -$(LATEX) $< 
205
206 %.eps: %.dia
207         $(DIA) -t eps-builtin -e $@ $<
208
209 %.png: %.dia
210         $(DIA) -e $@ $<
211
212 %.pdf: %.eps
213         $(EPSTOPDF) $<
214
215 %.eps: %.png
216         $(PNGTOPNM) $< | $(PNMTOPS) > $@
217
218 # PostScript files
219 $(PSDIR)/%.ps: $(DVIDIR)/%.dvi
220         @mkdir -p $(@D)
221         $(DVIPS) -o $@ $<
222
223 # Fo
224 $(FODIR)/%.fo: $(DOCBOOKDIR)/%.xml
225         @mkdir -p $(@D)
226         $(XSLTPROC) --output $@ xslt/fo.xsl $<
227
228 # PDF thru Fo
229 $(FOPDFDIR)/%.pdf: $(FODIR)/%.fo
230         @mkdir -p $(@D)
231         JAVA_OPTS=-Xmx250m $(FOP) -q -d $< -pdf $@
232
233 $(HTMLHELPDIR)/%: $(DOCBOOKDIR)/%.xml %-images-htmlhelp
234         $(XSLTPROC) --stringparam htmlhelp.chm $*.chm \
235                                 --stringparam manifest.in.base.dir "$@/" \
236                                 --stringparam base.dir "$@/" \
237         http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl $<
238
239 # Plucker docs
240 $(PLUCKERDIR)/%.pdb: $(HTMLDIR)/%.html 
241         @mkdir -p $(@D)
242         $(PLUCKERBUILD) -v -V 2 --stayonhost --zlib-compression -f $* -p $(PLUCKERDIR) file:$< 
243
244 # Texinfo docs
245 $(TEXINFODIR)/%.texi: $(DOCBOOKDIR)/%.xml
246         @mkdir -p $(@D)
247         cd $(@D) && $(DB2TEXI) $(shell pwd)/$<
248
249 $(TEXINFODIR)/%.info: $(TEXINFODIR)/%.texi
250         $(MAKEINFO) --no-validate --force -o $@ "$<"
251
252 # Manpages
253 $(MANPAGEDIR3)/smb.conf.5.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/parameters.global.xml
254
255 $(SMBDOTCONFDOC)/parameters.all.xml: $(wildcard $(SMBDOTCONFDOC)/*/*.xml) $(SMBDOTCONFDOC)/generate-file-list.sh
256         $(SMBDOTCONFDOC)/generate-file-list.sh $(SMBDOTCONFDOC) > $@
257
258 $(SMBDOTCONFDOC)/parameters.global.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
259         @echo "Generating list of global smb.conf options" 
260         $(XSLTPROC) --xinclude --param smb.context "'G'" --output $(SMBDOTCONFDOC)/parameters.global.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
261
262 $(SMBDOTCONFDOC)/parameters.service.xml: $(SMBDOTCONFDOC)/parameters.all.xml $(SMBDOTCONFDOC)/generate-context.xsl
263         @echo "Generating list of share-mode smb.conf options" 
264         $(XSLTPROC) --xinclude --param smb.context "'S'" --output $(SMBDOTCONFDOC)/parameters.service.xml $(SMBDOTCONFDOC)/generate-context.xsl $<
265
266 $(OUTPUTDIR)/%: $(DOCBOOKDIR)/%.xml xslt/man.xsl
267         @mkdir -p $(@D)
268         $(XSLTPROC) --output $@ xslt/man.xsl $<
269
270 # Individual smb.conf parameters
271 smb.conf-chunks: $(patsubst $(SMBDOTCONFDOC)/%.xml,$(HTMLDIR)/smb.conf/%.html,$(wildcard $(SMBDOTCONFDOC)/*/*.xml))
272         
273 $(HTMLDIR)/smb.conf/%.html: $(SMBDOTCONFDOC)/%.xml
274         @mkdir -p $(@D)
275         $(XSLTPROC) --output $@ xslt/smb.conf-html.xsl $<
276
277 # Pearson compatible XML
278 $(PEARSONDIR)/%.xml: %/index.xml xslt/pearson.xsl
279         @mkdir -p $(@D)
280         $(XSLTPROC) --xinclude --output $@ xslt/sambadoc2pearson.xsl $<
281
282 $(PEARSONDIR)/%.report.html: $(PEARSONDIR)/%.xml
283         @mkdir -p $(@D)
284         -$(XMLLINT) --valid --noout $< 2> $@
285
286 # Validation verification
287 %-validate: %/index.xml
288         cd $(<D) && $(XMLLINT) --xinclude --noent --postvalid --noout $(<F)
289
290 # Find undocumented parameters
291 undocumented: $(SMBDOTCONFDOC)/parameters.all.xml scripts/find_missing_doc.pl scripts/find_missing_manpages.pl
292         $(PERL) scripts/find_missing_doc.pl $(SRCDIR)
293         $(PERL) scripts/find_missing_manpages.pl $(SRCDIR)
294
295 samples: $(DOCBOOKDIR)/Samba3-HOWTO.xml xslt/extract-examples.xsl scripts/indent-smb.conf.pl
296         @mkdir -p $(EXAMPLESDIR)
297         $(XSLTPROC) --xinclude xslt/extract-examples.xsl $< > /dev/null 2> examples/README
298         for I in examples/*.conf; do { ./scripts/indent-smb.conf.pl < $$I > $$I.tmp; mv $$I.tmp $$I; } done
299
300 # Archiving
301 archive: pdf
302         @mkdir -p $(ARCHIVEDIR)
303         cp $(PDFDIR)/Samba3-HOWTO.pdf $(ARCHIVEDIR)/TOSHARG-$(DATETIME).pdf
304         cp $(PDFDIR)/Samba3-ByExample.pdf $(ARCHIVEDIR)/S3bE-$(DATETIME).pdf
305
306 # XSL scripts
307 xslt/html.xsl: xslt/html-common.xsl 
308 xslt/html-chunk.xsl: xslt/html-common.xsl 
309 xslt/latex.xsl: 
310 xslt/expand-sambadoc.xsl: 
311 xslt/generate-attributions.xsl: 
312 xslt/man.xsl:
313 xslt/pearson.xsl:
314
315 distclean clobber: clean
316         rm Makefile.settings config.status config.log configure
317
318
319 # Always keep intermediate files if we can
320 .SECONDARY:
321 .PHONY: clean clobber archive release everything all $(TARGETS) latexfigures
322