Issue an explicit warning if the docs can't be built at 'make dist'
[platform/upstream/libvorbis.git] / doc / Makefile.am
1 ## Process this with automake to create Makefile.in
2
3 SUBDIRS = vorbisfile vorbisenc
4
5 docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)
6
7 ### all of the static docs, commited to SVN and included as is
8 static_docs = \
9         draft-kerr-avt-vorbis-rtp-03.txt \
10         eightphase.png \
11         evenlsp.png \
12         floor1_inverse_dB_table.html \
13         floorval.png \
14         fourphase.png \
15         framing.html \
16         helper.html \
17         index.html \
18         lspmap.png \
19         oddlsp.png \
20         oggstream.html \
21         programming.html \
22         squarepolar.png \
23         stereo.html \
24         stream.png \
25         v-comment.html \
26         vorbis-clip.txt \
27         vorbis-errors.txt \
28         vorbis-fidelity.html \
29         vorbis.html \
30         vorbisword2.png \
31         wait.png \
32         white-ogg.png \
33         white-xifish.png
34
35 ### FIXME: bits needed by the spec which lives in xml
36 SPEC_PNG = \
37         components.png \
38         floor1-1.png \
39         floor1-2.png \
40         floor1-3.png \
41         floor1-4.png \
42         hufftree.png \
43         hufftree-under.png \
44         residue-pack.png \
45         residue2.png \
46         white-xifish.png \
47         window1.png \
48         window2.png
49 SPEC_PDF = xifish.pdf
50
51 # FIXME: also needed here
52 #       white-xifish.png 
53
54 built_docs = Vorbis_I_spec.html Vorbis_I_spec.pdf
55
56 # conditionally make the generated documentation
57 if BUILD_DOCS
58 doc_DATA = $(static_docs) $(SPEC_PNG) $(built_docs)
59 else
60 doc_DATA = $(static_docs) $(SPEC_PNG)
61 endif
62
63 EXTRA_DIST = $(static_docs) $(doc_sources) \
64         $(SPEC_PNG) $(SPEC_PDF) $(built_docs)
65
66 doc_sources = xml/Vorbis_I_spec.xml \
67         xml/01-introduction.xml \
68         xml/02-bitpacking.xml \
69         xml/03-codebook.xml \
70         xml/04-codec.xml \
71         xml/05-comment.xml \
72         xml/06-floor0.xml \
73         xml/07-floor1.xml \
74         xml/08-residue.xml \
75         xml/09-helper.xml \
76         xml/10-tables.xml \
77         xml/a1-encapsulation_ogg.xml \
78         xml/a2-encapsulation_rtp.xml \
79         xml/footer.xml \
80         xml/spec-common.xsl \
81         xml/spec-fo.xsl \
82         xml/spec-html.xsl
83
84 # these are expensive; only remove if we have to
85 DISTCLEANFILES = $(built_docs)
86 CLEANFILES = Vorbis_I_spec.fo spec.aux spec.log spec.out
87
88 # rules for temporary build dir for spec
89 BUILDDIR = build
90 # how to copy images to build dir
91 SPEC_PNG_BUILD = $(foreach file, $(SPEC_PNG), $(BUILDDIR)/$(file))
92 SPEC_PDF_BUILD = $(foreach file, $(SPEC_PDF), $(BUILDDIR)/$(file))
93 $(BUILDDIR)/%: $(srcdir)/%
94         @echo "Copying $< to $@"
95         @mkdir -p $(BUILDDIR)
96         @cp $< $@
97
98 # how to copy the xml to build dir; cheat by only targeting the main one
99 $(BUILDDIR)/Vorbis_I_spec.xml: $(doc_sources)
100         @mkdir -p $(BUILDDIR)
101         @for file in $(doc_sources); do cp $(srcdir)/$$file $(BUILDDIR); done
102 # translate the draft rtp.txt to .xml in the BUILDDIR
103 $(BUILDDIR)/draft-rtp.xml: draft-kerr-avt-vorbis-rtp-03.txt
104         cat $< | sed 's/\f//g' > $@
105 # cat $< | sed 's/\f//g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g' > $@
106
107 # explicit rules for generating docs
108 if BUILD_DOCS
109 Vorbis_I_spec.html: $(SPEC_PNG_BUILD) $(BUILDDIR)/Vorbis_I_spec.xml
110         cd build; xsltproc --xinclude --output Vorbis_I_spec.html spec-html.xsl Vorbis_I_spec.xml && mv $@ ..
111
112 Vorbis_I_spec.fo: $(BUILDDIR)/Vorbis_I_spec.xml
113         cd build; xsltproc --xinclude --output $@ spec-fo.xsl Vorbis_I_spec.xml && mv $@ ..
114
115 Vorbis_I_spec.pdf: Vorbis_I_spec.fo $(SPEC_PNG_BUILD) $(SPEC_PDF_BUILD)
116         cp $< build/spec.fo # work around a passivetex bug
117         cd build; pdfxmltex --interaction nonstopmode spec.fo
118         cd build; pdfxmltex --interaction nonstopmode spec.fo
119         rm build/spec.fo
120         mv build/spec.pdf $@
121 else
122 Vorbis_I_spec.html: NO_DOCS_ERROR
123 Vorbis_I_spec.pdf: NO_DOCS_ERROR
124 NO_DOCS_ERROR:
125         @echo
126         @echo "*** Documentation has not been built! ***"
127         @echo "Try re-running after passing --enable-docs to configure."
128         @echo
129 endif
130
131 # clean up build dir
132 clean-local:
133         -$(RM) -r $(BUILDDIR)