[ovs-dev] [PATCH v2] docs: Make 'pdf' and 'install-pdf' targets build and install PDF manpages.

Ben Pfaff blp at nicira.com
Thu Jan 12 18:01:39 UTC 2012


Thanks to Romain Lenglet for reminding me that there are standard Makefile
targets for generating and installing PDF documentation.

CC: Romain Lenglet <rlenglet at nicira.com>
Reported-by: Alan Shieh <ashieh at nicira.com>
Bug #8153.
---
v1->v2: Use standard 'pdf' target instead of invented 'pdf-man' target.
Add 'install-pdf' implementation.  Clean up generated files on "make
clean".

 AUTHORS           |    1 +
 Makefile.am       |   27 ++++++++++++++++++++++++++-
 NEWS              |    3 +++
 configure.ac      |    1 +
 m4/openvswitch.m4 |   12 ++++++++++++
 5 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 87b3ccd..e5c3a05 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -60,6 +60,7 @@ provided helpful bug reports or suggestions.
 Aaron M. Ucko           ucko at debian.org
 Aaron Rosen             arosen at clemson.edu
 Ahmed Bilal             numan252 at gmail.com
+Alan Shieh              ashieh at nicira.com
 Alban Browaeys          prahal at yahoo.com
 Alex Yip                alex at nicira.com
 Alexey I. Froloff       raorn at altlinux.org
diff --git a/Makefile.am b/Makefile.am
index 46de7fb..ab5f6e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Nicira Networks, Inc.
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Nicira Networks, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -167,6 +167,31 @@ manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
 CLEANFILES += manpage-check
 endif
 
+PDF = $(man_MANS:=.pdf) $(dist_man_MANS:=.pdf) $(noinst_man_MANS:=.pdf)
+CLEANFILES += $(PDF)
+if HAVE_GROFF
+if HAVE_PS2PDF
+pdf: $(PDF)
+install-pdf-local:
+	$(MKDIR_P) $(DESTDIR)$(pdfdir)
+	for pdf in $(PDF); do \
+	  base=`echo "$$pdf" | sed 's,^.*/,,'`; \
+	  $(INSTALL_DATA) "$$pdf" "$(DESTDIR)$(pdfdir)/$$base" || exit 1; \
+	done
+SUFFIXES += .1.pdf .5.pdf .8.pdf .1 .5 .8
+# These magic ps2pdf options to embed fonts are needed to make the
+# generated PDF files look decent in the Chrome PDF viewer.
+PS2PDF_FLAGS = -dEmbedAllFonts=true -dPDFSETTINGS=/printer
+man2pdf = LANG=en_US.UTF-8 groff -p -T ps -man $< | ps2pdf $(PS2PDF_FLAGS) - $@
+.1.1.pdf:
+	$(man2pdf)
+.5.5.pdf:
+	$(man2pdf)
+.8.8.pdf:
+	$(man2pdf)
+endif
+endif
+
 include $(srcdir)/manpages.mk
 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
 	@$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
diff --git a/NEWS b/NEWS
index 1128af0..fb05e6f 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ post-v1.4.0
           {=}, {!=}, {<}, {>}, {<=}, and {>=}.
     - ovsdb-tool now uses the typical database and schema installation
       directories as defaults.
+    - "pdf" and "install-pdf" Makefile targets now generate and install
+      PDF versions of manpages, respectively, if groff and ps2pdf are
+      available.
 
 
 v1.4.0 - xx xxx xxxx
diff --git a/configure.ac b/configure.ac
index a5cff70..59f36e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,7 @@ OVS_CHECK_SOCKET_LIBS
 OVS_CHECK_LINKER_SECTIONS
 OVS_CHECK_XENSERVER_VERSION
 OVS_CHECK_GROFF
+OVS_CHECK_PS2PDF
 
 OVS_ENABLE_OPTION([-Wall])
 OVS_ENABLE_OPTION([-Wno-sign-compare])
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index c59d5d4..0c90d7a 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -354,3 +354,15 @@ AC_DEFUN([OVS_CHECK_GROFF],
        ovs_cv_groff=no
      fi])
    AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])])
+
+dnl Checks for ps2pdf.
+AC_DEFUN([OVS_CHECK_PS2PDF],
+  [AC_CACHE_CHECK(
+    [for ps2pdf],
+    [ovs_cv_ps2pdf],
+    [if (echo quit | ps2pdf - -) >/dev/null 2>&1; then
+       ovs_cv_ps2pdf=yes
+     else
+       ovs_cv_ps2pdf=no
+     fi])
+   AM_CONDITIONAL([HAVE_PS2PDF], [test "$ovs_cv_ps2pdf" = yes])])
-- 
1.7.2.5




More information about the dev mailing list