1#!/bin/bash
2
3#
4# vice-launcher.sh - runs vice from the nearby application bundle
5#
6# Written by
7#  Christian Vogelgsang <chris@vogelgsang.org>
8#
9# This file is part of VICE, the Versatile Commodore Emulator.
10# See README for copyright notice.
11#
12#  This program is free software; you can redistribute it and/or modify
13#  it under the terms of the GNU General Public License as published by
14#  the Free Software Foundation; either version 2 of the License, or
15#  (at your option) any later version.
16#
17#  This program is distributed in the hope that it will be useful,
18#  but WITHOUT ANY WARRANTY; without even the implied warranty of
19#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20#  GNU General Public License for more details.
21#
22#  You should have received a copy of the GNU General Public License
23#  along with this program; if not, write to the Free Software
24#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25#  02111-1307  USA.
26#
27# Usage: make-bindist.sh <strip> <vice-version> <host-cpu> <host-system> <enable_arch> <zip|nozip> <x64sc-included> <top-srcdir> <exe-ext>
28#                         $1      $2             $3         $4            $5            $6          $7               $8           $9
29#
30
31REALFILE="$0"
32
33# find dir of real file (not the linked ones)
34DIR="`dirname \"$REALFILE\"`"
35while [ -h "$REALFILE" ]; do
36  REALFILE="`readlink \"$REALFILE\"`"
37  CURDIR="`dirname \"$REALFILE\"`"
38  if [ "${CURDIR:0:1}" = "/" ]; then
39    DIR="$CURDIR"
40  else
41    DIR="$DIR/$CURDIR"
42  fi
43done
44
45NAME="`basename \"$0\"`"
46
47# find bundle
48BUNDLE="$DIR/../VICE.app"
49if [ ! -d "$BUNDLE" ]; then
50  BUNDLE="$DIR/../$NAME.app"
51  if [ ! -d "$BUNDLE" ]; then
52    echo "Error: associated bundle '$BUNDLE' not found!"
53    exit 1
54  fi
55fi
56BASENAME="`basename \"$BUNDLE\" .app`"
57
58# find launcher
59if [ -e "$BUNDLE/Contents/Resources/script" ]; then
60  LAUNCHER="$BUNDLE/Contents/Resources/script"
61elif [ -e "$BUNDLE/Contents/MacOS/$BASENAME" ]; then
62  LAUNCHER="$BUNDLE/Contents/MacOS/$BASENAME"
63else
64  echo "Error: no launcher script found in '$BUNDLE'!"
65  exit 1
66fi
67
68# run launcher
69export PROGRAM="$NAME"
70exec "$LAUNCHER" "$@"
71