summaryrefslogtreecommitdiff
path: root/buildutil
diff options
context:
space:
mode:
Diffstat (limited to 'buildutil')
-rwxr-xr-xbuildutil/version-util37
1 files changed, 35 insertions, 2 deletions
diff --git a/buildutil/version-util b/buildutil/version-util
index 7e377ab..cf2aa31 100755
--- a/buildutil/version-util
+++ b/buildutil/version-util
@@ -10,6 +10,23 @@
# An indication if localy modified files exist is added.
# -----------------------------------------------------------------------------
+[ $# -lt 1 ] && echo "USAGE: version-util <versionfile>" && exit 1
+
+VERS_FILE=$1
+
+function createVers ()
+{
+cat <<EOF
+/* ATTENTION: this file is automatically generated and will be overwritten!
+ * Manual changes will get lost!
+ */
+#ifndef GEN_VERSION_SUFFIX_H
+#define GEN_VERSION_SUFFIX_H
+#define VERSION_SUFFIX $1
+#endif
+EOF
+}
+
function cvsVers ()
{
d=`cvs log -r -N 2> /dev/null \
@@ -34,10 +51,26 @@ function gitVers ()
echo "_git_${b}_${h}"
}
+function checkVers ()
+{
+ s=`$1`
+ if [ ! -e ${VERS_FILE} ]; then
+ echo "$VERS_FILE does not exist! creating a new one."
+ createVers $s > ${VERS_FILE}
+ else
+ v=`grep '^#define VERSION_SUFFIX' ${VERS_FILE} \
+ | awk '{print $3}'`
+ if [ "$v" != "$s" ]; then
+ echo "$VERS_FILE is being recreated!"
+ createVers $s > ${VERS_FILE}
+ fi
+ fi
+}
+
if [ -d CVS ]; then
- cvsVers
+ checkVers cvsVers
fi
if [ -d .git ]; then
- gitVers
+ checkVers gitVers
fi