test/configure.in
author Gabriel Jacobo <gabomdq@gmail.com>
Wed, 28 Aug 2013 12:43:29 -0300
changeset 7704 3182291fc65f
parent 7703 982abfefd19d
child 7794 7995e0920bf9
permissions -rw-r--r--
[Linux] Test config script: Add the X11 library search path if it is not empty

If ac_x_libraries is empty it means that the library's found in the default path,
so we skip adding it to the XLIB variable as it screws up the search path.
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     3 
     4 dnl Detect the canonical build and host environments
     5 AC_CONFIG_AUX_DIRS($srcdir/../build-scripts)
     6 AC_CANONICAL_HOST
     7 
     8 dnl Check for tools
     9 
    10 AC_PROG_CC
    11 
    12 dnl Check for compiler environment
    13 
    14 AC_C_CONST
    15 
    16 dnl We only care about this for building testnative at the moment, so these
    17 dnl  values shouldn't be considered absolute truth.
    18 dnl  (BeOS, for example, sets none of these.)
    19 ISUNIX="false"
    20 ISWINDOWS="false"
    21 ISMACOSX="false"
    22 
    23 dnl Figure out which math library to use
    24 case "$host" in
    25     *-*-cygwin* | *-*-mingw32*)
    26         ISWINDOWS="true"
    27         EXE=".exe"
    28         MATHLIB=""
    29         SYS_GL_LIBS="-lopengl32"
    30         ;;
    31     *-*-beos* | *-*-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     *)
    69         dnl Oh well, call it Unix...
    70         ISUNIX="true"
    71         EXE=""
    72         MATHLIB="-lm"
    73         SYS_GL_LIBS="-lGL"
    74         ;;
    75 esac
    76 AC_SUBST(EXE)
    77 AC_SUBST(MATHLIB)
    78 AC_SUBST(ISMACOSX)
    79 AC_SUBST(ISWINDOWS)
    80 AC_SUBST(ISUNIX)
    81 
    82 dnl Check for SDL
    83 SDL_VERSION=2.0.0
    84 AM_PATH_SDL2($SDL_VERSION,
    85             :,
    86 	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
    87 )
    88 CFLAGS="$CFLAGS $SDL_CFLAGS"
    89 LIBS="$LIBS  $SDL_LIBS -lSDL2_test"
    90 
    91 dnl Check for X11 path, needed for OpenGL on some systems
    92 AC_PATH_X
    93 if test x$have_x = xyes; then
    94     if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then
    95         :
    96     else
    97         CFLAGS="$CFLAGS -I$ac_x_includes"
    98     fi
    99     if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
   100         :
   101     else
   102         XPATH="-L$ac_x_libraries"
   103         if test "x$ac_x_libraries" = x; then
   104             XLIB="-lX11"
   105         else
   106             XLIB="-L$ac_x_libraries -lX11"
   107         fi
   108     fi
   109 fi
   110 
   111 dnl Check for OpenGL
   112 AC_MSG_CHECKING(for OpenGL support)
   113 have_opengl=no
   114 AC_TRY_COMPILE([
   115  #include "SDL_opengl.h"
   116 ],[
   117 ],[
   118 have_opengl=yes
   119 ])
   120 AC_MSG_RESULT($have_opengl)
   121 
   122 dnl Check for OpenGL ES
   123 AC_MSG_CHECKING(for OpenGL ES support)
   124 have_opengles=no
   125 AC_TRY_COMPILE([
   126  #if defined (__IPHONEOS__)
   127     #include <OpenGLES/ES1/gl.h>
   128  #else
   129     #include <GLES/gl.h>
   130  #endif /* __QNXNTO__ */
   131 ],[
   132 ],[
   133 have_opengles=yes
   134 ])
   135 AC_MSG_RESULT($have_opengles)
   136 
   137 GLLIB=""
   138 if test x$have_opengles = xyes; then
   139     CFLAGS="$CFLAGS -DHAVE_OPENGLES"
   140     GLLIB="$XPATH -lGLESv1_CM"
   141 elif test x$have_opengl = xyes; then
   142     CFLAGS="$CFLAGS -DHAVE_OPENGL"
   143     GLLIB="$XPATH $SYS_GL_LIBS"
   144 else
   145     GLLIB=""
   146 fi
   147 
   148 AC_SUBST(GLLIB)
   149 AC_SUBST(XLIB)
   150 
   151 dnl Check for SDL_ttf
   152 AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
   153 if test x$have_SDL_ttf = xyes; then
   154     CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
   155     SDL_TTF_LIB="-lSDL2_ttf"
   156 fi
   157 AC_SUBST(SDL_TTF_LIB)
   158 
   159 dnl Finally create all the generated files
   160 AC_OUTPUT([Makefile])