[PATCH] automatically generate man page

Jim Meyering jim at meyering.net
Tue Oct 19 18:55:02 UTC 2010


With this, we automatically get iwhd.8,
generated from iwhd --help output:
[requires that you install help2man,
when building from git-cloned sources]

>From b5773ad71f8121dcc1af8bab816c333b8398e773 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 19 Oct 2010 18:27:52 +0200
Subject: [PATCH] automatically generate man page

* configure.ac (AC_CONFIG_FILES): Add man/Makefile.
Check for help2man.
* Makefile.am (SUBDIRS): Add "." and man.
* man/Makefile.am: New file.
* .gitignore: Ignore new artifacts and anchor patterns.
---
 .gitignore      |   37 +++++++++++++++++++------------------
 Makefile.am     |    2 +-
 configure.ac    |    7 ++++++-
 man/Makefile.am |   29 +++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 20 deletions(-)
 create mode 100644 man/Makefile.am

diff --git a/.gitignore b/.gitignore
index e85dc40..6fbf252 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,25 +2,26 @@
 *~
 .\#*
 .deps
+/aclocal.m4
+/autom4te.cache/
+/build-aux
+/config.h
+/config.hin
+/config.log
+/config.status
+/configure
+/iwhd
+/iwhd-*.tar.gz
+/iwhd-qparser.c
+/iwhd-qparser.h
+/iwhd.spec
+/man/iwhd.8
+/qlexer.c
+/stamp-h1
+/t/*.log
+/t/parser
+/t/parser.c
 ChangeLog
 Makefile
 Makefile.in
 \#*\#
-aclocal.m4
-autom4te.cache/
-build-aux
-config.h
-config.hin
-config.log
-config.status
-configure
-iwhd
-iwhd-*.tar.gz
-iwhd-qparser.c
-iwhd-qparser.h
-iwhd.spec
-qlexer.c
-stamp-h1
-t/*.log
-t/parser
-t/parser.c
diff --git a/Makefile.am b/Makefile.am
index 5510cf1..44ff506 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS	= -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include

 iwhd_YFLAGS = -d

-SUBDIRS = t
+SUBDIRS = . t man
 ACLOCAL_AMFLAGS = -I ax

 # iwhd is short for Image WareHouse Daemon.
diff --git a/configure.ac b/configure.ac
index afbe4c3..78eb70b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,7 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_YACC
 AC_PROG_LEX
+AM_MISSING_PROG([HELP2MAN], [help2man])

 AC_CHECK_LIB([curl], [curl_easy_init],
 	[CURL_LIB=-lcurl],
@@ -88,5 +89,9 @@ AC_FUNC_MALLOC
 AC_FUNC_REALLOC
 AC_CHECK_FUNCS([gettimeofday memmove memset strcasecmp strdup strndup strtoul])

-AC_CONFIG_FILES([Makefile t/Makefile])
+AC_CONFIG_FILES([
+Makefile
+t/Makefile
+man/Makefile
+])
 AC_OUTPUT
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644
index 0000000..6015289
--- /dev/null
+++ b/man/Makefile.am
@@ -0,0 +1,29 @@
+# Automakefile for GNU diffutils man pages
+
+# Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dist_man8_MANS = iwhd.8
+MAINTAINERCLEANFILES = $(dist_man8_MANS)
+
+S = $(top_srcdir)
+iwhd.8: $S/rest.c
+
+# Depend on configure.ac to get version number changes.
+$(dist_man8_MANS): $(top_srcdir)/configure.ac
+	$(AM_V_GEN)base=`expr $@ : '\(.*\).8'` && \
+	  (echo '[NAME]' && sed 's@/\* *@@; s/-/\\-/; q' $S/$$base.c) | \
+	  $(HELP2MAN) -i - -S '$(PACKAGE) $(VERSION)' ../iwhd | \
+	  sed 's/^\.B info .*/.B info FIXME/' >$@
--
1.7.3.1.526.g2ee4


More information about the iwhd-devel mailing list