test/configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 19 Mar 2006 05:27:22 +0000
changeset 1550 31c2b8e4885e
parent 1387 835c1831f903
child 1654 0a53c90a37f9
child 1813 a7cda692b681
permissions -rw-r--r--
Fixed bug #166

From the autoconf obsolete macros documentation:
Macro: AC_CANONICAL_SYSTEM

Determine the system type and set output variables to the names of the canonical system types. See section Getting the Canonical System Type, for details about the variables this macro sets.

The user is encouraged to use either AC_CANONICAL_BUILD, or AC_CANONICAL_HOST, or AC_CANONICAL_TARGET, depending on the needs. Using AC_CANONICAL_TARGET is enough to run the two other macros.

From the documentation for the canonical environments:
case $target in
i386-*-mach* | i386-*-gnu*)
obj_format=aout emulation=mach bfd_gas=yes ;;
i960-*-bout) obj_format=bout ;;
esac

Note that the above example uses $target because it's taken from a tool which can be built on some architecture ($build), run on another ($host), but yet handle data for a third architecture ($target). Such tools are usually part of a compiler suite, they generate code for a specific $target.

However $target should be meaningless for most packages. If you want to base a decision on the system where your program will be run, make sure you use the $host variable.
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
slouken@0
    16
dnl Figure out which math library to use
slouken@1550
    17
case "$host" in
slouken@0
    18
    *-*-cygwin* | *-*-mingw32*)
slouken@1380
    19
        EXE=".exe"
slouken@0
    20
        MATHLIB=""
slouken@0
    21
        SYS_GL_LIBS="-lopengl32"
slouken@0
    22
        ;;
slouken@0
    23
    *-*-beos*)
slouken@1380
    24
        EXE=""
slouken@0
    25
        MATHLIB=""
slouken@0
    26
        SYS_GL_LIBS="-lGL"
slouken@0
    27
        ;;
patmandin@991
    28
    *-*-darwin* )
slouken@1380
    29
        EXE=""
slouken@0
    30
        MATHLIB=""
slouken@0
    31
        SYS_GL_LIBS=""
slouken@0
    32
        ;;
slouken@0
    33
    *-*-aix*)
slouken@1380
    34
        EXE=""
slouken@0
    35
        if test x$ac_cv_prog_gcc = xyes; then
slouken@0
    36
            CFLAGS="-mthreads"
patmandin@978
    37
        fi
slouken@0
    38
        SYS_GL_LIBS=""
slouken@0
    39
        ;;
patmandin@991
    40
    *-*-mint*)
slouken@1380
    41
        EXE=""
patmandin@991
    42
        MATHLIB=""
patmandin@991
    43
        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
patmandin@991
    44
        if test "x$OSMESA_CONFIG" = "xyes"; then
patmandin@991
    45
            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
patmandin@991
    46
            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
patmandin@991
    47
            CFLAGS="$CFLAGS $OSMESA_CFLAGS"
patmandin@991
    48
            SYS_GL_LIBS="$OSMESA_LIBS"
patmandin@991
    49
        else
patmandin@991
    50
            SYS_GL_LIBS="-lOSMesa"
patmandin@991
    51
        fi
patmandin@991
    52
		;;
slouken@0
    53
    *)
slouken@1380
    54
        EXE=""
slouken@0
    55
        MATHLIB="-lm"
slouken@1380
    56
        SYS_GL_LIBS="-lGL"
slouken@0
    57
        ;;
slouken@0
    58
esac
slouken@1380
    59
AC_SUBST(EXE)
slouken@0
    60
AC_SUBST(MATHLIB)
slouken@0
    61
slouken@0
    62
dnl Check for SDL
slouken@1387
    63
SDL_VERSION=1.2.10
slouken@0
    64
AM_PATH_SDL($SDL_VERSION,
slouken@0
    65
            :,
slouken@0
    66
	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@0
    67
)
slouken@0
    68
CFLAGS="$CFLAGS $SDL_CFLAGS"
slouken@0
    69
LIBS="$LIBS $SDL_LIBS"
slouken@0
    70
slouken@0
    71
dnl Check for OpenGL
slouken@0
    72
AC_MSG_CHECKING(for OpenGL support)
slouken@0
    73
have_opengl=no
slouken@0
    74
AC_TRY_COMPILE([
slouken@292
    75
 #include "SDL_opengl.h"
slouken@0
    76
],[
slouken@0
    77
],[
slouken@0
    78
have_opengl=yes
slouken@0
    79
])
slouken@0
    80
AC_MSG_RESULT($have_opengl)
slouken@0
    81
if test x$have_opengl = xyes; then
slouken@0
    82
    CFLAGS="$CFLAGS -DHAVE_OPENGL"
slouken@1380
    83
    GLLIB="$SYS_GL_LIBS"
slouken@0
    84
else
slouken@1380
    85
    GLLIB=""
slouken@0
    86
fi
slouken@1380
    87
AC_SUBST(GLLIB)
slouken@0
    88
slouken@1380
    89
dnl Finally create all the generated files
slouken@0
    90
AC_OUTPUT([Makefile])