Index: .gitignore
===================================================================
--- .gitignore	(revision 1c2215539b6fc902007acb74838c26980a8582a3)
+++ .gitignore	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -4,4 +4,5 @@
 .deps
 /bin/
+BUILD_VERSION.mk
 META.yml
 MYMETA.yml
@@ -40,3 +41,5 @@
 tester
 varstubs.c
+version.c
+version.c.new
 zcrypt
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 685cca76919848e87a4d135053ed4ebb281b5023)
+++ Makefile.am	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -1,6 +1,11 @@
 ACLOCAL_AMFLAGS = -I m4
 
-GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null))
-GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%))
+GIT_DESCRIPTION := $(if $(wildcard $(srcdir)/.git),$(shell cd $(srcdir) && git describe --match='barnowl-*' HEAD 2>/dev/null))
+VERSION = $(if $(GIT_DESCRIPTION),$(GIT_DESCRIPTION:barnowl-%=%),@VERSION@)
+-include BUILD_VERSION.mk
+
+FORCE:
+BUILD_VERSION.mk: $(if $(filter-out $(BUILD_VERSION),$(VERSION)),FORCE)
+	echo 'BUILD_VERSION = $(VERSION)' > $@
 
 bin_PROGRAMS = bin/barnowl
@@ -9,5 +14,5 @@
 endif
 
-zcrypt_SOURCES = zcrypt.c filterproc.c
+zcrypt_SOURCES = zcrypt.c filterproc.c version.c
 
 check_PROGRAMS = bin/tester
@@ -47,6 +52,5 @@
            -I$(top_srcdir)/libfaim/ \
            -DDATADIR='"$(pkgdatadir)"' \
-           -DBINDIR='"$(bindir)"' \
-           $(GIT_FLAGS)
+           -DBINDIR='"$(bindir)"'
 
 CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
@@ -64,5 +68,5 @@
 BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
 
-GEN_C = varstubs.c perlglue.c gmarshal_funcs.c
+GEN_C = varstubs.c perlglue.c gmarshal_funcs.c version.c version.c.new
 GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h
 
@@ -70,5 +74,5 @@
 
 # Only copy file into place if file.new is different
