5 # Copyright (C) 1997, 1999 Free Software Foundation, Inc.
7 # Author: Scott Predescu <ovidiu@net-community.com>
8 # Author: Ovidiu Predescu <ovidiu@net-community.com>
11 # This file is part of the GNUstep Makefile Package.
13 # This library is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; either version 2
16 # of the License, or (at your option) any later version.
18 # You should have received a copy of the GNU General Public
19 # License along with this library; see the file COPYING.LIB.
20 # If not, write to the Free Software Foundation,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 # Try to execute the GNUstep tool passed as argument. The tool is
24 # searched through the GNUstep directories if a complete or relative path name
25 # is not specified. The arguments passed after the tool name are passed
26 # unmodified to the tool.
28 if [ -z "$GNUSTEP_PATHLIST" ]; then
29 echo "The GNUSTEP_PATHLIST environment variable is missing."
30 echo "Did you forget to set up your environment using GNUstep.sh ?"
35 echo usage: `basename "$0"` [--library-combo=...] tool [arguments...]
36 echo `basename "$0"` --help for help
40 if [ -z "$EXEEXT" ]; then
44 # traps the parameters
49 tmp_root="$GNUSTEP_SYSTEM_ROOT"
50 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep-reset.sh"
51 LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
52 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep.sh"
53 echo "Switched to library combo $LIBRARY_COMBO"
57 echo usage: `basename "$0"` [--library-combo=...] tool [arguments...]
59 echo tool is the complete or relative name of the tool executable
60 echo without any extension, like defaults
62 echo [arguments...] are the arguments to the tool.
73 if [ -n "$EXEEXT" ]; then
78 /*) # An absolute path.
79 full_toolname="$tool";;
80 */*) # A relative path
81 tool_dir="`dirname \"$tool\"`";
82 tool_dir="`(cd \"$tool_dir\"; pwd)`";
83 tool_name="`basename \"$tool\"`";
84 full_toolname="${tool_dir}/${tool_name}";;
85 *) # A path that should be searched into GNUstep tool paths
87 # Search for a local tool
89 # We used to scan all ./*/$(GNUSTEP_HOST_LDIR)/ directories,
90 # but this facility was removed (GNUSTEP_HOST_LDIR is no
91 # longer even defined in this file), now we perform a much
94 # The really important one is looking into ./obj, anyway here
95 # is the order in which we search local directories -
96 # First, we search in ./
97 # Second, we search in ./obj
98 # Third, we search in ./Tools/
99 # Fourth, we search in ./Tools/obj
100 for dir in . obj Tools Tools/obj; do
102 if [ -x "$dir/$tool" ]; then
103 full_toolname="$dir/$tool"
104 # echo "Found: $dir/$tool";
109 if [ -z "$full_toolname" ]; then
111 # Local tool not found - Search for an installed one
112 # we search in GNUSTEP_PATHLIST, which means we
113 # search in the order in:
116 # GNUSTEP_NETWORK_ROOT
117 # GNUSTEP_SYSTEM_ROOT
119 # We look in the GNUSTEP_HOST_CPU/GNUSTEP_HOST_OS/LIBRARY_COMBO
120 # subdirectory first, then the GNUSTEP_HOST_CPU/GNUSTEP_HOST_OS
121 # subdirectory, then the top-level directory.
122 # (For flattened systems we skip the first two options.
124 if [ -n "$GNUSTEP_PATHLIST" ]; then
125 SPATH="$GNUSTEP_PATHLIST"
127 for dir in $SPATH; do
129 if [ -z "$GNUSTEP_FLATTENED" ]; then
130 tmpgnudir="$dir/Tools/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS"
131 tmplibdir="$tmpgnudir/$LIBRARY_COMBO"
132 # echo "$tmplibdir/$tool";
133 if [ -x "$tmplibdir/$tool" ]; then
134 # echo "Found: $tmplibdir/$tool";
135 full_toolname="$tmplibdir/$tool"
138 if [ -x "$tmpgnudir/$tool" ]; then
139 # echo "Found: $tmpgnudir/$tool";
140 full_toolname="$tmpgnudir/$tool"
144 # echo "$tmpdir/$tool";
145 if [ -x "$tmpdir/$tool" ]; then
146 # echo "Found: $tmpdir/$tool";
147 full_toolname="$tmpdir/$tool"
160 if [ -z "$full_toolname" ]; then
161 echo "Can't find the required tool: $tool!"
166 exec "$full_toolname" "$@"