1#! /bin/sh 2# 3# @configure_input@ 4# 5# Copyright (C) 1997 - 2007 Free Software Foundation, Inc. 6# 7# Author: Scott Predescu <ovidiu@net-community.com> 8# Author: Ovidiu Predescu <ovidiu@net-community.com> 9# Author: Nicola Pero <nicola.pero@meta-innovation.com> 10# Date: 1997 - 2007 11# 12# This file is part of the GNUstep Makefile Package. 13# 14# This library is free software; you can redistribute it and/or 15# modify it under the terms of the GNU General Public License 16# as published by the Free Software Foundation; either version 3 17# of the License, or (at your option) any later version. 18# 19# You should have received a copy of the GNU General Public 20# License along with this library; see the file COPYING. 21# If not, write to the Free Software Foundation, 22# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 24# 'opentool' is obsolete. You can invoke your tools directly, just 25# put them in your PATH :-) 26 27# Try to execute the GNUstep tool passed as argument. The tool is 28# searched through the GNUstep directories if a complete or relative path name 29# is not specified. The arguments passed after the tool name are passed 30# unmodified to the tool. 31 32if [ -z "$1" ]; then 33 echo usage: `basename "$0"` [--library-combo=...] tool [arguments...] 34 echo `basename "$0"` --help for help 35 exit 1 36fi 37 38# Try to determine GNUSTEP_MAKEFILES to source GNUstep.sh 39if [ -z "$GNUSTEP_CONFIG_FILE" ]; then 40 GNUSTEP_CONFIG_FILE=@GNUSTEP_CONFIG_FILE@ 41fi 42 43if [ -z "$GNUSTEP_USER_CONFIG_FILE" ]; then 44 GNUSTEP_USER_CONFIG_FILE=@GNUSTEP_USER_CONFIG_FILE@ 45fi 46 47if [ -f "$GNUSTEP_CONFIG_FILE" ]; then 48 . "$GNUSTEP_CONFIG_FILE" 49fi 50 51GNUSTEP_HOME=~ 52 53if [ -n "$GNUSTEP_USER_CONFIG_FILE" ]; then 54 case "$GNUSTEP_USER_CONFIG_FILE" in 55 /*) # An absolute path 56 if [ -f "$GNUSTEP_USER_CONFIG_FILE" ]; then 57 . "$GNUSTEP_USER_CONFIG_FILE" 58 fi;; 59 *) # Something else 60 if [ -f "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" ]; then 61 . "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" 62 fi;; 63 esac 64fi 65 66if [ -z "$GNUSTEP_MAKEFILES" ]; then 67 GNUSTEP_MAKEFILES=@GNUSTEP_MAKEFILES@ 68fi 69# OK, we now have GNUSTEP_MAKEFILES, source GNUstep.sh. 70 71# Also, we'd like to get the GNUSTEP_*_TOOLS directories so we can 72# search them, so tell GNUstep.sh to export all variabes. 73GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes 74. $GNUSTEP_MAKEFILES/GNUstep.sh 75unset GNUSTEP_SH_EXPORT_ALL_VARIABLES 76 77 78if [ -z "$EXEEXT" ]; then 79 EXEEXT=@EXEEXT@ 80fi 81 82# traps the parameters 83while true 84do 85 case "$1" in 86 --library-combo=*) 87 tmp_makefiles="$GNUSTEP_MAKEFILES" 88 . "$tmp_makefiles/GNUstep-reset.sh" 89 LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'` 90 . "$tmp_makefiles/GNUstep.sh" 91 echo "Switched to library combo $LIBRARY_COMBO" 92 shift 93 ;; 94 --help) 95 echo usage: `basename "$0"` [--library-combo=...] tool [arguments...] 96 echo 97 echo tool is the complete or relative name of the tool executable 98 echo without any extension, like defaults 99 echo 100 echo [arguments...] are the arguments to the tool. 101 exit 0 102 ;; 103 *) 104 break;; 105 esac 106done 107 108tool="$1"; 109shift; 110 111if [ -n "$EXEEXT" ]; then 112 tool="$tool$EXEEXT" 113fi 114 115case "$tool" in 116 /*) # An absolute path. 117 full_toolname="$tool";; 118 */*) # A relative path 119 tool_dir=`dirname "$tool"`; 120 tool_dir=`(cd "$tool_dir"; pwd)`; 121 tool_name=`basename "$tool"`; 122 full_toolname="${tool_dir}/${tool_name}";; 123 *) # A path that should be searched into GNUstep tool paths 124 125 # Search for a local tool 126 127 # We used to scan all ./*/$(GNUSTEP_HOST_LDIR)/ directories, 128 # but this facility was removed (GNUSTEP_HOST_LDIR is no 129 # longer even defined in this file), now we perform a much 130 # simpler search. 131 132 # The really important one is looking into ./obj, anyway here 133 # is the order in which we search local directories - 134 # First, we search in ./ 135 # Second, we search in ./obj 136 # Third, we search in ./Tools/ 137 # Fourth, we search in ./Tools/obj 138 for dir in . obj Tools Tools/obj; do 139 # echo "$dir/$tool"; 140 if [ -x "$dir/$tool" ]; then 141 full_toolname="$dir/$tool" 142 # echo "Found: $dir/$tool"; 143 break; 144 fi 145 done 146 147 if [ -z "$full_toolname" ]; then 148 149 # Local tool not found - Search for an installed one 150 # we search in the order in: 151 # GNUSTEP_USER_TOOLS 152 # GNUSTEP_LOCAL_TOOLS 153 # GNUSTEP_NETWORK_TOOLS 154 # GNUSTEP_SYSTEM_TOOLS 155 # 156 # We look in the GNUSTEP_HOST_CPU-GNUSTEP_HOST_OS/LIBRARY_COMBO 157 # subdirectory first, then the GNUSTEP_HOST_CPU-GNUSTEP_HOST_OS 158 # subdirectory, then the top-level directory. 159 # (For flattened systems we skip the first two options. 160 # 161 # TODO: Also search Admin Tools directories if appropriate 162 for dir in "$GNUSTEP_USER_TOOLS" "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_SYSTEM_TOOLS" ; do 163 if [ "$GNUSTEP_IS_FLATTENED" = "no" ]; then 164 tmpgnudir="$dir/$GNUSTEP_HOST_CPU-$GNUSTEP_HOST_OS" 165 tmplibdir="$dir/$GNUSTEP_HOST_CPU-$GNUSTEP_HOST_OS/$LIBRARY_COMBO" 166 # echo "$tmplibdir/$tool"; 167 if [ -x "$tmplibdir/$tool" ]; then 168 # echo "Found: $tmplibdir/$tool"; 169 full_toolname="$tmplibdir/$tool" 170 break; 171 fi 172 if [ -x "$tmpgnudir/$tool" ]; then 173 # echo "Found: $tmpgnudir/$tool"; 174 full_toolname="$tmpgnudir/$tool" 175 break; 176 fi 177 fi 178 # echo "$dir/$tool"; 179 if [ -x "$dir/$tool" ]; then 180 # echo "Found: $dir/$tool"; 181 full_toolname="$dir/$tool" 182 break; 183 fi 184 done 185 unset tmpgnudir 186 unset tmplibdir 187 fi 188 ;; 189esac 190 191if [ -z "$full_toolname" ]; then 192 echo "Can't find the required tool: $tool!" 193 exit 1 194fi 195 196"$full_toolname" "$@" 197 198