updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / freeorion / freeorion.sh
blobd80623ab2da10ec95ba8902e3e92c44ffff0cb0d
1 #!/bin/sh
3 # written by Markus Sinner, http://psitronic.de
5 # Nightly builds on.
6 # http://freeorion.psitronic.de/download/nightly/
8 # This is a wrapper-script for starting FreeOrion on
9 # ix86 (and maybe x64) Linux Systems.
10 # This script will CD into application and set some
11 # enviroment variables.
13 # ---- commandline PARAMETERS and ENVIROMENT variables -----
14 # This script supports parameters, that will be evaluated
15 # BEFORE freeorion binary is called and will be removed,
16 # because the binary won't support them.
17 # Currently only one parameter at a time is supported!
18 # Parameters other than these will be appended as command
19 # line parameters to the call of the freeorion binary.
21 # --strace
22 # This starts freeorion using the "strace" utility.
23 # Generates a strace logifle /tmp/freeorion.trace.
24 # Make sure it is installed on your system!
25 # --gdb
26 # Runs freeorion in a gdb instance, passes the original
27 # parameters through the --args parameter of gdb
30 # ENVIROMENT variables
31 # This script supports some enviroment variables. To set them
32 # either use the followin command BEFORE you execute this script.
33 # export XXXX="value"
34 # This permanently set the variable in you current shell script.
35 # Or you prepend the options when running this script, like this:
36 # PARAM1="hello" PARAM2="yo man" /usr/bin/freeorion.elf
38 # Supportet are:
39 # FO_TRACE=
40 # Use this to prepend something to calling freorion.
41 # This variables also is used internally, when --gdb or --trace
42 # appear on the command line.
43 # FO_GDB_ARGS=
44 # If you use --gbd, you should uses this env to add GDB parameters.
45 # Make sure you end this list of parameters with --args, otherwise
46 # gdb won't start. Example: FO_GDB_ARGS="-q -s fo.symbols --args"
47 # LD_LIBRARY_PATH=
48 # This is a well known env and will be honored by this script.
52 # ---------- STARTS HERE ---------------
53 # Change into application directory
54 # If this is a symlink, then we
55 # need to change into the dir of symlink-target.
56 if [ -h $0 ]; then
57 echo "I am Symlink. Following into my targets basedir"
58 ME=`readlink $0`
59 else
60 echo "Following into my basedir"
61 ME=$0
64 # This is important! Script won't work outside its installation dir
65 ROOT=/usr/share/freeorion
66 cd ${ROOT}
67 echo -n "CWD: "
68 pwd
72 # Check for python. If freeorionca binary is missing it, use
73 # the shipped version.
74 if ldd /usr/bin/freeorionca | grep "libpython.*not found"; then
75 #echo "python2.5 missing. Using shipped version."
76 PYTHON_USE_SHIPPED=1
77 else
78 #echo "python2.5 found. Using it."
79 PYTHON_USE_SHIPPED=0
82 # Set Python library home for loading modules
83 # If no python 2.5 is detected, use shipped python 2.5
84 if [ "$PYTHON_USE_SHIPPED" = "1" ]; then
85 export PYTHONHOME=/usr/lib/freeorion/python2.5
86 export PYTHONPATH=${PYTHONHOME}
87 export PYTHONDEBUG=1
88 export PYTHONVERBOSE=1
89 echo "PYTHONHOME=${PYTHONHOME}"
91 export LD_LIBRARY_PATH=${PYTHONHOME}:${LD_LIBRARY_PATH}
92 export LD_PRELOAD=${PYTHONHOME}/libutil.so.1:${PYTHONHOME}/libpython2.5.so
96 # Command line Parameter --gdb forces running in gdb
97 # Setting FO_TRACE to gdb results in other settings, see
98 # below
99 if [ "$1" = "--gdb" ]; then
100 FO_TRACE="gdb"
102 # Don't forget to remove the param
103 shift
106 if [ "$1" = "--strace" ]; then
107 TRACEFILE=/tmp/freeorion.trace
108 echo
109 echo "Tracing to ${TRACEFILE}"
110 echo
111 FO_TRACE="strace -f -o ${TRACEFILE}"
113 # Don't forget to remove the param
114 shift
119 # Add a parameter FO_GDB_ARGS to support gdb
120 # Or warn the user, if he changed FO_GDB_ARGS and has
121 # forgotten to end it with --args
122 if [ "$FO_TRACE" = "gdb" ]; then
123 if [ "$FO_GDB_ARGS" = "" ]; then
124 FO_GDB_ARGS="--args"
125 else
126 echo "****************************************************"
127 echo "** NOTE NOTE NOTE NOTE **"
128 echo "Running FO in gdb"
129 echo "If you use FO_GDB_ARGS on your command line, make"
130 echo "sure that you END this variabble with --args."
131 echo "Otherwise gdb will not start."
132 echo
133 echo "Type 'start' when the gdb instance has loaded!"
134 echo
139 # Support loading libs from application/lib
140 export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
142 # Call with settings-dir to avoid conflicting installations
143 ${FO_TRACE} ${FO_GDB_ARGS} /usr/bin/freeorion.elf --resource-dir ./default $@