aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/scripts/genver
blob: 0ce192213b483466bf056ea60f7681b6631e84f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/sh

# possible usage: $0 [-f] [version.m4] [version.def]
#
# -f would be 'force the update'

force=0
outputs=
for i in $*
do
    case "$i" in
     -f) force=1 ;;
     version.m4)
	outputs="version.m4 $outputs"
	;;
     *version.def)
	outputs="include/version.def $outputs"
	;;
     *) echo "Unrecognized option: $i"
	exit 1
	;;
    esac
done

case "$outputs" in
 '') outputs="version.m4 include/version.def" ;;
esac

set -e

. ./packageinfo.sh

dversion=`scripts/VersionName`

set +e

case "$outputs" in
 *version.m4*)
    echo "m4_define([VERSION_NUMBER],[${dversion}])" > /tmp/version.m4+
    cmp -s /tmp/version.m4+ version.m4
    rc=$?
    case "$force$rc" in
     00)
	rm -f /tmp/version.m4+
	;;
     *)
	mv /tmp/version.m4+ version.m4
	;;
    esac
    ;;
esac

case "$outputs" in
 *version.def*)
    echo "version = '${dversion}';" > /tmp/version.def+
    cmp -s /tmp/version.def+ include/version.def
    rc=$?
    case "$force$rc" in
     00)
	rm -f /tmp/version.def+
	;;
     *)
	mv /tmp/version.def+ include/version.def
	;;
    esac
    ;;
esac