1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(README)
3
4dnl Detect the canonical build and host environments
5AC_CONFIG_AUX_DIRS($srcdir/.)
6AC_CANONICAL_HOST
7
8dnl Check for tools
9
10AC_PROG_CC
11
12dnl Check for compiler environment
13
14AC_C_CONST
15
16dnl Figure out which math library to use
17case "$host" in
18    *-*-cygwin* | *-*-mingw32*)
19        EXE=".exe"
20        MATHLIB=""
21        SYS_GL_LIBS="-lopengl32"
22        ;;
23    *-*-beos* | *-*-haiku*)
24        EXE=""
25        MATHLIB=""
26        SYS_GL_LIBS="-lGL"
27        ;;
28    *-*-darwin* )
29        EXE=""
30        MATHLIB=""
31        SYS_GL_LIBS="-Wl,-framework,OpenGL"
32        ;;
33    *-*-aix*)
34        EXE=""
35        if test x$ac_cv_prog_gcc = xyes; then
36            CFLAGS="-mthreads"
37        fi
38        SYS_GL_LIBS=""
39        ;;
40    *-*-mint*)
41        EXE=""
42        MATHLIB=""
43        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
44        if test "x$OSMESA_CONFIG" = "xyes"; then
45            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
46            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
47            CFLAGS="$CFLAGS $OSMESA_CFLAGS"
48            SYS_GL_LIBS="$OSMESA_LIBS"
49        else
50            SYS_GL_LIBS="-lOSMesa"
51        fi
52        ;;
53    *-*-qnx*)
54        EXE=""
55        MATHLIB=""
56        SYS_GL_LIBS="-lGLES_CM"
57        ;;
58    *)
59        EXE=""
60        MATHLIB="-lm"
61        SYS_GL_LIBS="-lGL"
62        ;;
63esac
64AC_SUBST(EXE)
65AC_SUBST(MATHLIB)
66
67dnl Check for SDL
68SDL_VERSION=2.0.0
69AM_PATH_SDL2($SDL_VERSION,
70            :,
71	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
72)
73CFLAGS="$CFLAGS $SDL_CFLAGS"
74LIBS="$LIBS -lSDL2_test $SDL_LIBS"
75
76dnl Check for X11 path, needed for OpenGL on some systems
77AC_PATH_X
78if test x$have_x = xyes; then
79    if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then
80        :
81    else
82        CFLAGS="$CFLAGS -I$ac_x_includes"
83    fi
84    if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
85        :
86    else
87        if test "x$ac_x_libraries" = x; then
88            XPATH=""
89            XLIB="-lX11"
90        else
91            XPATH="-L$ac_x_libraries"
92            XLIB="-L$ac_x_libraries -lX11"
93        fi
94    fi
95fi
96
97dnl Check for OpenGL
98AC_MSG_CHECKING(for OpenGL support)
99have_opengl=no
100AC_TRY_COMPILE([
101 #include "SDL_opengl.h"
102],[
103],[
104have_opengl=yes
105])
106AC_MSG_RESULT($have_opengl)
107
108dnl Check for OpenGL ES
109AC_MSG_CHECKING(for OpenGL ES support)
110have_opengles=no
111AC_TRY_COMPILE([
112 #if defined (__IPHONEOS__)
113    #include <OpenGLES/ES1/gl.h>
114 #else
115    #include <GLES/gl.h>
116 #endif /* __QNXNTO__ */
117],[
118],[
119have_opengles=yes
120])
121AC_MSG_RESULT($have_opengles)
122
123dnl Check for OpenGL ES2
124AC_MSG_CHECKING(for OpenGL ES2 support)
125have_opengles2=no
126AC_TRY_COMPILE([
127 #if defined (__IPHONEOS__)
128    #include <OpenGLES/ES2/gl.h>
129    #include <OpenGLES/ES2/glext.h>
130 #else
131    #include <GLES2/gl2.h>
132    #include <GLES2/gl2ext.h>
133 #endif
134],[
135],[
136have_opengles2=yes
137])
138AC_MSG_RESULT($have_opengles2)
139
140GLLIB=""
141GLESLIB=""
142GLES2LIB=""
143if test x$have_opengles = xyes; then
144    CFLAGS="$CFLAGS -DHAVE_OPENGLES"
145    GLESLIB="$XPATH -lGLESv1_CM"
146fi
147if test x$have_opengles2 = xyes; then
148    CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
149    #GLES2LIB="$XPATH -lGLESv2"
150fi
151if test x$have_opengl = xyes; then
152    CFLAGS="$CFLAGS -DHAVE_OPENGL"
153    GLLIB="$XPATH $SYS_GL_LIBS"
154fi
155
156AC_SUBST(GLLIB)
157AC_SUBST(GLESLIB)
158AC_SUBST(GLES2LIB)
159AC_SUBST(XLIB)
160
161dnl Check for the SDL2_gfx lib
162have_sdlgfx=no
163AC_CHECK_LIB(SDL2_gfx, pixelColor , have_sdlgfx=yes)
164if test x$have_sdlgfx = xyes; then
165    LIBS="$LIBS -lSDL2_gfx"
166else
167    AC_MSG_ERROR([
168*** Unable to find SDL2_gfx library
169])
170fi
171
172dnl Finally create all the generated files
173AC_OUTPUT([Makefile])
174