]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/scripts/build/genver
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / ntp / scripts / build / genver
1 #! /bin/sh
2
3 # possible usage: $0 [-f] [version.m4] [version.def]
4 #
5 # -f would be 'force the update'
6
7 force=0
8 outputs=
9 for i in $*
10 do
11     case "$i" in
12      -f) 
13         force=1 
14         ;;
15      *version.m4)
16         outputs="m4/version.m4 $outputs"
17         ;;
18      *version.def)
19         outputs="include/version.def $outputs"
20         ;;
21      *version.texi)
22         outputs="include/version.texi $outputs"
23         ;;
24      *) echo "Unrecognized option: $i"
25         exit 1
26         ;;
27     esac
28 done
29
30 case "$outputs" in
31  '') outputs="m4/version.m4 include/version.def include/version.texi" ;;
32 esac
33
34 set -e
35
36 . ../packageinfo.sh
37
38 dversion=`../scripts/build/VersionName -p ../packageinfo.sh`
39
40 set +e
41
42 # Create intermediate files in $TEMPDIR defaulting it to /tmp
43 # if not set.  This avoids races when multiple builds run in
44 # parallel on shared source.
45
46 TEMPDIR=${TEMPDIR=/tmp}
47
48 case "$outputs" in
49  *version.m4*)
50     echo "m4_define([VERSION_NUMBER],[${dversion}])" > "${TEMPDIR}/version.m4+"
51     cmp -s "${TEMPDIR}/version.m4+" m4/version.m4
52     rc=$?
53     case "$force$rc" in
54      00)
55         rm -f "${TEMPDIR}/version.m4+"
56         ;;
57      *)
58         mv "${TEMPDIR}/version.m4+" m4/version.m4
59         ;;
60     esac
61     ;;
62 esac
63
64 case "$outputs" in
65  *version.def*)
66     echo "version = '${dversion}';" > "${TEMPDIR}/version.def+"
67     cmp -s "${TEMPDIR}/version.def+" include/version.def
68     rc=$?
69     case "$force$rc" in
70      00)
71         rm -f "${TEMPDIR}/version.def+"
72         ;;
73      *)
74         mv "${TEMPDIR}/version.def+" include/version.def
75         ;;
76     esac
77     ;;
78 esac
79
80 case "$outputs" in
81  *version.texi*)
82     echo "@set UPDATED `date +'%d %B %Y'`"      >  "${TEMPDIR}/version.texi+"
83     echo "@set EDITION $dversion"               >> "${TEMPDIR}/version.texi+"
84     echo "@set VERSION $dversion"               >> "${TEMPDIR}/version.texi+"
85     cmp -s "${TEMPDIR}/version.texi+" include/version.texi
86     rc=$?
87     case "$force$rc" in
88      00)
89         rm -f "${TEMPDIR}/version.texi+"
90         ;;
91      *)
92         mv "${TEMPDIR}/version.texi+" include/version.texi
93         ;;
94     esac
95     ;;
96 esac