2022-03-28 02:16:07 +00:00
|
|
|
#!/bin/sh
|
2014-03-15 16:59:03 +00:00
|
|
|
path="."
|
|
|
|
if [ x"$1" != x ]; then
|
|
|
|
path="$1"
|
|
|
|
fi
|
|
|
|
|
2022-03-28 02:16:07 +00:00
|
|
|
version() {
|
|
|
|
cat <<EOF > "$path/comptime.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Do not edit! This file was autogenerated
|
2016-01-14 12:31:48 +00:00
|
|
|
// by the $0 script with git
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
2022-03-28 02:16:07 +00:00
|
|
|
const char* compbranch = "$1";
|
|
|
|
const char* comprevision = "$2";
|
2014-03-15 16:59:03 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2022-03-28 02:16:07 +00:00
|
|
|
versiongit() {
|
|
|
|
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
gitversion="$(git rev-parse HEAD | cut -c -8)"
|
|
|
|
version "$gitbranch" "$gitversion";
|
|
|
|
exit 0
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2022-03-28 02:16:07 +00:00
|
|
|
versionsvn() {
|
|
|
|
svnrevision="$(svnversion -n $1)"
|
|
|
|
version "Subversion" "r$svnrevision";
|
|
|
|
exit 0
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
versionfake() {
|
2022-03-28 02:16:07 +00:00
|
|
|
version "Unknown" "illegal";
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
compversion() {
|
2022-03-28 02:16:07 +00:00
|
|
|
touch "$path/comptime.c"
|
|
|
|
versionfake
|
|
|
|
[ -d "$path/.svn" ] && versionsvn
|
|
|
|
[ -d "$path/../.git" ] && versiongit
|
|
|
|
exit 1
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2022-03-28 02:16:07 +00:00
|
|
|
[ -f "$path/comptime.c" ] && compversion
|
2014-03-15 16:59:03 +00:00
|
|
|
exit 2
|