diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-03-09 21:27:48 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-03-09 21:29:14 -0700 |
commit | 10d4c586ebfd53175c637c0a49498a759d5a99dd (patch) | |
tree | 7185c62422337227779c7a82c495ae88e2a2e82c | |
parent | 7197661e5e956292efd5d918c900f1b4a1b50948 (diff) | |
download | upwgen-10d4c586ebfd53175c637c0a49498a759d5a99dd.tar.gz upwgen-10d4c586ebfd53175c637c0a49498a759d5a99dd.tar.xz |
Implemented version output
Set initial version to 1.0 because 1.1 isn't ready yet.
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | src/main.c | 12 |
2 files changed, 18 insertions, 2 deletions
@@ -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) @@ -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 |