Commit | Line | Data |
---|---|---|
7e1cd073 TTN |
1 | #!/bin/sh |
2 | ||
3 | # Copyright (C) 2001 Free Software Foundation, Inc. | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or | |
6 | # modify it under the terms of the GNU General Public License as | |
7 | # published by the Free Software Foundation; either version 2, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | # General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this software; see the file COPYING. If not, write to | |
17 | # the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
18 | # Boston, MA 02111-1307 USA | |
19 | ||
20 | # Usage: guile-tools --version | |
21 | # guile-tools --help | |
22 | # guile-tools [OPTION] PROGRAM [ARGS] | |
23 | # | |
24 | # PROGRAM is run w/ ARGS. To see a list of available programs, use | |
25 | # "guile-tools --help" to find the default scripts directory and then | |
26 | # do a "ls" on that directory. Or just read the source 14 lines below. | |
27 | # | |
28 | # Options (only one of which may be used at a time): | |
29 | # --scriptsdir DIR -- Look in DIR for scripts | |
30 | # --guileversion VERS -- Look in $pkgdatadir/VERS/scripts for scripts | |
31 | # | |
32 | # TODO | |
33 | # - handle pre-install invocation | |
34 | # - "full" option processing (but see comment below) | |
35 | # | |
36 | # Author: Thien-Thi Nguyen | |
37 | ||
38 | prefix="@prefix@" | |
39 | pkgdatadir="@datadir@/@PACKAGE@" | |
40 | guileversion="@GUILE_VERSION@" | |
41 | default_scriptsdir=$pkgdatadir/$guileversion/scripts | |
42 | ||
43 | # pre-install invocation frob | |
44 | mydir=`dirname $0` | |
45 | if [ -d "$mydir/scripts" -a -f "$mydir/scripts/Makefile.am" ] ; then | |
46 | default_scriptsdir=`(cd $mydir/scripts ; pwd)` | |
47 | fi | |
48 | ||
49 | help () | |
50 | { | |
51 | echo "$0 [--scriptsdir DIR | --guileversion VERSION] PROGRAM [ARGS]" | |
52 | echo default scriptsdir: $default_scriptsdir | |
53 | } | |
54 | ||
55 | # option processing -- basically, you can override either the script dir | |
56 | # completely, or just the guile version. we choose implementation simplicity | |
57 | # over orthogonality. | |
58 | ||
59 | if [ x"$1" = x--version ] ; then | |
60 | echo $0 $guileversion | |
61 | exit 0 | |
62 | fi | |
63 | ||
64 | if [ x"$1" = x--help -o x"$1" = x ] ; then | |
65 | help | |
66 | exit 0 | |
67 | fi | |
68 | ||
69 | if [ x"$1" = x--scriptsdir ] ; then | |
70 | user_scriptsdir=$2 | |
71 | shift | |
72 | shift | |
73 | elif [ x"$1" = x--guileversion ] ; then | |
74 | user_scriptsdir=$pkgdatadir/$2/scripts | |
75 | shift | |
76 | shift | |
77 | fi | |
78 | ||
79 | scriptsdir=${user_scriptsdir-$default_scriptsdir} | |
80 | ||
81 | if [ ! -d $scriptsdir ] ; then | |
82 | echo $0: no such directory: $scriptsdir | |
83 | exit 1 | |
84 | fi | |
85 | ||
86 | if [ x"$1" = x ] ; then | |
87 | help | |
88 | exit 1 | |
89 | fi | |
90 | ||
91 | program=$scriptsdir/$1 | |
92 | shift | |
93 | ||
94 | if [ -x $program ] ; then | |
95 | exec $program "$@" | |
96 | else | |
97 | echo $0: no such program: $program | |
98 | exit 1 | |
99 | fi | |
100 | ||
101 | # guile-tools ends here |