summaryrefslogtreecommitdiff
path: root/scripts/build/genver
blob: c07324392cb0d3e349dea6dca3a9945febda12b3 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /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="m4/version.m4 $outputs"
	;;
     *version.def)
	outputs="include/version.def $outputs"
	;;
     *version.texi)
	outputs="include/version.texi $outputs"
	;;
     *) echo "Unrecognized option: $i"
	exit 1
	;;
    esac
done

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

set -e

. ../packageinfo.sh

dversion=`../scripts/build/VersionName -p ../packageinfo.sh`

set +e

# Create intermediate files in $TEMPDIR defaulting it to /tmp
# if not set.  This avoids races when multiple builds run in
# parallel on shared source.

TEMPDIR=${TEMPDIR=/tmp}

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

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

case "$outputs" in
 *version.texi*)
    echo "@set UPDATED `date +'%d %B %Y'`"	>  "${TEMPDIR}/version.texi+"
    echo "@set EDITION $dversion"		>> "${TEMPDIR}/version.texi+"
    echo "@set VERSION $dversion"		>> "${TEMPDIR}/version.texi+"
    cmp -s "${TEMPDIR}/version.texi+" include/version.texi
    rc=$?
    case "$force$rc" in
     00)
	rm -f "${TEMPDIR}/version.texi+"
	;;
     *)
	mv "${TEMPDIR}/version.texi+" include/version.texi
	;;
    esac
    ;;
esac