summaryrefslogtreecommitdiff
path: root/update-version
blob: 124924b47c964ad3121c951a0eef1738ae32a0c7 (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
#!/bin/sh

set -e

if [ $# -lt 3 ] || [ $# -gt 5 ]; then
  echo >&2 "Usage: $0 <major> <minor> <patchlevel> [ <suffix> [ - ] ]"
  echo >&2 "(use 5 arguments to produce patches for releases)"
  exit 1
fi

# Examples:
#   ./update-version 2 3 0 dev
#   ./update-version 2 3 0 rc1
#   ./update-version 2 3 0
#   ./update-version 2 3 0 p1 -

vers="$1.$2.$3"
full="$vers${4:+-$4}"
echo $full > VERSION
perl -pi -e "s/(?<=#define MPFR_VERSION_MAJOR ).*/$1/; \
             s/(?<=#define MPFR_VERSION_MINOR ).*/$2/; \
             s/(?<=#define MPFR_VERSION_PATCHLEVEL ).*/$3/; \
             s/(?<=#define MPFR_VERSION_STRING ).*/\"$full\"/" mpfr.h
perl -pi -e "s/(?<=return \").*\"/$full\"/" version.c

if [ $# -lt 5 ]; then
  # Up to 4 arguments...
  u="http://www.mpfr.org/mpfr-"
  perl -pi -e "s/(?<=\@set VERSION ).*/$full/" mpfr.texi
  perl -pi -e \
    "s,MPFR [\d.]+( web page \@url{$u)[\d.]+/,MPFR $vers\${1}$vers/," mpfr.texi
  perl -pi -e "s/(?<=AC_INIT).*/([MPFR],[$full])/" configure.in
  perl -pi -e "s,(?<=$u).*?/,$vers/," INSTALL
fi

# If there is a suffix, disable one of the tests in tests/tversion.c
if [ $# -ge 4 ]; then
  tvers=0
else
  tvers=1
fi
perl -pi -e "s/(?<=#if ).*/$tvers/" tests/tversion.c

echo "MPFR version successfully updated."
echo "Don't forget to update MPFR libtool version in Makefile.am."