]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Fix git-version file creation.
authorAndre Noll <maan@systemlinux.org>
Tue, 22 Feb 2011 12:02:17 +0000 (13:02 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 5 Mar 2011 12:18:31 +0000 (13:18 +0100)
ATM, this does not work well, since only the executables depend on
GIT-VERSION-FILE, but relinking these does not take into account the
new contents of GIT-VERSION-FILE. Hence a "make clean" is necessary
to produce executables that reports the correct version number.

This patch  changes GIT-VERSION-GEN so that it generates a preprocessor
define instead of setting a Makefile variable. This value is written
to stdout in any case and also to the file named "$1" if an argument
was given and the current git version differs from the contents of
this file (or if the file does not exist).

In order to not have to recompile everything on version changes,
the macros related to versioning are moved from para.h into the new
version.h file which is included only where necessary.

Makefile.in no longer uses phony targets to include the GIT_VERSION
variable. Instead we simply execute

$(shell ./GIT_VERSION_FILE version.h)

at the top of the Makefile.

16 files changed:
.gitignore
GIT-VERSION-GEN
Makefile.in
afh.c
audioc.c
audiod.c
client_common.c
command.c
fade.c
filter.c
gui.c
para.h
recv.c
server.c
version.h [new file with mode: 0644]
write.c

index d3a1fc5e94aa4cba84113021557b0a1b882a4f93..91c6f8589b600c26b00e845fa4413b85ba038944 100644 (file)
@@ -30,4 +30,4 @@ web_sync
 confdefs.h
 conftest
 conftest.c
 confdefs.h
 conftest
 conftest.c
-GIT-VERSION-FILE
+git-version.h
index a64d79612ef3fbde0eadf35d657a5ed67825abce..15c387942fad6748244a530728bf58edc69c83ff 100755 (executable)
@@ -1,22 +1,17 @@
-#!/bin/sh
-
-if test $# -ne 1; then
-       echo >&2 "usage: $0 <version file>"
-       exit 1
-fi
+#!/usr/bin/env bash
 
 
+(($# > 1)) && { echo >&2 "usage: $0 [<version file>]"; exit 1; }
 GVF="$1"
 GVF="$1"
-DEF_VER="unnamed_version"
 
 
+DEF_VER="unnamed_version"
 LF='
 '
 
 # First see if there is a version file (included in release tarballs),
 # then try git-describe, then default.
 LF='
 '
 
 # First see if there is a version file (included in release tarballs),
 # then try git-describe, then default.
-if test -f VERSION
-then
+if [[ -f VERSION ]]; then
        VN=$(cat VERSION) || VN="$DEF_VER"
        VN=$(cat VERSION) || VN="$DEF_VER"
-elif test -d .git -o -f .git &&
+elif [[ -d .git || -f .git ]] &&
        VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
        case "$VN" in
        *$LF*) (exit 1) ;;
        VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
        case "$VN" in
        *$LF*) (exit 1) ;;
@@ -32,14 +27,12 @@ else
 fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
 fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
+echo "$VN"
 
 
-if test -r $GVF
-then
-       VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
-else
-       VC=unset
+[[ -z "$GVF" ]] && exit 0
+if [[ -r "$GVF" ]]; then
+       VC=$(sed -e 's/^#define GIT_VERSION "//; s/"$//' < "$GVF")
+       [[ "$VN" == "$VC" ]] && exit 0
 fi
 fi
-test "$VN" = "$VC" || {
-       echo >&2 "GIT_VERSION = $VN"
-       echo "GIT_VERSION = $VN" >$GVF
-}
+echo >&2 "new git version: $VN"
+echo "#define GIT_VERSION \"$VN\"" >$GVF
index c64b5ae7250ce5cceb178f39089319ae38894a11..06c86eb622247a2944f26a762e6f0986cdc2fe25 100644 (file)
@@ -16,6 +16,8 @@ uname_rs := $(shell uname -rs)
 cc_version := $(shell $(CC) --version | head -n 1)
 codename := deterministic entropy
 
 cc_version := $(shell $(CC) --version | head -n 1)
 codename := deterministic entropy
 
+GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
+
 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
 DEBUG_CPPFLAGS += -Wredundant-decls
 # produces false positives
 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
 DEBUG_CPPFLAGS += -Wredundant-decls
 # produces false positives
@@ -59,7 +61,6 @@ CPPFLAGS += @arch_cppflags@
 CPPFLAGS += -I/usr/local/include
 CPPFLAGS += -I$(cmdline_dir)
 CPPFLAGS += @osl_cppflags@
 CPPFLAGS += -I/usr/local/include
 CPPFLAGS += -I$(cmdline_dir)
 CPPFLAGS += @osl_cppflags@
-CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"'
 
 man_pages := $(patsubst %, man/man1/%.1, @executables@)
 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
 
 man_pages := $(patsubst %, man/man1/%.1, @executables@)
 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
@@ -99,18 +100,12 @@ else
        Q = @
 endif
 
        Q = @
 endif
 
-.PHONY: dep all clean distclean maintainer-clean install man tarball\
-       .FORCE-GIT-VERSION-FILE
+.PHONY: dep all clean distclean maintainer-clean install man tarball
 all: dep @executables@ $(man_pages)
 dep: $(deps)
 man: $(man_pages)
 tarball: $(tarball)
 
 all: dep @executables@ $(man_pages)
 dep: $(deps)
 man: $(man_pages)
 tarball: $(tarball)
 
-GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
-       @./GIT-VERSION-GEN GIT-VERSION-FILE
--include GIT-VERSION-FILE
-@executables@: GIT-VERSION-FILE
-
 -include $(ggo_dir)/makefile
 
 %_command_list.c: %.cmd
 -include $(ggo_dir)/makefile
 
 %_command_list.c: %.cmd
@@ -303,7 +298,7 @@ $(tarball): $(cmdline_generated)
        git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
                | tar --delete $(tarball_delete) > $(tarball_pfx).tar
        mkdir -p $(tarball_pfx)/$(cmdline_dir)
        git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
                | tar --delete $(tarball_delete) > $(tarball_pfx).tar
        mkdir -p $(tarball_pfx)/$(cmdline_dir)
-       echo $(GIT_VERSION) > $(tarball_pfx)/VERSION
+       ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
        cp -r $(autocrap) $(tarball_pfx)
        cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
        tar rf $(tarball_pfx).tar $(tarball_pfx)/*
        cp -r $(autocrap) $(tarball_pfx)
        cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
        tar rf $(tarball_pfx).tar $(tarball_pfx)/*
diff --git a/afh.c b/afh.c
index c5d7aec296a7a44b2fedfd2532ad838f89654e6c..37d71224ba5631cc24f79c194810c20f9d9eb95e 100644 (file)
--- a/afh.c
+++ b/afh.c
@@ -16,6 +16,7 @@
 #include "fd.h"
 #include "afh.h"
 #include "error.h"
 #include "fd.h"
 #include "afh.h"
 #include "error.h"
+#include "version.h"
 
 static struct afh_args_info conf;
 /** The list of all status items */
 
 static struct afh_args_info conf;
 /** The list of all status items */
index 74fb824cfff9d7193ebe42af9bfdc97ed5863fe0..adcae715e28d29c48da934a16360dab8b5ecc476 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -16,6 +16,7 @@
 #include "net.h"
 #include "string.h"
 #include "fd.h"
 #include "net.h"
 #include "string.h"
 #include "fd.h"
+#include "version.h"
 
 INIT_AUDIOC_ERRLISTS;
 
 
 INIT_AUDIOC_ERRLISTS;
 
index 8b17d95fba692db0b2dd9126226cb8fb2cb682d5..8dd69c60910a725999b193c3e254df9f9c69c2a3 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -33,6 +33,7 @@
 #include "write.h"
 #include "write_common.h"
 #include "signal.h"
 #include "write.h"
 #include "write_common.h"
 #include "signal.h"
+#include "version.h"
 
 /** define the array of error lists needed by para_audiod */
 INIT_AUDIOD_ERRLISTS;
 
 /** define the array of error lists needed by para_audiod */
 INIT_AUDIOD_ERRLISTS;
index a7115fd75ac33495d9dd36862ff446757bd9666c..54bb9433e34cbd0a5bbfed50d07a7d536e0f8b65 100644 (file)
@@ -25,6 +25,7 @@
 #include "client.h"
 #include "hash.h"
 #include "buffer_tree.h"
 #include "client.h"
 #include "hash.h"
 #include "buffer_tree.h"
+#include "version.h"
 
 /** The size of the receiving buffer. */
 #define CLIENT_BUFSIZE 4000
 
 /** The size of the receiving buffer. */
 #define CLIENT_BUFSIZE 4000
index f9ef6cd75ab8733408d3c2542230ae806281bf85..029e28908d70237041570063aca0f13d4bb78416 100644 (file)
--- a/command.c
+++ b/command.c
@@ -37,6 +37,7 @@
 #include "afs_command_list.h"
 #include "sched.h"
 #include "signal.h"
 #include "afs_command_list.h"
 #include "sched.h"
 #include "signal.h"
+#include "version.h"
 
 /** Commands including options must be shorter than this. */
 #define MAX_COMMAND_LEN 32768
 
 /** Commands including options must be shorter than this. */
 #define MAX_COMMAND_LEN 32768
diff --git a/fade.c b/fade.c
index 8eeb79e7d3f335b08ed1d2b8f3606e2fdec4cd6d..8affd69d57682cde8b41ec1cef4d6f51af44c52a 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -23,6 +23,7 @@
 #include "fd.h"
 #include "string.h"
 #include "error.h"
 #include "fd.h"
 #include "string.h"
 #include "error.h"
+#include "version.h"
 
 INIT_FADE_ERRLISTS;
 static struct fade_args_info conf;
 
 INIT_FADE_ERRLISTS;
 static struct fade_args_info conf;
index 1d938c45ac059a92ac59ac364be5abc73ebc2a13..0dfc94b1cc7213e024f6bc626c48be79cb09df75 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -20,6 +20,7 @@
 #include "stdin.h"
 #include "stdout.h"
 #include "error.h"
 #include "stdin.h"
 #include "stdout.h"
 #include "error.h"
+#include "version.h"
 
 /** The list of all status items used by para_{server,audiod,gui}. */
 const char *status_item_list[] = {STATUS_ITEM_ARRAY};
 
 /** The list of all status items used by para_{server,audiod,gui}. */
 const char *status_item_list[] = {STATUS_ITEM_ARRAY};
diff --git a/gui.c b/gui.c
index 38addd9815cc5bf2775c80278679a1e9c64e872e..4be81f749da4bfd244443973b0a6acb0c9207439 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -22,6 +22,7 @@
 #include "list.h"
 #include "sched.h"
 #include "signal.h"
 #include "list.h"
 #include "sched.h"
 #include "signal.h"
+#include "version.h"
 
 /** define the array of error lists needed by para_gui */
 INIT_GUI_ERRLISTS;
 
 /** define the array of error lists needed by para_gui */
 INIT_GUI_ERRLISTS;
diff --git a/para.h b/para.h
index 29c5c2b89c4ac3e0ca820c26c07cd8be4755f266..3121850f87ae27581d45da79e0f3ae9d57eced78 100644 (file)
--- a/para.h
+++ b/para.h
                va_end(argp); \
        }
 
                va_end(argp); \
        }
 
