| 1 |
#!/bin/csh -f |
| 2 |
# Copyright (c) 2011 FFLAS-FFPACK |
| 3 |
# written by Brice Boyer (briceboyer) <[email protected]> |
| 4 |
# adapted from LinBox configuration |
| 5 |
# |
| 6 |
# ========LICENCE======== |
| 7 |
# This file is part of the library FFLAS-FFPACK. |
| 8 |
# |
| 9 |
# FFLAS-FFPACK is free software: you can redistribute it and/or modify |
| 10 |
# it under the terms of the GNU Lesser General Public |
| 11 |
# License as published by the Free Software Foundation; either |
| 12 |
# version 2.1 of the License, or (at your option) any later version. |
| 13 |
# |
| 14 |
# This library is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
# Lesser General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU Lesser General Public |
| 20 |
# License along with this library; if not, write to the Free Software |
| 21 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 |
# ========LICENCE======== |
| 23 |
#/ |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
set conf = configure.ac |
| 28 |
set ver = Makefile.am |
| 29 |
|
| 30 |
#verbatim second argument of AC_INIT |
| 31 |
set verb = `grep ^AC_INIT $conf | cut -d',' -f2` |
| 32 |
#removes spaces and brackets |
| 33 |
set vern = `echo "$verb" | sed 's/ //g;s/\[//;s/\]//'` |
| 34 |
echo "Current version is $vern." |
| 35 |
|
| 36 |
|
| 37 |
echo -n "Increment library version ? (y/n)" |
| 38 |
set answ = $< |
| 39 |
if ("$answ" == "y") then |
| 40 |
set line = `fgrep -n ^AC_INIT $conf | cut -d':' -f1` #gets the line |
| 41 |
set macro = `echo "$vern" | cut -d'.' -f1` #a version number is macro.minor.micro |
| 42 |
set minor = `echo "$vern" | cut -d'.' -f2` |
| 43 |
set micro = `echo "$vern" | cut -d'.' -f3` |
| 44 |
set tmpfile = `mktemp` #tempfile |
| 45 |
set sedfile = `mktemp` #temp sed file |
| 46 |
set pmicro = `echo $micro` |
| 47 |
@ pmicro ++ |
| 48 |
set pminor = `echo $minor` |
| 49 |
@ pminor ++ |
| 50 |
set pmacro = `echo $macro` |
| 51 |
@ pmacro ++ |
| 52 |
echo "Increment micro revision number ($vern -> $macro.$minor.$pmicro) ? press '0' " |
| 53 |
echo "Increment minor revision number ($vern -> $macro.$pminor.0) ? press '1' " |
| 54 |
echo -n "Increment macro revision number ($vern -> $pmacro.0.0) ? press '2' " |
| 55 |
set increm = $< |
| 56 |
switch ($increm) |
| 57 |
case 0: |
| 58 |
set newv = "[$macro.$minor.$pmicro]" |
| 59 |
breaksw |
| 60 |
case 1: |
| 61 |
set newv = "[$macro.$pminor.0]" |
| 62 |
breaksw |
| 63 |
case 2: |
| 64 |
set newv = "[$pmacro.0.0]" |
| 65 |
breaksw |
| 66 |
default: |
| 67 |
set newv = "$verb" |
| 68 |
echo "'$increm' read. Not incrementing anything." |
| 69 |
breaksw |
| 70 |
endsw |
| 71 |
|
| 72 |
#replacing [ ] and . with escaped version for sed would understand them as 'operators' |
| 73 |
echo "$line s/$verb/$newv/" | sed 's/\./\\\./g;s/\[/\\\[/g;s/\]/\\\]/g' > $sedfile |
| 74 |
sed -f $sedfile $conf > $tmpfile |
| 75 |
#clean up |
| 76 |
\rm -f $sedfile |
| 77 |
#diff for changes |
| 78 |
diff -u0 $conf $tmpfile |
| 79 |
#if something was changed, confirm incrementation : |
| 80 |
if ("$newv" != "$verb") then |
| 81 |
echo -n "Confirmation of incrementation ? (yes/no)" |
| 82 |
set answ = $< |
| 83 |
set backupconf = $conf.back$$ |
| 84 |
if ("$answ" == "yes") then |
| 85 |
\cp -p $conf $backupconf |
| 86 |
echo "Back-up of $conf made in $backupconf. Now overwriting $conf." |
| 87 |
\mv -f $tmpfile $conf |
| 88 |
else |
| 89 |
echo "'$answ' read. Not incrementing anything." |
| 90 |
\rm -f $tmpfile |
| 91 |
exit 0 ; |
| 92 |
endif |
| 93 |
#now change Makefile accordingly |
| 94 |
echo -n "Incrementing Makefile revision accordingly" |
| 95 |
set tmpfile = `mktemp` #tempfile |
| 96 |
set sedfile = `mktemp` #tempfile |
| 97 |
switch ($increm) |
| 98 |
case 0: |
| 99 |
echo -n "s/VERSION.*/VERSION=$macro.$minor.$pmicro/" >> $sedfile |
| 100 |
breaksw |
| 101 |
case 1: |
| 102 |
echo "s/VERSION.*/VERSION=$macro.$pminor.0/" > $sedfile |
| 103 |
breaksw |
| 104 |
case 2: |
| 105 |
echo "s/VERSION.*/VERSION=$pmacro.0.0/" > $sedfile |
| 106 |
breaksw |
| 107 |
default: |
| 108 |
echo "Something abnormal happened" |
| 109 |
exit 1 |
| 110 |
breaksw |
| 111 |
endsw |
| 112 |
sed -f $sedfile $ver > $tmpfile |
| 113 |
\rm -f $sedfile |
| 114 |
diff -u0 $ver $tmpfile |
| 115 |
echo -n "Confirmation of incrementation ? (yes/no) " |
| 116 |
set answ = $< |
| 117 |
if ("$answ" == "yes") then |
| 118 |
\mv -f $tmpfile $ver |
| 119 |
echo " your old $conf is destroyed..." |
| 120 |
\rm -f $backupconf |
| 121 |
else |
| 122 |
echo "'$answ' read. Not incrementing anything." |
| 123 |
echo " your old $conf is restored..." |
| 124 |
\rm -f $tmpfile |
| 125 |
\mv -f $backupconf $conf |
| 126 |
exit 0 |
| 127 |
endif |
| 128 |
|
| 129 |
endif |
| 130 |
else |
| 131 |
echo "'$answ' read. Not doing anything." |
| 132 |
endif |
| 133 |
|
| 134 |
exit 0 |
| 135 |
|