#!/bin/bash

if [ -z $SW_HOME ]; then
  echo "The \$SW_HOME environment variable is not set, please set it to the directory you installed Silent Wings!\n"
  exit 1;
fi

export SW2_HOME=${SW_HOME}
export SW2_DATA=${SW_HOME}/data
export LD_LIBRARY_PATH=${SW_HOME}/lib

missing_sw_gui_libs=`ldd $SW_HOME/bin/sw_gui | grep "not found"`
if [ ! -z "$missing_sw_gui_libs" ]; then
  cat << !
ERROR!
  
You are missing some important system libraries.
See the following list for details:

$missing_sw_gui_libs

Check your linux distribution and ensure that at least the following packages are installed:

 - Qt (installed automatically with the KDE desktop)
 - OpenAL (must often be installed separately)

Please contact support@silentwings.no if you have any questions about this error message.
!
  exit 1
fi

missing_swings_libs=`ldd $SW_HOME/bin/swings | grep "not found"`
if [ ! -z "$missing_swings_libs" ]; then
    cat << !
ERROR!
    
You are missing some important system libraries.
See the following list for details:

$missing_swings_libs

Check your linux distribution and ensure that at least the following packages are installed:

 - Qt (installed automatically with the KDE desktop)
 - OpenAL (must often be installed separately)
 
Please contact support@silentwings.no if you have any questions about this error message.
!
  exit 1
fi

#ldd $SW_HOME/bin/sw_gui
#echo "SW_HOME=$SW_HOME";
#echo "SW2_DATA=$SW2_DATA";

exec $SW_HOME/bin/sw_gui
