docs: manual: fix formatting
[platform/upstream/gstreamer.git] / docs / manuals.mak
index 91940a6..c0fec85 100644 (file)
-# Included by directories containing manuals.
-# Expects the following to be defined:
-# manualname
-# htmlname
-# sgml_files
-# fig_files
-# eps_files
-# png_files
-
-PDFFILES=$(manualname).pdf
-PSFILES=$(manualname).ps
-
-if HAVE_FIG2DEV
-$(manualname)/$(htmlname): $(sgml_files) $(png_files)
-else
-$(manualname)/$(htmlname): $(sgml_files)
-endif
-if HAVE_DB2HTML
-       db2html $(manualname).sgml
-else
-       echo "Can't build $@: don't have db2html tool"
-endif
-
-$(manualname).pdf: $(manualname).ps
-if HAVE_PS2PDF
-       @if [ -r $< ] ; then ps2pdf $< $@ ; fi
-else
-       echo "Can't build $@: don't have ps2pdf tool"
-endif
-
-if HAVE_FIG2DEV
-$(manualname).ps: $(sgml_files) $(eps_files)
-else
-$(manualname).ps: $(sgml_files)
-endif
-if HAVE_PS2PDF
-       @if [ -r $< ] ; then db2ps $(manualname).sgml ; fi
-else
-       echo "Can't build $@: don't have db2ps tool"
-endif
-
-images :
-       mkdir images
-
-images/%.png : %.fig images
-       fig2dev -L png -s 16 $< $@
-
-images/%.eps : %.fig images
-       fig2dev -L eps -s 16 -m 0.5 $< $@
-
-$(manualname)/images:
-       @ln -sf ../images $(manualname)/images
-
-htmldocs: $(manualname)/$(htmlname) $(manualname)/images
-htmldist: htmldocs
-       @if [ -r $(manualname)/$(htmlname) ] ; then \
-           echo "Adding $(manualname)/$(htmlname) to distribution" ; \
-           $(mkinstalldirs) $(distdir)/$(manualname) ; \
-           cp -a $(manualname)/*.html $(distdir)/$(manualname)/ ; \
-       else \
-           echo "Skipping $(manualname)/$(htmlname) from distribution: can't build" ; \
-       fi
-
-pdfdocs: $(PDFFILES)
-pdfdist: pdfdocs
-       @for a in $(PDFFILES) ; do \
-       if [ -r $$a ] ; then \
-           echo "Adding $$a to distribution" ; \
-           cp -a $$a $(distdir)/ ; \
-       else \
-           echo "Skipping $$a from distribution: can't build" ; \
-       fi \
-       done
-
-psdocs: $(PSFILES)
-psdist: psdocs
-       @for a in $(PSFILES) ; do \
-       if [ -r $$a ] ; then \
-           echo "Adding $$a to distribution" ; \
-           cp -a $$a $(distdir)/ ; \
-       else \
-           echo "Skipping $$a from distribution: can't build" ; \
-       fi \
-       done
-
-# Data to install, in the usual automake way
-docdatadir   = $(datadir)/gstreamer
-docdata_DATA = $(PDFFILES) $(PSFILES)
-
-htmlinst:
-       @if [ -r $(manualname)/$(htmlname) ] ; then \
-           echo "Installing $(manualname)" ; \
-           $(mkinstalldirs) $(DESTDIR)$(docdatadir)/$(manualname) ; \
-           $(mkinstalldirs) $(DESTDIR)$(docdatadir)/$(manualname)/images ; \
-           $(INSTALL_DATA) $(manualname)/*.html $(DESTDIR)$(docdatadir)/$(manualname) ; \
-           for a in "x" $(png_files); do \
-           if [ "x$$a" != "xx" ] ; then \
-           if [ -r $$a ] ; then \
-           $(INSTALL_DATA) $$a $(DESTDIR)$(docdatadir)/$(manualname)/images ; \
-           fi; fi; done \
-       else \
-           if [ -r $(srcdir)/$(manualname)/$(htmlname) ] ; then \
-               echo "Installing $(srcdir)/$(manualname)" ; \
-               $(mkinstalldirs) $(DESTDIR)$(docdatadir)/$(manualname) ; \
-               $(mkinstalldirs) $(DESTDIR)$(docdatadir)/$(manualname)/images ; \
-               $(INSTALL_DATA) $(srcdir)/$(manualname)/*.html $(DESTDIR)$(docdatadir)/$(manualname) ; \
-               for a in "x" $(png_files); do \
-               if [ "x$$a" != "xx" ] ; then \
-               if [ -r $$a ] ; then \
-               $(INSTALL_DATA) $$a $(DESTDIR)$(docdatadir)/$(manualname)/images ; \
-               fi; fi; done \
-           else \
-               echo "NOT installing HTML documentation: not present, and can't generate" ; \
-           fi \
-       fi
-
-htmluninst:
-       $(RM) -rf $(DESTDIR)$(docdatadir)/$(manualname)
-
-all-local: htmldocs pdfdocs psdocs
-clean-local:
-       $(RM) -rf $(manualname)/ $(manualname).junk/ images/*.eps images/*.png *.eps *.png *.ps *.pdf *.aux *.dvi *.log *.tex DBTOHTML_OUTPUT_DIR*
-dist-hook: htmldist pdfdist psdist
-install-data-local: htmlinst
-uninstall-local: htmluninst
+### These are all generic; we set all the variables we need
+
+# intermediary build path
+BUILDDIR = build
+# same for images
+BUILDIMAGESDIR = $(BUILDDIR)/images
+
+# images
+# right now, we only allow .png and .fig as source
+# we might add more later if we feel the need
+
+# PNG's can be source or built from .fig
+PNG = $(strip $(PNG_SRC) $(FIG_SRC:.fig=.png))
+# EPS .ps files can be built from .png or .fig
+EPS = $(strip $(FIG_SRC:.fig=.ps) $(PNG_SRC:.png=.ps))
+# PDF .pdf files can be built from .png or .fig
+PDF = $(strip $(FIG_SRC:.fig=.pdf) $(PNG_SRC:.png=.pdf))
+
+# where we expect to find images during building, whether by copying
+# or by generating them
+PNG_BUILT = $(foreach file, $(PNG), $(BUILDIMAGESDIR)/$(file))
+EPS_BUILT = $(foreach file, $(EPS), $(BUILDIMAGESDIR)/$(file))
+PDF_BUILT = $(foreach file, $(PDF), $(BUILDIMAGESDIR)/$(file))
+
+SRC = $(XML) $(PNG_SRC) $(FIG_SRC) $(CSS) $(EXTRA_SRC)
+
+# generate A4 docs
+PAPER_LOCALE = nl_NL
+
+### generate all documentation by default
+# hook in html generation
+all-local: html
+
+# can we generate HTML ?
+if     DOC_HTML
+HTML_DAT = html
+HTML_TARGET = html/index.html
+else  #!DOC_HTML
+HTML_DAT =
+HTML_TARGET =
+endif #DOC_HTML
+html: $(HTML_TARGET)
+
+# can we generate PS ?
+if     DOC_PS
+PS_DAT = $(DOC).ps
+else  #!DOC_PS
+PS_DAT =
+endif #DOC_PS
+ps: $(PS_DAT)
+
+# can we generate PDF ?
+if     DOC_PDF
+PDF_DAT = $(DOC).pdf
+else  #!DOC_PDF
+PDF_DAT =
+endif #DOC_PDF
+pdf: $(PDF_DAT)
+
+debug:
+       @echo "outputting some useful debug information"
+       @echo "Source XML:"
+       @echo "XML: '$(XML)'"
+       @echo "CSS: '$(CSS)'"
+       @echo "Source image files:"
+       @echo "PNG_SRC: '$(PNG_SRC)'"
+       @echo "FIG_SRC: '$(FIG_SRC)'"
+       @echo "All used image files:"
+       @echo "PNG: '$(PNG)'"
+       @echo "EPS: '$(EPS)'"
+       @echo "PDF: '$(PDF)'"
+       @echo "All used image files in their built path:"
+       @echo "PNG_BUILT: '$(PNG_BUILT)'"
+       @echo "EPS_BUILT: '$(EPS_BUILT)'"
+       @echo "PDF_BUILT: '$(PDF_BUILT)'"
+       @echo "End result products:"
+       @echo "HTML_DAT: '$(HTML_DAT)'"
+       @echo "PS_DAT:   '$(PS_DAT)'"
+       @echo "PDF_DAT:  '$(PDF_DAT)'"
+
+# a rule to copy all of the source for docs into $(builddir)/build
+$(BUILDDIR)/$(MAIN): $(XML) $(CSS) $(EXTRA_SRC)
+       @-mkdir -p $(BUILDDIR); \
+       if test "x$(EXTRA_SRC)" != "x"; then for a in $(EXTRA_SRC); do cp $(srcdir)/$$a $(BUILDDIR); done; fi ; \
+       for a in $(XML); do cp $(srcdir)/$$a $(BUILDDIR); done ; \
+       for a in $(CSS); do cp $(srcdir)/$$a $(BUILDDIR); done ; \
+       cp ../version.entities $(BUILDDIR) ; \
+       cp $(top_srcdir)/docs/url.entities $(BUILDDIR)
+
+html/index.html: $(BUILDDIR)/$(MAIN) $(PNG_BUILT) $(FIG_SRC)
+       @$(MAKE) check-local
+       @echo "*** Generating HTML output ***"
+       @-mkdir -p html
+       @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities
+       @cd $(BUILDDIR) && $(XSLTPROC) -o ../html/ --stringparam chunker.output.encoding UTF-8 --stringparam  use.id.as.filename 1 $(XSLTPROC_FLAGS) "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl" $(MAIN)
+       @test "x$(CSS)" != "x" && \
+          echo "Copying .css files: $(CSS)" && \
+          cp $(srcdir)/$(CSS) html
+       @test "x$(PNG)" != "x" && \
+          echo "Copying .png images: $(PNG_BUILT)" && \
+         mkdir -p html/images && \
+          cp $(PNG_BUILT) html/images || true
+
+$(DOC).ps: $(BUILDDIR)/$(MAIN) $(EPS_BUILT) $(PNG_SRC) $(FIG_SRC)
+       @$(MAKE) check-local
+       @echo "*** Generating PS output ***"
+       @cp -f $(srcdir)/../image-eps $(BUILDDIR)/image.entities
+       cd $(BUILDDIR) && SP_ENCODING="UTF-8" docbook2ps -o .. $(MAIN)
+#      export LC_PAPER=$(PAPER_LOCALE) && cd $(BUILDDIR) && xmlto ps -o .. $(MAIN)
+
+$(DOC).pdf: $(DOC).ps
+       @$(MAKE) check-local
+       @echo "*** Generating PDF output ***"
+       @ps2pdf $(DOC).ps
+
+#$(DOC).pdf: $(MAIN) $(PDF) $(FIG_SRC)
+#      @echo "*** Generating PDF output ***"
+#      @cp -f $(srcdir)/../image-pdf image.entities
+#      @export LC_PAPER=$(PAPER_LOCALE) && xmlto pdf $(MAIN)
+#      @rm image.entities
 
+clean-local:
+       -$(RM) -r $(BUILDDIR)
+       -$(RM) -r html
+       -$(RM) $(DOC).ps
+       -$(RM) $(DOC).pdf
+       -$(RM) -r www
+
+### image generation
+
+# copy png from source dir png
+$(BUILDIMAGESDIR)/%.png: $(srcdir)/%.png
+       @echo "Copying $< to $@"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @cp $< $@
+# make png from fig
+$(BUILDIMAGESDIR)/%.png: %.fig
+       @echo "Generating $@ from $<"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @fig2dev -Lpng $< $@
+
+# make ps(EPS) from fig
+$(BUILDIMAGESDIR)/%.ps: %.fig
+       @echo "Generating $@ from $<"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @fig2dev -Leps $< $@
+
+# make pdf from fig
+$(BUILDIMAGESDIR)/%.pdf: %.fig
+       @echo "Generating $@ from $<"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @fig2dev -Lpdf $< $@
+
+# make pdf from png
+$(BUILDIMAGESDIR)/%.pdf: %.png
+       @echo "Generating $@ from $<"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @cat $< | pngtopnm | pnmtops -noturn 2> /dev/null | epstopdf --filter --outfile $@ 2> /dev/null
+
+# make ps(EPS) from png
+$(BUILDIMAGESDIR)/%.ps: %.png
+       @echo "Generating $@ from $<"
+       @mkdir -p $(BUILDIMAGESDIR)
+       @cat $< | pngtopnm | pnmtops -noturn > $@ 2> /dev/null
+
+# make sure xml validates properly
+check-local: $(BUILDDIR)/$(MAIN)
+       @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities
+       @cd $(BUILDDIR) && xmllint -noout -valid $(MAIN)
+       @cd $(BUILDDIR) && \
+       if [ `which curl` ]; then \
+    links=`$(XSLTPROC) $(XSLTPROC_FLAGS) --xinclude $(abs_top_srcdir)/docs/list-ulink.xsl $(MAIN) | egrep '^http' | sort | uniq` && \
+    have_error=0 && \
+    for link in $$links; do \
+      code=`curl -s -m20 -o /dev/null -I -w "%{http_code}" $$link`; \
+      if [ \( $$? -ne 0 \) -o \( $$code -gt 399 \) ]; then \
+        echo "exit_status=$$?, http_code=$$code: $$link"; \
+        grep -Hnr "$$link" .; \
+        have_error=1; \
+      fi; \
+    done \
+  fi
+
+# avoid 'cp: cannot create regular file `build/image.entities': File exists'
+# errors during 'make distcheck' by disabling parallel builds
+.NOTPARALLEL: