From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> as previously discussed on the mailing list, this is the Makefile magic that allows to autogenerate man page by adding the ipc_common.sh.errors template to the man pages requesting it. There is still room for improvement, but this should give an idea before we do the batch job. Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> --- Makefile.am | 1 + build-aux/genman | 48 ++++++++++++++++++ configure.ac | 1 + man/Makefile.am | 27 +++++++++-- man/ipc_common.sh.errors | 3 + man/votequorum_initialize.3 | 106 ---------------------------------------- man/votequorum_initialize.3.in | 106 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 182 insertions(+), 110 deletions(-) create mode 100755 build-aux/genman create mode 100644 man/ipc_common.sh.errors delete mode 100644 man/votequorum_initialize.3 create mode 100644 man/votequorum_initialize.3.in diff --git a/Makefile.am b/Makefile.am index 178b34d..6f5ea30 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..c3f07a6 --- /dev/null +++ b/build-aux/genman @@ -0,0 +1,48 @@ +#!/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 +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 + +# 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 d03c91b..1a20a0c 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..16035f9 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -39,8 +39,25 @@ xml_man = corosync-xmlproc.8 \ INDEX_HTML = index.html +autogen_man = votequorum_initialize.3 + +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 \ @@ -98,7 +115,6 @@ dist_man_MANS = \ votequorum_context_set.3 \ votequorum_finalize.3 \ votequorum_getinfo.3 \ - votequorum_initialize.3 \ votequorum_qdevice_getinfo.3 \ votequorum_qdevice_poll.3 \ votequorum_qdevice_register.3 \ @@ -142,7 +158,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 +174,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 + diff --git a/man/votequorum_initialize.3 b/man/votequorum_initialize.3 deleted file mode 100644 index 55548eb..0000000 --- a/man/votequorum_initialize.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\"/* -.\" * Copyright (c) 2009 Red Hat, Inc. -.\" * -.\" * All rights reserved. -.\" * -.\" * Author: Christine Caulfield <ccaulfie@xxxxxxxxxx> -.\" * -.\" * This software licensed under BSD license, the text of which follows: -.\" * -.\" * Redistribution and use in source and binary forms, with or without -.\" * modification, are permitted provided that the following conditions are met: -.\" * -.\" * - Redistributions of source code must retain the above copyright notice, -.\" * this list of conditions and the following disclaimer. -.\" * - Redistributions in binary form must reproduce the above copyright notice, -.\" * this list of conditions and the following disclaimer in the documentation -.\" * and/or other materials provided with the distribution. -.\" * - Neither the name of the MontaVista Software, Inc. nor the names of its -.\" * contributors may be used to endorse or promote products derived from this -.\" * software without specific prior written permission. -.\" * -.\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -.\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -.\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -.\" * THE POSSIBILITY OF SUCH DAMAGE. -.\" */ -.TH VOTEQUORUM_INITIALIZE 3 2009-01-26 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual" -.SH NAME -votequorum_initialize \- Create a new connection to the VoteQuorum service -.SH SYNOPSIS -.B #include <corosync/votequorum.h> -.sp -.BI "int votequorum_initialize(votequorum_handle_t *" handle ", votequorum_callbacks_t *" callbacks "); -.SH DESCRIPTION -The -.B votequorum_initialize -function is used to initialize a connection to the vote-based quorum database API. -.PP -Each application may have several connections to the votequorum API. Each application -uses the -.I handle -argument to uniquely identify the connection. The -.I handle -argument is then used in other function calls to identify the connection to be used -for communication with the votequorum service. -.PP -Every time the voting configuraton changes (eg a node joins or leave the cluster), the callback is called. -The callback function is described by the following type definitions: - -typedef void (*votequorum_notification_fn_t) ( - votequorum_handle_t handle, - uint64_t context, - uint32_t quorate, - uint32_t node_list_entries, - votequorum_node_t node_list[] - ); - -.ta -.fi -.RE -.IP -.PP -.PP -The -.I callbacks -argument is of the type: -.IP -.RS -.ne 18 -.nf -.PP -typedef struct { - votequorum_notification_fn_t votequorum_notify_fn; -} votequorum_callbacks_t; - -.ta -.fi -.RE -.IP -.PP -When a configuration change occurs, the callback -is called from the -.B votequorum_dispatch() -function. -.PP -.SH RETURN VALUE -This call returns the CS_OK value if successful, otherwise an error is returned. -.PP -.SH BUGS -Callbacks are not support at the moment. -.PP -.SH ERRORS -The errors are undocumented. -.SH "SEE ALSO" -.BR votequorum_overview (8), -.BR votequorum_finalize (3), -.BR votequorum_fd_get (3), -.BR votequorum_dispatch (3), -.PP diff --git a/man/votequorum_initialize.3.in b/man/votequorum_initialize.3.in new file mode 100644 index 0000000..5277873 --- /dev/null +++ b/man/votequorum_initialize.3.in @@ -0,0 +1,106 @@ +.\"/* +.\" * Copyright (c) 2009,2012 Red Hat, Inc. +.\" * +.\" * All rights reserved. +.\" * +.\" * Author: Christine Caulfield <ccaulfie@xxxxxxxxxx> +.\" * +.\" * This software licensed under BSD license, the text of which follows: +.\" * +.\" * Redistribution and use in source and binary forms, with or without +.\" * modification, are permitted provided that the following conditions are met: +.\" * +.\" * - Redistributions of source code must retain the above copyright notice, +.\" * this list of conditions and the following disclaimer. +.\" * - Redistributions in binary form must reproduce the above copyright notice, +.\" * this list of conditions and the following disclaimer in the documentation +.\" * and/or other materials provided with the distribution. +.\" * - Neither the name of the MontaVista Software, Inc. nor the names of its +.\" * contributors may be used to endorse or promote products derived from this +.\" * software without specific prior written permission. +.\" * +.\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +.\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +.\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +.\" * THE POSSIBILITY OF SUCH DAMAGE. +.\" */ +.TH VOTEQUORUM_INITIALIZE 3 @BUILDDATE@ "corosync Man Page" "Corosync Cluster Engine Programmer's Manual" +.SH NAME +votequorum_initialize \- Create a new connection to the VoteQuorum service +.SH SYNOPSIS +.B #include <corosync/votequorum.h> +.sp +.BI "int votequorum_initialize(votequorum_handle_t *" handle ", votequorum_callbacks_t *" callbacks "); +.SH DESCRIPTION +The +.B votequorum_initialize +function is used to initialize a connection to the vote-based quorum database API. +.PP +Each application may have several connections to the votequorum API. Each application +uses the +.I handle +argument to uniquely identify the connection. The +.I handle +argument is then used in other function calls to identify the connection to be used +for communication with the votequorum service. +.PP +Every time the voting configuraton changes (eg a node joins or leave the cluster), the callback is called. +The callback function is described by the following type definitions: + +typedef void (*votequorum_notification_fn_t) ( + votequorum_handle_t handle, + uint64_t context, + uint32_t quorate, + uint32_t node_list_entries, + votequorum_node_t node_list[] + ); + +.ta +.fi +.RE +.IP +.PP +.PP +The +.I callbacks +argument is of the type: +.IP +.RS +.ne 18 +.nf +.PP +typedef struct { + votequorum_notification_fn_t votequorum_notify_fn; +} votequorum_callbacks_t; + +.ta +.fi +.RE +.IP +.PP +When a configuration change occurs, the callback +is called from the +.B votequorum_dispatch() +function. +.PP +.SH RETURN VALUE +This call returns the CS_OK value if successful, otherwise an error is returned. +.PP +.SH BUGS +Callbacks are not support at the moment. +.PP +.SH ERRORS +@COMMONIPCERRORS@ +.SH "SEE ALSO" +.BR votequorum_overview (8), +.BR votequorum_finalize (3), +.BR votequorum_fd_get (3), +.BR votequorum_dispatch (3), +.PP -- 1.7.7.6 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss