Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 333)
+++ src/Makefile.am	(working copy)
@@ -18,7 +18,7 @@
 	-I$(top_srcdir)/lib-src/enigma-core \
 	-I$(top_srcdir)/lib-src/enet/include \
 	-I$(top_srcdir)/lib-src \
-	-I$(top_builddir)/intl
+	-I$(top_builddir)/intl @SDL_CFLAGS@
 
 
 enigma_SOURCES = 		\
@@ -190,11 +190,6 @@
 
 endif
 
-
-enigma_LIBS = \
-	@SDL_LIBS@
-
-
 enigma_LDADD = \
 	@LIBINTL@ \
 	$(top_builddir)/lib-src/enigma-core/libecl.a \
@@ -203,7 +198,8 @@
 	$(top_builddir)/lib-src/oxydlib/liboxyd.a \
 	$(top_builddir)/lib-src/zipios++/src/libzipios.a \
 	-lz \
-	$(mingw_ldadd)
+	$(mingw_ldadd) \
+	@SDL_LIBS@
 
 # Rule for creating Lua interfaces from package descriptions using 'tolua'
 TOLUA=@TOLUA@
Index: tools/Makefile.am
===================================================================
--- tools/Makefile.am	(revision 333)
+++ tools/Makefile.am	(working copy)
@@ -7,11 +7,11 @@
 TTFTOOL = 
 endif
 
-if CXXLUA
-noinst_PROGRAMS =  $(TTFTOOL)
-else
+#if CXXLUA
+#noinst_PROGRAMS =  $(TTFTOOL)
+#else
 noinst_PROGRAMS = tolua $(TTFTOOL)
-endif
+#endif
 
 
 ttf2bmf_SOURCES = ttf2bmf.cc getopt.c getopt1.c getopt.h
@@ -19,6 +19,12 @@
 ttf2bmf_LDADD = -lSDL_ttf
 
 tolua_SOURCES = tolua.c toluabind.c toluabind.h
+if CXXLUA
+tolua_CFLAGS = -I$(top_srcdir)/lib-src/lua -x c++ @CXXFLAGS@
+tolua_LDADD = -L$(top_builddir)/lib-src/lua -llua -lstdc++
+else
 tolua_CFLAGS = -I$(top_srcdir)/lib-src/lua
 tolua_LDADD = -L$(top_builddir)/lib-src/lua -llua 
+endif
 
+
Index: configure.ac
===================================================================
--- configure.ac	(revision 333)
+++ configure.ac	(working copy)
@@ -79,17 +79,14 @@
 dnl ======================================================================
 dnl Check for libraries
 dnl ======================================================================
+AC_SEARCH_LIBS([dlopen], [dl])
+
 AM_PATH_SDL(1.2.0)
 AC_SUBST(SDL_LIBS)
 AC_SUBST(SDL_CFLAGS)
 
-dnl The flags are now substituted inside the Makefile, but not used for the
-dnl rest of the script. So we manually put them in. This is necessary if
-dnl SDL has not been installed in the canonical locations.
-CFLAGS="$CFLAGS $SDL_CFLAGS"
-CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
-LIBS="$LIBS $SDL_LIBS"
 
+
 dnl When using the included gettext package from the /intl subdir
 dnl /intl needs to be added to the list of include folders
 if test "$BUILD_INCLUDED_LIBINTL" = yes; then
@@ -103,6 +100,18 @@
    AC_CHECK_LIB(winmm,main)
 fi
 
+dnl The flags are now substituted inside the Makefile, but not used for the
+dnl rest of the script. So we manually put them in. This is necessary if
+dnl SDL has not been installed in the canonical locations.
+CFLAGS_NOSDL="$CFLAGS"
+CXXFLAGS_NOSDL="$CXXFLAGS"
+LIBS_NOSDL="$LIBS"
+
+
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
 dnl ----------------------------------------
 dnl Check for SDL image library
 dnl Check for SDL mixer library
@@ -140,7 +149,16 @@
   AC_DEFINE(HAVE_SDLTTF, , [Whether SDL_ttf library was found during configure])
 fi
 
+SDL_LIBS="$SDL_LIBS -lSDL_ttf"
 
+dnl ---------------------------------------
+dnl Restoring variables to _NOSDL State
+dnl ---------------------------------------
+
+CFLAGS="$CFLAGS_NOSDL"
+CXXFLAGS="$CXXFLAGS_NOSDL"
+LIBS="$LIBS_NOSDL"
+
 dnl ----------------------------------------
 dnl Check for libpng
 dnl ---------------------------------------
