Steal M4 macros from GHC
authorPHO <pho@cielonegro.org>
Thu, 17 May 2012 16:49:26 +0000 (01:49 +0900)
committerPHO <pho@cielonegro.org>
Thu, 17 May 2012 16:49:26 +0000 (01:49 +0900)
.gitignore
am/docbook.am [new file with mode: 0644]
configure.ac
m4/docbook.m4 [new file with mode: 0644]
src/Makefile.am
src/mission-chan.xml

index cc8dc83afc204f102b3e158abcf136c0aeb76a77..4a45c0967d9cbfb6cb8a807b5579f01c40c6fb2f 100644 (file)
@@ -1,10 +1,11 @@
 *.cache
 *.log
-Makefile
+
 Makefile.in
 aclocal.m4
-config.status
 configure
 configure.scan
 install-sh
 missing
+
+_build
diff --git a/am/docbook.am b/am/docbook.am
new file mode 100644 (file)
index 0000000..c573c46
--- /dev/null
@@ -0,0 +1,24 @@
+DOCBOOK_STYLESHEET = \
+       http://docbook.sourceforge.net/release/xsl/current/xhtml-1_1/chunk.xsl
+
+EXTRA_DIST = $(DOCBOOK_FILES)
+
+html-local:
+       "$(XmllintCmd)" \
+               --noout \
+               --xinclude \
+               --postvalid \
+               --noent \
+               "$(srcdir)/$(DOCBOOK_MAIN)"
+
+       "$(XsltprocCmd)" \
+               --xinclude \
+               --stringparam base.dir "html/" \
+               --stringparam chunker.output.indent "yes" \
+               --stringparam use.id.as.filename "yes" \
+               --nonet \
+               "$(DOCBOOK_STYLESHEET)" \
+               "$(srcdir)/$(DOCBOOK_MAIN)"
+
+clean-local:
+       -rm -rf "html"
index d3334b11fbaab22c3dc4fd0982b714e449845bb3..3c9db491bc4e5f35183fe2d9f2c1539f5574171f 100644 (file)
@@ -6,16 +6,13 @@ AC_INIT([oh-my-god], [0.1], [null@example.org])
 AM_INIT_AUTOMAKE
 AM_MAINTAINER_MODE
 
-# Checks for programs.
+# Checks for the DocBook toolchain.
+FP_CHECK_DOCBOOK_DTD
+FP_DOCBOOK_XSL
+FP_PROG_DBLATEX
 
-# Checks for libraries.
-
-# Checks for header files.
-
-# Checks for typedefs, structures, and compiler characteristics.
-
-# Checks for library functions.
-
-AC_CONFIG_FILES([Makefile
-                 src/Makefile])
+AC_CONFIG_FILES([
+    Makefile
+    src/Makefile
+])
 AC_OUTPUT
