Skip to content

Commit

Permalink
gengetopt generated files (cmdline.{c,h}) were modified previously to…
Browse files Browse the repository at this point in the history
… add support to new

command line options and setting SYSCONFDIR. This commit corrected this behaviour by
introducing an intermediate cmdline.c.in which will have the correct sysconfdir substituted
during configure stage to generate cmdline.c. The corresponding gengetopt generated files
were re-generated by gengetopt 2.22.1. Manpages that depend on the gengetopt help output
will need to be re-generated.
  • Loading branch information
bernardli committed Apr 4, 2011
1 parent 1f9eafe commit d251675
Show file tree
Hide file tree
Showing 14 changed files with 756 additions and 221 deletions.
11 changes: 8 additions & 3 deletions monitor-core/gmetad/Makefile.am
Expand Up @@ -12,10 +12,14 @@ GLDFLAGS =
endif

INCLUDES = @APR_INCLUDES@
AM_CFLAGS = -I$(top_builddir)/lib -I$(top_builddir)/gmond -I$(top_builddir)/include $(GCFLAGS) -DSYSCONFDIR='"$(sysconfdir)"'
AM_CFLAGS = -I$(top_builddir)/lib -I$(top_builddir)/gmond -I$(top_builddir)/include $(GCFLAGS)

sbin_PROGRAMS = gmetad
gmetad_SOURCES = gmetad.c cmdline.c cmdline.h gmetad.h data_thread.c \
sbin_PROGRAMS = gmetad

cmdline.c: cmdline.c.in $(FIXCONFIG)
$(FIXCONFIG) cmdline.c.in

gmetad_SOURCES = gmetad.c cmdline.c.in cmdline.c cmdline.h gmetad.h data_thread.c \
server.c process_xml.c rrd_helpers.c conf.c conf.h type_hash.c \
xml_hash.c cleanup.c rrd_helpers.h daemon_init.c daemon_init.h
gmetad_LDADD = $(top_builddir)/lib/libganglia.la -lrrd -lm \
Expand All @@ -39,3 +43,4 @@ install-data-hook: gmetad.conf
mkdir -p $(DESTDIR)$(sysconfdir) && \
$(INSTALL_DATA) gmetad.conf $(DESTDIR)$(sysconfdir)/gmetad.conf

CLEANFILES = cmdline.c
24 changes: 12 additions & 12 deletions monitor-core/gmetad/cmdline.c → monitor-core/gmetad/cmdline.c.in
@@ -1,7 +1,7 @@
/*
File autogenerated by gengetopt version 2.22
File autogenerated by gengetopt version 2.22.1
generated with the following command:
/usr/local/bin/gengetopt --input ./cmdline.sh
/usr/local/bin/gengetopt --c-extension=c.in --input ./cmdline.sh

The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
Expand All @@ -21,7 +21,7 @@

#include "cmdline.h"

const char *gengetopt_args_info_purpose = "Purpose:\n The Ganglia Meta Daemon (gmetad) collects information from\n multiple gmond or gmetad data sources, saves the information to local\n round-robin databases, and exports XML which is the concatentation of\n all data sources";
const char *gengetopt_args_info_purpose = "The Ganglia Meta Daemon (gmetad) collects information from\nmultiple gmond or gmetad data sources, saves the information to local\nround-robin databases, and exports XML which is the concatentation of\nall data sources";

const char *gengetopt_args_info_usage = "Usage: gmetad [OPTIONS]...";

Expand All @@ -30,8 +30,8 @@ const char *gengetopt_args_info_description = "";
const char *gengetopt_args_info_help[] = {
" -h, --help Print help and exit",
" -V, --version Print version and exit",
" -c, --conf=STRING Location of gmetad configuration file \n (default='" SYSCONFDIR "/gmetad.conf')",
" -d, --debug=INT Debug level. If greater than zero, daemon will stay in \n foreground. (default='0')",
" -c, --conf=STRING Location of gmetad configuration file \n (default=`@sysconfdir@/gmetad.conf')",
" -d, --debug=INT Debug level. If greater than zero, daemon will stay in \n foreground. (default=`0')",
" -p, --pid-file=STRING Write process-id to file",
0
};
Expand Down Expand Up @@ -67,7 +67,7 @@ void clear_given (struct gengetopt_args_info *args_info)
static
void clear_args (struct gengetopt_args_info *args_info)
{
args_info->conf_arg = gengetopt_strdup (SYSCONFDIR "/gmetad.conf");
args_info->conf_arg = gengetopt_strdup ("@sysconfdir@/gmetad.conf");
args_info->conf_orig = NULL;
args_info->debug_arg = 0;
args_info->debug_orig = NULL;
Expand Down Expand Up @@ -107,7 +107,7 @@ static void print_help_common(void) {
printf("\n");

if (strlen(gengetopt_args_info_description) > 0)
printf("%s\n", gengetopt_args_info_description);
printf("%s\n\n", gengetopt_args_info_description);
}

void
Expand Down Expand Up @@ -348,11 +348,11 @@ int update_arg(void *field, char **orig_field,
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
{
if (short_opt != '-')
fprintf (stderr, "%s: '--%s' ('-%c') option given more than once%s\n",
fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
package_name, long_opt, short_opt,
(additional_error ? additional_error : ""));
else
fprintf (stderr, "%s: '--%s' option given more than once%s\n",
fprintf (stderr, "%s: `--%s' option given more than once%s\n",
package_name, long_opt,
(additional_error ? additional_error : ""));
return 1; /* failure */
Expand Down Expand Up @@ -462,7 +462,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

