Index: orxonox/branches/sound/configure.ac
===================================================================
--- orxonox/branches/sound/configure.ac	(revision 2964)
+++ orxonox/branches/sound/configure.ac	(revision 3238)
@@ -3,5 +3,12 @@
 
 AC_PREREQ(2.56)
-AC_INIT(orxonox, 0.1-pre-alpha, orxonox-dev@mail.datacore.ch)
+AC_INIT(orxonox, 0.2.0_alpha-r1, orxonox-dev@mail.datacore.ch)
+
+# Detect the canonical host and target build environment.
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+
 AM_INIT_AUTOMAKE
 
@@ -12,16 +19,66 @@
 # Checks for programs.
 AC_PROG_CXX
-AC_PROG_CC
-
-
-
 AC_HEADER_STDC
 
+### CHECKING  OPTIONAT ARGUMENTS
+## DEBUG-statement
+DEBUG=no
+AC_MSG_CHECKING([if DEBUG-mode should be enabled])
+AC_ARG_ENABLE([debug], 
+	AC_HELP_STRING(	[--enable-debug], [compiles in debug mode. Lots of debug info about the game.]),
+	 DEBUG=$enableval)
+
+if test "$DEBUG" = "no"; then 
+	echo "no"
+	echo " -> Setting debuglevel to 1. Like this you can still see errors."
+	DEBUG=1
+elif test "$DEBUG" = yes; then
+	echo "yes"
+	echo " -> Setting debuglevel to 3. HARD DEBUG MODE!!."
+	DEBUG=3
+else       
+	echo "yes set to $DEBUG"
+fi
+	AC_DEFINE_UNQUOTED(DEBUG, $DEBUG, [in which debug mode we are])
+
+AC_SUBST(DEBUG)
+
+## GTK-disabled
+AC_MSG_CHECKING([if gtk should be enabled])
+AC_ARG_WITH([gtk], 
+	AC_HELP_STRING(	[--without-gtk], 
+	[Prevents GTK from being loaded]), [def_gtk=no], [def_gtk=yes]) 
+if test "$def_gtk" = yes; then 
+  echo "yes"
+fi 
+if test "$def_gtk" = no; then 
+  echo "no"
+fi
+### SDL_image-disable
+def_sdl_image=yes
+AC_MSG_CHECKING([if SDL_image should be enabled])
+AC_ARG_WITH([sdl_image], 
+	AC_HELP_STRING(	[--without-sdl-image], 
+	[Prevents SDL_image from being loaded]), [def_sdl_image=no]) 
+if test "$def_sdl_image" = yes; then 
+  echo "yes"
+fi 
+if test "$def_sdl_image" = no; then 
+  echo "no"
+fi
+
+
+## PROGRAMM CHECKING
+# checking for Doxygen
+AC_PATH_PROG(DOXYGEN, doxygen)
+AM_CONDITIONAL(DOXYGEN, test $DOXYGEN)
+
 ### CHECKING FOR SYSTEM ###
 
 AC_MSG_CHECKING([for System])
-case `uname` in
+## checking for openGL-environment and other sys-specific parameters
+case "$target" in
 ### WINDOWS ###
-  *MINGW*)
+  *-*-mingw32*)
 echo "mingw-WINDOWS detected"
 
@@ -64,5 +121,4 @@
     fi
 
-
 # checking for mingw32
     AC_CHECK_LIB([mingw32], [main], FOUND_mingw32=yes)
@@ -77,48 +133,33 @@
     AC_CHECK_LIB([sdlmain], [main], FOUND_sdlmain=yes)
     if test "$FOUND_sdlmain" = "yes" ; then
-	LIBS="$LIBS -lsdlmain"
-    else
-	 echo "------------------"
-	 echo "SDL library not found."
-	 echo "please install the SDL library, which can be found at http://www.libsdl.org"
-	 echo "------------------"
-	 exit 1
+       LIBS="$LIBS -lsdlmain"
+    else
+        echo "------------------"
+        echo "SDL library not found."
+        echo "please install the SDL library, which can be found at http://www.libsdl.org"
+        echo "------------------"
+        exit 1
     fi
     AC_CHECK_LIB([sdl], [main], FOUND_sdl=yes)
     if test "$FOUND_sdl" = "yes" ; then