diff --git a/m4/docbook.m4 b/m4/docbook.m4
new file mode 100644 (file)
index 0000000..188e31e
--- /dev/null
@@ -0,0 +1,168 @@
+# FP_GEN_DOCBOOK_XML
+# ------------------
+# Generates a DocBook XML V4.5 document in conftest.xml.
+#
+# It took a lot of experimentation to find a document that will cause
+# xsltproc to fail with an error code when the relevant
+# stylesheets/DTDs are not found.  I couldn't make xsltproc fail with
+# a single-file document, it seems a multi-file document is needed.
+# -- SDM 2009-06-03
+#
+AC_DEFUN([FP_GEN_DOCBOOK_XML],
+[rm -f conftest.xml conftest-book.xml
+cat > conftest.xml << EOF
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [[
+<!ENTITY conftest-book SYSTEM "conftest-book.xml">
+]]>
+<book id="test">
+&conftest-book;
+</book>
+EOF
+cat >conftest-book.xml << EOF
+<?xml version="1.0" encoding="iso-8859-1"?>
+  <title>A DocBook &ldquo;Test Document&rdquo;</title>
+  <chapter id="id-one">
+    <title>A Chapter Title</title>
+    <para>This is a paragraph, referencing <xref linkend="id-two"/>.</para>
+  </chapter>
+  <chapter id="id-two">
+    <title>Another Chapter Title</title>
+    <para>This is another paragraph, referencing <xref linkend="id-one"/>.</para>
+  </chapter>
+EOF
+]) # FP_GEN_DOCBOOK_XML
+
+
+# FP_PROG_DBLATEX
+# ----------------
+# Sets the output variable DblatexCmd to the full path of dblatex,
+# which we use for building PDF and PS docs.
+# DblatexCmd is empty if dblatex could not be found.
+AC_DEFUN([FP_PROG_DBLATEX],
+[AC_PATH_PROG([DblatexCmd], [dblatex])
+if test -z "$DblatexCmd"; then
+  AC_MSG_WARN([cannot find dblatex in your PATH, you will not be able to build the PDF and PS documentation])
+fi
+])# FP_PROG_DBLATEX
+
+
+# FP_PROG_XSLTPROC
+# ----------------
+# Sets the output variable XsltprocCmd to the full path of the XSLT processor
+# xsltproc. XsltprocCmd is empty if xsltproc could not be found.
+AC_DEFUN([FP_PROG_XSLTPROC],
+[AC_PATH_PROG([XsltprocCmd], [xsltproc])
+if test -z "$XsltprocCmd"; then
+  AC_MSG_WARN([cannot find xsltproc in your PATH, you will not be able to build the HTML documentation])
+fi
+])# FP_PROG_XSLTPROC
+
+
+# FP_DOCBOOK_XSL
+# ----------------------------
+# Check that we can process a DocBook XML document to HTML using xsltproc.
+AC_DEFUN([FP_DOCBOOK_XSL],
+[AC_REQUIRE([FP_PROG_XSLTPROC])dnl
+if test -n "$XsltprocCmd"; then
+  AC_CACHE_CHECK([for DocBook XSL stylesheet], fp_cv_dir_docbook_xsl,
+  [FP_GEN_DOCBOOK_XML
+  fp_cv_dir_docbook_xsl=no
+  if $XsltprocCmd --nonet http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl conftest.xml > /dev/null 2>&1; then
+     fp_cv_dir_docbook_xsl=yes
+  fi
+  rm -rf conftest*])
+fi
+if test x"$fp_cv_dir_docbook_xsl" = xno; then
+  AC_MSG_WARN([cannot find DocBook XSL stylesheets, you will not be able to build the documentation])
+  HAVE_DOCBOOK_XSL=NO
+else
+  HAVE_DOCBOOK_XSL=YES
+fi
+AC_SUBST([HAVE_DOCBOOK_XSL])
+])# FP_DOCBOOK_XSL
+
+
+# FP_PROG_XMLLINT
+# ----------------
+# Sets the output variable XmllintCmd to the full path of the XSLT processor
+# xmllint. XmllintCmd is empty if xmllint could not be found.
+AC_DEFUN([FP_PROG_XMLLINT],
+[AC_PATH_PROG([XmllintCmd], [xmllint])
+if test -z "$XmllintCmd"; then
+  AC_MSG_WARN([cannot find xmllint in your PATH, you will not be able to validate your documentation])
+fi
+])# FP_PROG_XMLLINT
+
+
+# FP_CHECK_DOCBOOK_DTD
+# --------------------
+AC_DEFUN([FP_CHECK_DOCBOOK_DTD],
+[AC_REQUIRE([FP_PROG_XMLLINT])dnl
+if test -n "$XmllintCmd"; then
+  AC_MSG_CHECKING([for DocBook DTD])
+  FP_GEN_DOCBOOK_XML
+  if $XmllintCmd --nonet --valid --noout conftest.xml ; then
+    AC_MSG_RESULT([ok])
+  else
+    AC_MSG_RESULT([failed])
+    AC_MSG_WARN([cannot find a DTD for DocBook XML V4.5, you will not be able to validate your documentation])
+    AC_MSG_WARN([check your XML_CATALOG_FILES environment variable and/or /etc/xml/catalog])
+  fi
+  rm -rf conftest*
+fi
+])# FP_CHECK_DOCBOOK_DTD
+
+
+# FP_GEN_FO
+# ------------------
+# Generates a formatting objects document in conftest.fo.
+AC_DEFUN([FP_GEN_FO],
+[rm -f conftest.fo
+cat > conftest.fo << EOF
+<?xml version="1.0"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="blank">
+      <fo:region-body/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="blank">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>
+        Test!
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>
+EOF
+]) # FP_GEN_FO
+
+
+# FP_PROG_FOP
+# -----------
+# Set the output variable 'FopCmd' to the first working 'fop' in the current
+# 'PATH'. Note that /usr/bin/fop is broken in SuSE 9.1 (unpatched), so try
+# /usr/share/fop/fop.sh in that case (or no 'fop'), too.
+AC_DEFUN([FP_PROG_FOP],
+[AC_PATH_PROGS([FopCmd1], [fop fop.sh])
+if test -n "$FopCmd1"; then
+  AC_CACHE_CHECK([for $FopCmd1 usability], [fp_cv_fop_usability],
+    [FP_GEN_FO
+    if "$FopCmd1" -fo conftest.fo -ps conftest.ps > /dev/null 2>&1; then
+      fp_cv_fop_usability=yes
+    else
+      fp_cv_fop_usability=no
+    fi
+    rm -rf conftest*])
+  if test x"$fp_cv_fop_usability" = xyes; then
+     FopCmd=$FopCmd1
+  fi
+fi
+if test -z "$FopCmd"; then
+  AC_PATH_PROGS([FopCmd2], [fop.sh], , [/usr/share/fop])
+  FopCmd=$FopCmd2
+fi
+AC_SUBST([FopCmd])
+])# FP_PROG_FOP
index 8b88ce23e1490af48d0a658db7bbd013f78dec44..25eca7ceac42b3d11a36f82ccc17f58bec7ef833 100644 (file)
@@ -5,19 +5,4 @@ DOCBOOK_FILES = \
        mission-chan.xml \
        $(NULL)
 
-DOCBOOK_STYLESHEET = \
-       http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl
-
-EXTRA_DIST = $(DOCBOOK_FILES)
-
-html-local:
-       $(XMLLINT) --noout --xinclude --postvalid --noent $(DOCBOOK_MAIN)
-       $(XSLTPROC) \
-               --stringparam base.dir html/ \
-               --stringparam use.id.as.filename 1 \
-               --nonet \
-               $(DOCBOOK_STYLESHEET) \
-               $(DOCBOOK_MAIN)
-
-clean-local:
-       -rm -rf html
+include $(top_srcdir)/am/docbook.am
index 35f3dd41bf81db34f6a73c6195b6f52947e1c338..845d4adbce6e5eccfd4d9c6361ef089dc43d0c8b 100644 (file)
@@ -7,9 +7,9 @@
   </bookinfo>
 
   <chapter id="mission-chan-1">
-    <title>ミッションちゃんの大冒険</title>
+    <title lang="ja">ミッションちゃんの大冒険</title>
 
     <para>Lorem ipsum...</para>
   </chapter>
 
-</book>
\ No newline at end of file
+</book>