Add the bzr version number to non release builds
authorJonathan McDowell <noodles@earth.li>
Thu, 7 Apr 2011 03:17:57 +0000 (20:17 -0700)
committerJonathan McDowell <noodles@earth.li>
Thu, 7 Apr 2011 03:17:57 +0000 (20:17 -0700)
  If we're building from a bzr checkout then include the revision
  number in the version string we report.

.bzrignore
Makefile.in
armor.c
gpgwww.c
keyd.c
keydctl.c
lookup.c

index 70d4591abd7c79f08d1364acb85e73eca09f4cc6..69bae54986044b959819552ed90ab8dd8b3a180b 100644 (file)
@@ -18,3 +18,4 @@ stripkey
 tags
 .depend
 autom4te.cache
+version.h
index 66a3b5c60a481e764cc24cbc17a38e71441c85b1..49ea2a5a6bae3f972456c42658aa62e6c6f34189 100644 (file)
@@ -142,6 +142,7 @@ clean:
        $(RM) $(PROGS) $(OBJS) Makefile.bak testparse maxpath *.core core \
                gpgwww.o add.o lookup.o main.o maxpath.o onak.o sixdegrees \
                sixdegrees.o splitkeys.o stripkey.o onak.conf keyd.o \
+               version.h \
                $(foreach be,@BACKENDS@,keydb_$(be).o) *.so
 ifeq (x@KEYD@, xyes)
        $(RM) keyd.o keydb_$(DBTYPE).o
@@ -151,7 +152,16 @@ distclean: clean
        $(RM) -f Makefile .depend config.log config.status config.h
        $(RM) -r autom4te.cache
 
-.depend: $(SRCS)
+version.h:
+       @echo '#include "config.h"' > version.h
+       @if [ -e .bzr ]; then \
+               echo "#define ONAK_VERSION PACKAGE_VERSION \"+bzr`bzr revno`\"" \
+               >> version.h; \
+       else \
+               echo "#define ONAK_VERSION PACKAGE_VERSION" >> version.h; \
+       fi
+
+.depend: $(SRCS) version.h
        rm -f .depend
        $(MAKEDEPEND) $(CFLAGS) $(SRCS) > .depend
 
diff --git a/armor.c b/armor.c
index bb0085e348d3b73846367b7bab80938e0cc75f21..a192f77d18d8df0f624f67b2b54e2eac5fbb6a39 100644 (file)
--- a/armor.c
+++ b/armor.c
@@ -9,11 +9,11 @@
 #include <stdlib.h>
 
 #include "armor.h"
-#include "config.h"
 #include "keystructs.h"
 #include "log.h"
 #include "onak-conf.h"
 #include "parsekey.h"
+#include "version.h"
 
 #define ARMOR_WIDTH 64
 
@@ -323,8 +323,8 @@ int armor_openpgp_stream(int (*putchar_func)(void *ctx, size_t count,
         */
        putchar_func(ctx, sizeof("-----BEGIN PGP PUBLIC KEY BLOCK-----\n") - 1,
                (unsigned char *) "-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
-       putchar_func(ctx, sizeof("Version: onak " PACKAGE_VERSION "\n\n") - 1,
-               (unsigned char *) "Version: onak " PACKAGE_VERSION "\n\n");
+       putchar_func(ctx, sizeof("Version: onak " ONAK_VERSION "\n\n") - 1,
+               (unsigned char *) "Version: onak " ONAK_VERSION "\n\n");
        
        armor_init(&armor_ctx);
        armor_ctx.putchar_func = putchar_func;
index 7d90a00332f585fc4be843af4ea73bfcb83f02ea..f087123e65d58a2479766b349b79695cea06ecb2 100644 (file)
--- a/gpgwww.c
+++ b/gpgwww.c
@@ -14,7 +14,6 @@
 #include "armor.h"
 #include "charfuncs.h"
 #include "cleanup.h"
-#include "config.h"
 #include "getcgi.h"
 #include "hash.h"
 #include "keydb.h"
@@ -23,6 +22,7 @@
 #include "onak-conf.h"
 #include "parsekey.h"
 #include "stats.h"
+#include "version.h"
 
 #define OP_UNKNOWN 0
 #define OP_GET     1
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
 
        if (op != OP_GET) {
                puts("<HR>");
-               puts("Produced by gpgwww " PACKAGE_VERSION ", part of onak. "
+               puts("Produced by gpgwww " ONAK_VERSION ", part of onak. "
                        "<A HREF=\"mailto:noodles-onak@earth.li\">"
                        "Jonathan McDowell</A>");
                end_html();
diff --git a/keyd.c b/keyd.c
index c2d83491ea91fc6e23dcd75ee57ff0a9bbef1ec9..1a349a600b8d78b836bc7249f444de523b29e8ac 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -19,7 +19,6 @@
 #include <sys/un.h>
 #include <unistd.h>
 
-#include "config.h"
 #include "charfuncs.h"
 #include "cleanup.h"
 #include "keyd.h"
@@ -30,6 +29,7 @@
 #include "mem.h"
 #include "onak-conf.h"
 #include "parsekey.h"
+#include "version.h"
 
 void daemonize(void)
 {
@@ -381,7 +381,7 @@ int sock_accept(int fd)
 
 static void usage(void)
 {
-       puts("keyd " PACKAGE_VERSION " - backend key serving daemon for the "
+       puts("keyd " ONAK_VERSION " - backend key serving daemon for the "
                "onak PGP keyserver.\n");
        puts("Usage:\n");
        puts("\tkeyd [options]\n");
index b786fea3e9c7f5ae3bb662d53f7dd4f269182da9..96af7d2e61c12e018ffa9fb0238fbb191e990b0c 100644 (file)
--- a/keydctl.c
+++ b/keydctl.c
@@ -13,9 +13,9 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#include "config.h"
 #include "keyd.h"
 #include "onak-conf.h"
+#include "version.h"
 
 /* HACK: We need to stop onak-conf.o requiring this. */
 void *DBFUNCS = NULL;
@@ -147,7 +147,7 @@ static void keyd_status(void)
 
 static void usage(void)
 {
-       puts("keydctl " PACKAGE_VERSION " - control an onak keyd instance.\n");
+       puts("keydctl " ONAK_VERSION " - control an onak keyd instance.\n");
        puts("Usage:\n");
        puts("\tonak [options] <command> <parameters>\n");
        puts("\tCommands:\n");
index fafef123e6b37566bcc86dad4946a71374857d7d..9bafcc8950258932830d1ed436e01711f56650a1 100644 (file)
--- a/lookup.c
+++ b/lookup.c
@@ -17,7 +17,6 @@
 #include "charfuncs.h"
 #include "cleankey.h"
 #include "cleanup.h"
-#include "config.h"
 #include "getcgi.h"
 #include "keydb.h"
 #include "keyindex.h"
@@ -26,6 +25,7 @@
 #include "onak-conf.h"
 #include "parsekey.h"
 #include "photoid.h"
+#include "version.h"
 
 #define OP_UNKNOWN 0
 #define OP_GET     1
@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
        }
        if (!mrhkp) {
                puts("<hr>");
-               puts("Produced by onak " PACKAGE_VERSION 
+               puts("Produced by onak " ONAK_VERSION 
                                " by Jonathan McDowell");
                end_html();
        }