summaryrefslogtreecommitdiff
path: root/update-version
blob: d4f5569b82d44dd8ef8b2e0740f893128c330adf (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
#!/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

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