[master] ee74961 Fix option RST generation dependant on rst2man to not make use of gnu make order only prerequisites.
Martin Blix Grydeland
martin at varnish-cache.org
Thu Jun 13 12:41:24 CEST 2013
commit ee74961527e07870a6055944c886619ff7eee224
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed May 29 15:51:55 2013 +0200
Fix option RST generation dependant on rst2man to not make use of gnu
make order only prerequisites.
diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am
index d9971fc..e5afa45 100644
--- a/bin/varnishlog/Makefile.am
+++ b/bin/varnishlog/Makefile.am
@@ -9,6 +9,7 @@ dist_man_MANS = varnishlog.1
varnishlog_SOURCES = \
varnishlog.c \
varnishlog_options.h \
+ varnishlog_options.c \
$(top_builddir)/lib/libvarnishtools/vut.c \
$(top_builddir)/lib/libvarnish/vas.c \
$(top_builddir)/lib/libvarnish/flopen.c \
@@ -23,21 +24,24 @@ varnishlog_LDADD = \
${RT_LIBS} ${LIBM} ${PTHREAD_LIBS}
noinst_PROGRAMS = varnishlog_opt2rst
-varnishlog_opt2rst_CFLAGS = -DOPT2RST_INC="varnishlog_options.h"
varnishlog_opt2rst_SOURCES = \
varnishlog_options.h \
+ varnishlog_options.c \
$(top_builddir)/lib/libvarnishtools/opt2rst.c
BUILT_SOURCES = varnishlog_options.rst varnishlog_synopsis.rst
-
-EXTRA_DIST = varnishlog_options.rst varnishlog_synopsis.rst
+EXTRA_DIST = $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(EXTRA_DIST)
-varnishlog_options.rst: varnishlog_options.h | varnishlog_opt2rst
+varnishlog_options.rst:
./varnishlog_opt2rst options > $@
-varnishlog_synopsis.rst: varnishlog_options.h | varnishlog_opt2rst
+varnishlog_synopsis.rst:
./varnishlog_opt2rst synopsis > $@
+if HAVE_RST2MAN
+varnishlog_options.rst varnishlog_synopsis.rst: varnishlog_opt2rst
+endif
+
varnishlog.1: \
$(top_srcdir)/doc/sphinx/reference/varnishlog.rst \
varnishlog_options.rst \
diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index 13075fd..d3d9e29 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -42,6 +42,7 @@
#include "vapi/vsm.h"
#include "vapi/vsl.h"
+#include "vapi/voptget.h"
#include "vas.h"
#include "vcs.h"
#include "vpf.h"
@@ -49,12 +50,6 @@
#include "vtim.h"
#include "vut.h"
-#define VOPT_OPTSTRING
-#define VOPT_SYNOPSIS
-#define VOPT_USAGE
-#define VOPT_INC "varnishlog_options.h"
-#include "vapi/voptget.h"
-
static void
usage(void)
{
diff --git a/bin/varnishlog/varnishlog_options.c b/bin/varnishlog/varnishlog_options.c
new file mode 100644
index 0000000..4b5037d
--- /dev/null
+++ b/bin/varnishlog/varnishlog_options.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2013 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Martin Blix Grydeland <martin at varnish-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * Option definitions for varnishlog
+ */
+
+#include <stdlib.h>
+#define VOPT_DEFINITION
+#define VOPT_INC "varnishlog_options.h"
+#include "vapi/voptget.h"
diff --git a/include/vapi/voptget.h b/include/vapi/voptget.h
index 443d316..4f30848 100644
--- a/include/vapi/voptget.h
+++ b/include/vapi/voptget.h
@@ -35,47 +35,48 @@
* l: Long description
*/
-#ifdef VOPT_OPTSTRING
+extern const char vopt_optstring[];
+extern const char vopt_synopsis[];
+extern const char *vopt_usage[];
+struct vopt_list {
+ const char *option;
+ const char *synopsis;
+ const char *desc;
+ const char *ldesc;
+};
+extern const struct vopt_list vopt_list[];
+extern unsigned vopt_list_n;
+
+#ifdef VOPT_DEFINITION
+
+#ifndef VOPT_INC
+#error "VOPT_INC undefined"
+#endif
+
#define VOPT(o,s,d,l) o
const char vopt_optstring[] =
#include VOPT_INC
;
#undef VOPT
-#endif
-#ifdef VOPT_SYNOPSIS
#define VOPT(o,s,d,l) " " s
const char vopt_synopsis[] =
#include VOPT_INC
;
#undef VOPT
-#endif
-#ifdef VOPT_USAGE
#define VOPT(o,s,d,l) s, d,
const char *vopt_usage[] = {
#include VOPT_INC
NULL, NULL,
};
#undef VOPT
-#endif
-#ifndef VOPTGET_H
-#define VOPTGET_H
-
-struct vopt_full {
- const char *option;
- const char *synopsis;
- const char *desc;
- const char *ldesc;
-};
-
-#endif
-
-#ifdef VOPT_FULL
#define VOPT(o,s,d,l) { o,s,d,l },
-const struct vopt_full vopt_full[] = {
+const struct vopt_list vopt_list[] = {
#include VOPT_INC
};
#undef VOPT
-#endif
+unsigned vopt_list_n = sizeof vopt_list / sizeof vopt_list[0];
+
+#endif /* VOPT_DEFINITION */
diff --git a/lib/libvarnishtools/opt2rst.c b/lib/libvarnishtools/opt2rst.c
index 3ad60db..1ed08e0 100644
--- a/lib/libvarnishtools/opt2rst.c
+++ b/lib/libvarnishtools/opt2rst.c
@@ -31,16 +31,6 @@
#include <stdio.h>
#include <string.h>
-#ifndef OPT2RST_INC
-#error "OPT2RST_INC undefined"
-#endif
-
-#define STRINGIFY(x) #x
-#define TOSTRING(x) STRINGIFY(x)
-
-#define VOPT_SYNOPSIS
-#define VOPT_FULL
-#define VOPT_INC TOSTRING(OPT2RST_INC)
#include "vapi/voptget.h"
static void
@@ -68,7 +58,7 @@ print_tabbed(const char *string, int tabs)
}
static void
-print_opt(const struct vopt_full *opt)
+print_opt(const struct vopt_list *opt)
{
print_nobrackets(opt->synopsis);
printf("\n\n");
@@ -93,8 +83,8 @@ main(int argc, char * const *argv)
if (!strcmp(argv[1], "synopsis"))
printf(".. |synopsis| replace:: %s\n", vopt_synopsis);
else if (!strcmp(argv[1], "options"))
- for (i = 0; i < sizeof vopt_full / sizeof vopt_full[0]; i++)
- print_opt(&vopt_full[i]);
+ for (i = 0; i < vopt_list_n; i++)
+ print_opt(&vopt_list[i]);
else
usage();
More information about the varnish-commit
mailing list