From: Andre Noll Date: Fri, 12 Apr 2013 11:54:12 +0000 (+0200) Subject: Make gengetopt descriptions work. X-Git-Tag: v0.4.13~23^2~9 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b59e0eeefe6b51a26c1165f587bf3776369460a5 Make gengetopt descriptions work. With gengetopt's text and description options it is not possible to print a text only when --detailed-help was given, but not when only --help is given. Moreover, headers generated with old versions of gengetopt do not export the description text. However, declaring it unconditionally causes compiler warnings on new systems. To circumvent these problems, we introduce a new test for configure which checks whether the description string is declared. If it is not, we simply append the declaration to the *.cmdline.h files. This change allows to move the description string of para_play to the gengetopt source file. --- diff --git a/Makefile.in b/Makefile.in index f3dfea00..4103d762 100644 --- a/Makefile.in +++ b/Makefile.in @@ -9,6 +9,7 @@ PACKAGE_VERSION := @PACKAGE_VERSION@ PACKAGE_STRING := @PACKAGE_STRING@ install_sh := @install_sh@ executables := @executables@ +ggo_descriptions_declared := @ggo_descriptions_declared@ GENGETOPT := @gengetopt@ HELP2MAN := @help2man@ diff --git a/configure.ac b/configure.ac index 47dc6ace..0bd47916 100644 --- a/configure.ac +++ b/configure.ac @@ -465,7 +465,15 @@ AC_MSG_RESULT($have_ucred) if test ${have_ucred} = yes; then AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred) fi - +########################################################################### gengetopt +echo 'option "z" z "" flag off' | $gengetopt --file-name conftest-ggo && +AC_CHECK_DECL( + [gengetopt_args_info_description], + [ggo_descriptions_declared=yes], + [ggo_descriptions_declared=no], + [#include "conftest-ggo.h"] +) +AC_SUBST(ggo_descriptions_declared) ########################################################################### curses have_curses="yes" OLD_CPPFLAGS="$CPPFLAGS" diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index 7e1d10b5..c816bd74 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -12,6 +12,9 @@ endef $(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo git-version.h | $(cmdline_dir) @[ -z "$(Q)" ] || echo 'GGO $<' $(Q) $(GENGETOPT) $(ggo_opts) < $< +ifeq ($(ggo_descriptions_declared),no) + echo 'extern const char *$(*F)_args_info_description;' >> $(cmdline_dir)/$(*F).cmdline.h +endif $(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \ $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/color.m4 \ diff --git a/m4/gengetopt/play.m4 b/m4/gengetopt/play.m4 index 57f954c4..230e8388 100644 --- a/m4/gengetopt/play.m4 +++ b/m4/gengetopt/play.m4 @@ -1,4 +1,12 @@ args "--unamed-opts=audio_file --no-handle-version --conf-parser --no-handle-help" + +description "para_play operates either in command mode or in insert +mode. In insert mode it presents a prompt and allows to enter commands +like stop, play, pause etc. In command mode the current audio file +is shown and the program reads single key strokes from stdin. Keys +may be mapped to commands. Whenever a mapped key is pressed, the +associated command is executed." + include(header.m4) define(CURRENT_PROGRAM,para_play) define(DEFAULT_CONFIG_FILE,~/.paraslash/play.conf) diff --git a/play.c b/play.c index 255886b3..7c1ee932 100644 --- a/play.c +++ b/play.c @@ -137,16 +137,6 @@ static void check_afh_receiver_or_die(void) exit(EXIT_FAILURE); } -/** Description to be included in the --detailed-help output. */ -#define PP_DESC \ -"para_play is a command line audio player.\n" \ -"\n" \ -"It operates either in command mode or in insert mode. In insert mode it\n" \ -"presents a prompt and allows to enter para_play commands like stop, play, pause\n" \ -"etc. In command mode, the current audio file is shown and the program reads\n" \ -"single key strokes from stdin. Keys may be mapped to para_play commands.\n" \ -"Whenever a mapped key is pressed, the associated command is executed.\n" \ - __noreturn static void print_help_and_die(void) { int d = conf.detailed_help_given; @@ -156,7 +146,7 @@ __noreturn static void print_help_and_die(void) printf_or_die("%s\n\n", version_single_line("play")); printf_or_die("%s\n\n", play_args_info_usage); if (d) - printf_or_die("%s\n", PP_DESC); + printf_or_die("%s\n", play_args_info_description); for (; *p; p++) printf_or_die("%s\n", *p); exit(0);