c = getopt_long (argc, argv, "hVc:d:p:", long_options, &option_index);

if (c == -1) break; /* Exit from 'while (1)' loop. */
if (c == -1) break; /* Exit from `while (1)' loop. */

switch (c)
{
Expand All @@ -481,7 +481,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

if (update_arg( (void *)&(args_info->conf_arg),
&(args_info->conf_orig), &(args_info->conf_given),
&(local_args_info.conf_given), optarg, 0, SYSCONFDIR "/gmetad.conf", ARG_STRING,
&(local_args_info.conf_given), optarg, 0, "@sysconfdir@/gmetad.conf", ARG_STRING,
check_ambiguity, override, 0, 0,
"conf", 'c',
additional_error))
Expand Down Expand Up @@ -515,7 +515,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

case 0: /* Long option with no short option */
case '?': /* Invalid option. */
/* 'getopt_long' already printed an error message. */
/* `getopt_long' already printed an error message. */
goto failure;

default: /* bug: option not considered. */
Expand Down
4 changes: 2 additions & 2 deletions monitor-core/gmetad/cmdline.h
@@ -1,6 +1,6 @@
/** @file cmdline.h
* @brief The header file for the command line option parser
* generated by GNU Gengetopt version 2.22
* generated by GNU Gengetopt version 2.22.1
* http://www.gnu.org/software/gengetopt.
* DO NOT modify this file, since it can be overwritten
* @author GNU Gengetopt by Lorenzo Bettini */
Expand Down Expand Up @@ -34,7 +34,7 @@ struct gengetopt_args_info
{
const char *help_help; /**< @brief Print help and exit help description. */
const char *version_help; /**< @brief Print version and exit help description. */
char * conf_arg; /**< @brief Location of gmetad configuration file (default='SYSCONFDIR/gmetad.conf'). */
char * conf_arg; /**< @brief Location of gmetad configuration file (default='@sysconfdir@/gmetad.conf'). */
char * conf_orig; /**< @brief Location of gmetad configuration file original value given at command line. */
const char *conf_help; /**< @brief Location of gmetad configuration file help description. */
int debug_arg; /**< @brief Debug level. If greater than zero, daemon will stay in foreground. (default='0'). */
Expand Down
2 changes: 1 addition & 1 deletion monitor-core/gmetad/cmdline.sh
Expand Up @@ -7,7 +7,7 @@ multiple gmond or gmetad data sources, saves the information to local
round-robin databases, and exports XML which is the concatentation of
all data sources"

option "conf" c "Location of gmetad configuration file" string default="/etc/ganglia/gmetad.conf" no
option "conf" c "Location of gmetad configuration file" string default="@sysconfdir@/gmetad.conf" no
option "debug" d "Debug level. If greater than zero, daemon will stay in foreground." int default="0" no
option "pid-file" p "Write process-id to file" string no

Expand Down
12 changes: 10 additions & 2 deletions monitor-core/gmetric/Makefile.am
@@ -1,3 +1,5 @@
include $(top_srcdir)/ganglia.inc

if STATIC_BUILD
GCFLAGS =
GLDADD =
Expand All @@ -8,13 +10,19 @@ GLDADD =
GLDFLAGS =
endif

AM_CFLAGS = -I../lib -I../include $(GCFLAGS) -DSYSCONFDIR='"$(sysconfdir)"'
AM_CFLAGS = -I../lib -I../include $(GCFLAGS)

bin_PROGRAMS = gmetric
gmetric_SOURCES = gmetric.c cmdline.c cmdline.h

cmdline.c: cmdline.c.in $(FIXCONFIG)
$(FIXCONFIG) cmdline.c.in

gmetric_SOURCES = gmetric.c cmdline.c.in cmdline.c cmdline.h
gmetric_LDADD = $(top_builddir)/lib/libganglia.la \
$(top_builddir)/lib/libgetopthelper.a \
$(top_builddir)/libmetrics/libmetrics.la \
$(GLDADD)

gmetric_LDFLAGS = $(GLDFLAGS)

CLEANFILES = cmdline.c
@@ -1,7 +1,7 @@
/*
File autogenerated by gengetopt version 2.22
File autogenerated by gengetopt version 2.22.1
generated with the following command:
/usr/local/bin/gengetopt --input ./cmdline.sh
/usr/local/bin/gengetopt --c-extension=c.in --input ./cmdline.sh

The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
Expand All @@ -21,7 +21,7 @@

#include "cmdline.h"

const char *gengetopt_args_info_purpose = "Purpose:\n The Ganglia Metric Client (gmetric) announces a metric\n on the list of defined send channels defined in a configuration file";
const char *gengetopt_args_info_purpose = "The Ganglia Metric Client (gmetric) announces a metric\non the list of defined send channels defined in a configuration file";

const char *gengetopt_args_info_usage = "Usage: gmetric [OPTIONS]...";

Expand All @@ -30,18 +30,18 @@ const char *gengetopt_args_info_description = "";
const char *gengetopt_args_info_help[] = {
" -h, --help Print help and exit",
" -V, --version Print version and exit",
" -c, --conf=STRING The configuration file to use for finding send channels \n (default='" SYSCONFDIR "/gmond.conf')",
" -c, --conf=STRING The configuration file to use for finding send channels \n (default=`@sysconfdir@/gmond.conf')",
" -n, --name=STRING Name of the metric",
" -v, --value=STRING Value of the metric",
" -t, --type=STRING Either \n string|int8|uint8|int16|uint16|int32|uint32|float|double",
" -u, --units=STRING Unit of measure for the value e.g. Kilobytes, Celcius \n (default='')",
" -s, --slope=STRING Either zero|positive|negative|both (default='both')",
" -x, --tmax=INT The maximum time in seconds between gmetric calls \n (default='60')",
" -d, --dmax=INT The lifetime in seconds of this metric (default='0')",
" -u, --units=STRING Unit of measure for the value e.g. Kilobytes, Celcius \n (default=`')",
" -s, --slope=STRING Either zero|positive|negative|both (default=`both')",
" -x, --tmax=INT The maximum time in seconds between gmetric calls \n (default=`60')",
" -d, --dmax=INT The lifetime in seconds of this metric (default=`0')",
" -g, --group=STRING Group of the metric",
" -D, --desc=STRING Description of the metric",
" -T, --title=STRING Title of the metric",
" -S, --spoof=STRING IP address and name of host/device (colon separated) we \n are spoofing (default='')",
" -S, --spoof=STRING IP address and name of host/device (colon separated) we \n are spoofing (default=`')",
" -H, --heartbeat spoof a heartbeat message (use with spoof option)",
0
};
Expand Down Expand Up @@ -87,7 +87,7 @@ void clear_given (struct gengetopt_args_info *args_info)
static
void clear_args (struct gengetopt_args_info *args_info)
{
args_info->conf_arg = gengetopt_strdup (SYSCONFDIR "/gmond.conf");
args_info->conf_arg = gengetopt_strdup ("@sysconfdir@/gmond.conf");
args_info->conf_orig = NULL;
args_info->name_arg = NULL;
args_info->name_orig = NULL;
Expand Down Expand Up @@ -155,7 +155,7 @@ static void print_help_common(void) {
printf("\n");

if (strlen(gengetopt_args_info_description) > 0)
printf("%s\n", gengetopt_args_info_description);
printf("%s\n\n", gengetopt_args_info_description);
}

void
Expand Down Expand Up @@ -433,11 +433,11 @@ int update_arg(void *field, char **orig_field,
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
{
if (short_opt != '-')
fprintf (stderr, "%s: '--%s' ('-%c') option given more than once%s\n",
fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
package_name, long_opt, short_opt,
(additional_error ? additional_error : ""));
else
fprintf (stderr, "%s: '--%s' option given more than once%s\n",
fprintf (stderr, "%s: `--%s' option given more than once%s\n",
package_name, long_opt,
(additional_error ? additional_error : ""));
return 1; /* failure */
Expand Down Expand Up @@ -557,7 +557,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

c = getopt_long (argc, argv, "hVc:n:v:t:u:s:x:d:g:D:T:S:H", long_options, &option_index);

if (c == -1) break; /* Exit from 'while (1)' loop. */
if (c == -1) break; /* Exit from `while (1)' loop. */

switch (c)
{
Expand All @@ -576,7 +576,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

if (update_arg( (void *)&(args_info->conf_arg),
&(args_info->conf_orig), &(args_info->conf_given),
&(local_args_info.conf_given), optarg, 0, SYSCONFDIR "/gmond.conf", ARG_STRING,
&(local_args_info.conf_given), optarg, 0, "@sysconfdir@/gmond.conf", ARG_STRING,
check_ambiguity, override, 0, 0,
"conf", 'c',
additional_error))
Expand Down Expand Up @@ -672,7 +672,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

if (update_arg( (void *)&(args_info->group_arg),
&(args_info->group_orig), &(args_info->group_given),
&(local_args_info.group_given), optarg, 0, "", ARG_STRING,
&(local_args_info.group_given), optarg, 0, 0, ARG_STRING,
check_ambiguity, override, 0, 0,
"group", 'g',
additional_error))
Expand All @@ -684,7 +684,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

if (update_arg( (void *)&(args_info->desc_arg),
&(args_info->desc_orig), &(args_info->desc_given),
&(local_args_info.desc_given), optarg, 0, "", ARG_STRING,
&(local_args_info.desc_given), optarg, 0, 0, ARG_STRING,
check_ambiguity, override, 0, 0,
"desc", 'D',
additional_error))
Expand All @@ -696,7 +696,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

if (update_arg( (void *)&(args_info->title_arg),
&(args_info->title_orig), &(args_info->title_given),
&(local_args_info.title_given), optarg, 0, "", ARG_STRING,
&(local_args_info.title_given), optarg, 0, 0, ARG_STRING,
check_ambiguity, override, 0, 0,
"title", 'T',
additional_error))
Expand Down Expand Up @@ -730,7 +730,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf

case 0: /* Long option with no short option */
case '?': /* Invalid option. */
/* 'getopt_long' already printed an error message. */
/* `getopt_long' already printed an error message. */
goto failure;

default: /* bug: option not considered. */
Expand Down
6 changes: 3 additions & 3 deletions monitor-core/gmetric/cmdline.h
@@ -1,6 +1,6 @@
/** @file cmdline.h
* @brief The header file for the command line option parser
* generated by GNU Gengetopt version 2.22
* generated by GNU Gengetopt version 2.22.1
* http://www.gnu.org/software/gengetopt.
* DO NOT modify this file, since it can be overwritten
* @author GNU Gengetopt by Lorenzo Bettini */
Expand Down Expand Up @@ -34,7 +34,7 @@ struct gengetopt_args_info
{
const char *help_help; /**< @brief Print help and exit help description. */
const char *version_help; /**< @brief Print version and exit help description. */
char * conf_arg; /**< @brief The configuration file to use for finding send channels (default='SYSCONFDIR/gmond.conf'). */
char * conf_arg; /**< @brief The configuration file to use for finding send channels (default='@sysconfdir@/gmond.conf'). */
char * conf_orig; /**< @brief The configuration file to use for finding send channels original value given at command line. */
const char *conf_help; /**< @brief The configuration file to use for finding send channels help description. */
char * name_arg; /**< @brief Name of the metric. */
Expand Down Expand Up @@ -83,7 +83,7 @@ struct gengetopt_args_info
unsigned int tmax_given ; /**< @brief Whether tmax was given. */
unsigned int dmax_given ; /**< @brief Whether dmax was given. */
unsigned int group_given ; /**< @brief Whether group was given. */
unsigned int desc_given ; /**< @brief Whether description was given. */
unsigned int desc_given ; /**< @brief Whether desc was given. */
unsigned int title_given ; /**< @brief Whether title was given. */
unsigned int spoof_given ; /**< @brief Whether spoof was given. */
unsigned int heartbeat_given ; /**< @brief Whether heartbeat was given. */
Expand Down
5 changes: 4 additions & 1 deletion monitor-core/gmetric/cmdline.sh
Expand Up @@ -5,14 +5,17 @@ package "gmetric"
purpose "The Ganglia Metric Client (gmetric) announces a metric
on the list of defined send channels defined in a configuration file"

option "conf" c "The configuration file to use for finding send channels" string default="/etc/ganglia/gmond.conf" no
option "conf" c "The configuration file to use for finding send channels" string default="@sysconfdir@/gmond.conf" no
option "name" n "Name of the metric" string no
option "value" v "Value of the metric" string no
option "type" t "Either string|int8|uint8|int16|uint16|int32|uint32|float|double" string no
option "units" u "Unit of measure for the value e.g. Kilobytes, Celcius" string default="" no
option "slope" s "Either zero|positive|negative|both" string default="both" no
option "tmax" x "The maximum time in seconds between gmetric calls" int default="60" no
option "dmax" d "The lifetime in seconds of this metric" int default="0" no
option "group" g "Group of the metric" string no
option "desc" D "Description of the metric" string no
option "title" T "Title of the metric" string no
option "spoof" S "IP address and name of host/device (colon separated) we are spoofing" string default="" no
option "heartbeat" H "spoof a heartbeat message (use with spoof option)" no

Expand Down
10 changes: 8 additions & 2 deletions monitor-core/gmond/Makefile.am
Expand Up @@ -30,11 +30,15 @@ GCFLAGS += -DSFLOW
endif

INCLUDES = @APR_INCLUDES@
AM_CFLAGS = -I$(top_builddir)/lib -I$(top_builddir)/include/ -I$(top_builddir)/libmetrics $(GCFLAGS) -DSYSCONFDIR='"$(sysconfdir)"'
AM_CFLAGS = -I$(top_builddir)/lib -I$(top_builddir)/include/ -I$(top_builddir)/libmetrics $(GCFLAGS)

sbin_PROGRAMS = gmond

cmdline.c: cmdline.c.in $(FIXCONFIG)
$(FIXCONFIG) cmdline.c.in

# metric.h and dtd.h are for gmetad/gmetric for now....
gmond_SOURCES = gmond.c cmdline.c cmdline.h dtd.h g25_config.c core_metrics.c g25_config.h gmond_internal.h
gmond_SOURCES = gmond.c cmdline.c.in cmdline.c cmdline.h dtd.h g25_config.c core_metrics.c g25_config.h gmond_internal.h
if BUILD_SFLOW
gmond_SOURCES += sflow.h sflow.c sflow_gmetric.h
endif
Expand Down Expand Up @@ -67,3 +71,5 @@ gmond.solaris.init: gmond.solaris.init.in $(FIXCONFIG)
# something
install-exec-hook: gmond.solaris.init
# $(INSTALL_SCRIPT) gmond.solaris.init

CLEANFILES = cmdline.c

0 comments on commit d251675

Please sign in to comment.