| 1 #!/bin/sh |
1 #!/bin/sh |
| 2 |
2 # |
| 3 VERSION=0.1.0 |
3 # setup-gettext - Provides compatibility with versions of gettext |
| |
4 # from the 0.10.x series and 0.11.x. |
| |
5 # |
| |
6 # Copyright (C) 2002 Christian Hammond. |
| |
7 # |
| |
8 # This program is free software; you can redistribute it and/or |
| |
9 # modify it under the terms of the GNU General Public License as |
| |
10 # published by the Free Software Foundation; either version 2 of |
| |
11 # the License, or (at your option) any later version. |
| |
12 # |
| |
13 # This program is distributed in the hope that it will be useful, |
| |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
16 # GNU General Public License for more details. |
| |
17 # |
| |
18 # You should have received a copy of the GNU General Public |
| |
19 # License along with this program; if not, write to the Free |
| |
20 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| |
21 # MA 02111-1307 USA |
| |
22 # |
| |
23 |
| |
24 VERSION=0.1.3 |
| |
25 |
| |
26 VERBOSE=0 |
| 4 |
27 |
| 5 parse_gettext_version() { |
28 parse_gettext_version() { |
| 6 GETTEXT_VERSION=`$GETTEXT_TOOL --version | sed -n 's/^.*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*$/\1.\2.\3/p'` |
29 GETTEXT_VERSION=`$GETTEXT_TOOL --version | sed -n 's/^.*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*$/\1.\2.\3/p'` |
| 7 GETTEXT_MAJOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^\([0-9]\+\).*/\1/p'` |
30 GETTEXT_MAJOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^\([0-9]\+\).*/\1/p'` |
| 8 GETTEXT_MINOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^[0-9]\+\.\([0-9]\+\).*/\1/p'` |
31 GETTEXT_MINOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^[0-9]\+\.\([0-9]\+\).*/\1/p'` |
| 19 GETTEXT_TOOL= |
42 GETTEXT_TOOL= |
| 20 } |
43 } |
| 21 } |
44 } |
| 22 } |
45 } |
| 23 |
46 |
| |
47 install() { |
| |
48 [ -f configure.in ] && { |
| |
49 cp configure.in .tmp-configure.in |
| |
50 sed -f 's/^AM_GNU_GETTEXT\(.*\)$/AM_GNU_GETTEXT\1\ |
| |
51 AM_GNU_GETTEXT_VERSION(0.10.40)/' < .tmp-configure.in > configure.in |
| |
52 rm .tmp-configure.in |
| |
53 } |
| |
54 |
| |
55 [ -f configure.ac ] && { |
| |
56 cp configure.ac .tmp-configure.ac |
| |
57 sed -f 's/^AM_GNU_GETTEXT\(.*\)$/AM_GNU_GETTEXT\1\ |
| |
58 AM_GNU_GETTEXT_VERSION(0.10.40)/' < .tmp-configure.ac > configure.ac |
| |
59 rm .tmp-configure.ac |
| |
60 } |
| |
61 |
| |
62 [ -f autogen.sh ] && { |
| |
63 cp autogen.sh .tmp-autogen.sh |
| |
64 sed -f 's/\(gettextize\|autopoint\) --version/.\/setup-gettext --gettext-tool/1' -f 's/^\(echo.*|[\t ]*\)\?\(gettextize\|autopoint\) -.*$/.\/setup-gettext/1' < .tmp-autogen.sh > autogen.sh |
| |
65 rm .tmp-autogen.sh |
| |
66 } |
| |
67 |
| |
68 echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' >> acinclude.m4 |
| |
69 } |
| |
70 |
| 24 backup_m4() { |
71 backup_m4() { |
| 25 [ -d m4 ] && mv m4 m4~ |
72 [ -d m4 ] && mv m4 m4~ |
| 26 } |
73 } |
| 27 |
74 |
| 28 restore_m4() { |
75 restore_m4() { |
| 66 if [ $NUMVAR -gt 0 ]; then |
113 if [ $NUMVAR -gt 0 ]; then |
| 67 if [ $NUMVAR -gt 1 ]; then |
114 if [ $NUMVAR -gt 1 ]; then |
| 68 echo "Only one option at a time!" |
115 echo "Only one option at a time!" |
| 69 exit 1 |
116 exit 1 |
| 70 |
117 |
| 71 elif [ $1 == "--gettext-tool" ]; then |
118 elif [ $1 = "--gettext-tool" ]; then |
| 72 echo $GETTEXT_TOOL |
119 echo $GETTEXT_TOOL |
| 73 exit 0 |
120 exit 0 |
| 74 |
121 |
| 75 elif [ $1 == "--help" ]; then |
122 elif [ $1 = "--help" ]; then |
| 76 echo "setup-gettext v$VERSION" |
123 echo "setup-gettext v$VERSION" |
| 77 echo "Usage:" |
124 echo "Usage:" |
| 78 echo " --gettext-tool Returns gettextize or autopoint, depending" |
125 echo " --gettext-tool Returns gettextize or autopoint, depending" |
| 79 echo " on the version of gettext installed." |
126 echo " on the version of gettext installed." |
| 80 echo " --gettext-version Returns the version of gettext installed." |
127 echo " --gettext-version Returns the version of gettext installed." |
| 83 echo " --gettext-micro-version Returns the micro version of gettext installed." |
130 echo " --gettext-micro-version Returns the micro version of gettext installed." |
| 84 echo " --help Displays this help screen." |
131 echo " --help Displays this help screen." |
| 85 echo |
132 echo |
| 86 exit 0 |
133 exit 0 |
| 87 |
134 |
| 88 elif [ $1 == "--version" ]; then |
135 elif [ $1 = "--version" ]; then |
| 89 echo $VERSION |
136 echo $VERSION |
| 90 exit 0 |
137 exit 0 |
| 91 |
138 |
| 92 elif [ $1 == "--gettext-version" ]; then |
139 elif [ $1 = "--gettext-version" ]; then |
| 93 echo $GETTEXT_VERSION |
140 echo $GETTEXT_VERSION |
| 94 exit 0 |
141 exit 0 |
| 95 |
142 |
| 96 elif [ $1 == "--gettext-major-version" ]; then |
143 elif [ $1 = "--gettext-major-version" ]; then |
| 97 echo $GETTEXT_MAJOR_VERSION |
144 echo $GETTEXT_MAJOR_VERSION |
| 98 exit 0 |
145 exit 0 |
| 99 |
146 |
| 100 elif [ $1 == "--gettext-minor-version" ]; then |
147 elif [ $1 = "--gettext-minor-version" ]; then |
| 101 echo $GETTEXT_MINOR_VERSION |
148 echo $GETTEXT_MINOR_VERSION |
| 102 exit 0 |
149 exit 0 |
| 103 |
150 |
| 104 elif [ $1 == "--gettext-micro-version" ]; then |
151 elif [ $1 = "--gettext-micro-version" ]; then |
| 105 echo $GETTEXT_MICRO_VERSION |
152 echo $GETTEXT_MICRO_VERSION |
| 106 exit 0 |
153 exit 0 |
| 107 |
154 |
| 108 elif [ $1 == "--happy-url" ]; then |
155 elif [ $1 = "--install" ]; then |
| |
156 install |
| |
157 echo "setup-gettext installed." |
| |
158 exit 0 |
| |
159 |
| |
160 elif [ $1 = "--happy-url" ]; then |
| 109 echo http://gaim.sf.net/forkgettext.jpg |
161 echo http://gaim.sf.net/forkgettext.jpg |
| 110 exit 0 |
162 exit 0 |
| |
163 |
| |
164 elif [ $1 = "--verbose" ]; then |
| |
165 VERBOSE=1 |
| 111 |
166 |
| 112 else |
167 else |
| 113 echo "Invalid option '$1'" |
168 echo "Invalid option '$1'" |
| 114 exit 1 |
169 exit 1 |
| 115 fi |
170 fi |
| 116 fi |
171 fi |
| 117 |
172 |
| 118 # Okay, run the main stuff |
173 # Okay, run the main stuff |
| 119 if [ "$GETTEXT_TOOL" == "autopoint" ]; then |
174 if [ "$GETTEXT_TOOL" = "autopoint" ]; then |
| 120 backup_m4 |
175 backup_m4 |
| |
176 [ $VERBOSE -eq 1 ] && echo " autopoint --force" |
| 121 echo n | autopoint --force || abort |
177 echo n | autopoint --force || abort |
| 122 restore_m4 |
178 restore_m4 |
| 123 else |
179 else |
| 124 if [ $GETTEXT_MINOR_VERSION -eq 11 ]; then |
180 if [ $GETTEXT_MINOR_VERSION -eq 11 ]; then |
| 125 backup_m4 |
181 backup_m4 |
| 126 |
182 |
| 127 # Gettext is pure evil. It DEMANDS that we press Return no matter |
183 # Gettext is pure evil. It DEMANDS that we press Return no matter |
| 128 # what. This gets rid of their happy "feature" of doom. |
184 # what. This gets rid of their happy "feature" of doom. |
| |
185 [ $VERBOSE -eq 1 ] && \ |
| |
186 echo " gettextize --copy --force --intl --no-changelog" |
| |
187 |
| 129 sed 's:read .*< /dev/tty::' `which gettextize` > .temp-gettextize |
188 sed 's:read .*< /dev/tty::' `which gettextize` > .temp-gettextize |
| 130 chmod +x .temp-gettextize |
189 chmod +x .temp-gettextize |
| 131 echo n | ./.temp-gettextize --copy --force --intl --no-changelog || abort |
190 echo n | ./.temp-gettextize --copy --force --intl --no-changelog || abort |
| 132 rm .temp-gettextize |
191 rm .temp-gettextize |
| 133 |
192 |
| 134 restore_files |
193 restore_files |
| 135 restore_m4 |
194 restore_m4 |
| 136 |
195 |
| 137 [ -e po/Makevars.template ] && mv po/Makevars.template po/Makevars |
196 [ -f po/Makevars.template ] && mv po/Makevars.template po/Makevars |
| 138 else |
197 else |
| |
198 [ $VERBOSE -eq 1 ] && echo " gettextize --copy --force" |
| 139 echo n | gettextize --copy --force || exit; |
199 echo n | gettextize --copy --force || exit; |
| 140 fi |
200 fi |
| 141 fi |
201 fi |
| 142 |
202 |