Updated Branches:
  refs/heads/master c54477a5a -> aeb5bbb7f

TS-2377: install man pages as part of the build

Add options to conf.py to tell us the man pages for each section,
because AFAICT there's no portable way to set automake variables
from shell output commands. We also teach conf.py to test for a
current sphinx version at configure time.

Wire up sphinx to the man page install and test for the sphinx
version pretty aggressively at configure time. Distro packaging
seems prety variable, so I think it's best to be conservative.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/aeb5bbb7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/aeb5bbb7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/aeb5bbb7

Branch: refs/heads/master
Commit: aeb5bbb7f4d557b1a45b0554401c2699046da8f5
Parents: c54477a
Author: James Peach <[email protected]>
Authored: Wed Nov 20 09:16:50 2013 -0800
Committer: James Peach <[email protected]>
Committed: Thu Nov 21 11:18:26 2013 -0800

----------------------------------------------------------------------
 CHANGES         |  3 +++
 configure.ac    | 35 +++++++++++++++++++++++++++++++++++
 doc/Makefile.am | 14 ++++++++++----
 doc/conf.py     | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aeb5bbb7/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8fc1232..ab7ae4c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+
+  *) [TS-2377] Install man pages as part of the build.
+
   *) [TS-2379] Add a new field: '%<chp>', "client_host_port" to LogFormat.
 
   *) [TS-2374] Abort the producer if the none of it`s consumers is alive.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aeb5bbb7/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index bd76888..192ede8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -669,6 +669,41 @@ AC_CHECK_PROG(ASCPP, cpp, cpp)
 AC_CHECK_TOOL(AR, ar, ar)
 AC_ISC_POSIX
 
+AM_PATH_PYTHON([2.4], [
+  dnl action-if-found
+  TS_MAN1_MANPAGES=`$PYTHON $srcdir/doc/conf.py --man-pages --section=1 | $AWK 
'{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
+  TS_MAN3_MANPAGES=`$PYTHON $srcdir/doc/conf.py --man-pages --section=3 | $AWK 
'{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
+  TS_MAN5_MANPAGES=`$PYTHON $srcdir/doc/conf.py --man-pages --section=5 | $AWK 
'{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
+  TS_MAN8_MANPAGES=`$PYTHON $srcdir/doc/conf.py --man-pages --section=8 | $AWK 
'{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
+
+  # If we have python, check if the Sphinx version looks OK.
+  AS_IF(["$PYTHON" "$srcdir/doc/conf.py" --check-version], [
+    sphinx_version_check=yes
+  ])
+
+], [
+  dnl action-if-not-found
+  :
+])
+
+AC_ARG_VAR(SPHINXBUILD, [the sphinx-build documentation generator])
+AC_ARG_VAR(SPHINXOPTS, [additional sphinx-build options])
+AC_CHECK_PROG([SPHINXBUILD], [sphinx-build], [sphinx-build], [false])
+
+AC_SUBST(TS_MAN1_MANPAGES)
+AC_SUBST(TS_MAN3_MANPAGES)
+AC_SUBST(TS_MAN5_MANPAGES)
+AC_SUBST(TS_MAN8_MANPAGES)
+
+AC_MSG_CHECKING([whether to build man pages])
+AS_IF([test "x$sphinx_version_check" = "xyes" -a "x$SPHINXBUILD" != "xfalse"], 
[
+  AM_CONDITIONAL([BUILD_MANPAGES], [true])
+  AC_MSG_RESULT([yes])
+], [
+  AM_CONDITIONAL([BUILD_MANPAGES], [false])
+  AC_MSG_RESULT([no])
+])
+
 # Do bison check by hand because we must do a version check.
 # Use YACC because it makes autotools shut up.
 BISON_MAJOR=2

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aeb5bbb7/doc/Makefile.am
----------------------------------------------------------------------
diff --git a/doc/Makefile.am b/doc/Makefile.am
index c016929..7181247 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -78,8 +78,16 @@ dist_trafficshell_DATA = \
   man/show_version.1 \
   man/show_virtual-ip.1
 
-man1_MANS = \
-  man/traffic_shell.1
+if BUILD_MANPAGES
+
+man1_MANS = $(TS_MAN1_MANPAGES) man/traffic_shell.1
+man3_MANS = $(TS_MAN3_MANPAGES)
+man5_MANS = $(TS_MAN5_MANPAGES)
+man8_MANS = $(TS_MAN8_MANPAGES)
+
+$(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS): man
+
+endif
 
 EXTRA_DIST = \
   Doxyfile.in \
@@ -96,8 +104,6 @@ doxygen: Doxyfile
 #
 
 # You can set these variables from the command line.
-SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
 PAPER         = letter
 BUILDDIR      = docbuild
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aeb5bbb7/doc/conf.py
----------------------------------------------------------------------
diff --git a/doc/conf.py b/doc/conf.py
index 0539bff..98539e0 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -363,3 +363,35 @@ epub_copyright = u'2013, [email protected]'
 
 # Allow duplicate toc entries.
 #epub_tocdup = True
+
+if __name__ == '__main__':
+  # Use optparse instead of argparse because this needs to work on old Python 
versions.
+  import optparse
+
+  parser = optparse.OptionParser(description='Traffic Server Sphinx docs 
configuration')
+  parser.add_option('--check-version', action='store_true', dest='checkvers')
+  parser.add_option('--man-pages', action='store_true', dest='manpages')
+  parser.add_option('--section', type=int, default=0, dest='section')
+
+  (options, args) = parser.parse_args()
+
+  # Print the names of the man pages for the requested manual section.
+  if options.manpages:
+    for page in man_pages:
+      if options.section == 0 or options.section == int(page[4][0]):
+        print page[1] + '.' + page[4]
+
+  # Check whether we have a recent version of sphinx. EPEL and CentOS are 
completely crazy and I don't understand their
+  # packaging at all. The test below works on Ubuntu and places where sphinx 
is installed sanely AFAICT.
+  if options.checkvers:
+    print 'checking for sphinx version >= 1.1... ',
+    try:
+      import sphinx
+      version = sphinx.__version__
+      (major, minor, micro) = version.split('.')
+      if (int(major) > 1) or (int(major) == 1 and int(minor) >= 1):
+        print 'found ' + sphinx.__version__
+      sys.exit(0)
+    except Exception as e:
+      print e
+      sys.exit(1)

Reply via email to