test/configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 12:47:47 -0700
changeset 7495 c4ba5e5c2765
parent 6785 c094c438c0a6
child 7703 982abfefd19d
permissions -rw-r--r--
Fixed bug 1973 - test/Makefile.in fails on Mac OS X with X11 enabled...

Ryan C. Gordon

If you have the X11 SDK installed on Mac OS X, you'll build with X11 support, but the Makefile doesn't build anything but the Cocoa testnative code for Mac OS X, which is fine, but then testnative fails to link because testnative.h enables the X11 support based on the SDL config header.

Building the testnativex11.c code on Mac OS X doesn't work because you need to explicitly link with "-L/usr/X11/lib -lX11" if this code is enabled, but you can't link with that by default because the X11 SDK might be missing.

So this needs a little configure magic to do the right thing (or forcibly disabling X11 support on Mac OS X in testnative.h).
slouken@0
     1
dnl Process this file with autoconf to produce a configure script.
slouken@0
     2
AC_INIT(README)
slouken@0
     3
slouken@1550
     4
dnl Detect the canonical build and host environments
slouken@1380
     5
AC_CONFIG_AUX_DIRS($srcdir/../build-scripts)
slouken@1550
     6
AC_CANONICAL_HOST
slouken@0
     7
slouken@0
     8
dnl Check for tools
slouken@0
     9
slouken@0
    10
AC_PROG_CC
slouken@0
    11
slouken@0
    12
dnl Check for compiler environment
slouken@0
    13
slouken@0
    14
AC_C_CONST
slouken@0
    15
icculus@6390
    16
dnl We only care about this for building testnative at the moment, so these
icculus@6390
    17
dnl  values shouldn't be considered absolute truth.
icculus@6390
    18
dnl  (BeOS, for example, sets none of these.)
icculus@6390
    19
ISUNIX="false"
icculus@6390
    20
ISWINDOWS="false"
icculus@6390
    21
ISMACOSX="false"
icculus@6390
    22
slouken@0
    23
dnl Figure out which math library to use
slouken@1550
    24
case "$host" in
slouken@0
    25
    *-*-cygwin* | *-*-mingw32*)
icculus@6390
    26
        ISWINDOWS="true"
slouken@1380
    27
        EXE=".exe"
slouken@0
    28
        MATHLIB=""
slouken@0
    29
        SYS_GL_LIBS="-lopengl32"
slouken@0
    30
        ;;
slouken@3292
    31
    *-*-beos* | *-*-haiku*)
slouken@1380
    32
        EXE=""
slouken@0
    33
        MATHLIB=""
slouken@0
    34
        SYS_GL_LIBS="-lGL"
slouken@0
    35
        ;;
patmandin@991
    36
    *-*-darwin* )
icculus@6390
    37
        ISMACOSX="true"
slouken@1380
    38
        EXE=""
slouken@0
    39
        MATHLIB=""
icculus@3623
    40
        SYS_GL_LIBS="-Wl,-framework,OpenGL"
slouken@0
    41
        ;;
slouken@0
    42
    *-*-aix*)
icculus@6390
    43
        ISUNIX="true"
slouken@1380
    44
        EXE=""
slouken@0
    45
        if test x$ac_cv_prog_gcc = xyes; then
slouken@0
    46
            CFLAGS="-mthreads"
patmandin@978
    47
        fi
slouken@0
    48
        SYS_GL_LIBS=""
slouken@0
    49
        ;;
patmandin@991
    50
    *-*-mint*)
slouken@1380
    51
        EXE=""
patmandin@991
    52
        MATHLIB=""
patmandin@991
    53
        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
patmandin@991
    54
        if test "x$OSMESA_CONFIG" = "xyes"; then
patmandin@991
    55
            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
patmandin@991
    56
            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
patmandin@991
    57
            CFLAGS="$CFLAGS $OSMESA_CFLAGS"
patmandin@991
    58
            SYS_GL_LIBS="$OSMESA_LIBS"
patmandin@991
    59
        else
patmandin@991
    60
            SYS_GL_LIBS="-lOSMesa"
patmandin@991
    61
        fi
slouken@3087
    62
        ;;
slouken@3087
    63
    *-*-qnx*)
slouken@3087
    64
        EXE=""
slouken@3087
    65
        MATHLIB=""
slouken@3087
    66
        SYS_GL_LIBS="-lGLES_CM"
slouken@3087
    67
        ;;
slouken@0
    68
    *)
icculus@6390
    69
        dnl Oh well, call it Unix...
icculus@6390
    70
        ISUNIX="true"
slouken@1380
    71
        EXE=""
