Make all commands print git version and improve version string.
authorAndre Noll <maan@systemlinux.org>
Tue, 26 Mar 2013 23:30:49 +0000 (23:30 +0000)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Jun 2013 16:29:03 +0000 (18:29 +0200)
Currently the format of the first line of the help output varies
between executables, for example:

para_afh git (0.4.12.12.g15a4: spectral gravity)
para_audioc git

This difference comes from the fact that para_afh has its own
->print_help method which uses the VERSION_SINGLE_LINE macro of
version.h while para_audioc relies on gengetopt's help output.

The latter uses the make variable PACKAGE_VERSION which gets
initialized at configure time through the second argument in AC_INIT
of configure.ac. This value is either the version number for or the
string "git".

It's a good thing to have the abbreviated git version encoded in
all executables, so this commit changes the argument of gengetopt's
--set-version to the git version string including the codename. With
the patch applied, the output of all commands looks like this if
--version was given:

para_filter 0.4.12.12.g11d7 (spectral gravity)

To make sure things stay consistent, the patch introduces the
VERSION_SINGLE_LINE macro and changes all commands to use it instead
of open coding the version string.

audiod.c
filter.c
m4/gengetopt/makefile
play.c
recv.c
version.h
write.c

index e3e3bd9..e0ca15e 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1305,8 +1305,7 @@ __noreturn static void print_help_and_die(void)
        const char **p = d? audiod_args_info_detailed_help
                : audiod_args_info_help;
 
-       printf_or_die("%s\n\n", AUDIOD_CMDLINE_PARSER_PACKAGE "-"
-               AUDIOD_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", VERSION_SINGLE_LINE("audiod"));
        printf_or_die("%s\n\n", audiod_args_info_usage);
        for (; *p; p++)
                printf_or_die("%s\n", *p);
index c6af586..65d6c64 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -51,8 +51,7 @@ __noreturn static void print_help_and_die(void)
        const char **p = d? filter_args_info_detailed_help
                : filter_args_info_help;
 
-       printf_or_die("%s\n\n", FILTER_CMDLINE_PARSER_PACKAGE "-"
-               FILTER_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", VERSION_SINGLE_LINE("filter"));
        printf_or_die("%s\n\n", filter_args_info_usage);
        for (; *p; p++)
                printf_or_die("%s\n", *p);
index 05be137..7e1d10b 100644 (file)
@@ -1,6 +1,6 @@
 define ggo_opts
        --output-dir=$(cmdline_dir) \
-       --set-version="$(PACKAGE_VERSION)" \
+       --set-version="$(GIT_VERSION) ($(codename))" \
        --arg-struct-name=$(*F)_args_info \
        --file-name=$(*F).cmdline \
        --func-name=$(*F)_cmdline_parser \
@@ -9,7 +9,7 @@ endef
 
 .PRECIOUS: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h $(ggo_dir)/%.ggo
 
-$(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo | $(cmdline_dir)
+$(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo git-version.h | $(cmdline_dir)
        @[ -z "$(Q)" ] || echo 'GGO $<'
        $(Q) $(GENGETOPT) $(ggo_opts) < $<
 
diff --git a/play.c b/play.c
index 814ec16..9204792 100644 (file)
--- a/play.c
+++ b/play.c
@@ -153,9 +153,7 @@ __noreturn static void print_help_and_die(void)
        const char **p = d? play_args_info_detailed_help
                : play_args_info_help;
 
-//     printf_or_die("%s\n\n", PLAY_CMDLINE_PARSER_PACKAGE "-"
-//             PLAY_CMDLINE_PARSER_VERSION);
-
+       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);
diff --git a/recv.c b/recv.c
index bc727de..f8b5847 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -43,8 +43,7 @@ __noreturn static void print_help_and_die(void)
        const char **p = d? recv_args_info_detailed_help
                : recv_args_info_help;
 
-       printf_or_die("%s\n\n", RECV_CMDLINE_PARSER_PACKAGE "-"
-               RECV_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", VERSION_SINGLE_LINE("recv"));
        printf_or_die("%s\n\n", recv_args_info_usage);
        for (; *p; p++)
                printf_or_die("%s\n", *p);
index 3d86521..6309fd0 100644 (file)
--- a/version.h
+++ b/version.h
@@ -2,9 +2,11 @@
 
 #include "git-version.h"
 
+#define VERSION_SINGLE_LINE(prefix) "para_" prefix \
+       " " GIT_VERSION " (" CODENAME ")"
+
 /** Version text printed by all executables if -V was given. */
-#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \
-       " (" GIT_VERSION ": " CODENAME ")" "\n" \
+#define VERSION_TEXT(prefix) VERSION_SINGLE_LINE(prefix) "\n" \
        "Copyright (C) 2013 Andre Noll\n" \
        "This is free software with ABSOLUTELY NO WARRANTY." \
        " See COPYING for details.\n" \
diff --git a/write.c b/write.c
index f4f757f..0f04fe5 100644 (file)
--- a/write.c
+++ b/write.c
@@ -39,8 +39,7 @@ __noreturn static void print_help_and_die(void)
        const char **p = d? write_args_info_detailed_help
                : write_args_info_help;
 
-       printf_or_die("%s\n\n", WRITE_CMDLINE_PARSER_PACKAGE "-"
-               WRITE_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", VERSION_SINGLE_LINE("write"));
        printf_or_die("%s\n\n", write_args_info_usage);
        for (; *p; p++)
                printf_or_die("%s\n", *p);