Index: branches/script_engine/acinclude.m4
===================================================================
--- branches/script_engine/acinclude.m4	(revision 7645)
+++ branches/script_engine/acinclude.m4	(revision 7648)
@@ -19,27 +19,143 @@
 
 
-dnl AX_CHECK_REQUIRED_HEADER_LIB([HEADER-NAME], [LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE])
+dnl AX_CHECK_REQUIRED_HEADER_LIB([HEADER-NAME], [LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE], [CFLAGS], [OTHER_LIBS])
 AC_DEFUN([AX_CHECK_REQUIRED_HEADER_LIB], [
     _header_check=""
     _lib_check=""
+    LAST_FOUND_LIB=""
+
+    _lib_USED=""
+    _header_USED=""
 
     for _header in $1
     do
-      AC_CHECK_HEADER([$_header], [_header_check="yes"], [_header_check="no"])
-      if  test "x$_header_check" = "xyes" ; then
+      AC_CHECK_HEADER([${_header}], [_header_check="yes" ; _header_USED=${_header}], [_header_check="no"], $7)
+      if  test "x${_header_check}" = "xyes" ; then
         break
       fi
     done
-    AC_CHECK_LIB([$2], [$3], [_lib_check="yes"], [_lib_check="no"])
-    if [test x$_header_check = "xyes" && test "x$_lib_check" = "xyes"] ; then
-         LIBS="$LIBS -l$2"
-	 $4
+    for _check_library in $2
+    do
+      AC_CHECK_LIB([${_check_library}], [$3], [_lib_check="yes"; _lib_USED=${_check_library}], [_lib_check="no"], $8)
+      if test "x${_lib_check}" = "xyes" ; then
+        LAST_FOUND_LIB=${_lib_USED}
+	break
+      fi
+    done
+    if [test "x${_header_check}" = "xyes" && test "x${_lib_check}" = "xyes"] ; then
+	m4_ifval([$4], [$4], [
+         LIBS="${LIBS} -l${_lib_USED}"])
     else
+	m4_ifval([$5], [$5], [
          echo "------------------"
          echo "LIBRARY $2 not found."
          echo "please install the $2-LIBRARY-package which can be found at $6"
          echo "------------------"
-	 $5
-         exit -1
+	 exit -1])
     fi
 ])
