c4432337180febc71eb3add42eaf7d58268a865f
[lemu] / version.sh
1 #!/bin/sh
2 # generate new version.h
3
4 set -e
5
6 if [ $# -lt 2 ]
7 then
8 echo "usage: `basename $0` <major> <minor> [<extra>]"
9 exit 1
10 fi
11
12 maj=`printf "%u" $1`
13 min=`printf "%u" $2`
14 shift 2
15 ext="$@"
16
17 str="${maj}.${min}"
18 if [ -n "${ext}" ]
19 then
20 str="${str}-${ext}"
21 fi
22 now=`TZ=UTC date "+%Y-%m-%d"`
23
24 commit=`git rev-parse HEAD`
25 branch=`git rev-parse --abbrev-ref HEAD`
26
27 cat>"version.h"<<EOF
28 #ifndef VERSION_H
29 #define VERSION_H
30
31 #define VERSION_MAJOR ${maj}
32 #define VERSION_MINOR ${min}
33 #define VERSION_EXTRA_STR "${ext}"
34 #define VERSION_STR "${str}"
35 #define VERSION_DATE "${now}"
36 #define VERSION_COMMIT "${commit}"
37 #define VERSION_BRANCH "${branch}"
38
39 #endif
40 EOF
41