]> ruderich.org/simon Gitweb - wall-notify/wall-notify.git/commitdiff
add option -v to display current version
authorSimon Ruderich <simon@ruderich.org>
Sun, 18 May 2014 15:20:23 +0000 (17:20 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sun, 18 May 2014 15:20:23 +0000 (17:20 +0200)
This includes the current Git commit id if a git checkout is used.

.gitignore
man/wall-notify.txt
src/Makefile.am
src/wall-notify.c

index caf945d2b1790abf248e5344a297d95ffe6c37da..2dc54acf30aa84b34e28c386995e1bac9af1ee32 100644 (file)
@@ -15,6 +15,7 @@
 /src/.deps/
 /src/Makefile
 /src/Makefile.in
 /src/.deps/
 /src/Makefile
 /src/Makefile.in
+/src/git_version
 /src/wall-notify
 /src/wall-notify.o
 /stamp-h1
 /src/wall-notify
 /src/wall-notify.o
 /stamp-h1
index e059204b9c6b17f62e5ae21ee7fd845f756f9e8f..4a53825065c29180c46be4ad48b06ef4701fe1ef 100644 (file)
@@ -10,7 +10,7 @@ wall-notify - receive wall messages and pass them to a notification program
 SYNOPSIS
 --------
 
 SYNOPSIS
 --------
 
-*wall-notify* ['-X'] ['-m'] 'cmd' ['args']..
+*wall-notify* ['-X'] ['-m'] ['-v'] 'cmd' ['args']..
 
 
 DESCRIPTION
 
 
 DESCRIPTION
@@ -35,6 +35,9 @@ OPTIONS
     only messages from root are allowed. Be careful when using this option, it
     might be abused by local users to send fake messages.
 
     only messages from root are allowed. Be careful when using this option, it
     might be abused by local users to send fake messages.
 
+*-v*::
+    Display version.
+
 
 AUTHORS
 -------
 
 AUTHORS
 -------
index 5b18bbea2b20f7cae72f47ca707a821d06524cfe..e6a129584df79adbdcd40a199401d2bfa4e57244 100644 (file)
@@ -1 +1,10 @@
 bin_PROGRAMS = wall-notify
 bin_PROGRAMS = wall-notify
+
+# Provide current Git commit id as macro.
+AM_CPPFLAGS = -DGIT_VERSION="\"`cat $(srcdir)/git_version`\""
+wall-notify.$(OBJEXT): $(srcdir)/git_version
+
+$(srcdir)/git_version: $(SOURCES)
+       test -d $(top_srcdir)/.git && git describe --always >$@ || :>$@
+clean-local:
+       rm -f $(srcdir)/git_version
index bd1e8ad0112705b69355a882cf51f7cba2c510dc..9056af343a0be36ccd8ff9b7990bdc2055508816 100644 (file)
@@ -361,11 +361,12 @@ static void *x11_event_loop_thread(void *unused) {
 #endif
 
 static void usage(const char *argv0) {
 #endif
 
 static void usage(const char *argv0) {
-    fprintf(stderr, "usage: %s [-X] [-m] <cmd args..>\n", argv0);
+    fprintf(stderr, "usage: %s [-X] [-m] [-v] <cmd args..>\n", argv0);
     fprintf(stderr, "Pass wall messages to <cmd args..>.\n");
     fprintf(stderr, "\n");
     fprintf(stderr, "-X quit when the current X session terminates\n");
     fprintf(stderr, "-m allow messages from normal users (like `mesg y`)\n");
     fprintf(stderr, "Pass wall messages to <cmd args..>.\n");
     fprintf(stderr, "\n");
     fprintf(stderr, "-X quit when the current X session terminates\n");
     fprintf(stderr, "-m allow messages from normal users (like `mesg y`)\n");
+    fprintf(stderr, "-v display version\n");
 #ifdef DONT_USE_X11
     fprintf(stderr, "\n");
     fprintf(stderr, "compiled without X11 support, -X disabled\n");
 #ifdef DONT_USE_X11
     fprintf(stderr, "\n");
     fprintf(stderr, "compiled without X11 support, -X disabled\n");
@@ -392,7 +393,7 @@ int main(int argc, char **argv) {
      * the optstring with "+" fixes this behaver. This is not POSIX
      * compatible, but the option should be ignored on other systems.
      */
      * the optstring with "+" fixes this behaver. This is not POSIX
      * compatible, but the option should be ignored on other systems.
      */
-    while ((option = getopt(argc, argv, "+Xmh")) != -1) {
+    while ((option = getopt(argc, argv, "+Xmhv")) != -1) {
         switch (option) {
             case 'X':
                 enable_x11 = 1;
         switch (option) {
             case 'X':
                 enable_x11 = 1;
@@ -403,6 +404,12 @@ int main(int argc, char **argv) {
             case 'h':
                 usage(argv[0]);
                 break;
             case 'h':
                 usage(argv[0]);
                 break;
+            case 'v':
+                printf("%s%s\n",
+                       PACKAGE_STRING,
+                       strlen(GIT_VERSION) ? " (Git " GIT_VERSION ")" : "");
+                exit(0);
+                break;
             default:
                 fprintf(stderr, "%s: unknown option '%s'!\n\n",
                                 argv[0], argv[optind - 1]);
             default:
                 fprintf(stderr, "%s: unknown option '%s'!\n\n",
                                 argv[0], argv[optind - 1]);