2016-05-10 00:08:35 +00:00
|
|
|
#!/bin/bash -e
|
2014-03-15 16:59:03 +00:00
|
|
|
path="."
|
|
|
|
if [ x"$1" != x ]; then
|
|
|
|
path="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
versiongit() {
|
2016-01-14 12:31:48 +00:00
|
|
|
gitbranch=`git rev-parse --abbrev-ref HEAD`
|
|
|
|
gitversion=`git rev-parse HEAD`
|
2014-03-15 16:59:03 +00:00
|
|
|
cat <<EOF > $path/comptime.h
|
|
|
|
|
|
|
|
// 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
|
|
|
//
|
2016-01-14 12:31:48 +00:00
|
|
|
const char* compbranch = "$gitbranch";
|
|
|
|
const char* comprevision = "${gitversion:0:8}";
|
2014-03-15 16:59:03 +00:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
versionsvn() {
|
|
|
|
svnrevision=`svnversion -n $1`
|
|
|
|
cat <<EOF > $path/comptime.h
|
|
|
|
|
|
|
|
// Do not edit! This file was autogenerated
|
|
|
|
// by the $0 script with subversion
|
|
|
|
//
|
2016-01-14 12:31:48 +00:00
|
|
|
const char* compbranch = "Subversion";
|
2014-03-15 16:59:03 +00:00
|
|
|
const char* comprevision = "r$svnrevision";
|
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
versionfake() {
|
|
|
|
cat <<EOF > $path/comptime.h
|
|
|
|
|
|
|
|
// Do not edit! This file was autogenerated
|
|
|
|
// by the $0 script with an unknown or nonexist SCM
|
|
|
|
//
|
2016-01-14 12:31:48 +00:00
|
|
|
const char* compbranch = "Unknown";
|
2014-03-15 16:59:03 +00:00
|
|
|
const char* comprevision = "illegal";
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
compversion() {
|
|
|
|
touch $path/comptime.c
|
|
|
|
versionfake
|
|
|
|
test -d $path/.svn && versionsvn
|
|
|
|
test -d $path/../.git && versiongit
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
test -f $path/comptime.c && compversion
|
|
|
|
exit 2
|