-/** Version text used by various commands if -V switch was given. */
-#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \
-       " (" GIT_VERSION ": " CODENAME ")" "\n" \
-       "Copyright (C) 2011 Andre Noll\n" \
-       "This is free software with ABSOLUTELY NO WARRANTY." \
-       " See COPYING for details.\n" \
-       "Written by Andre Noll.\n" \
-       "Report bugs to <maan@systemlinux.org>.\n"
-
-/** Print out \p VERSION_TEXT and exit if version flag was given. */
-#define HANDLE_VERSION_FLAG(_prefix, _args_info_struct) \
-       if (_args_info_struct.version_given) { \
-               printf("%s", VERSION_TEXT(_prefix)); \
-               exit(EXIT_SUCCESS); \
-       }
-
 /** Sent by para_client to initiate the authentication procedure. */
 #define AUTH_REQUEST_MSG "auth rsa "
 /** Sent by para_server for commands that expect a data file. */
 /** Sent by para_client to initiate the authentication procedure. */
 #define AUTH_REQUEST_MSG "auth rsa "
 /** Sent by para_server for commands that expect a data file. */
diff --git a/recv.c b/recv.c
index a737e4cbde81760cc2bf2014bd72b56b07210a60..ae8a1f663b725cbed40f763e0105fd04d2d4dcc9 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -22,6 +22,7 @@
 #include "error.h"
 #include "stdout.h"
 #include "buffer_tree.h"
 #include "error.h"
 #include "stdout.h"
 #include "buffer_tree.h"
