summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--src/main.c12
2 files changed, 18 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 731b5b0..5ac06a0 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,16 @@ CCOPTS = -Wall -std=gnu99
out = upwgen
PREFIX = /usr/bin
+VERSION = 1
+PATCHLEVEL = 0
+EXTRAVERSION =
+
+VERSTR = "$(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL))$(EXTRAVERSION)"
+
all:
@if [ ! -d obj ]; then mkdir obj; fi
$(CC) $(CCOPTS) -c src/i18n_cat.c -o obj/i18n_cat.o
- $(CC) $(CCOPTS) src/main.c obj/*.o -o $(out)
+ $(CC) $(CCOPTS) -DVERSTR=$(VERSTR) src/main.c obj/*.o -o $(out)
install:
mkdir -p $(DESTDIR)/$(PREFIX)
diff --git a/src/main.c b/src/main.c
index 1111a2c..226b8d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,6 +21,11 @@
#include "i18n_cat.h"
+// Shamelessly ripped off from the GCC docs on stringizing
+// This (xstr) converts a macro to a string literal
+#define xstr(s) str(s)
+#define str(s) #s
+
void usage() {
printf(
@@ -42,6 +47,7 @@ void usage() {
"\n"
" -h,--help Print this help text\n"
" -d,--debug Enable debug mode (prints entire character pool)\n"
+ " -V,--version Prints the version\n"
);
}
@@ -99,7 +105,11 @@ int main(int argc, char* argv[]) {
return 0;
} else if(strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--debug") == 0) {
- debug = 1;
+ debug = 1;
+
+ } else if(strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
+ printf("upwgen %s\n", xstr(VERSTR));
+ return 0;
} else {
// If we reach this block, the user specified a custom length (or

Generated by cgit