slouken@0
    72
        MATHLIB="-lm"
slouken@1380
    73
        SYS_GL_LIBS="-lGL"
slouken@0
    74
        ;;
slouken@0
    75
esac
slouken@1380
    76
AC_SUBST(EXE)
slouken@0
    77
AC_SUBST(MATHLIB)
icculus@6390
    78
AC_SUBST(ISMACOSX)
icculus@6390
    79
AC_SUBST(ISWINDOWS)
icculus@6390
    80
AC_SUBST(ISUNIX)
slouken@0
    81
slouken@0
    82
dnl Check for SDL
slouken@6250
    83
SDL_VERSION=2.0.0
slouken@6272
    84
AM_PATH_SDL2($SDL_VERSION,
slouken@0
    85
            :,
slouken@0
    86
	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@0
    87
)
slouken@0
    88
CFLAGS="$CFLAGS $SDL_CFLAGS"
slouken@6785
    89
LIBS="$LIBS -lSDL2_test $SDL_LIBS"
slouken@0
    90
slouken@2138
    91
dnl Check for X11 path, needed for OpenGL on some systems
slouken@2138
    92
AC_PATH_X
slouken@2138
    93
if test x$have_x = xyes; then
slouken@2138
    94
    if test x$ac_x_includes = xno || test x$ac_x_includes = x; then
slouken@2138
    95
        :
slouken@2138
    96
    else
slouken@2138
    97
        CFLAGS="$CFLAGS -I$ac_x_includes"
slouken@2138
    98
    fi
slouken@2138
    99
    if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then
slouken@2138
   100
        :
slouken@2138
   101
    else
slouken@2138
   102
        XPATH="-L$ac_x_libraries"
slouken@7495
   103
        XLIB="-L$ac_x_libraries -lX11"
slouken@2138
   104
    fi
slouken@2138
   105
fi
slouken@2138
   106
slouken@0
   107
dnl Check for OpenGL
slouken@0
   108
AC_MSG_CHECKING(for OpenGL support)
slouken@0
   109
have_opengl=no
slouken@0
   110
AC_TRY_COMPILE([
slouken@292
   111
 #include "SDL_opengl.h"
slouken@0
   112
],[
slouken@0
   113
],[
slouken@0
   114
have_opengl=yes
slouken@0
   115
])
slouken@0
   116
AC_MSG_RESULT($have_opengl)
slouken@3087
   117
slouken@3087
   118
dnl Check for OpenGL ES
slouken@3087
   119
AC_MSG_CHECKING(for OpenGL ES support)
slouken@3087
   120
have_opengles=no
slouken@3087
   121
AC_TRY_COMPILE([
slouken@6188
   122
 #if defined (__IPHONEOS__)
slouken@3087
   123
    #include <OpenGLES/ES1/gl.h>
slouken@3087
   124
 #else
slouken@6188
   125
    #include <GLES/gl.h>
slouken@3087
   126
 #endif /* __QNXNTO__ */
slouken@3087
   127
],[
slouken@3087
   128
],[
slouken@3087
   129
have_opengles=yes
slouken@3087
   130
])
slouken@3087
   131
AC_MSG_RESULT($have_opengles)
slouken@3090
   132
slouken@6188
   133
GLLIB=""
slouken@6188
   134
if test x$have_opengles = xyes; then
slouken@6188
   135
    CFLAGS="$CFLAGS -DHAVE_OPENGLES"
slouken@6188
   136
    GLLIB="$XPATH -lGLESv1_CM"
slouken@6188
   137
elif test x$have_opengl = xyes; then
slouken@3090
   138
    CFLAGS="$CFLAGS -DHAVE_OPENGL"
slouken@3090
   139
    GLLIB="$XPATH $SYS_GL_LIBS"
slouken@3087
   140
else
slouken@3087
   141
    GLLIB=""
slouken@3087
   142
fi
slouken@3087
   143
slouken@1380
   144
AC_SUBST(GLLIB)
slouken@7495
   145
AC_SUBST(XLIB)
slouken@0
   146
slouken@3280
   147
dnl Check for SDL_ttf
slouken@6598
   148
AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
slouken@3280
   149
if test x$have_SDL_ttf = xyes; then
slouken@3280
   150
    CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
slouken@6598
   151
    SDL_TTF_LIB="-lSDL2_ttf"
slouken@3280
   152
fi
slouken@3280
   153
AC_SUBST(SDL_TTF_LIB)
slouken@3280
   154
slouken@1380
   155
dnl Finally create all the generated files
slouken@0
   156
AC_OUTPUT([Makefile])