*** empty log message ***
[bpt/guile.git] / guile-tools.in
CommitLineData
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
38prefix="@prefix@"
39pkgdatadir="@datadir@/@PACKAGE@"
40guileversion="@GUILE_VERSION@"
41default_scriptsdir=$pkgdatadir/$guileversion/scripts
42
43# pre-install invocation frob
44mydir=`dirname $0`
45if [ -d "$mydir/scripts" -a -f "$mydir/scripts/Makefile.am" ] ; then
46 default_scriptsdir=`(cd $mydir/scripts ; pwd)`
47fi
48
49help ()
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
59if [ x"$1" = x--version ] ; then
60 echo $0 $guileversion
61 exit 0
62fi
63
64if [ x"$1" = x--help -o x"$1" = x ] ; then
65 help
66 exit 0
67fi
68
69if [ x"$1" = x--scriptsdir ] ; then
70 user_scriptsdir=$2
71 shift
72 shift
73elif [ x"$1" = x--guileversion ] ; then
74 user_scriptsdir=$pkgdatadir/$2/scripts
75 shift
76 shift
77fi
78
79scriptsdir=${user_scriptsdir-$default_scriptsdir}
80
81if [ ! -d $scriptsdir ] ; then
82 echo $0: no such directory: $scriptsdir
83 exit 1
84fi
85
86if [ x"$1" = x ] ; then
87 help
88 exit 1
89fi
90
91program=$scriptsdir/$1
92shift
93
94if [ -x $program ] ; then
95 exec $program "$@"
96else
97 echo $0: no such program: $program
98 exit 1
99fi
100
101# guile-tools ends here