]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Make gengetopt descriptions work.
authorAndre Noll <maan@systemlinux.org>
Fri, 12 Apr 2013 11:54:12 +0000 (13:54 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Jun 2013 16:29:03 +0000 (18:29 +0200)
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.

Makefile.in
configure.ac
m4/gengetopt/makefile
m4/gengetopt/play.m4
play.c

index f3dfea0065c31a564156000d0b1842eedc24e6c7..4103d762e15ed74eb1c3ae97b7123356711fd1aa 100644 (file)
@@ -9,6 +9,7 @@ PACKAGE_VERSION := @PACKAGE_VERSION@
 PACKAGE_STRING := @PACKAGE_STRING@
 install_sh := @install_sh@
 executables := @executables@
 PACKAGE_STRING := @PACKAGE_STRING@
 install_sh := @install_sh@
 executables := @executables@
+ggo_descriptions_declared := @ggo_descriptions_declared@
 
 GENGETOPT := @gengetopt@
 HELP2MAN := @help2man@
 
 GENGETOPT := @gengetopt@
 HELP2MAN := @help2man@
index 47dc6ace9817b4da10d296b8995935100e93e447..0bd479165614be03e5ad6a9cac35ab8f044d309b 100644 (file)
@@ -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
 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"
 ########################################################################### curses
 have_curses="yes"
 OLD_CPPFLAGS="$CPPFLAGS"
index 7e1d10b584bbbcb199141199b5bc9ca12ab0d69a..c816bd74ad8669b469417144e9aa01f13bdd6589 100644 (file)
@@ -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) < $<
 $(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 \
 
 $(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \
        $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/color.m4 \
index 57f954c4c0ee094f3f8323d2d25956672f91a0f3..230e8388e16cb06843a2fa3680f22a160081cf88 100644 (file)
@@ -1,4 +1,12 @@
 args "--unamed-opts=audio_file --no-handle-version --conf-parser --no-handle-help"
 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)
 include(header.m4)
 define(CURRENT_PROGRAM,para_play)
 define(DEFAULT_CONFIG_FILE,~/.paraslash/play.conf)
diff --git a/play.c b/play.c
index 255886b3530629b775f09bfbeaa47a7e771445ec..7c1ee93259ce6bd800daed3600ce7aae3400ffd9 100644 (file)
--- a/play.c
+++ b/play.c
@@ -137,16 +137,6 @@ static void check_afh_receiver_or_die(void)
        exit(EXIT_FAILURE);
 }
 
        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;
 __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\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);
        for (; *p; p++)
                printf_or_die("%s\n", *p);
        exit(0);