+#include "version.h"
 
 /** The gengetopt args info struct. */
 static struct recv_args_info conf;
 
 /** The gengetopt args info struct. */
 static struct recv_args_info conf;
index 35d6f19137b3a881482df4e65c3945d6bcdb8a78..4d54f74b63d47e52fee508a899bc3b8970d1e1b6 100644 (file)
--- a/server.c
+++ b/server.c
@@ -91,6 +91,7 @@
 #include "signal.h"
 #include "user_list.h"
 #include "color.h"
 #include "signal.h"
 #include "user_list.h"
 #include "color.h"
+#include "version.h"
 
 /** Define the array of error lists needed by para_server. */
 INIT_SERVER_ERRLISTS;
 
 /** Define the array of error lists needed by para_server. */
 INIT_SERVER_ERRLISTS;
diff --git a/version.h b/version.h
new file mode 100644 (file)
index 0000000..3b83966
--- /dev/null
+++ b/version.h
@@ -0,0 +1,17 @@
+#include "git-version.h"
+/** Version text used by various commands if -V switch was given. */
+#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \
+       " (" GIT_VERSION ": " CODENAME ")" "\n" \
+       "Copyright (C) 2011 Andre Noll\n" \
+       "This is free software with ABSOLUTELY NO WARRANTY." \
+       " See COPYING for details.\n" \
+       "Written by Andre Noll.\n" \
+       "Report bugs to <maan@systemlinux.org>.\n"
+
+/** Print out \p VERSION_TEXT and exit if version flag was given. */
+#define HANDLE_VERSION_FLAG(_prefix, _args_info_struct) \
+       if (_args_info_struct.version_given) { \
+               printf("%s", VERSION_TEXT(_prefix)); \
+               exit(EXIT_SUCCESS); \
+       }
+
diff --git a/write.c b/write.c
index 2ea9d2132bee5f64224f3f9d635af8f83777a33e..cf48922a473e23a85d4153d9784af0cfcbb3011f 100644 (file)
--- a/write.c
+++ b/write.c
@@ -23,6 +23,7 @@
 #include "write_common.h"
 #include "fd.h"
 #include "error.h"
 #include "write_common.h"
 #include "fd.h"
 #include "error.h"
+#include "version.h"
 
 INIT_WRITE_ERRLISTS;
 
 
 INIT_WRITE_ERRLISTS;