summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--main.c10
-rw-r--r--version.c16
-rw-r--r--version.h18
4 files changed, 49 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ece7f79..f1b9e7c 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
#
NAME = eeshow
-OBJS = main.o \
+OBJS = main.o version.o \
kicad/sch-parse.o kicad/sch-render.o kicad/lib-parse.o \
kicad/lib-render.o kicad/dwg.o kicad/delta.o \
gui/gui.o gui/over.o gui/style.o gui/aoi.o gui/fmt-pango.o gui/input.o \
@@ -33,6 +33,10 @@ LDLIBS = -lm \
`pkg-config --libs libgit2` \
`pkg-config --libs gtk+-3.0`
+GIT_VERSION = $(shell git log -1 --format='%h' -s .)
+GIT_STATUS = $(shell [ -z "`git status -s -uno`" ] || echo +)
+CFLAGS += -DVERSION='"$(GIT_VERSION)$(GIT_STATUS)"'
+
ifneq ($(USE_WEBKIT),)
CFLAGS += -DUSE_WEBKIT `pkg-config --cflags webkit2gtk-4.0`
LDLIBS += `pkg-config --libs webkit2gtk-4.0`
@@ -44,10 +48,12 @@ endif
include ../common/Makefile.c-common
.PHONY: test neo900 sch test testref png pngref pdf diff view newref
+.PHONY: version.c
all:: $(NAME)
$(NAME): $(OBJS)
+ $(MAKE) version.o
$(CC) -o $(NAME) $(OBJS) $(LDLIBS)
help.inc: $(HELP_TEXT) Makefile
diff --git a/main.c b/main.c
index 15fa8e7..7f2256e 100644
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@
#include "gui/fmt-pango.h"
#include "file/git-hist.h"
#include "gui/gui.h"
+#include "version.h"
#include "main.h"
@@ -50,6 +51,7 @@ void usage(const char *name)
" %*s[-- driver_spec]\n"
" %s [-v ...] -C [rev:]file\n"
" %s [-v ...] -H path_into_repo\n"
+" %s -V\n"
" %s gdb ...\n"
"\n"
" rev git revision\n"
@@ -58,6 +60,7 @@ void usage(const char *name)
" -C 'cat' the file to standard output\n"
" -H show history of repository on standard output\n"
" -N n limit history to n revisions (unlimited if omitted or 0)\n"
+" -V print revision (version) number and exit\n"
" gdb run eeshow under gdb\n"
"\n"
"No driver spec: enter GUI\n"
@@ -83,7 +86,7 @@ void usage(const char *name)
" diff [-o output.pdf] [-s scale] [file.lib ...] file.sch\n"
"\n"
" see PNG\n"
- , name, name, (int) strlen(name) + 1, "", name, name, name);
+ , name, name, (int) strlen(name) + 1, "", name, name, name, name);
exit(1);
}
@@ -127,7 +130,7 @@ int main(int argc, char **argv)
if (!have_dashdash)
gtk_init(&argc, &argv);
- while ((c = getopt(dashdash, argv, "rvC:F:H:N:")) != EOF)
+ while ((c = getopt(dashdash, argv, "rvC:F:H:N:V")) != EOF)
switch (c) {
case 'r':
recurse = 1;
@@ -147,6 +150,9 @@ int main(int argc, char **argv)
case 'N':
limit = atoi(optarg);
break;
+ case 'V':
+ fprintf(stderr, "%s\n", version);
+ return 1;
default:
usage(*argv);
}
diff --git a/version.c b/version.c
new file mode 100644
index 0000000..a8b276f
--- /dev/null
+++ b/version.c
@@ -0,0 +1,16 @@
+/*
+ * version.c - GIT version
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include "version.h"
+
+
+const char *version = VERSION;
diff --git a/version.h b/version.h
new file mode 100644
index 0000000..deb101f
--- /dev/null
+++ b/version.h
@@ -0,0 +1,18 @@
+/*
+ * version.h - GIT version
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+extern const char *version;
+
+#endif /* !VERSION_H */