From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>
this is useful to include ipc_common errors into all man pages
Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
:100644 100644 b16eae6... 4ac40c6... M Makefile.am
:000000 100755 0000000... 94ae715... A build-aux/genman
:100644 100644 65abfae... b2e52f4... M configure.ac
:100644 100644 b173810... 37fad93... M man/Makefile.am
:000000 100644 0000000... 5aa3a11... A man/ipc_common.sh.errors
Makefile.am | 1 +
build-aux/genman | 52 ++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
man/Makefile.am | 26 ++++++++++++++++++++--
man/ipc_common.sh.errors | 3 ++
5 files changed, 80 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index b16eae6..4ac40c6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,6 +37,7 @@ EXTRA_DIST = autogen.sh $(SPEC).in \
build-aux/git-version-gen \
build-aux/gitlog-to-changelog \
build-aux/release.mk \
+ build-aux/genman \
.version
AUTOMAKE_OPTIONS = foreign
diff --git a/build-aux/genman b/build-aux/genman
new file mode 100755
index 0000000..94ae715
--- /dev/null
+++ b/build-aux/genman
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -e
+
+# Set variables
+# in - input man page (something_foo.3.in)
+# out - output file (something_foo.3)
+# common - common ipc error file
+
+in="$1"
+out="$2"
+common="$3"
+
+# make sure to trap on error and ctrl+c
+# so we can cleanup our temporary files
+# and provide error back to Makefile
+cleanup() {
+ rm -f "$out"-t "$out"
+}
+
+trap "cleanup" ABRT
+trap "cleanup" QUIT
+trap "cleanup" TERM
+trap "cleanup" INT
+trap "cleanup" ERR
+
+# Determine build date in man page format YYYY-MM-DD
+date="$(LC_ALL=C date "+%F")"
+
+# do the hack.. it looks ugly but it works fine
+
+# remove temporary file
+rm -f "$out"-t
+
+# insert the $common ipc error file in the man page
+if grep -q @COMMONIPCERRORS@ "$in"; then
+ awk "{print}(\$1 ~ /@COMMONIPCERRORS@/){exit 0}" "$in" > "$out"-t
+ cat "$common" >> "$out"-t
+ awk -v p=0 "(\$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" "$in" >> "$out"-t
+else
+ cp "$in" "$out"-t
+fi
+
+# substitute BUILDDATE with precalculated date
+# and remove COMMONIPCERRORS tag from above
+sed -i \
+ -e 's#@BUILDDATE@#'$date'#g' \
+ -e 's#@COMMONIPCERRORS@##g' \
+ "$out"-t
+
+# move in place as requested
+mv "$out"-t "$out"
diff --git a/configure.ac b/configure.ac
index 65abfae..b2e52f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,7 @@ AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
AC_CHECK_PROGS([AUGTOOL], [augtool])
AC_CHECK_PROGS([DOT], [dot])
AC_CHECK_PROGS([DOXYGEN], [doxygen])
+AC_CHECK_PROGS([AWK], [awk])
# Checks for libraries.
AC_CHECK_LIB([dl], [dlopen])
diff --git a/man/Makefile.am b/man/Makefile.am
index b173810..37fad93 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -39,8 +39,25 @@ xml_man = corosync-xmlproc.8 \
INDEX_HTML = index.html
+autogen_man =
+
+autogen_common = ipc_common.sh.errors
+
EXTRA_DIST = $(INDEX_HTML) \
- $(xml_man)
+ $(xml_man) \
+ $(autogen_man:%=%.in) \
+ $(autogen_common)
+
+man_MANS = $(autogen_man)
+
+%.3: %.3.in $(autogen_common) $(top_srcdir)/build-aux/genman
+ @echo Generating $@ man page && \
+ rm -f $@-t $@ && \
+ $(top_srcdir)/build-aux/genman \
+ $(srcdir)/$@.in \
+ $(builddir)/$@-t \
+ $(srcdir)/$(autogen_common) && \
+ mv $@-t $@
dist_man_MANS = \
corosync.conf.5 \
@@ -142,7 +159,7 @@ endif
if BUILD_HTML_DOCS
-HTML_DOCS = $(dist_man_MANS:%=%.html)
+HTML_DOCS = $(dist_man_MANS:%=%.html) $(man_MANS:%=%.html)
%.html: %
$(GROFF) -mandoc -Thtml $^ > $@
@@ -158,6 +175,9 @@ uninstall-local:
all-local: $(HTML_DOCS)
clean-local:
- rm -rf $(HTML_DOCS)
+ rm -rf $(HTML_DOCS) $(autogen_man)
+else
+clean-local:
+ rm -rf $(autogen_man)
endif
diff --git a/man/ipc_common.sh.errors b/man/ipc_common.sh.errors
new file mode 100644
index 0000000..5aa3a11
--- /dev/null
+++ b/man/ipc_common.sh.errors
@@ -0,0 +1,3 @@
+.PP
+Common errors go here
+
--
1.7.7.6
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss
[Corosync Project]
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]