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