#!/bin/sh # Run this script from the top or tools directory to update some files # before a patch is built. set -e LC_ALL=C export LC_ALL if [ $# -ne 1 ]; then echo >&2 "Usage: $0 " exit 1 fi dir=`pwd` [ -d src ] || [ "`basename "$dir"`" != tools ] || cd .. replace() { if [ ! -h "$2" ] && [ -r "$2" ] && [ -w "$2" ]; then err=`perl -pi -e "$1" "$2" 2>&1 >/dev/null` if [ -n "$err" ]; then printf >&2 "Error from perl:\n%s\n" "$err" exit 2 fi else printf >&2 "Error: %s is not a readable/writable file\n" "$2" exit 2 fi } vers="`perl -pe 's/^(\d+\.\d+\.\d+).*/\1/' VERSION`" if [ -z "$vers" ]; then echo >&2 "Error: could not get the current MPFR version" exit 2 fi full="${vers}-p$1" echo $full > VERSION replace "s/(?<=#define MPFR_VERSION_STRING ).*/\"$full\"/" src/mpfr.h replace "s/(?<=return \").*\"/$full\"/" src/version.c replace "s/(?<=#if ).*/0/" tests/tversion.c echo "MPFR version successfully updated."