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/../build-scripts)
6AC_CANONICAL_HOST
7
8dnl Check for tools
9
10AC_PROG_CC
11
12dnl Check for compiler environment
13
14AC_C_CONST
15
16dnl We only care about this for building testnative at the moment, so these
17dnl  values shouldn't be considered absolute truth.
18dnl  (Haiku, for example, sets none of these.)
19ISUNIX="false"
20ISWINDOWS="false"
21ISMACOSX="false"
22
23dnl Figure out which math library to use
24case "$host" in
25    *-*-cygwin* | *-*-mingw32*)
26        ISWINDOWS="true"
27        EXE=".exe"
28        MATHLIB=""
29        SYS_GL_LIBS="-lopengl32"
30        ;;
31    *-*-haiku*)
32        EXE=""
33        MATHLIB=""
34        SYS_GL_LIBS="-lGL"
35        ;;
36    *-*-darwin* )
37        ISMACOSX="true"
38        EXE=""
39        MATHLIB=""
40        SYS_GL_LIBS="-Wl,-framework,OpenGL"
41        ;;
42    *-*-aix*)
43        ISUNIX="true"
44        EXE=""
45        if test x$ac_cv_prog_gcc = xyes; then
46            CFLAGS="-mthreads"
47        fi
48        SYS_GL_LIBS=""
49        ;;
50    *-*-mint*)
51        EXE=""
52        MATHLIB=""
53        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
54        if test "x$OSMESA_CONFIG" = "xyes"; then
55            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
56            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
57            CFLAGS="$CFLAGS $OSMESA_CFLAGS"
58            SYS_GL_LIBS="$OSMESA_LIBS"
59        else
60            SYS_GL_LIBS="-lOSMesa"
61        fi
62        ;;
63    *-*-qnx*)
64        EXE=""
65        MATHLIB=""
66        SYS_GL_LIBS="-lGLES_CM"
67        ;;
68    *-*-emscripten* )
69        dnl This should really be .js, but we need to specify extra flags when compiling to js
70        EXE=".bc"
71        MATHLIB=""
72        SYS_GL_LIBS=""
73        ;;
74    *)
75        dnl Oh well, call it Unix...
76        ISUNIX="true"
77        EXE=""
78        MATHLIB="-lm"
79        SYS_GL_LIBS="-lGL"
80        ;;
81esac
82AC_SUBST(EXE)
83AC_SUBST(MATHLIB)
84AC_SUBST(ISMACOSX)
85AC_SUBST(ISWINDOWS)
86AC_SUBST(ISUNIX)
87
88dnl Check for SDL
89SDL_VERSION=2.0.0
90AM_PATH_SDL2($SDL_VERSION,
91            :,
92	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
93)
94CFLAGS="$CFLAGS $SDL_CFLAGS"
95LIBS="$LIBS -lSDL2_test $SDL_LIBS"
96
97dnl Check for X11 path, needed for OpenGL on some systems
98AC_PATH_X
99if test x$have_x = xyes; then
100    if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then
101        :
102    else
103        CFLAGS="$CFLAGS -I$ac_x_includes"
104    fi
105    if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
106        :
107    else
108        if test "x$ac_x_libraries" = x; then
109            XPATH=""
110            XLIB="-lX11"
111        else
112            XPATH="-L$ac_x_libraries"
113            XLIB="-L$ac_x_libraries -lX11"
114        fi
115    fi
116fi
117
118dnl Check for OpenGL
119AC_MSG_CHECKING(for OpenGL support)
120have_opengl=no
121AC_TRY_COMPILE([
122 #include "SDL_opengl.h"
123],[
124],[
125have_opengl=yes
126])
127AC_MSG_RESULT($have_opengl)
128
129dnl Check for OpenGL ES
130AC_MSG_CHECKING(for OpenGL ES support)
131have_opengles=no
132AC_TRY_COMPILE([
133 #if defined (__IPHONEOS__)
134    #include <OpenGLES/ES1/gl.h>
135 #else
136    #include <GLES/gl.h>
137 #endif /* __QNXNTO__ */
138],[
139],[
140have_opengles=yes
141])
142AC_MSG_RESULT($have_opengles)
143
144dnl Check for OpenGL ES2
145AC_MSG_CHECKING(for OpenGL ES2 support)
146have_opengles2=no
147AC_TRY_COMPILE([
148 #if defined (__IPHONEOS__)
149    #include <OpenGLES/ES2/gl.h>
150    #include <OpenGLES/ES2/glext.h>
151 #else
152    #include <GLES2/gl2.h>
153    #include <GLES2/gl2ext.h>
154 #endif
155],[
156],[
157have_opengles2=yes
158])
159AC_MSG_RESULT($have_opengles2)
160
161GLLIB=""
162GLESLIB=""
163GLES2LIB=""
164if test x$have_opengles = xyes; then
165    CFLAGS="$CFLAGS -DHAVE_OPENGLES"
166    GLESLIB="$XPATH -lGLESv1_CM"
167fi
168if test x$have_opengles2 = xyes; then
169    CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
170    #GLES2LIB="$XPATH -lGLESv2"
171fi
172if test x$have_opengl = xyes; then
173    CFLAGS="$CFLAGS -DHAVE_OPENGL"
174    GLLIB="$XPATH $SYS_GL_LIBS"
175fi
176
177AC_SUBST(GLLIB)
178AC_SUBST(GLESLIB)
179AC_SUBST(GLES2LIB)
180AC_SUBST(XLIB)
181
182dnl Check for SDL_ttf
183AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
184if test x$have_SDL_ttf = xyes; then
185    CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
186    SDL_TTF_LIB="-lSDL2_ttf"
187fi
188AC_SUBST(SDL_TTF_LIB)
189
190dnl Finally create all the generated files
191AC_OUTPUT([Makefile])
192