Mercurial > hg > xemacs-beta
annotate etc/xemacs-fe.sh @ 5898:2aeaf9bc7175
Regenerate configure.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Tue, 05 May 2015 04:06:37 +0900 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
177 | 1 #! /bin/sh |
2 # emacs-fe --- front end driver for `emacs' and other programs | |
3 | |
4 # Copyright (C) 1995, 1996 Noah S. Friedman | |
5 | |
6 # Author: Noah Friedman <friedman@prep.ai.mit.edu> | |
7 # Created: 1995-09-11 | |
8 | |
9 # $.Id: emacs-fe,v 1.8 1996/03/07 04:32:33 friedman Exp $ | |
10 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
11 # This file is part of XEmacs. |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
12 |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
13 # XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
14 # under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
15 # Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
16 # option) any later version. |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
17 |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
18 # XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
19 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
20 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
21 # for more details. |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
22 |
177 | 23 # You should have received a copy of the GNU General Public License |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
367
diff
changeset
|
24 # along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
177 | 25 |
26 # Commentary: | |
27 | |
28 # Inspired by a similar set of scripts by Charles Sandel <sandel@cli.com>, | |
29 # but generalized into this single script. | |
30 | |
31 # Front-end shell script for GNU Emacs, used to manage multiple versions of | |
32 # Emacs and its associated utilities. | |
33 # | |
34 # Strategy: Install this script as "$prefix/bin/[progname]", for each | |
35 # program named [progname], (e.g. "emacs", "ispell", "etags", etc). These | |
36 # are the commands users would normally execute to run them. | |
37 | |
38 # Give each version of emacs/xemacs/mule/ispell a separate hierarchy under | |
39 # $prefix/[emacs|xemacs|mule|ispell], with the name | |
40 # "[emacs|xemacs|mule|ispell]-NN.NN" where NN.NN is the version number. | |
41 # This script looks at what versions are available, and selects a version, | |
42 # currently whatever is specified by $DEFAULTLVERSION. | |
43 | |
44 # However, users can specify their own choice to force the selection of a | |
45 # particular version by setting the environment variable PROGNAMEVERSION | |
46 # (e.g. EMACSVERSION, MULEVERSION, XEMACSVERSION, etc.) to have a value | |
47 # which is the version number of the program that they want to use (just | |
48 # the numeric value), or to specify either the NEWEST or OLDEST versions. | |
49 | |
50 # Code: | |
51 | |
52 # Name by which this script was invoked. | |
53 progname=`echo "$0" | sed -e 's/[^\/]*\///g'` | |
54 | |
55 # To prevent hairy quoting and escaping later. | |
56 bq='`' | |
57 eq="'" | |
58 | |
59 case "$progname" in | |
60 emacs-fe-print ) | |
61 case $# in | |
62 1 ) : ;; | |
63 * ) | |
64 echo "$progname: Exactly one argument is required." 1>&2 | |
65 exit 1 | |
66 ;; | |
67 esac | |
68 | |
69 # sed is more portable than `dirname' | |
70 dir=`echo "$0" | sed -e 's/\/*$//' -e 's/\/[^\/]*$//'` | |
71 if test -f "$dir/$1"; then | |
72 EMACS_FE_PRINT=t | |
73 export EMACS_FE_PRINT | |
74 exec "$dir/$1" | |
75 fi | |
76 | |
77 echo "$progname: $bq$dir/$1$eq does not seem to exist." 1>&2 | |
78 exit 1 | |
79 ;; | |
80 esac | |
81 | |
82 DEFAULTVERSION="${DEFAULTVERSION-NEWEST}" | |
83 VARIANT="${EMACSVARIANT-emacs}" | |
84 | |
85 if [ "$prefix" = "" ] ; then | |
86 # root of the GNU installed tree | |
87 prefix=/usr/local/gnu | |
88 fi | |
89 | |
90 if [ ! -d "$prefix" ] ; then | |
91 echo "Cannot find root of GNU tree ($prefix)." | |
92 exit 1 | |
93 fi | |
94 | |
95 case "$progname" in | |
96 emacs | lemacs | xemacs | mule | ispell ) | |
97 if [ "$eprefix" = "" ] ; then | |
98 # prefix name of the subdirectory | |
99 eprefix="${progname}/${progname}-" | |
100 fi | |
101 ;; | |
102 * ) | |
103 eprefix="$VARIANT/${VARIANT}-" | |
104 ;; | |
105 esac | |
106 | |
107 # Find out which versions are available on the system and sort them | |
108 # in numeric order. | |
109 # | |
110 # The largish sed script prefixes all version numbers with a sort key. | |
111 # That key is constructed by padding out any single or double digits to 3 | |
367 | 112 # digits from the version number, then converting all occurrences of `.' to |
177 | 113 # `0', and prefixing and suffixing the entire result with an additional |
114 # zero. After sorting, the sort key is stripped from the output. | |
115 # We do all this because `sort' cannot numerically sort decimal numbers and | |
116 # will stop on the first `.'. | |
117 # This may not work correctly if the version number has more than 4 levels | |
118 # of minor versions (e.g. "1.2.3.4.5" may cause problems). | |
119 availversions=`ls -1d $prefix/${eprefix}*/. 2> /dev/null \ | |
120 | sed -n \ | |
121 -e "s#^$prefix/$eprefix\([0-9.][0-9.]*\)/\.*#\1#" \ | |
122 -e 'h | |
123 s/[^.]*[^0-9.][^.]*\.//g | |
124 :0 | |
125 /[0-9.][0-9.]*\.[0-9.][0-9.]*\.[0-9.][0-9.]*\.[0-9.][0-9.]*/!{ | |
126 s/$/.0/ | |
127 b 0 | |
128 } | |
129 s/^/./ | |
130 s/$/./ | |
131 :1 | |
132 s/\.\([0-9]\)\./.00\1./g | |
133 s/\.\([0-9][0-9]\)\./.0\1./g | |
134 t 1 | |
135 s/\./0/g | |
136 G | |
137 s/\n/ /' \ | |
138 -e 'p' \ | |
139 | sort -nu \ | |
140 | sed -e 's/.* //'` | |
141 | |
142 if [ "$availversions" = "" ] ; then | |
143 echo "No version of $progname found in $prefix/$eprefix*." | |
144 exit 1 | |
145 fi | |
146 | |
147 # This sets `oldest' to the oldest version available, and `newest' | |
148 # to the newest version available. | |
149 # On line 1, we save the original pattern in the hold space and restore it | |
150 # in case it is the only line of input. | |
151 eval `echo "$availversions" \ | |
152 | sed -ne '1{h;s/^/oldest=/p;g;} | |
153 ${s/^/newest=/p;} | |
154 '` | |
155 | |
156 # The environment variable [progname]VERSION can have a value which specifies | |
157 # a version number, OR it can contain the values "NEWEST" or "OLDEST" to | |
158 # specify the newest or oldest version which was found. | |
159 sed_upcase='y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | |
160 | |
161 PROGNAME=`echo "$progname" | sed -e "$sed_upcase" -e 's/-/_/g'` | |
162 eval version=\"\$${PROGNAME}VERSION\" | |
163 | |
164 # If there is no ETAGSVERSION, EMACSCLIENTVERSION, etc, then look for | |
165 # EMACSVERSION, XEMACSVERSION, or whatever the current variant is. | |
166 case "$version" in | |
167 '' ) | |
168 case "$progname" in | |
169 ispell ) | |
170 # If this is ispell and ISPELLVERSION isn't set, just use 3.1. | |
171 # We could run this script recursively with a flag indicating to | |
172 # find the current emacs variant and version and just print it out, | |
173 # but that is a very pathological case and is a lot of work. | |
174 version=3.1 ;; | |
175 * ) | |
176 variant=`echo "$VARIANT" | sed -e "$sed_upcase"` | |
177 eval version=\"\$${variant}VERSION\" | |
178 case "$version" in | |
179 '' ) version="$DEFAULTVERSION" ;; | |
180 esac | |
181 ;; | |
182 esac | |
183 esac | |
184 | |
185 case "$version" in | |
186 [Oo][Ll][Dd][Ee][Ss][Tt]) version="$oldest" ;; | |
187 [Nn][Ee][Ww][Ee][Ss][Tt]) version="$newest" ;; | |
188 '') version="$oldest" ;; | |
189 *) | |
190 if [ ! -d "$prefix/$eprefix$version" ] ; then | |
191 echo "$progname: $version: Cannot find requested version." 1>&2 | |
192 version= | |
193 fi | |
194 ;; | |
195 esac | |
196 | |
197 # If we don't have a version by now, then give up. | |
198 if [ "$version" = "" ] ; then | |
199 exec 1>&2 | |
200 echo "$progname: Cannot determine which version to use." | |
201 case "$availversions" in | |
202 */* ) | |
203 echo "Available versions are:" | |
204 for f in $availversions; do | |
205 echo " $f" | |
206 done | sort | |
207 ;; | |
208 * ) | |
209 echo "Available versions are:" $availversions | |
210 ;; | |
211 esac | |
212 exit 1 | |
213 fi | |
214 | |
215 case "$progname" in | |
216 emacs | lemacs | xemacs | mule ) | |
217 EMACSVARIANT=$progname | |
218 eval ${PROGNAME}VERSION=$version | |
219 eval export EMACSVARIANT ${PROGNAME}VERSION | |
220 | |
221 case "$EMACSVARIANT-$version" in | |
222 emacs-18* ) ISPELLVERSION=4.0 ;; | |
223 emacs-19.[0-9] ) ISPELLVERSION=4.0 ;; | |
224 emacs-19.1[0-9] ) ISPELLVERSION=4.0 ;; | |
225 emacs-19.2[0-2] ) ISPELLVERSION=4.0 ;; | |
226 emacs-19.2[3-9] ) ISPELLVERSION=3.1 ;; | |
227 emacs-* ) ISPELLVERSION=3.1 ;; | |
228 | |
229 lemacs-19.[0-9] ) ISPELLVERSION=3.0.09 ;; | |
230 lemacs-19.10 ) ISPELLVERSION=3.1 ;; | |
231 | |
232 xemacs-* ) ISPELLVERSION=3.1 ;; | |
233 | |
234 mule-* ) ISPELLVERSION=3.1 ;; | |
235 esac | |
236 export ISPELLVERSION | |
237 ;; | |
238 esac | |
239 | |
240 case "$progname" in | |
241 xemacs ) | |
242 # xemacs expects to use the keysym database in /usr/openwin, but that | |
243 # database doesn't define many of the keysyms it uses. Unless the user | |
244 # has already defined their own, specify the keysym database in X11. | |
245 XKEYSYMDB="${XKEYSYMDB-/usr/local/X11/lib/X11/XKeysymDB}" | |
246 export XKEYSYMDB | |
247 | |
248 # Some versions of xemacs (e.g. 19.12) are dynamically linked against | |
249 # the openwin tooltalk library (libtt.so), so add openwin to the | |
250 # dynamic load path if necessary. | |
251 case "$LD_LIBRARY_PATH" in | |
252 *'/usr/openwin/lib'* ) : ;; | |
253 '' ) | |
254 LD_LIBRARY_PATH=/usr/local/X11R5/lib:/usr/openwin/lib:/lib | |
255 export LD_LIBRARY_PATH | |
256 ;; | |
257 * ) | |
258 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/openwin/lib" | |
259 export LD_LIBRARY_PATH | |
260 ;; | |
261 esac | |
262 ;; | |
263 esac | |
264 | |
265 # Set up the MANPATH so that the man pages for this version | |
266 # are searched first | |
267 if [ -d $prefix/$eprefix$version/man ] ; then | |
268 MANPATH=$prefix/$eprefix$version/man:$MANPATH | |
269 export MANPATH | |
270 fi | |
271 | |
272 # There is no need to do this, and it can potentially cause problems, | |
273 # especially if a program like `xemacs' exists in that directory and gets | |
274 # run in subshells instead of this script. | |
275 #PATH=$prefix/$eprefix$version/bin:$PATH | |
276 #export PATH | |
277 | |
278 searchdirs=`exec 2> /dev/null | |
279 cd $prefix/$eprefix$version \ | |
280 && find bin \ | |
281 libexec/$VARIANT/$version/* \ | |
282 lib/$VARIANT/$version/* \ | |
283 lib/$VARIANT-$version/* \ | |
284 lib/$VARIANT/etc \ | |
285 lib/etc \ | |
286 -type d -print` | |
287 | |
288 for dir in $searchdirs ; do | |
289 for p in $progname-$version $progname ; do | |
290 prog="$prefix/$eprefix$version/$dir/$p" | |
291 | |
292 if test -f "$prog" ; then | |
293 case "${EMACS_FE_PRINT+set}" in | |
294 set ) | |
295 echo "$prog" | |
296 exit 0 | |
297 ;; | |
298 esac | |
299 | |
300 exec "$prog" ${1+"$@"} | |
301 fi | |
302 done | |
303 done | |
304 | |
305 exec 1>&2 | |
306 | |
307 echo "$progname: Cannot find $bq$progname-$version$eq or $bq$progname$eq in" | |
308 | |
309 for d in $searchdirs ; do | |
310 ls -1d $prefix/$eprefix$version/$d 2> /dev/null \ | |
311 | sed -e "s/^/$progname: /" | |
312 done | |
313 | |
314 exit 1 | |
315 | |
316 # emacs-fe ends here |