-    	LIBS="$LIBS -lsdl"
-    else
-	 echo "------------------"
-	 echo "SDL library not found."
-	 echo "please install the SDL library, which can be found at http://www.libsdl.org"
-	 echo "------------------"
-	 exit -1
-    fi
-
-# checking for SDL-Mixer-headers
-    AC_CHECK_HEADERS(SDL/SDL_mixer.h ,,
-      [AC_MSG_ERROR([cannot find SDL headers]) ])
-
-#checking for libSDL_mixer
-    AC_CHECK_LIB([SDL_mixer], [main], FOUND_SDL_mixer=yes)
-    if test "$FOUND_SDL_mixer" = "yes" ; then
-	LIBS="$LIBS -lSDL_mixer"
-    else
-	 echo "------------------"
-	 echo "SDL Mixer library not found."
-	 echo "please install the SDL Mixer library, which can be found at http://www.libsdl.org"
-	 echo "------------------"
-	 exit 1
-    fi
-
+       LIBS="$LIBS -lsdl"
+    else
+        echo "------------------"
+        echo "SDL library not found."
+        echo "please install the SDL library, which can be found at http://www.libsdl.org"
+        echo "------------------"
+        exit -1
+    fi
 
     ;;
 
 ### LINUX ###
- *Linux*)
+ *-*-linux*)
 echo "Linux detected"
 
  Linux="yes"
 
+CPPFLAGS="-I/usr/X11R6/include"
+LDFLAGS="-L/usr/Mesa-6.0.1/lib -L/usr/X11R6/lib $LDFLAGS"
 # checking gl header
    AC_CHECK_HEADERS(GL/gl.h ,,
@@ -156,65 +197,179 @@
       [AC_MSG_ERROR([cannot find SDL headers]) ])
 
+# checking for SDL-lib
     AC_CHECK_LIB([SDL], [main], FOUND_SDL=yes)
      if test "$FOUND_SDL" = "yes" ; then
-    	LIBS="$LIBS -lSDL"
+       LIBS="$LIBS -lSDL"
      else
-	 echo "------------------"
-	 echo "SDL library not found."
-	 echo "please install the SDL library, which can be found at http://www.libsdl.org"
-	 echo "------------------"
-	 exit -1
+        echo "------------------"
+        echo "SDL library not found."
+	echo "please install the SDL library, which can be found at http://www.libsdl.org"
+        echo "------------------"
+        exit -1
      fi   
-	
+
+
+## checking for SDL
+#    SDL_VERSION=1.2.7
+#    AM_PATH_SDL($SDL_VERSION,
+#      :,
+#      AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
+#      )
+#    CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+#    LIBS="$LIBS $SDL_LIBS"
+    ;;
+
+### OS X ###
+ *darwin*)
+echo "OS X detected"
+
+ osX="yes"
+
+ CPPFLAGS="-I/sw/include $CPPFLAGS"
+# checking gl header
+   AC_CHECK_HEADERS(OpenGL/gl.h ,,
+      [AC_MSG_ERROR([cannot find opengl headers]) ])
+# cheking for GLU-header
+    AC_CHECK_HEADERS(OpenGL/glu.h ,,
+      [AC_MSG_ERROR([cannot find opengl headers]) ])
+
+   LIBS="$LIBS -framework OpenGL"
+
+# checking for SDL-headers
+#    AC_CHECK_HEADERS(SDL/SDL.h ,,
+#      [AC_MSG_ERROR([cannot find SDL headers]) ])
+
+## checking for SDL
+#    SDL_VERSION=1.2.7
+#    AM_PATH_SDL($SDL_VERSION,
+#      :,
+#      AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
+#      )
+
+       SDL_CFLAGS=`sdl-config --cflags`
+       SDL_LIBS=`sdl-config --libs`
+       CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+       LIBS="$LIBS $SDL_LIBS"
+
+    ;;
+
+  *)
+    ;;
+esac
+
+AC_SUBST(MSBITFIELDS)
+
+
+## check for SDL_mixer
 # checking for SDL-Mixer-headers
     AC_CHECK_HEADERS(SDL/SDL_mixer.h ,,
       [AC_MSG_ERROR([cannot find SDL headers]) ])
-
-
+ 
+ 
 #checking for libSDL_mixer
     AC_CHECK_LIB([SDL_mixer], [main], FOUND_SDL_mixer=yes)
     if test "$FOUND_SDL_mixer" = "yes" ; then
