summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>2013-02-26 18:24:02 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-26 10:47:04 -0800
commit42fa5a6368a3cc25b804b7dff769b806e86113ac (patch)
tree9a7c2e19e947a26acb8da7297bd6383776e0fcd6
parent686a27aee95a78213778ccbaa58c0fd7d88d12f6 (diff)
downloadsubsurface-42fa5a6368a3cc25b804b7dff769b806e86113ac.tar.gz
Generate/update a version.h header file.
This is dedicated to Lubomir ;) Should work (tm). Not sure though if you want target 'gen_version_file' as a pre-requisite to $(NAME) or some other target. [Dirk Hohndel: minor adjustments to make it work with gtk-gui.c] Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--.gitignore1
-rw-r--r--Makefile20
-rw-r--r--gtk-gui.c2
3 files changed, 18 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index ff447f7ed..50d668f39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*.dmg
*.patch
*.xml
+version.h
!dives/*.xml
*~
po/*.mo
diff --git a/Makefile b/Makefile
index a8e4d2fef..f0d1b8e43 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,12 @@ DESKTOPFILE = $(NAME).desktop
MANFILES = $(NAME).1
XSLTFILES = xslt/*.xslt
+VERSION_FILE = version.h
+# There's only one line in $(VERSION_FILE); use the shell builtin `read'
+STORED_VERSION_STRING = \
+ $(subst ",,$(shell read ignore ignore v <$(VERSION_FILE) && echo $$v))
+#" workaround editor syntax highlighting quirk
+
UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win")
GET_VERSION = ./scripts/get-version
VERSION_STRING := $(shell $(GET_VERSION) linux || echo "v$(VERSION)")
@@ -157,7 +163,13 @@ OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o deco.o plann
DEPS = $(wildcard .dep/*.dep)
-$(NAME): $(OBJS) $(MSGOBJS) $(INFOPLIST)
+gen_version_file:
+ifneq ($(STORED_VERSION_STRING),$(VERSION_STRING))
+ $(info updating $(VERSION_FILE) to $(VERSION_STRING))
+ @echo \#define VERSION_STRING \"$(VERSION_STRING)\" >$(VERSION_FILE)
+endif
+
+$(NAME): gen_version_file $(OBJS) $(MSGOBJS) $(INFOPLIST)
$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
install: $(NAME)
@@ -256,8 +268,7 @@ prepare-po-files:
EXTRA_FLAGS = $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
$(XSLT) $(ZIP) $(LIBDIVECOMPUTERCFLAGS) \
- $(LIBSOUPCFLAGS) $(OSMGPSMAPFLAGS) $(GCONF2CFLAGS) \
- -DVERSION_STRING='"$(VERSION_STRING)"'
+ $(LIBSOUPCFLAGS) $(OSMGPSMAPFLAGS) $(GCONF2CFLAGS)
%.o: %.c
@echo ' CC' $<
@@ -290,7 +301,8 @@ doc:
$(MAKE) -C Documentation doc
clean:
- rm -f $(OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot
+ rm -f $(OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \
+ $(VERSION_FILE)
rm -rf share .dep
-include $(DEPS)
diff --git a/gtk-gui.c b/gtk-gui.c
index 8f912b5bc..a68047464 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -22,7 +22,7 @@
#include "uemis.h"
#include "device.h"
#include "webservice.h"
-
+#include "version.h"
#include "libdivecomputer.h"
#include <gdk-pixbuf/gdk-pixbuf.h>