-%: %.new
+owl_prototypes.h version.c: %: %.new
 	@diff -U0 $@ $< || { \
 	 test -f $@ && echo '$@ changed!'; \
@@ -87,4 +91,7 @@
 	$(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
 
+version.c.new: Makefile BUILD_VERSION.mk
+	$(AM_V_GEN)echo 'const char *version = "$(VERSION)";' > $@
+
 gmarshal_funcs.h: marshal_types
 	glib-genmarshal --header $< > $@
@@ -96,5 +103,5 @@
 	$(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
 
-CLEANFILES = $(BUILT_SOURCES) $(GEN_C) $(noinst_SCRIPTS) $(check_SCRIPTS)
+CLEANFILES = $(BUILT_SOURCES) $(GEN_C) $(noinst_SCRIPTS) $(check_SCRIPTS) BUILD_VERSION.mk
 EXTRA_DIST = \
     autogen.sh \
Index: commands.c
===================================================================
--- commands.c	(revision a38becdc448115e22939c9ae8e8c8c16302ba876)
+++ commands.c	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -1114,5 +1114,5 @@
 void owl_command_version(void)
 {
-  owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
+  owl_function_makemsg("BarnOwl version %s", version);
 }
 
Index: functions.c
===================================================================
--- functions.c	(revision a38becdc448115e22939c9ae8e8c8c16302ba876)
+++ functions.c	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -115,8 +115,6 @@
 void owl_function_show_license(void)
 {
-  const char *text;
-
-  text=""
-    "BarnOwl version " OWL_VERSION_STRING "\n"
+  char *text = g_strdup_printf(
+    "BarnOwl version %s\n"
     "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
     "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
@@ -155,6 +153,8 @@
     "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n"
     "OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n"
-    "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n";
+    "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
+    version);
   owl_function_popless_text(text);
+  g_free(text);
 }
 
@@ -1359,6 +1359,6 @@
 void owl_function_about(void)
 {
-  owl_function_popless_text(
-    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
+  char *text = g_strdup_printf(
+    "This is BarnOwl version %s.\n\n"
     "BarnOwl is a fork of the Owl zephyr client, written and\n"
     "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
@@ -1379,6 +1379,8 @@
     "This program is free software. You can redistribute it and/or\n"
     "modify under the terms of the Sleepycat License. Use the \n"
-    "':show license' command to display the full license\n"
-  );
+      "':show license' command to display the full license\n",
+      version);
+  owl_function_popless_text(text);
+  g_free(text);
 }
 
@@ -1781,5 +1783,5 @@
 
   owl_fmtext_append_normal(&fm, "  Version: ");
-  owl_fmtext_append_normal(&fm, OWL_VERSION_STRING);
+  owl_fmtext_append_normal(&fm, version);
   owl_fmtext_append_normal(&fm, "\n");
 
Index: owl.c
===================================================================
--- owl.c	(revision 120dac7db15c30f52572662fbba2fde2b3ecc12a)
+++ owl.c	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -36,5 +36,5 @@
 void usage(FILE *file)
 {
-  fprintf(file, "Barnowl version %s\n", OWL_VERSION_STRING);
+  fprintf(file, "Barnowl version %s\n", version);
   fprintf(file, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
   fprintf(file, "  -n,--no-subs        don't load zephyr subscriptions\n");
@@ -80,5 +80,5 @@
       break;
     case 'v':
-      printf("This is BarnOwl version %s\n", OWL_VERSION_STRING);
+      printf("This is BarnOwl version %s\n", version);
       exit(0);
     case 'h':
@@ -578,7 +578,7 @@
   /* welcome message */
   owl_function_debugmsg("startup: creating splash message");
-  owl_function_adminmsg("",
+  char *welcome = g_strdup_printf(
     "-----------------------------------------------------------------------\n"
-    "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n"
+    "Welcome to BarnOwl version %s.\n"
     "To see a quick introduction, type ':show quickstart'.                  \n"
     "Press 'h' for on-line help.                                            \n"
@@ -588,6 +588,8 @@
     "                                                                 OvO   \n"
     "Please report any bugs or suggestions to bug-barnowl@mit.edu    (   )  \n"
-    "-----------------------------------------------------------------m-m---\n"
-  );
+    "-----------------------------------------------------------------m-m---\n",
+    version);
+  owl_function_adminmsg("", welcome);
+  g_free(welcome);
 
   owl_function_debugmsg("startup: setting context interactive");
Index: owl.h
===================================================================
--- owl.h	(revision 120dac7db15c30f52572662fbba2fde2b3ecc12a)
+++ owl.h	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -64,13 +64,5 @@
 #include "window.h"
 
-#ifndef OWL_VERSION_STRING
-#ifdef  GIT_VERSION
-#define stringify(x)       __stringify(x)
-#define __stringify(x)     #x
-#define OWL_VERSION_STRING stringify(GIT_VERSION)
-#else
-#define OWL_VERSION_STRING PACKAGE_VERSION
-#endif
-#endif /* !OWL_VERSION_STRING */
+extern const char *version;
 
 /* Feature that is being tested to redirect stderr through a pipe. 
Index: perlconfig.c
===================================================================
--- perlconfig.c	(revision 96d80e9b4aa667605b9c786b0272e1ab04dfbe9b)
+++ perlconfig.c	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -336,5 +336,5 @@
   }
 
-  sv_setpv(get_sv("BarnOwl::VERSION", TRUE), OWL_VERSION_STRING);
+  sv_setpv(get_sv("BarnOwl::VERSION", TRUE), version);
 
   /* Add the system lib path to @INC */
Index: zcrypt.c
===================================================================
--- zcrypt.c	(revision 8f335a834f5386dab0d7b5f0030cf9d5c03c6d42)
+++ zcrypt.c	(revision ca1fb26a9a22aea6ecd68b0150859ef065c6afc5)
@@ -29,13 +29,5 @@
 #include "filterproc.h"
 
-#ifndef OWL_VERSION_STRING
-#ifdef  GIT_VERSION
-#define stringify(x)       __stringify(x)
-#define __stringify(x)     #x
-#define OWL_VERSION_STRING stringify(GIT_VERSION)
-#else
-#define OWL_VERSION_STRING PACKAGE_VERSION
-#endif
-#endif /* !OWL_VERSION_STRING */
+extern const char *version;
 
 /* Annotate functions in which the caller owns the return value and is
@@ -157,5 +149,5 @@
       case OPT_VERSION:
         /* Version */
-        printf("This is zcrypt version %s\n", OWL_VERSION_STRING);
+        printf("This is zcrypt version %s\n", version);
         exit(0);
       case OPT_HELP:
