#!/bin/sh -ex
TMP="$1".tmp
DST="$1"
GAP_BUILD_VERSION="4.8.10, 15-Jan-2018, build"
if command -v git >/dev/null 2>&1 ; then
if test -d .git ; then
GAP_BUILD_VERSION=`git describe --tags --dirty || echo`
fi
fi
GAP_BUILD_DATE=`date +"%Y-%m-%d %H:%M:%S (%Z)"`
cat > "$TMP" <<EOF
#ifndef GAP_BUILD_VERSION
#define GAP_BUILD_VERSION "$GAP_BUILD_VERSION"
#define GAP_BUILD_DATETIME "$GAP_BUILD_DATE"
#endif
EOF
if ! cmp -s $TMP $DST ; then
cp "$TMP" "$DST"
fi;
rm $TMP