aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--src/tweetpipe.c9
2 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 28209e9..a554cda 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
+VERSION := $(shell git describe --tags --dirty --always)
+
PREFIX ?= /usr/local
WFLAGS ?= -Wall -Wextra -Wmissing-prototypes -Wdiv-by-zero -Wbad-function-cast -Wcast-align -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wnested-externs -Wno-unknown-pragmas -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wno-type-limits
CFLAGS ?= -O3 -mtune=native -fno-exceptions -flto $(WFLAGS)
+CFLAGS += -DVERSION_STRING=\"$(VERSION)\"
CPPFLAGS += -I. -Iext
STRIP ?= strip
diff --git a/src/tweetpipe.c b/src/tweetpipe.c
index 768faaf..ffeb18b 100644
--- a/src/tweetpipe.c
+++ b/src/tweetpipe.c
@@ -5,9 +5,10 @@
static struct option getopt_long_options[] = {
{ "help", 0, NULL, 'h' }, { "decrypt", 0, NULL, 'd' }, { "encrypt", 0, NULL, 'e' },
{ "in", 1, NULL, 'i' }, { "out", 1, NULL, 'o' }, { "pass", 1, NULL, 'p' },
- { "passfile", 1, NULL, 'P' }, { "passgen", 0, NULL, 'G' }, { NULL, 0, NULL, 0 }
+ { "passfile", 1, NULL, 'P' }, { "passgen", 0, NULL, 'G' }, { "version", 0, NULL, 'v' },
+ { NULL, 0, NULL, 0 }
};
-static const char *getopt_options = "hdeGi:o:p:P:";
+static const char *getopt_options = "hdeGvi:o:p:P:";
static void
usage(FILE *stream)
@@ -316,6 +317,10 @@ options_parse(Context *ctx, int argc, char *argv[])
case 'P':
read_password_file(ctx, optarg);
break;
+ case 'v':
+ printf("%s\n", VERSION_STRING);
+ exit(0);
+ break; /* NOTREACHED */
default:
usage(stderr);
}