5 # Copyright (C) 1999-2002 Free Software Foundation, Inc.
7 # Author: Adam Fedor <fedor@gnu.org>
10 # Author: Nicola Pero <n.pero@mi.flashnet.it>
13 # This file is part of the GNUstep Makefile Package.
15 # This library is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
20 # You should have received a copy of the GNU General Public
21 # License along with this library; see the file COPYING.LIB.
22 # If not, write to the Free Software Foundation,
23 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 # This is a shell script which attempts to find the GNUstep executable
26 # of the same name based on the current host and library_combo.
28 #--------------------------------------------------------------------------
30 #--------------------------------------------------------------------------
31 if [ -z "$EXEEXT" ]; then
34 if [ -z "$LIBRARY_COMBO" ]; then
35 LIBRARY_COMBO=@ac_cv_library_combo@
40 show_available_platforms=0
48 echo usage: `basename "$0"` [--library-combo=...]
49 echo " [--available-platforms][--full-executable-path]"
50 echo " [--relative-executable-path] [arguments...]"
52 echo " --library-combo=... specifies a GNUstep backend to use."
53 echo " It overrides the default LIBRARY_COMBO environment variable."
55 echo " --available-platforms displays a list of valid exec hosts"
56 echo " --full-executable-path displays full path to executable"
57 echo " --relative-executable-path displays subdirectory path"
58 echo " arguments... are the arguments to the application."
62 tmp_root="$GNUSTEP_SYSTEM_ROOT"
63 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep-reset.sh"
64 LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
65 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep.sh"
68 --available-platforms)
69 show_available_platforms=1
72 --full-executable-path)
76 --relative-executable-path)
85 if [ "$LIBRARY_COMBO" = nx ]; then
86 LIBRARY_COMBO=nx-nx-nx
87 elif [ "$LIBRARY_COMBO" = gnu ]; then
88 LIBRARY_COMBO=gnu-gnu-gnu
89 elif [ "$LIBRARY_COMBO" = fd ]; then
90 LIBRARY_COMBO=gnu-fd-gnu
91 elif [ "$LIBRARY_COMBO" = apple ]; then
92 LIBRARY_COMBO=apple-apple-apple
96 # Find path to ourself
97 dir="`dirname \"$app\"`"
100 /*) # An absolute path.
101 full_appname="$dir";;
102 */*) # A relative path
103 full_appname="`(cd \"$dir\"; pwd)`";;
104 *) # A path that needs to be searched
105 if [ -n "$GNUSTEP_PATHLIST" ]; then
106 SPATH="$GNUSTEP_PATHLIST"
112 for path_dir in $SPATH; do
113 if [ -d "$path_dir/$dir" ]; then
114 full_appname="`(cd \"$path_dir/$dir\"; pwd)`"
117 if [ -d "$path_dir/Applications/$dir" ]; then
118 full_appname="`(cd \"$path_dir/Applications/$dir\"; pwd)`"
124 if [ -z "$full_appname" ]; then
125 echo "Can't find absolute path for $app! Please specify full path when"
126 echo "invoking executable"
134 if [ -f "$full_appname/Resources/Info-gnustep.plist" ]; then
135 # -n disable auto-print (for portability reasons)
136 # /^ *NSExecutable *=/ matches every line beginning with
137 # zero or more spaces, followed by 'NSExecutable', followed by zero or
138 # more spaces, followed by '='
139 # to this line we apply the following commands:
140 # s/"//g; which deletes all " in the line.
141 # s/^ *NSExecutable *= *\([^ ;]*\) *;.*/\1/p;
142 # which replaces 'NSExecutable = Gorm; ' with 'Gorm', then, because
143 # of the 'p' at the end, prints out the result
144 # q; which quits sed since we know there must be only a single line
146 appname=`sed -n -e '/^ *NSExecutable *=/ \
147 {s/"//g; s/^ *NSExecutable *= *\([^ ;]*\) *;.*/\1/p; q;}' \
148 "$full_appname/Resources/Info-gnustep.plist"`
150 if [ -z "$appname" ]; then
151 appname="`basename \"$app\"`"
154 appname="$appname$EXEEXT"
156 if [ $show_available_platforms = 1 ]; then
163 # Determine the host information
165 if [ -z "$GNUSTEP_HOST" ]; then
166 GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/config.guess)`
167 GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/config.sub $GNUSTEP_HOST)`
170 if [ -z "$GNUSTEP_HOST_CPU" ]; then
171 GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/cpu.sh $GNUSTEP_HOST`
172 GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_cpu.sh $GNUSTEP_HOST_CPU`
173 export GNUSTEP_HOST_CPU
175 if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
176 GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/vendor.sh $GNUSTEP_HOST`
177 GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
178 export GNUSTEP_HOST_VENDOR
180 if [ -z "$GNUSTEP_HOST_OS" ]; then
181 GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/os.sh $GNUSTEP_HOST`
182 GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_os.sh $GNUSTEP_HOST_OS`
183 export GNUSTEP_HOST_OS
187 # Make sure the executable is there
189 if [ -x "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname" ]; then
190 relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
191 elif [ -x "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$appname" ]; then
192 relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$appname"
193 elif [ -x "$full_appname/$GNUSTEP_HOST_CPU/$appname" ]; then
194 relative_path="$GNUSTEP_HOST_CPU/$appname"
195 elif [ "$full_appname/$appname" != "$0" -a -x "$full_appname/$appname" ]; then
196 relative_path="$appname"
198 # Search for a binary for this machine but a different library combo
199 if [ -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS" ]; then
201 cd "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS";
203 for lib_combo in * ; do
204 if [ "$lib_combo" != '*' ]; then
205 if [ -x "$lib_combo/$appname" ]; then
206 # Switch LIBRARY_COMBO on the fly
207 tmp_root="$GNUSTEP_SYSTEM_ROOT"
208 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep-reset.sh"
209 LIBRARY_COMBO="$lib_combo"
210 . "$tmp_root/@MAKEFILES_SUFFIX@/GNUstep.sh"
211 # Use the found executable
212 relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
219 if [ "$found" != yes ]; then
220 echo "$full_appname application does not have a binary for this kind of machine/operating system ($GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS)."
226 if [ $show_relative_path = 1 ]; then
227 echo "$relative_path"
230 if [ $show_full_path = 1 ]; then
231 echo "$full_appname/$relative_path"
235 if [ "$LIBRARY_COMBO" = nx-nx-nx -a "$GNUSTEP_HOST_OS" = nextstep4 ]; then
236 if [ -f "$full_appname/library_paths.openapp" ]; then
237 additional_library_paths="`cat $full_appname/library_paths.openapp`"
240 if [ -f "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/library_paths.openapp" ]; then
241 additional_library_paths="`cat \"$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/library_paths.openapp\"`"
245 # Load up LD_LIBRARY_PATH
246 . "$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/ld_lib_path.sh"
248 exec "$full_appname/$relative_path" "$@"