Split code into modules, handle USR1, minor fixes.
[reservoir_sample] / version.sh
1 #!/bin/sh
2 # generate new version.h
3
4 if [ $# -lt 2 ]
5 then
6 echo "usage: `basename $0` <major> <minor> [<extra>]"
7 exit 1
8 fi
9
10 maj=`printf "%u" $1` || exit 1
11 min=`printf "%u" $2` || exit 1
12 shift 2
13 ext="$@"
14
15 str="${maj}.${min}"
16 if [ -n "${ext}" ]
17 then
18 str="${str}-${ext}"
19 fi
20 now=`TZ=UTC date "+%Y-%m-%d"` || exit 1
21
22 cat>"version.h"<<EOF
23 #ifndef VERSION_H
24 #define VERSION_H
25
26 #define VERSION_MAJOR ${maj}
27 #define VERSION_MINOR ${min}
28 #define VERSION_EXTRA_STR "${ext}"
29 #define VERSION_STR "${str}"
30 #define VERSION_DATE "${now}"
31
32 #endif
33 EOF
34