Store git version string to a C file, not a header.
authorMichael Poole <mdpoole@troilus.org>
Fri, 14 Dec 2007 02:42:30 +0000 (21:42 -0500)
committerMichael Poole <mdpoole@troilus.org>
Fri, 14 Dec 2007 02:42:30 +0000 (21:42 -0500)
.gitignore: Update git-ignore.* file name.
Makefile.am: Update rebuild rules and srvx_SOURCES to match.
common.h: Declare git_version[].
main-common.c: Include git_version in version banner.  Update copyright years.
modcmd.c: Use git_version instead of GIT_VERSION.

src/.gitignore
src/Makefile.am
src/common.h
src/main-common.c
src/modcmd.c

index 647196b54f996ee7566649be3063516fe13d7306..2b2b6d4ac60875b2c6e2101ce30d53b6cd021daf 100644 (file)
@@ -2,6 +2,6 @@ Makefile.in
 config.h.in
 .deps
 config.h
-git-version.h
+git-version.c
 modules-list.h
 stamp-h1
index f24e00000aa854afa789d9d9378f792df8b93bc2..155ccd60e3f76cd86edec271016f64484b01033f 100644 (file)
@@ -15,23 +15,22 @@ noinst_DATA = \
        mod-memoserv.help \
        mod-sockcheck.help
 EXTRA_DIST = $(noinst_DATA)
-BUILT_SOURCES = git-version.h
-noinst_HEADERS = git-version.h
 
 if HAS_GIT
+BUILT_SOURCES = git-version.c
 .PHONY: checkversion
-git-version.h: checkversion
+git-version.c: checkversion
 checkversion:
        @GIT_VERSION=`$(GIT) describe`; \
        [ "z$$GIT_VERSION" != "z" ] || exit 0; \
-       TMPFILE=`mktemp git-version.h.XXXXXX` || exit 1 ; \
-       echo "#define GIT_VERSION \"$${GIT_VERSION}\"" >> $$TMPFILE ; \
-       if diff -q git-version.h $$TMPFILE >/dev/null 2>&1 ; then \
+       TMPFILE=`mktemp git-version.c.XXXXXX` || exit 1 ; \
+       echo "const char git_version[] = \"$${GIT_VERSION}\";" >> $$TMPFILE ; \
+       if diff -q git-version.c $$TMPFILE >/dev/null 2>&1 ; then \
            rm $$TMPFILE ; \
         else \
-           echo "Putting new git version into git-version.h" ; \
-           rm -f git-version.h ; \
-           mv $$TMPFILE git-version.h ; \
+           echo "Putting new git version into git-version.c" ; \
+           rm -f git-version.c ; \
+           mv $$TMPFILE git-version.c ; \
        fi
 endif
 
@@ -57,7 +56,7 @@ EXTRA_srvx_SOURCES = \
 srvx_LDADD = @MODULE_OBJS@
 srvx_DEPENDENCIES = @MODULE_OBJS@
 srvx_SOURCES = \
-       git-version.h \
+       git-version.c \
        chanserv.c chanserv.h \
        compat.c compat.h \
        conf.c conf.h \
index b979aa1a25138d1dad80420e6929ee61fbf9fe02..c23597c3ff9ac811ede4fb48114bc26555ec0927 100644 (file)
@@ -122,6 +122,7 @@ extern void verify(const void *ptr);
 extern time_t now;
 extern int quit_services;
 extern struct log_type *MAIN_LOG;
+extern const char git_version[];
 
 typedef union irc_in_addr {
     uint32_t in6_32[4];
index 16ba7c705843e8dbf4202526c05db431ca7b500d..2e4571005f4249d5e1ccf346de40cb024e08efae 100644 (file)
@@ -549,8 +549,10 @@ version()
 {
     printf("    --------------------------------------------------\n"
            "    - "PACKAGE_STRING" ("CODENAME"), Built: " __DATE__ ", " __TIME__".\n"
-           "    - Copyright (C) 2000 - 2005, srvx Development Team\n"
-           "    --------------------------------------------------\n");
+           "    - Copyright (C) 2000 - 2007, srvx Development Team\n"
+           "    - Version tag %s\n"
+           "    --------------------------------------------------\n",
+           git_version);
 }
 
 static void
index 910e22f27b49e2318a3a5b8eceb7892643eb9076..e41a1eaa1682aedf2a7e2185469c0be6bdd128bc 100644 (file)
@@ -18,7 +18,6 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
-#include "git-version.h"
 #include "chanserv.h"
 #include "conf.h"
 #include "modcmd.h"
@@ -877,7 +876,7 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, in
              * users, except to add copyright information pertaining
              * to changes you make to srvx.
              */
-            snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, GIT_VERSION);
+            snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, git_version);
             irc_notice_user(bot, user, response);
         }
         return;
@@ -1857,7 +1856,7 @@ static MODCMD_FUNC(cmd_version) {
      */
     send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__".  Copyright 2000-2007 srvx Development Team.");
     if (argc > 1)
-        send_message_type(4, user, cmd->parent->bot, "%s", GIT_VERSION);
+        send_message_type(4, user, cmd->parent->bot, "%s", git_version);
     else
         send_message_type(12, user, cmd->parent->bot, "The srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net.");
     return 1;