| 1 | #! /bin/sh |
| 2 | |
| 3 | # Time-stamp: <2015-09-27 13:45:22 feeley> |
| 4 | |
| 5 | # Utility to change the version of Gambit attached to a source file. |
| 6 | # |
| 7 | # Usage: changev 40062 40063 file1 file2 |
| 8 | |
| 9 | OLDVERSION=$1 |
| 10 | NEWVERSION=$2 |
| 11 | TEMPFILE=/tmp/changev.$$ |
| 12 | |
| 13 | OLDMAJORVERSION=`eval expr $OLDVERSION / 100000` |
| 14 | OLDMINORVERSION=`eval expr $OLDVERSION % 100000 / 1000` |
| 15 | OLDREVISIONVERSION=`eval expr $OLDVERSION % 1000` |
| 16 | OLDVERSIONSTRING="v$OLDMAJORVERSION"."$OLDMINORVERSION"."$OLDREVISIONVERSION" |
| 17 | OLDDISTSTRING="v$OLDMAJORVERSION"_"$OLDMINORVERSION"_"$OLDREVISIONVERSION" |
| 18 | |
| 19 | NEWMAJORVERSION=`eval expr $NEWVERSION / 100000` |
| 20 | NEWMINORVERSION=`eval expr $NEWVERSION % 100000 / 1000` |
| 21 | NEWREVISIONVERSION=`eval expr $NEWVERSION % 1000` |
| 22 | NEWVERSIONSTRING="v$NEWMAJORVERSION"."$NEWMINORVERSION"."$NEWREVISIONVERSION" |
| 23 | NEWDISTSTRING="v$NEWMAJORVERSION"_"$NEWMINORVERSION"_"$NEWREVISIONVERSION" |
| 24 | |
| 25 | while [ -n "$3" ] |
| 26 | do |
| 27 | |
| 28 | FILE=$3 |
| 29 | |
| 30 | sed -e "s/#define ___VERSION $OLDVERSION/#define ___VERSION $NEWVERSION/g" -e "s/Gambit $OLDVERSIONSTRING/Gambit $NEWVERSIONSTRING/g" -e "s/Gambit Version $OLDVERSIONSTRING/Gambit Version $NEWVERSIONSTRING/g" -e "s/Gambit,$OLDVERSION/Gambit,$NEWVERSION/g" -e "s/(define (system-version) $OLDVERSION)/(define (system-version) $NEWVERSION)/g" -e "s/PACKAGE_VERSION=\'$OLDVERSION\'/PACKAGE_VERSION=\'$NEWVERSION\'/g" -e "s/PACKAGE_STRING=\'Gambit $OLDVERSION\'/PACKAGE_STRING=\'Gambit $NEWVERSION\'/g" -e "s/Gambit $OLDVERSION/Gambit $NEWVERSION/g" -e "s/Gambit configure $OLDVERSION/Gambit configure $NEWVERSION/g" -e "s/Gambit \$as_me $OLDVERSION/Gambit \$as_me $NEWVERSION/g" -e "s/Gambit config.status $OLDVERSION/Gambit config.status $NEWVERSION/g" -e "s/___VERSION != $OLDVERSION/___VERSION != $NEWVERSION/g" -e "s/gambit-not$OLDVERSION.h/gambit-not$NEWVERSION.h/g" -e "s/AC_INIT(Gambit,$OLDVERSIONSTRING,[email protected],gambit-$OLDDISTSTRING)/AC_INIT(Gambit,$NEWVERSIONSTRING,[email protected],gambit-$NEWDISTSTRING)/g" -e "s/gambit_dist_if_downloaded=\"gambit-$OLDDISTSTRING/gambit_dist_if_downloaded=\"gambit-$NEWDISTSTRING/g" $FILE > $TEMPFILE |
| 31 | |
| 32 | diff -q $FILE $TEMPFILE > /dev/null |
| 33 | |
| 34 | if [ $? -eq 1 ] |
| 35 | then |
| 36 | echo =================================================== $FILE |
| 37 | diff $FILE $TEMPFILE |
| 38 | if [ -x $FILE ] |
| 39 | then |
| 40 | chmod +x $TEMPFILE |
| 41 | fi |
| 42 | mv $TEMPFILE $FILE |
| 43 | #rm -f $TEMPFILE |
| 44 | else |
| 45 | rm -f $TEMPFILE |
| 46 | fi |
| 47 | |
| 48 | shift |
| 49 | |
| 50 | done |