+
+
+
+
+dnl AX_CHECK_LUA([LUA_DIR])
+AC_DEFUN([AX_CHECK_LUA], [
+#dnl checking for LUA.
+LUA_LIBS=
+LUA_INCLUDES=
+dnl Check for Lua.
+
+LUA_INCLUDE_DIRECTORY="/usr/include"
+LUA_COMMON_INCLUDE_DIRECTORIES="
+      `ls -dr $1                       2>/dev/null`
+      /usr/include
+      `ls -dr /usr/include/lua*        2>/dev/null`
+      `ls -dr /usr/lib/lua/include     2>/dev/null`
+      `ls -dr /usr/local/include/lua   2>/dev/null`
+      `ls -dr /opt/lua*/include        2>/dev/null`
+      `ls -dr /Developer/lua*/include  2>/dev/null`
+    "
+
+  for _lua_include_directory in ${LUA_COMMON_INCLUDE_DIRECTORIES}
+    do
+      if test -e ${_lua_include_directory}/lua.h ; then
+        LUA_INCLUDE_DIRECTORY=${_lua_include_directory}
+	CPPFLAGS="${CPPFLAGS} -I${LUA_INCLUDE_DIRECTORY}"
+        break
+      fi
+  done
+    if test -n ${LUA_INCLUDE_DIRECTORY} ; then
+      echo "Lua-Include Directory is: ${LUA_INCLUDE_DIRECTORY}"
+    else
+      AC_MSG_ERROR([Lua Headers not found])
+    fi
+
+
+AC_CHECK_LIB([dl], [dlopen])
+AX_CHECK_REQUIRED_HEADER_LIB([lua.h], [lua lua50], [lua_open],
+dnl libLUA found
+     [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"  AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base],
+dnl liblualib found
+      [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"],,
+      [http://www.lua.org],, [${LUA_LIBS} -ldl -lm])],
+dnl liblua not found (download it)
+       [AX_GET_INSTALL_NECESSARY_LIB([http://www.lua.org/ftp], [lua-5.0.tar.gz], [lua-5.0], [extern_libs/], [include/*.h lib/*.a])
+       LUA_LIBS="-llualib -llua"  LUA_INCLUDES="-I$(top_build_dir)/extern_libs" ], [http://www.lua.org])
+
+AC_SUBST([LUA_LIBS])
+AC_SUBST([LUA_INCLUDES])
+])
+
+
+
+
+
+dnl AX_GET_INSTALL_NECESSARY_LIB([FTP-DIR], [DIST-FILE], [DIST-DIR], [INSTALL-DIR], [INSTALL-FILES], [CONFIG-FLAGS], [MAKE-OPTS])
+AC_DEFUN([AX_GET_INSTALL_NECESSARY_LIB], [
+
+   _get_install_FTP=$1
+   _get_install_DISTFILE=$2
+   _get_install_DISTDIR=$3
+   _get_install_INSTALLDIR=$4
+   dnl $5 is left out (inegrated bellow)
+   _get_install_CONFIGFLAGS=$6
+   _get_install_MAKEOPTS=$7
+
+dnl DOWNLOADING THE FILE
+   if test -f "${_get_install_DISTFILE}" ; then
+     echo "${_get_install_DISTFILE} already downloaded"
+   else
+     echo "Getting ${_get_install_DISTFILE} from ${_get_install_FTP}/${_get_install_DISTFILE}"
+     echo `wget ${_get_install_FTP}/${_get_install_DISTFILE}`
+   fi
+
+dnl UNCOMPRESS STAGE
+   echo "Uncompressing ${_get_install_DISTFILE}"
+   echo `tar xzvf ${_get_install_DISTFILE}`
+
+dnl ENTER DIRECTORY AND EXECUTE CONFIGURE AND MAKE
+   _get_install_PWD=`pwd`
+   cd ${_get_install_DISTDIR}
+dnl configure
+   if test -x "configure" ; then
+    ./configure ${_get_install_CONFIGFLAGS}
+   fi
+   make ${_get_install_MAKEOPTS}
+   cd ${_get_install_PWD}
+
+dnl INSTALL STAGE
+   echo "Installing Libraries and Headers into ${_get_install_INSTALLDIR} local directory"
+
+   mkdir -p ${_get_install_INSTALLDIR}
+   for _get_install_installfile in $5
+    do
+     echo "copy  ${_get_install_DISTDIR}/${_get_install_installfile} to ${_get_install_INSTALLDIR}/"
+     cp `ls -dr ${_get_install_DISTDIR}/${_get_install_installfile}` "${_get_install_INSTALLDIR}/"
+    done
+
+#cleaning up
+  echo "rm -rf ${_get_install_DISTDIR}"
+  rm -rf ${_get_install_DISTDIR}
+  echo "rm ${_get_install_DISTFILE}"
+  rm ${_get_install_DISTFILE}
+])
Index: branches/script_engine/config.h.in
===================================================================
--- branches/script_engine/config.h.in	(revision 7645)
+++ branches/script_engine/config.h.in	(revision 7648)
@@ -39,4 +39,7 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+#undef HAVE_LIBDL
 
 /* Define to 1 if you have the `m' library (-lm). */
Index: branches/script_engine/configure.ac
===================================================================
--- branches/script_engine/configure.ac	(revision 7645)
+++ branches/script_engine/configure.ac	(revision 7648)
@@ -38,5 +38,5 @@
 AM_INIT_AUTOMAKE
 
-AC_CONFIG_SRCDIR([./src])
+AC_CONFIG_SRCDIR([./src/orxonox.cc])
 AC_CONFIG_HEADER([config.h])
 
@@ -571,4 +571,10 @@
 AM_CONDITIONAL(HAVE_CURL, test "x$have_curl" = "xyes")
 
+#-----#
+# LUA #
+#-----#
+LUA_DIR="/usr/include/lua"
+AX_CHECK_LUA([${LUA_DIR}])
+
 #--------#
 # efence #
@@ -643,9 +649,10 @@
                  src/lib/gui/gtk_gui/Makefile
                  src/lib/gui/gl_gui/Makefile
+                 src/lib/script_engine/Makefile
                  src/lib/parser/Makefile
                  src/lib/parser/tinyxml/Makefile
                  src/lib/parser/ini_parser/Makefile
                  src/lib/parser/cmdline_parser/Makefile
-		 src/lib/parser/preferences/Makefile
+                 src/lib/parser/preferences/Makefile
                  src/util/Makefile
                  src/world_entities/Makefile
Index: branches/script_engine/src/lib/Makefile.am
===================================================================
--- branches/script_engine/src/lib/Makefile.am	(revision 7645)
+++ branches/script_engine/src/lib/Makefile.am	(revision 7648)
@@ -71,3 +71,4 @@
 	parser \
 	shell \
+	script_engine \
 	gui
Index: branches/script_engine/src/lib/script_engine/Makefile.am
===================================================================
--- branches/script_engine/src/lib/script_engine/Makefile.am	(revision 7645)
+++ branches/script_engine/src/lib/script_engine/Makefile.am	(revision 7648)
@@ -1,12 +1,21 @@
+
+INCLUDES= -I../../../extern_libs
+
+noinst_LIBRARIES = libORXscript.a
+
+libORXscript_a_SOURCES = \
+		Script.cc \
+		scriptable.cc\
+		VirtualMachine.cc
+
+AM_CPPFLAGS= @LUA_INCLUDES@
 
 bin_PROGRAMS = main
+main_SOURCES = \
+		main.cc
+main_LDADD = libORXscript.a -L../../../extern_libs @LUA_LIBS@
 
-main_SOURCES = \
-		Script.cc \
-		scriptable.cc\
-		VirtualMachine.cc \
-		main.cc
+main_LDFLAGS =
 
-main_LDADD = @LUA_LIBS@
 
 noinst_HEADERS = \