-	LIBS="$LIBS -lSDL_mixer"
-    else
-	 echo "------------------"
-	 echo "SDL Mixer library not found."
-	 echo "please install the SDL Mixer library, which can be found at http://www.libsdl.org"
-	 echo "------------------"
-	 exit 1
-    fi
-
-    ;;
-  *)
-    mingw="no"
-    ;;
-esac
-AC_MSG_RESULT([$mingw])
-AC_SUBST(MSBITFIELDS)
-
-#### Checking for LIBraries.
-
-# FIXME: Replace `main' with a function in `-lOSMesa':
-AC_CHECK_LIB([OSMesa], [main])
-# FIXME: Replace `main' with a function in `-lX11':
-AC_CHECK_LIB([X11], [main])
-# FIXME: Replace `main' with a function in `-lXt':
-AC_CHECK_LIB([Xt], [main])
+       LIBS="$LIBS -lSDL_mixer"
+    else
+        echo "------------------"
+        echo "SDL Mixer library not found."
+        echo "please install the SDL Mixer library, which can be found at http://www.libsdl.org"
+        echo "------------------"
+        exit 1
+    fi
+
+
+## check for SDL_Image
+if test "$def_sdl_image" = "yes"; then
+# checking for SDL_image-headers
+  AC_CHECK_HEADERS(SDL/SDL_image.h ,,
+      [echo "sdl_image not found. falling back to other options"; def_sdl_image=no ])
+fi
+if test "$def_sdl_image" = "yes"; then
+# checking for SDL_image-lib
+  AC_CHECK_LIB([SDL_image], [main], FOUND_SDL_image=yes)
+     if test "$FOUND_SDL_image" = "yes" ; then
+       LIBS="$LIBS -lSDL_image"
+     else
+        echo "------------------"
+        echo "SDL_image library not found."
+	echo "please install the SDL_image library, which can be found at http://www.libsdl.org/projects/SDL_image/"
+        echo "------------------"
+        exit -1
+     fi   
+fi
+
+
+if test "$def_sdl_image" = "no"; then
+ ## checking for libjpeg
+ AC_CHECK_HEADERS(jpeglib.h ,jpegHeader="yes",
+        jpegHeader="no")
+ if test $jpegHeader = "no"; then
+	echo " not including jpeg."
+ else
+  AC_CHECK_LIB([jpeg], [main], FOUND_jpeg=yes)
+    if test "$FOUND_jpeg" = "yes" ; then
+      LIBS="$LIBS -ljpeg"
+    else
+	 echo "------------------"
+	 echo "jpeg library not found."
+	 echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org"
+	 echo "------------------"
+	 exit -1
+    fi   
+ fi
+
+ ## checking for libpng
+ AC_CHECK_HEADERS(png.h ,pngHeader="yes",
+        pngHeader="no")
+ if test $pngHeader = "no"; then
+	echo " not including png."
+ else
+  AC_CHECK_LIB([png], [main], FOUND_png=yes)
+    if test "$FOUND_png" = "yes" ; then
+      LIBS="$LIBS -lpng"
+    else
+	 echo "------------------"
+	 echo "png library not found."
+	 echo "please install the png library, which can be found at http://libpng.org/pub/png/libpng.html"
+	 echo "------------------"
+	 exit -1
+    fi
+ fi   
+fi
+
+## checking for GTK
+if test "$def_gtk" = yes; then 
+
+	#PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.0.3 gthread-2.0 >= 2.0.3, have_gtk2=yes, have_gtk2=no)
+	AC_MSG_CHECKING([for gtk2.0])
+	if `pkg-config --exists gtk+-2.0`; then
+  		echo "yes"
+  		have_gtk2=yes
+		GTK2_LIBS=`pkg-config --libs gtk+-2.0`
+		GTK2_CFLAGS=`pkg-config --cflags gtk+-2.0`
+		AC_DEFINE_UNQUOTED(HAVE_GTK2, 1, [if we have GTK2])
+	else
+		echo "no"
+	fi
+
+fi
+AC_SUBST(GTK2_LIBS)
+AC_SUBST(GTK2_CFLAGS)
+AM_CONDITIONAL(HAVE_GTK2, test x$have_gtk2 = xyes)
+
 
 
 #checking for pthread libs
-AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes)
-if test "$FOUND_pthread" = "yes" ; then
-    LIBS="$LIBS -lpthread"
-fi
-
-
+# AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes)
+# if test "$FOUND_pthread" = "yes" ; then
+#    LIBS="$LIBS -lpthread"
+# fi
 
 
 # FIXME: Replace `main' with a function in `-lm':
-AC_CHECK_LIB([m], [main])
-
-LIBS="$LIBS `pkg-config --libs  gtk+-2.0`"
-
-
+ AC_CHECK_LIB([m], [main])
+
+ 
 # Checks for header files.
 AC_HEADER_STDC
@@ -229,7 +384,7 @@
 
 AC_CONFIG_FILES([Makefile
-		 console/Makefile
-                 gui/Makefile
+		 src/console/Makefile
+                 src/gui/Makefile
                  src/Makefile
-		 importer/Makefile])
+		 src/importer/Makefile])
 AC_OUTPUT
