1999-06-02 03:16:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-05-02 15:07:49 +00:00
|
|
|
# @configure_input@
|
|
|
|
#
|
2002-06-07 15:41:08 +00:00
|
|
|
# Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
1999-06-02 03:16:12 +00:00
|
|
|
#
|
|
|
|
# Author: Adam Fedor <fedor@gnu.org>
|
|
|
|
# Date: May 1999
|
2002-06-07 15:41:08 +00:00
|
|
|
#
|
|
|
|
# Author: Nicola Pero <n.pero@mi.flashnet.it>
|
2007-02-14 22:20:09 +00:00
|
|
|
# Date: 2001, 2002,2007
|
1999-06-02 03:16:12 +00:00
|
|
|
#
|
|
|
|
# This file is part of the GNUstep Makefile Package.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
2007-10-30 14:18:41 +00:00
|
|
|
# as published by the Free Software Foundation; either version 3
|
1999-06-02 03:16:12 +00:00
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public
|
2007-07-13 10:11:48 +00:00
|
|
|
# License along with this library; see the file COPYING.
|
1999-06-02 03:16:12 +00:00
|
|
|
# If not, write to the Free Software Foundation,
|
2005-05-22 03:20:14 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1999-06-02 03:16:12 +00:00
|
|
|
|
|
|
|
# This is a shell script which attempts to find the GNUstep executable
|
|
|
|
# of the same name based on the current host and library_combo.
|
|
|
|
|
2006-10-03 17:23:36 +00:00
|
|
|
# This is installed inside the application directory in the
|
|
|
|
# non-flattened case. In the flattened case, we install the binary
|
2007-02-14 22:20:09 +00:00
|
|
|
# directly in the application directory and no wrappers are used.
|
2006-10-03 17:23:36 +00:00
|
|
|
|
1999-06-02 03:16:12 +00:00
|
|
|
if [ -z "$EXEEXT" ]; then
|
|
|
|
EXEEXT=@EXEEXT@
|
|
|
|
fi
|
|
|
|
if [ -z "$LIBRARY_COMBO" ]; then
|
|
|
|
LIBRARY_COMBO=@ac_cv_library_combo@
|
|
|
|
fi
|
|
|
|
|
2007-02-14 22:20:09 +00:00
|
|
|
|
|
|
|
# Try to determine GNUSTEP_MAKEFILES to source GNUstep.sh
|
|
|
|
if [ -z "$GNUSTEP_CONFIG_FILE" ]; then
|
|
|
|
GNUSTEP_CONFIG_FILE=@GNUSTEP_CONFIG_FILE@
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$GNUSTEP_USER_CONFIG_FILE" ]; then
|
|
|
|
GNUSTEP_USER_CONFIG_FILE=@GNUSTEP_USER_CONFIG_FILE@
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$GNUSTEP_CONFIG_FILE" ]; then
|
|
|
|
. "$GNUSTEP_CONFIG_FILE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
GNUSTEP_HOME=~
|
|
|
|
|
|
|
|
if [ -n "$GNUSTEP_USER_CONFIG_FILE" ]; then
|
|
|
|
case "$GNUSTEP_USER_CONFIG_FILE" in
|
|
|
|
/*) # An absolute path
|
|
|
|
if [ -f "$GNUSTEP_USER_CONFIG_FILE" ]; then
|
|
|
|
. "$GNUSTEP_USER_CONFIG_FILE"
|
|
|
|
fi;;
|
|
|
|
*) # Something else
|
|
|
|
if [ -f "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" ]; then
|
|
|
|
. "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE"
|
|
|
|
fi;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$GNUSTEP_MAKEFILES" ]; then
|
|
|
|
GNUSTEP_MAKEFILES=@GNUSTEP_MAKEFILES@
|
|
|
|
fi
|
|
|
|
# OK, we now have GNUSTEP_MAKEFILES, we later can source GNUstep.sh.
|
|
|
|
|
1999-06-02 03:16:12 +00:00
|
|
|
# Process arguments
|
2007-02-14 22:20:09 +00:00
|
|
|
this_script="$0"
|
1999-06-02 03:16:12 +00:00
|
|
|
show_available_platforms=0
|
|
|
|
show_relative_path=0
|
|
|
|
show_full_path=0
|
|
|
|
while true
|
|
|
|
do
|
2003-05-14 15:10:22 +00:00
|
|
|
case "$1" in
|
1999-06-02 03:16:12 +00:00
|
|
|
|
|
|
|
--script-help)
|
2003-05-14 15:10:22 +00:00
|
|
|
echo usage: `basename "$0"` [--library-combo=...]
|
1999-06-02 03:16:12 +00:00
|
|
|
echo " [--available-platforms][--full-executable-path]"
|
|
|
|
echo " [--relative-executable-path] [arguments...]"
|
|
|
|
echo
|
|
|
|
echo " --library-combo=... specifies a GNUstep backend to use."
|
|
|
|
echo " It overrides the default LIBRARY_COMBO environment variable."
|
|
|
|
echo
|
|
|
|
echo " --available-platforms displays a list of valid exec hosts"
|
|
|
|
echo " --full-executable-path displays full path to executable"
|
|
|
|
echo " --relative-executable-path displays subdirectory path"
|
|
|
|
echo " arguments... are the arguments to the application."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--library-combo=*)
|
2005-10-12 20:45:14 +00:00
|
|
|
tmp_makefiles="$GNUSTEP_MAKEFILES"
|
|
|
|
. "$tmp_makefiles/GNUstep-reset.sh"
|
|
|
|
LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
|
2007-02-14 22:20:09 +00:00
|
|
|
GNUSTEP_MAKEFILES="$tmp_makefiles"
|
1999-06-02 03:16:12 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--available-platforms)
|
|
|
|
show_available_platforms=1
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--full-executable-path)
|
|
|
|
show_full_path=1
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
--relative-executable-path)
|
|
|
|
show_relative_path=1
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$LIBRARY_COMBO" = nx ]; then
|
2001-04-13 19:49:16 +00:00
|
|
|
LIBRARY_COMBO=nx-nx-nx
|
|
|
|
elif [ "$LIBRARY_COMBO" = gnu ]; then
|
|
|
|
LIBRARY_COMBO=gnu-gnu-gnu
|
|
|
|
elif [ "$LIBRARY_COMBO" = fd ]; then
|
|
|
|
LIBRARY_COMBO=gnu-fd-gnu
|
2002-12-30 16:29:55 +00:00
|
|
|
elif [ "$LIBRARY_COMBO" = apple ]; then
|
|
|
|
LIBRARY_COMBO=apple-apple-apple
|
1999-06-02 03:16:12 +00:00
|
|
|
fi
|
|
|
|
export LIBRARY_COMBO
|
|
|
|
|
2007-02-14 22:20:09 +00:00
|
|
|
# We now have determined both GNUSTEP_MAKEFILES and LIBRARY_COMBO.
|
|
|
|
# Source GNUstep.sh to make sure all the environment is setup
|
|
|
|
# to work in this LIBRARY_COMBO.
|
|
|
|
. "$GNUSTEP_MAKEFILES/GNUstep.sh"
|
|
|
|
|
|
|
|
# Find path to directory containing ourselves. This directory is
|
|
|
|
# the .app directory.
|
|
|
|
dir="`dirname \"$this_script\"`"
|
|
|
|
|
|
|
|
# Find the absolute path of the directory. This will be something like
|
|
|
|
# /home/nicola/testing/Applications/Gorm.app
|
2007-02-15 00:16:46 +00:00
|
|
|
full_appname="`(cd \"$dir\"; pwd)`"
|
1999-06-02 03:16:12 +00:00
|
|
|
|
|
|
|
if [ -z "$full_appname" ]; then
|
2007-02-14 22:20:09 +00:00
|
|
|
echo "Can't find absolute path for $this_script! Please specify full path when"
|
1999-06-02 03:16:12 +00:00
|
|
|
echo "invoking executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
2007-02-14 22:20:09 +00:00
|
|
|
# Get base app name (eg, Gorm in the case of Gorm.app, but crazy people might
|
|
|
|
# configure it differently by using a different NSExecutable setting in
|
|
|
|
# Info-gnustep.plist).
|
1999-06-02 03:16:12 +00:00
|
|
|
#
|
1999-06-11 21:08:17 +00:00
|
|
|
appname=
|
2002-01-14 21:57:30 +00:00
|
|
|
if [ -f "$full_appname/Resources/Info-gnustep.plist" ]; then
|
2002-01-21 16:22:29 +00:00
|
|
|
# -n disable auto-print (for portability reasons)
|
2002-01-26 16:35:52 +00:00
|
|
|
# /^ *NSExecutable *=/ matches every line beginning with
|
2002-01-21 16:22:29 +00:00
|
|
|
# zero or more spaces, followed by 'NSExecutable', followed by zero or
|
|
|
|
# more spaces, followed by '='
|
|
|
|
# to this line we apply the following commands:
|
2002-01-26 16:35:52 +00:00
|
|
|
# s/"//g; which deletes all " in the line.
|
|
|
|
# s/^ *NSExecutable *= *\([^ ;]*\) *;.*/\1/p;
|
|
|
|
# which replaces 'NSExecutable = Gorm; ' with 'Gorm', then, because
|
2002-01-21 16:22:29 +00:00
|
|
|
# of the 'p' at the end, prints out the result
|
2002-01-21 18:04:42 +00:00
|
|
|
# q; which quits sed since we know there must be only a single line
|
|
|
|
# to replace.
|
2002-01-26 16:35:52 +00:00
|
|
|
appname=`sed -n -e '/^ *NSExecutable *=/ \
|
|
|
|
{s/"//g; s/^ *NSExecutable *= *\([^ ;]*\) *;.*/\1/p; q;}' \
|
2002-01-21 16:22:29 +00:00
|
|
|
"$full_appname/Resources/Info-gnustep.plist"`
|
1999-06-02 03:16:12 +00:00
|
|
|
fi
|
1999-06-11 21:08:17 +00:00
|
|
|
if [ -z "$appname" ]; then
|
2007-02-14 22:20:09 +00:00
|
|
|
appname="`basename \"$this_script\"`"
|
1999-06-02 03:16:12 +00:00
|
|
|
fi
|
|
|
|
|
2002-01-22 00:39:49 +00:00
|
|
|
appname="$appname$EXEEXT"
|
1999-06-02 03:16:12 +00:00
|
|
|
|
|
|
|
if [ $show_available_platforms = 1 ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
cd "$full_appname"
|
2007-02-14 22:20:09 +00:00
|
|
|
#TODO: show available_platforms
|
1999-06-02 03:16:12 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Make sure the executable is there
|
|
|
|
#
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -x "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname" ]; then
|
|
|
|
relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
|
|
|
|
elif [ -x "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$appname" ]; then
|
|
|
|
relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$appname"
|
|
|
|
elif [ -x "$full_appname/$GNUSTEP_HOST_CPU/$appname" ]; then
|
|
|
|
relative_path="$GNUSTEP_HOST_CPU/$appname"
|
|
|
|
elif [ "$full_appname/$appname" != "$0" -a -x "$full_appname/$appname" ]; then
|
|
|
|
relative_path="$appname"
|
1999-06-02 03:16:12 +00:00
|
|
|
else
|
2002-06-07 15:41:08 +00:00
|
|
|
# Search for a binary for this machine but a different library combo
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS" ]; then
|
|
|
|
tmp_path="`pwd`"
|
2002-06-07 15:41:08 +00:00
|
|
|
cd "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS";
|
|
|
|
found=no
|
|
|
|
for lib_combo in * ; do
|
|
|
|
if [ "$lib_combo" != '*' ]; then
|
|
|
|
if [ -x "$lib_combo/$appname" ]; then
|
|
|
|
# Switch LIBRARY_COMBO on the fly
|
2005-10-12 20:45:14 +00:00
|
|
|
tmp_makefiles="$GNUSTEP_MAKEFILES"
|
|
|
|
. "$tmp_makefiles/GNUstep-reset.sh"
|
2002-06-07 15:41:08 +00:00
|
|
|
LIBRARY_COMBO="$lib_combo"
|
2005-10-12 20:45:14 +00:00
|
|
|
. "$tmp_makefiles/GNUstep.sh"
|
2002-06-07 15:41:08 +00:00
|
|
|
# Use the found executable
|
|
|
|
relative_path="$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
|
|
|
|
found=yes
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
cd "$tmp_path"
|
|
|
|
if [ "$found" != yes ]; then
|
|
|
|
echo "$full_appname application does not have a binary for this kind of machine/operating system ($GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS)."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
1999-06-02 03:16:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $show_relative_path = 1 ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
echo "$relative_path"
|
1999-06-02 03:16:12 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ $show_full_path = 1 ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
echo "$full_appname/$relative_path"
|
1999-06-02 03:16:12 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-05-14 15:10:22 +00:00
|
|
|
exec "$full_appname/$relative_path" "$@"
|
1999-06-02 03:16:12 +00:00
|
|
|
|