#!/bin/sh

# This file is automatically-generated by automake and autoconf from k3d.in ... do not edit manually!

###################################################
# Setup our default configured paths

prefix=/usr/local/k3d
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
libexecdir=${exec_prefix}/libexec
datadir=${prefix}/share
sysconfdir=${prefix}/etc
sharedstatedir=${prefix}/com
localstatedir=${prefix}/var
libdir=${exec_prefix}/lib
infodir=${prefix}/share/info
mandir=${prefix}/share/man
includedir=${prefix}/include
oldincludedir=/usr/include
pkgdatadir=$datadir/k3d
pkglibdir=$libdir/k3d
pkgincludedir=$includedir/k3d

k3d_default_options=~/.k3d/options.k3d
k3d_default_plugins=$pkglibdir
k3d_default_shader_cache=~/.k3d/shadercache
k3d_default_share=$pkgdatadir
k3d_default_tutorials=$pkgdatadir/tutorials
k3d_default_user_interface=$libdir/libk3dngui.so
k3d_null_user_interface=$libdir/libk3dnui.so

#####################################################
# Setup paths that can be overridden ...

k3d_options=$k3d_default_options
k3d_plugins=$k3d_default_plugins
k3d_shader_cache=$k3d_default_shader_cache
k3d_share=$k3d_default_share
k3d_tutorials=$k3d_default_tutorials
k3d_user_interface=$k3d_default_user_interface

######################################################
# Override paths with environment variables

if test -n "$K3D_OPTIONS_PATH"; then
	k3d_options=$K3D_OPTIONS_PATH
fi

if test -n "$K3D_PLUGIN_PATHS"; then
	k3d_plugins=$K3D_PLUGIN_PATHS
fi

if test -n "$K3D_SHADER_CACHE_PATH"; then
	k3d_shader_cache=$K3D_SHADER_CACHE_PATH
fi

if test -n "$K3D_SHARE_PATH"; then
	k3d_share=$K3D_SHARE_PATH
fi

if test -n "$K3D_TUTORIALS_PATH"; then
	k3d_tutorials=$K3D_TUTORIALS_PATH
fi

if test -n "$K3D_USER_INTERFACE_PATH"; then
	k3d_user_interface=$K3D_USER_INTERFACE_PATH
fi

#####################################################
# Look for arguments that allow us to return immediately ...

while test -n "$1"; do
	case $1 in
		-h | --help )
			cat << eof
			
usage: k3d [options]

      --color                     color-codes log messages based on their level
      --exit                      exits the program (useful after running scripts in batch mode)
  -h, --help                      prints this help information and exits
      --log-level [level]         specifies the minimum message priority to log -
                                    valid values are "warning", "information", "debug" [default: warning]
  -n, --new                       creates a new document after startup
  -o, --open [file]               opens the given file after startup
      --options [file]            overrides the filepath for storing user options [default: $k3d_default_options]
      --plugins [path]            overrides the path(s) for loading plugin libraries [default: $k3d_default_plugins]
      --script [file]             play the given script after startup (use - for stdin)
      --shadercache [path]        overrides the path for storing compiled shaders [default: $k3d_default_shader_cache]
      --share [path]              overrides the path for loading shared data files [default: $k3d_default_share]
      --show-process              prints the process name next to log messages
      --show-timestamps           prints timestamps next to log messages
      --syslog                    logs messages to syslog
      --ui [file]                 specifies the user interface plugin to use
      --version                   prints program version information and exits
     
Standard user interface options:

      --batch                     operate in batch (no user intervention) mode
      --no-custom-layouts         disable custom user interface layouts (useful when playing-back recorded tutorials)
      --no-splash                 disables the startup splash screen
      --record-tutorials          immediately opens the tutorial recorder following startup
      --show-tutorials            immediately opens the tutorial menu following startup
      --tutorials [path]          overrides the path for loading interactive tutorials [default: $k3d_default_tutorials]
     
eof
			exit 0;;
		
		--version )
			cat << eof
			
K-3D Version 0.6.6.0
Copyright (c) 1995-2006, Timothy M. Shead.  All Rights Reserved.  See the AUTHORS file for contributors.
Licensed by the GNU General Public License.  See the COPYING file for details.
K-3D Home Page: http://k3d.sourceforge.net
Bug reports to tshead@k-3d.com

eof
			exit 0;;

		--options ) k3d_options=$2; shift 2;;
		
		--plugins ) k3d_plugins=$2; shift 2;;
		
		--shadercache ) k3d_shader_cache=$2; shift 2;;
		
		--share ) k3d_share=$2; shift 2;;
		
		--show-arguments ) k3d_show_arguments="yes"; shift;;
		
		--tutorials ) k3d_tutorials=$2; shift 2;;

		--ui ) k3d_user_interface=$2; shift 2;;
		
		*) arguments="$arguments $1"; shift;;
	esac
done

######################################################
# Allow "&" as a synonym for the default paths
# in selected cases

k3d_plugins=`echo "$k3d_plugins" | sed -e "s|&|$k3d_default_plugins|g"`

######################################################
# Allow "none" as a synonym for the NULL user interface

if test x$k3d_user_interface = "xnone"; then
	k3d_user_interface="$k3d_null_user_interface"
fi

######################################################
# By default, we run the binary from its configured directory,
# but it can be overridden by specifying k3d_execdir when run
# (we use this for the "make test" target)

if test x$k3d_execdir = "x"; then
	k3d_execdir=${exec_prefix}/bin
fi

######################################################
# Make it happen!

export PATH=$k3d_execdir:$PATH

command="$k3d_execdir/k3d-bin \
	--options $k3d_options \
	--plugins $k3d_plugins \
	--shadercache $k3d_shader_cache \
	--share $k3d_share \
	--tutorials $k3d_tutorials \
	--ui $k3d_user_interface \
	$arguments"

if test x$k3d_show_arguments = "xyes"; then
	echo $command
else
	eval $command
fi

