#!/bin/sh

#Authors: Bernd Paysan, Anton Ertl
#Copyright (C) 2008,2011,2012,2014,2015,2016,2017,2018,2019,2020,2023 Free Software Foundation, Inc.

#This file is part of Gforth.

#Gforth is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation, either version 3
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program. If not, see http://www.gnu.org/licenses/.

machine=@machine@
VERSION=@PACKAGE_VERSION@
DEST=$1
shift
export CROSS_PREFIX=@CROSS_PREFIX@
@NO_CROSS@test -z "$ENGINE" && ENGINE=./gforth
@NO_CROSS@test -f "gforth-light.fi" && KERNEL="gforth-light.fi"
export libccdir="$PWD/lib/gforth/$VERSION/$machine/libcc-named/"
export libccnameddir="$libccdir"
if test x"@LIB_SUFFIX@" = "x.so" ; then
   export libccdir="$libccdir/.libs/"
fi
if test -n "$C_INCLUDE_PATH"; then
    export C_INCLUDE_PATH="@srcdir@/include/gforth/$VERSION/$machine:@srcdir@/engine:$C_INCLUDE_PATH"
else
    export C_INCLUDE_PATH="@srcdir@/include/gforth/$VERSION/$machine:@srcdir@/engine"
fi
EXTRAPATH="also c-lib :noname 2drop s\" $DEST\" ; is replace-rpath previous 0 warnings !@ get-current environment-wordlist set-current : os-type ( -- c-addr u ) s\" @host_os@\" ; set-current warnings !"
if test -f "$ENGINE" -a -f "$KERNEL"; then 
  $ENGINE -p ".@PATHSEP@~+@PATHSEP@@srcdir@@PATHSEP@$PWD" --die-on-signal -i $KERNEL -e "$EXTRAPATH" "$@"
else
  export includedir=`pwd`/include
  @GFORTHKER@ -p ".@PATHSEP@~+@PATHSEP@@srcdir@@PATHSEP@$PWD" exboot.fs startup.fs \
      -e "$EXTRAPATH" "$@"
fi
