configure.in
author Sam Lantinga <slouken@libsdl.org>
Wed, 28 Oct 2009 04:27:50 +0000
changeset 3415 1756b9569141
parent 3405 d5f2dd33f4eb
child 3426 ee0178f1c507
permissions -rw-r--r--
Adam Strzelecki to SDL

Actually after my patch commited in r4928 MinGW configure seems to generate broken Makefile due MSYS bash bug. (Attaching cure/patch below)

The problem is that:

TEST=`echo 'one\\
two\\
three\\'`
echo "$TEST"

Should echo:
one\
two\
three\

Does it on Linux, Mac.. all UNIX but not on MSYS (MinGW) which outputs:
one\two\three\
(new lines removed, probably it doesn't like backslashes)
Probably this bug should be submitted to MSYS team, but not waiting till MSYS gets it fixed (they have very slow release cycles) here goes simple cure...

My patch simply replaces single quoted SED rules where we needed newlien injection with double quoted ones.

Tested on Mac, Linux & MinGW. Please review it ASAP coz this may be showstopper for everybody compiling with MinGW.
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     3 AC_CONFIG_HEADER(include/SDL_config.h)
     4 AC_GNU_SOURCE
     5 AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
     6 
     7 dnl Save the CFLAGS to see whether they were passed in or generated
     8 orig_CFLAGS="$CFLAGS"
     9 
    10 dnl Set various version strings - taken gratefully from the GTk sources
    11 #
    12 # Making releases:
    13 # Edit include/SDL/SDL_version.h and change the version, then:
    14 #   SDL_MICRO_VERSION += 1;
    15 #   SDL_INTERFACE_AGE += 1;
    16 #   SDL_BINARY_AGE += 1;
    17 # if any functions have been added, set SDL_INTERFACE_AGE to 0.
    18 # if backwards compatibility has been broken,
    19 # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
    20 #
    21 SDL_MAJOR_VERSION=1
    22 SDL_MINOR_VERSION=3
    23 SDL_MICRO_VERSION=0
    24 SDL_INTERFACE_AGE=0
    25 SDL_BINARY_AGE=0
    26 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
    27 
    28 AC_SUBST(SDL_MAJOR_VERSION)
    29 AC_SUBST(SDL_MINOR_VERSION)
    30 AC_SUBST(SDL_MICRO_VERSION)
    31 AC_SUBST(SDL_INTERFACE_AGE)
    32 AC_SUBST(SDL_BINARY_AGE)
    33 AC_SUBST(SDL_VERSION)
    34 
    35 # libtool versioning
    36 LT_INIT([win32-dll])
    37 
    38 LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
    39 LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
    40 LT_REVISION=$SDL_INTERFACE_AGE
    41 LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
    42 m4_pattern_allow([^LT_])
    43 
    44 AC_SUBST(LT_RELEASE)
    45 AC_SUBST(LT_CURRENT)
    46 AC_SUBST(LT_REVISION)
    47 AC_SUBST(LT_AGE)
    48 
    49 dnl Detect the canonical build and host environments
    50 dnl AC_CANONICAL_HOST
    51 AC_C_BIGENDIAN
    52 if test x$ac_cv_c_bigendian = xyes; then
    53     AC_DEFINE(SDL_BYTEORDER, 4321)
    54 else
    55     AC_DEFINE(SDL_BYTEORDER, 1234)
    56 fi
    57 
    58 dnl Check for tools
    59 AC_PROG_LIBTOOL
    60 AC_PROG_CC
    61 AC_PROG_CXX
    62 AC_PROG_INSTALL
    63 AC_PROG_MAKE_SET
    64 if test -z "$host_alias"; then
    65     hostaliaswindres=
    66 else
    67     hostaliaswindres="$host_alias-windres"
    68 fi
    69 AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
    70 
    71 dnl Set up the compiler and linker flags
    72 INCLUDE="-I$srcdir/include"
    73 if test x$srcdir != x.; then
    74     # Remove SDL_config.h from the source directory, since it's the
    75     # default one, and we want to include the one that we generate.
    76     if test -f $srcdir/include/SDL_config.h; then
    77         rm $srcdir/include/SDL_config.h
    78     fi
    79     INCLUDE="-Iinclude $INCLUDE"
    80 fi
    81 case "$host" in
    82     *-*-cygwin*)
    83         # We build SDL on cygwin without the UNIX emulation layer
    84         BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
    85         BASE_LDFLAGS="-mno-cygwin"
    86         ;;
    87     *)
    88         BASE_CFLAGS="-D_GNU_SOURCE=1"
    89         BASE_LDFLAGS=""
    90         ;;
    91 esac
    92 BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
    93 # The default optimization for SDL 1.3 is -O3 (Bug #31)
    94 if test x$orig_CFLAGS = x; then
    95     BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
    96 fi
    97 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    98 BUILD_LDFLAGS="$LDFLAGS"
    99 EXTRA_LDFLAGS="$BASE_LDFLAGS"
   100 ## These are common directories to find software packages
   101 #for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
   102 #    if test -d $path/include; then
   103 #        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
   104 #    fi
   105 #    if test -d $path/lib; then
   106 #        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
   107 #    fi
   108 #done
   109 SDL_CFLAGS="$BASE_CFLAGS"
   110 SDL_LIBS="-lSDL $BASE_LDFLAGS"
   111 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
   112 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
   113 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
   114 
   115 dnl set this to use on systems that use lib64 instead of lib
   116 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   117 
   118 dnl Function to find a library in the compiler search path
   119 find_lib()
   120 {
   121     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   122     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   123     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   124     if test "$cross_compiling" = yes; then
   125         host_lib_path=""
   126     else
   127         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   128     fi
   129     for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
   130         lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
   131         if test x$lib != x; then
   132             echo $lib
   133             return
   134         fi
   135     done
   136 }
   137 
   138 dnl Check for compiler characteristics
   139 AC_C_CONST
   140 AC_C_INLINE
   141 AC_C_VOLATILE
   142 
   143 dnl See whether we can use gcc style dependency tracking
   144 AC_ARG_ENABLE(dependency-tracking,
   145 AC_HELP_STRING([--enable-dependency-tracking],
   146                [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
   147               , enable_dependency_tracking=yes)
   148 if test x$enable_dependency_tracking = xyes; then
   149     have_gcc_mmd_mt=no
   150     AC_MSG_CHECKING(for GCC -MMD -MT option)
   151     AC_TRY_COMPILE([
   152     #if !defined(__GNUC__) || __GNUC__ < 3
   153     #error Dependency tracking requires GCC 3.0 or newer
   154     #endif
   155     ],[
   156     ],[
   157     have_gcc_mmd_mt=yes
   158     ])
   159     AC_MSG_RESULT($have_gcc_mmd_mt)
   160 
   161     if test x$have_gcc_mmd_mt = xyes; then
   162         DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
   163     fi
   164 fi
   165     
   166 dnl See whether we are allowed to use the system C library
   167 AC_ARG_ENABLE(libc,
   168 AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
   169               , enable_libc=yes)
   170 if test x$enable_libc = xyes; then
   171     AC_DEFINE(HAVE_LIBC)
   172 
   173     dnl Check for C library headers
   174     AC_HEADER_STDC
   175     AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
   176 
   177     dnl Check for typedefs, structures, etc.
   178     AC_TYPE_SIZE_T
   179     if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
   180         AC_CHECK_TYPE(int64_t)
   181         if test x$ac_cv_type_int64_t = xyes; then
   182             AC_DEFINE(SDL_HAS_64BIT_TYPE)
   183         fi
   184         have_inttypes=yes
   185     fi
   186 
   187     dnl Check for defines
   188     AC_CHECK_DEFINE(M_PI, math.h)
   189 
   190     dnl Checks for library functions.
   191     case "$host" in
   192     *-*-cygwin* | *-*-mingw32*)
   193         ;;
   194     *)
   195         AC_FUNC_ALLOCA
   196         ;;
   197     esac
   198 
   199     AC_FUNC_MEMCMP
   200     if test x$ac_cv_func_memcmp_working = xyes; then
   201         AC_DEFINE(HAVE_MEMCMP)
   202     fi
   203     AC_FUNC_STRTOD
   204     if test x$ac_cv_func_strtod = xyes; then
   205         AC_DEFINE(HAVE_STRTOD)
   206     fi
   207     AC_CHECK_FUNC(mprotect,
   208         AC_TRY_COMPILE([
   209           #include <sys/types.h>
   210           #include <sys/mman.h>
   211         ],[
   212         ],[
   213         AC_DEFINE(HAVE_MPROTECT)
   214         ]),
   215     )
   216     AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
   217 
   218     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
   219     AC_CHECK_FUNCS(ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
   220 
   221     AC_CHECK_LIB(iconv, libiconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
   222     AC_CHECK_FUNCS(iconv)
   223 fi
   224 
   225 AC_CHECK_SIZEOF(void*)
   226 if test x$have_inttypes != xyes; then
   227     AC_CHECK_SIZEOF(char, 1)
   228     AC_CHECK_SIZEOF(short, 2)
   229     AC_CHECK_SIZEOF(int, 4)
   230     AC_CHECK_SIZEOF(long, 4)
   231     AC_CHECK_SIZEOF(long long, 8)
   232     if test x$ac_cv_sizeof_char = x1; then
   233         AC_DEFINE(int8_t, signed char)
   234         AC_DEFINE(uint8_t, unsigned char)
   235     fi
   236     if test x$ac_cv_sizeof_short = x2; then
   237         AC_DEFINE(int16_t, signed short)
   238         AC_DEFINE(uint16_t, unsigned short)
   239     else
   240         if test x$ac_cv_sizeof_int = x2; then
   241             AC_DEFINE(int16_t, signed int)
   242             AC_DEFINE(uint16_t, unsigned int)
   243         fi
   244     fi
   245     if test x$ac_cv_sizeof_int = x4; then
   246         AC_DEFINE(int32_t, signed int)
   247         AC_DEFINE(uint32_t, unsigned int)
   248     else
   249         if test x$ac_cv_sizeof_long = x4; then
   250             AC_DEFINE(int32_t, signed long)
   251             AC_DEFINE(uint32_t, unsigned long)
   252         fi
   253     fi
   254     if test x$ac_cv_sizeof_long = x8; then
   255         AC_DEFINE(int64_t, signed long)
   256         AC_DEFINE(uint64_t, unsigned long)
   257         AC_DEFINE(SDL_HAS_64BIT_TYPE)
   258     else
   259         if test x$ac_cv_sizeof_long_long = x8; then
   260             AC_DEFINE(int64_t, signed long long)
   261             AC_DEFINE(uint64_t, unsigned long long)
   262             AC_DEFINE(SDL_HAS_64BIT_TYPE)
   263         fi
   264     fi
   265     AC_DEFINE(size_t, unsigned int)
   266     AC_DEFINE(uintptr_t, unsigned long)
   267 fi
   268 
   269 # Standard C sources
   270 SOURCES="$SOURCES $srcdir/src/*.c"
   271 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   272 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   273 SOURCES="$SOURCES $srcdir/src/events/*.c"
   274 SOURCES="$SOURCES $srcdir/src/file/*.c"
   275 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   276 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   277 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   278 SOURCES="$SOURCES $srcdir/src/video/*.c"
   279 
   280 dnl Enable/disable various subsystems of the SDL library
   281 
   282 AC_ARG_ENABLE(atomic,
   283 AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
   284               , enable_atomic=yes)
   285 if test x$enable_atomic != xyes; then
   286     AC_DEFINE(SDL_ATOMIC_DISABLED)
   287 fi
   288 AC_ARG_ENABLE(audio,
   289 AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
   290               , enable_audio=yes)
   291 if test x$enable_audio != xyes; then
   292     AC_DEFINE(SDL_AUDIO_DISABLED)
   293 fi
   294 AC_ARG_ENABLE(video,
   295 AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
   296               , enable_video=yes)
   297 if test x$enable_video != xyes; then
   298     AC_DEFINE(SDL_VIDEO_DISABLED)
   299 fi
   300 AC_ARG_ENABLE(events,
   301 AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
   302               , enable_events=yes)
   303 if test x$enable_events != xyes; then
   304     AC_DEFINE(SDL_EVENTS_DISABLED)
   305 fi
   306 AC_ARG_ENABLE(joystick,
   307 AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
   308               , enable_joystick=yes)
   309 if test x$enable_joystick != xyes; then
   310     AC_DEFINE(SDL_JOYSTICK_DISABLED)
   311 else
   312     SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   313 fi
   314 AC_ARG_ENABLE(haptic,
   315 AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
   316               , enable_haptic=yes)
   317 if test x$enable_haptic != xyes; then
   318     AC_DEFINE(SDL_HAPTIC_DISABLED)
   319 else
   320     SOURCES="$SOURCES $srcdir/src/haptic/*.c"
   321 fi
   322 AC_ARG_ENABLE(power,
   323 AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
   324               , enable_power=yes)
   325 if test x$enable_power != xyes; then
   326     AC_DEFINE(SDL_POWER_DISABLED)
   327 else
   328     SOURCES="$SOURCES $srcdir/src/power/*.c"
   329 fi
   330 AC_ARG_ENABLE(threads,
   331 AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
   332               , enable_threads=yes)
   333 if test x$enable_threads != xyes; then
   334     AC_DEFINE(SDL_THREADS_DISABLED)
   335 fi
   336 AC_ARG_ENABLE(timers,
   337 AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
   338               , enable_timers=yes)
   339 if test x$enable_timers != xyes; then
   340     AC_DEFINE(SDL_TIMERS_DISABLED)
   341 fi
   342 AC_ARG_ENABLE(file,
   343 AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
   344               , enable_file=yes)
   345 if test x$enable_file != xyes; then
   346     AC_DEFINE(SDL_FILE_DISABLED)
   347 fi
   348 AC_ARG_ENABLE(loadso,
   349 AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
   350               , enable_loadso=yes)
   351 if test x$enable_loadso != xyes; then
   352     AC_DEFINE(SDL_LOADSO_DISABLED)
   353 fi
   354 AC_ARG_ENABLE(cpuinfo,
   355 AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
   356               , enable_cpuinfo=yes)
   357 if test x$enable_cpuinfo != xyes; then
   358     AC_DEFINE(SDL_CPUINFO_DISABLED)
   359 fi
   360 AC_ARG_ENABLE(assembly,
   361 AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
   362               , enable_assembly=yes)
   363 if test x$enable_assembly = xyes; then
   364     AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
   365 
   366     # Make sure that we don't generate floating point code that would
   367     # cause illegal instruction exceptions on older processors
   368     case "$host" in
   369         *-*-darwin*)
   370             # Don't need to worry about Apple hardware, it's all SSE capable
   371             default_ssemath=yes
   372             ;;
   373         *64-*-*)
   374             # x86 64-bit architectures all have SSE instructions
   375             default_ssemath=yes
   376             ;;
   377         *)
   378             default_ssemath=no
   379             ;;
   380     esac
   381     AC_ARG_ENABLE(ssemath,
   382 AC_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=no]]]),
   383                   , enable_ssemath=$default_ssemath)
   384     if test x$enable_ssemath = xno; then
   385         if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes; then
   386             EXTRA_CFLAGS="$EXTRA_CFLAGS -mfpmath=387"
   387         fi
   388     fi
   389 
   390     dnl Check for various instruction support
   391     AC_ARG_ENABLE(mmx,
   392 AC_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
   393                   , enable_mmx=yes)
   394     if test x$enable_mmx = xyes; then
   395         save_CFLAGS="$CFLAGS"
   396         have_gcc_mmx=no
   397         AC_MSG_CHECKING(for GCC -mmmx option)
   398         mmx_CFLAGS="-mmmx"
   399         CFLAGS="$save_CFLAGS $mmx_CFLAGS"
   400 
   401         AC_TRY_COMPILE([
   402         #include <mmintrin.h>
   403         #ifndef __MMX__
   404         #error Assembler CPP flag not enabled
   405         #endif
   406         ],[
   407         ],[
   408         have_gcc_mmx=yes
   409         ])
   410         AC_MSG_RESULT($have_gcc_mmx)
   411         CFLAGS="$save_CFLAGS"
   412 
   413         if test x$have_gcc_mmx = xyes; then
   414             EXTRA_CFLAGS="$EXTRA_CFLAGS $mmx_CFLAGS"
   415         fi
   416     fi
   417 
   418     AC_ARG_ENABLE(3dnow,
   419 AC_HELP_STRING([--enable-3dnow], [use MMX assembly routines [[default=yes]]]),
   420                   , enable_3dnow=yes)
   421     if test x$enable_3dnow = xyes; then
   422         save_CFLAGS="$CFLAGS"
   423         have_gcc_3dnow=no
   424         AC_MSG_CHECKING(for GCC -m3dnow option)
   425         amd3dnow_CFLAGS="-m3dnow"
   426         CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
   427 
   428         AC_TRY_COMPILE([
   429         #include <mm3dnow.h>
   430         #ifndef __3dNOW__
   431         #error Assembler CPP flag not enabled
   432         #endif
   433         ],[
   434         ],[
   435         have_gcc_3dnow=yes
   436         ])
   437         AC_MSG_RESULT($have_gcc_3dnow)
   438         CFLAGS="$save_CFLAGS"
   439 
   440         if test x$have_gcc_3dnow = xyes; then
   441             EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
   442         fi
   443     fi
   444 
   445     AC_ARG_ENABLE(sse,
   446 AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
   447                   , enable_sse=yes)
   448     if test x$enable_sse = xyes; then
   449         save_CFLAGS="$CFLAGS"
   450         have_gcc_sse=no
   451         AC_MSG_CHECKING(for GCC -msse option)
   452         sse_CFLAGS="-msse"
   453         CFLAGS="$save_CFLAGS $sse_CFLAGS"
   454 
   455         AC_TRY_COMPILE([
   456         #include <xmmintrin.h>
   457         #ifndef __SSE__
   458         #error Assembler CPP flag not enabled
   459         #endif
   460         ],[
   461         ],[
   462         have_gcc_sse=yes
   463         ])
   464         AC_MSG_RESULT($have_gcc_sse)
   465         CFLAGS="$save_CFLAGS"
   466 
   467         if test x$have_gcc_sse = xyes; then
   468             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse_CFLAGS"
   469         fi
   470     fi
   471 
   472     AC_ARG_ENABLE(sse2,
   473 AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
   474                   , enable_sse2=$default_ssemath)
   475     if test x$enable_sse2 = xyes; then
   476         save_CFLAGS="$CFLAGS"
   477         have_gcc_sse2=no
   478         AC_MSG_CHECKING(for GCC -msse2 option)
   479         sse2_CFLAGS="-msse2"
   480         CFLAGS="$save_CFLAGS $sse2_CFLAGS"
   481 
   482         AC_TRY_COMPILE([
   483         #include <emmintrin.h>
   484         #ifndef __SSE2__
   485         #error Assembler CPP flag not enabled
   486         #endif
   487         ],[
   488         ],[
   489         have_gcc_sse2=yes
   490         ])
   491         AC_MSG_RESULT($have_gcc_sse2)
   492         CFLAGS="$save_CFLAGS"
   493 
   494         if test x$have_gcc_sse2 = xyes; then
   495             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
   496         fi
   497     fi
   498 
   499     AC_ARG_ENABLE(altivec,
   500 AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
   501                   , enable_altivec=yes)
   502     if test x$enable_altivec = xyes; then
   503         save_CFLAGS="$CFLAGS"
   504         have_gcc_altivec=no
   505         have_altivec_h_hdr=no
   506         altivec_CFLAGS="-maltivec"
   507         CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   508 
   509         AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
   510         AC_TRY_COMPILE([
   511         #include <altivec.h>
   512         vector unsigned int vzero() {
   513             return vec_splat_u32(0);
   514         }
   515         ],[
   516         ],[
   517         have_gcc_altivec=yes
   518         have_altivec_h_hdr=yes
   519         ])
   520         AC_MSG_RESULT($have_gcc_altivec)
   521 
   522         if test x$have_gcc_altivec = xno; then
   523             AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
   524             AC_TRY_COMPILE([
   525             vector unsigned int vzero() {
   526                 return vec_splat_u32(0);
   527             }
   528             ],[
   529             ],[
   530             have_gcc_altivec=yes
   531             ])
   532             AC_MSG_RESULT($have_gcc_altivec)
   533         fi
   534 
   535         if test x$have_gcc_altivec = xno; then
   536             AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
   537             altivec_CFLAGS="-faltivec"
   538             CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   539             AC_TRY_COMPILE([
   540             #include <altivec.h>
   541             vector unsigned int vzero() {
   542                 return vec_splat_u32(0);
   543             }
   544             ],[
   545             ],[
   546             have_gcc_altivec=yes
   547             have_altivec_h_hdr=yes
   548             ])
   549             AC_MSG_RESULT($have_gcc_altivec)
   550         fi
   551 
   552         if test x$have_gcc_altivec = xno; then
   553             AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
   554             AC_TRY_COMPILE([
   555             vector unsigned int vzero() {
   556                 return vec_splat_u32(0);
   557             }
   558             ],[
   559             ],[
   560             have_gcc_altivec=yes
   561             ])
   562             AC_MSG_RESULT($have_gcc_altivec)
   563         fi
   564         CFLAGS="$save_CFLAGS"
   565 
   566         if test x$have_gcc_altivec = xyes; then
   567             AC_DEFINE(SDL_ALTIVEC_BLITTERS)
   568             if test x$have_altivec_h_hdr = xyes; then
   569               AC_DEFINE(HAVE_ALTIVEC_H)
   570             fi
   571             EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
   572         fi
   573     fi
   574 fi
   575 
   576 dnl See if the OSS audio interface is supported
   577 CheckOSS()
   578 {
   579     AC_ARG_ENABLE(oss,
   580 AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=yes]]]),
   581                   , enable_oss=yes)
   582     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   583         AC_MSG_CHECKING(for OSS audio support)
   584         have_oss=no
   585         if test x$have_oss != xyes; then
   586             AC_TRY_COMPILE([
   587               #include <sys/soundcard.h>
   588             ],[
   589               int arg = SNDCTL_DSP_SETFRAGMENT;
   590             ],[
   591             have_oss=yes
   592             ])
   593         fi
   594         if test x$have_oss != xyes; then
   595             AC_TRY_COMPILE([
   596               #include <soundcard.h>
   597             ],[
   598               int arg = SNDCTL_DSP_SETFRAGMENT;
   599             ],[
   600             have_oss=yes
   601             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
   602             ])
   603         fi
   604         AC_MSG_RESULT($have_oss)
   605         if test x$have_oss = xyes; then
   606             AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
   607             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   608             SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
   609             have_audio=yes
   610 
   611             # We may need to link with ossaudio emulation library
   612             case "$host" in
   613                 *-*-openbsd*|*-*-netbsd*)
   614                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
   615             esac
   616         fi
   617     fi
   618 }
   619 
   620 dnl See if the ALSA audio interface is supported
   621 CheckALSA()
   622 {
   623     AC_ARG_ENABLE(alsa,
   624 AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
   625                   , enable_alsa=yes)
   626     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   627         AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
   628         # Restore all flags from before the ALSA detection runs
   629         CFLAGS="$alsa_save_CFLAGS"
   630         LDFLAGS="$alsa_save_LDFLAGS"
   631         LIBS="$alsa_save_LIBS"
   632         if test x$have_alsa = xyes; then
   633             AC_ARG_ENABLE(alsa-shared,
   634 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
   635                           , enable_alsa_shared=yes)
   636             alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   637 
   638             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
   639             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   640             EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
   641             if test x$have_loadso != xyes && \
   642                test x$enable_alsa_shared = xyes; then
   643                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
   644             fi
   645             if test x$have_loadso = xyes && \
   646                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   647                 echo "-- dynamic libasound -> $alsa_lib"
   648                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
   649             else
   650                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
   651             fi
   652             have_audio=yes
   653         fi
   654     fi
   655 }
   656 
   657 dnl Check whether we want to use IRIX 6.5+ native audio or not
   658 CheckDMEDIA()
   659 {
   660     if test x$enable_audio = xyes; then
   661         AC_MSG_CHECKING(for dmedia audio support)
   662         have_dmedia=no
   663         AC_TRY_COMPILE([
   664           #include <dmedia/audio.h>
   665         ],[
   666           ALport audio_port;
   667         ],[
   668         have_dmedia=yes
   669         ])
   670         AC_MSG_RESULT($have_dmedia)
   671         # Set up files for the audio library
   672         if test x$have_dmedia = xyes; then
   673             AC_DEFINE(SDL_AUDIO_DRIVER_DMEDIA)
   674             SOURCES="$SOURCES $srcdir/src/audio/dmedia/*.c"
   675             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laudio"
   676             have_audio=yes
   677         fi
   678     fi
   679 }
   680 
   681 dnl Check whether we want to use Tru64 UNIX native audio or not
   682 CheckMME()
   683 {
   684     dnl Make sure we are running on an Tru64 UNIX
   685     case $ARCH in
   686         osf)
   687             ;;
   688         *)
   689             return
   690             ;;
   691     esac
   692     if test x$enable_audio = xyes; then
   693         AC_MSG_CHECKING(for MME audio support)
   694         MME_CFLAGS="-I/usr/include/mme"
   695         MME_LIBS="-lmme"
   696         have_mme=no
   697         save_CFLAGS="$CFLAGS"
   698         CFLAGS="$CFLAGS $MME_CFLAGS"
   699         AC_TRY_COMPILE([
   700           #include <mme_api.h>
   701         ],[
   702           HWAVEOUT sound;
   703         ],[
   704         have_mme=yes
   705         ])
   706         CFLAGS="$save_CFLAGS"
   707         AC_MSG_RESULT($have_mme)
   708         # Set up files for the audio library
   709         if test x$have_mme = xyes; then
   710             AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
   711             SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
   712             EXTRA_CFLAGS="$EXTRA_CFLAGS $MME_CFLAGS"
   713             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MME_LIBS"
   714             have_audio=yes
   715         fi
   716     fi
   717 }
   718 
   719 dnl Find the ESD includes and libraries
   720 CheckESD()
   721 {
   722     AC_ARG_ENABLE(esd,
   723 AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
   724                   , enable_esd=yes)
   725     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   726         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   727         if test x$have_esd = xyes; then
   728             AC_ARG_ENABLE(esd-shared,
   729 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
   730                           , enable_esd_shared=yes)
   731             esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   732 
   733             AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
   734             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   735             EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
   736             if test x$have_loadso != xyes && \
   737                test x$enable_esd_shared = xyes; then
   738                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
   739             fi
   740             if test x$have_loadso = xyes && \
   741                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   742                 echo "-- dynamic libesd -> $esd_lib"
   743                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
   744             else
   745                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
   746             fi
   747             have_audio=yes
   748         fi
   749     fi
   750 }
   751 
   752 dnl Find PulseAudio
   753 CheckPulseAudio()
   754 {
   755     AC_ARG_ENABLE(pulseaudio,
   756 AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
   757                   , enable_pulseaudio=yes)
   758     if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
   759         audio_pulseaudio=no
   760 
   761         PULSEAUDIO_REQUIRED_VERSION=0.9
   762 
   763         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   764         AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support)
   765         if test x$PKG_CONFIG != xno; then
   766         if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
   767                 PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
   768                 PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
   769                 audio_pulseaudio=yes
   770             fi
   771         fi
   772         AC_MSG_RESULT($audio_pulseaudio)
   773 
   774         if test x$audio_pulseaudio = xyes; then
   775             AC_ARG_ENABLE(pulseaudio-shared,
   776 AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
   777                           , enable_pulseaudio_shared=yes)
   778             pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   779 
   780             AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO)
   781             SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
   782             EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
   783             if test x$have_loadso != xyes && \
   784                test x$enable_pulseaudio_shared = xyes; then
   785                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
   786             fi
   787             if test x$have_loadso = xyes && \
   788                test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
   789                 echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
   790                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib")
   791             else
   792                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
   793             fi
   794             have_audio=yes
   795         fi
   796     fi
   797 }
   798 
   799 CheckARTSC()
   800 {
   801     AC_ARG_ENABLE(arts,
   802 AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
   803                   , enable_arts=yes)
   804     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
   805         AC_PATH_PROG(ARTSCONFIG, artsc-config)
   806         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
   807             : # arts isn't installed
   808         else
   809             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
   810             ARTS_LIBS=`$ARTSCONFIG --libs`
   811             AC_MSG_CHECKING(for aRts development environment)
   812             audio_arts=no
   813             save_CFLAGS="$CFLAGS"
   814             CFLAGS="$CFLAGS $ARTS_CFLAGS"
   815             AC_TRY_COMPILE([
   816              #include <artsc.h>
   817             ],[
   818              arts_stream_t stream;
   819             ],[
   820             audio_arts=yes
   821             ])
   822             CFLAGS="$save_CFLAGS"
   823             AC_MSG_RESULT($audio_arts)
   824             if test x$audio_arts = xyes; then
   825                 AC_ARG_ENABLE(arts-shared,
   826 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
   827                               , enable_arts_shared=yes)
   828                 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   829 
   830                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
   831                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
   832                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
   833                 if test x$have_loadso != xyes && \
   834                    test x$enable_arts_shared = xyes; then
   835                     AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
   836                 fi
   837                 if test x$have_loadso = xyes && \
   838                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
   839                     echo "-- dynamic libartsc -> $arts_lib"
   840                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
   841                 else
   842                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
   843                 fi
   844                 have_audio=yes
   845             fi
   846         fi
   847     fi
   848 }
   849 
   850 dnl See if the NAS audio interface is supported
   851 CheckNAS()
   852 {
   853     AC_ARG_ENABLE(nas,
   854 AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
   855                   , enable_nas=yes)
   856     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
   857         AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
   858         AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
   859 
   860         AC_MSG_CHECKING(for NAS audio support)
   861         have_nas=no
   862 
   863         if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
   864             have_nas=yes
   865             NAS_LIBS="-laudio"
   866 
   867         elif test -r /usr/X11R6/include/audio/audiolib.h; then
   868             have_nas=yes
   869             NAS_CFLAGS="-I/usr/X11R6/include/"
   870             NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
   871 
   872         dnl On IRIX, the NAS includes are in a different directory,
   873         dnl and libnas must be explicitly linked in
   874 
   875         elif test -r /usr/freeware/include/nas/audiolib.h; then
   876             have_nas=yes
   877             NAS_LIBS="-lnas -lXt"
   878         fi
   879 
   880         AC_MSG_RESULT($have_nas)
   881 
   882         if test x$have_nas = xyes; then
   883             AC_ARG_ENABLE(nas-shared,
   884 AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
   885                           , enable_nas_shared=yes)
   886             nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   887 
   888             if test x$have_loadso != xyes && \
   889                test x$enable_nas_shared = xyes; then
   890                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
   891             fi
   892             if test x$have_loadso = xyes && \
   893                test x$enable_nas_shared = xyes && test x$nas_lib != x; then
   894                 echo "-- dynamic libaudio -> $nas_lib"
   895                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
   896             else
   897                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
   898             fi
   899 
   900             AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
   901             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
   902             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
   903             have_audio=yes
   904         fi
   905     fi
   906 }
   907 
   908 dnl rcg07142001 See if the user wants the disk writer audio driver...
   909 CheckDiskAudio()
   910 {
   911     AC_ARG_ENABLE(diskaudio,
   912 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
   913                   , enable_diskaudio=yes)
   914     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
   915         AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
   916         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
   917     fi
   918 }
   919 
   920 dnl rcg03142006 See if the user wants the dummy audio driver...
   921 CheckDummyAudio()
   922 {
   923     AC_ARG_ENABLE(dummyaudio,
   924 AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
   925                   , enable_dummyaudio=yes)
   926     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
   927         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY)
   928         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
   929     fi
   930 }
   931 
   932 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   933 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   934 CheckVisibilityHidden()
   935 {
   936     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
   937     have_gcc_fvisibility=no
   938 
   939     visibility_CFLAGS="-fvisibility=hidden"
   940     save_CFLAGS="$CFLAGS"
   941     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
   942     AC_TRY_COMPILE([
   943     #if !defined(__GNUC__) || __GNUC__ < 4
   944     #error SDL only uses visibility attributes in GCC 4 or newer
   945     #endif
   946     ],[
   947     ],[
   948     have_gcc_fvisibility=yes
   949     ])
   950     AC_MSG_RESULT($have_gcc_fvisibility)
   951     CFLAGS="$save_CFLAGS"
   952 
   953     if test x$have_gcc_fvisibility = xyes; then
   954         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
   955     fi
   956 }
   957 
   958 
   959 dnl Find the X11 include and library directories
   960 CheckX11()
   961 {
   962     AC_ARG_ENABLE(video-x11,
   963 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
   964                   , enable_video_x11=yes)
   965     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
   966         case "$host" in
   967             *-*-darwin*)
   968                 # This isn't necessary for X11, but fixes GLX detection
   969                 if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
   970                     x_includes="/usr/X11R6/include"
   971                     x_libraries="/usr/X11R6/lib"
   972                 fi
   973                 ;;
   974         esac
   975         AC_PATH_X
   976         AC_PATH_XTRA
   977         if test x$have_x = xyes; then
   978             # Only allow dynamically loaded X11 if the X11 function pointers
   979             # will not end up in the global namespace, which causes problems
   980             # with other libraries calling X11 functions.
   981             x11_symbols_private=$have_gcc_fvisibility
   982 
   983             AC_ARG_ENABLE(x11-shared,
   984 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
   985                           , enable_x11_shared=maybe)
   986 
   987             case "$host" in
   988                 *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
   989                     x11_symbols_private=yes
   990                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
   991                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
   992                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
   993                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
   994                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
   995                     xss_lib='/usr/X11R6/lib/libXss.6.dylib'
   996                     ;;
   997                 *-*-osf*)
   998                     x11_lib='libX11.so'
   999                     x11ext_lib='libXext.so'
  1000                     ;;
  1001                 *-*-irix*) # IRIX 6.5 requires that we use /usr/lib32
  1002                     x11_lib='libX11.so'
  1003                     x11ext_lib='libXext.so'
  1004                     ;;
  1005                 *)
  1006                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1007                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1008                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1009                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1010                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1011                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1012                     ;;
  1013             esac
  1014 
  1015             if test x$ac_cv_func_shmat != xyes; then
  1016                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1017             fi
  1018             CFLAGS="$CFLAGS $X_CFLAGS"
  1019             LDFLAGS="$LDFLAGS $X_LIBS"
  1020 
  1021             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
  1022             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1023             SOURCES="$SOURCES $srcdir/src/video/Xext/XmuStdCmap/*.c"
  1024             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1025 
  1026             if test x$enable_x11_shared = xmaybe; then
  1027                 enable_x11_shared=$x11_symbols_private
  1028             fi
  1029             if test x$have_loadso != xyes && \
  1030                test x$enable_x11_shared = xyes; then
  1031                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1032                 enable_x11_shared=no
  1033             fi
  1034             if test x$x11_symbols_private != xyes && \
  1035                test x$enable_x11_shared = xyes; then
  1036                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1037                 enable_x11_shared=no
  1038             fi
  1039 
  1040             if test x$have_loadso = xyes && \
  1041                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1042                 echo "-- dynamic libX11 -> $x11_lib"
  1043                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1044                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
  1045                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
  1046             else
  1047                 enable_x11_shared=no
  1048                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1049             fi
  1050             have_video=yes
  1051 
  1052             AC_ARG_ENABLE(video-x11-vm,
  1053 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1054                           , enable_video_x11_vm=yes)
  1055             if test x$enable_video_x11_vm = xyes; then
  1056                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
  1057                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
  1058             fi
  1059             AC_ARG_ENABLE(video-x11-xv,
  1060 AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
  1061                           , enable_video_x11_xv=yes)
  1062             if test x$enable_video_x11_xv = xyes; then
  1063                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
  1064                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
  1065             fi
  1066             AC_ARG_ENABLE(video-x11-xinerama,
  1067 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1068                             , enable_video_x11_xinerama=yes)
  1069             if test x$enable_video_x11_xinerama = xyes; then
  1070                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
  1071                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
  1072             fi
  1073             AC_ARG_ENABLE(video-x11-xrandr,
  1074 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1075                             , enable_video_x11_xrandr=yes)
  1076             if test x$enable_video_x11_xrandr = xyes; then
  1077                 definitely_enable_video_x11_xrandr=no
  1078                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1079                                 have_xrandr_h_hdr=yes,
  1080                                 have_xrandr_h_hdr=no,
  1081                                 [#include <X11/Xlib.h>
  1082                                 ])
  1083                 if test x$have_xrandr_h_hdr = xyes; then
  1084                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1085                         echo "-- dynamic libXrender -> $xrender_lib"
  1086                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1087                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
  1088                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
  1089                         definitely_enable_video_x11_xrandr=yes
  1090                     else
  1091                         AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
  1092                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1093                         if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
  1094                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
  1095                             definitely_enable_video_x11_xrandr=yes
  1096                         fi
  1097                     fi
  1098                 fi
  1099             fi
  1100             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1101                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
  1102             fi
  1103             AC_ARG_ENABLE(video-x11-xinput,
  1104 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1105                             , enable_video_x11_xinput=yes)
  1106             if test x$enable_video_x11_xinput = xyes; then
  1107                 definitely_enable_video_x11_xinput=no
  1108                 AC_CHECK_HEADER(X11/extensions/XInput.h,
  1109                                 have_xinput_h_hdr=yes,
  1110                                 have_xinput_h_hdr=no,
  1111                                 [#include <X11/Xlib.h>
  1112                                 ])
  1113                 if test x$have_xinput_h_hdr = xyes; then
  1114                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1115                         echo "-- dynamic libXi -> $xinput_lib"
  1116                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT, "$xinput_lib")
  1117                         definitely_enable_video_x11_xinput=yes
  1118                     else
  1119                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1120                         if test x$have_xinput_lib = xyes ; then
  1121                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1122                             definitely_enable_video_x11_xinput=yes
  1123                         fi
  1124                     fi
  1125                 fi
  1126             fi
  1127             if test x$definitely_enable_video_x11_xinput = xyes; then
  1128                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT)
  1129             fi
  1130             AC_ARG_ENABLE(video-x11-scrnsaver,
  1131 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1132                             , enable_video_x11_scrnsaver=yes)
  1133             if test x$enable_video_x11_scrnsaver = xyes; then
  1134                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1135                                 have_scrnsaver_h_hdr=yes,
  1136                                 have_scrnsaver_h_hdr=no,
  1137                                 [#include <X11/Xlib.h>
  1138                                 ])
  1139                 if test x$have_scrnsaver_h_hdr = xyes; then
  1140                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1141                         echo "-- dynamic libXss -> $xss_lib"
  1142                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib")
  1143                         definitely_enable_video_x11_scrnsaver=yes
  1144                     else
  1145                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1146                         if test x$have_xss_lib = xyes ; then
  1147                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1148                             definitely_enable_video_x11_scrnsaver=yes
  1149                         fi
  1150                     fi
  1151                 fi
  1152             fi
  1153             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1154                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SCRNSAVER)
  1155             fi
  1156 
  1157             AC_ARG_ENABLE(render-x11,
  1158 AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
  1159                                 , enable_render_x11=yes)
  1160             if test x$enable_render_x11 = xyes; then
  1161                 AC_DEFINE(SDL_VIDEO_RENDER_X11)
  1162             fi
  1163         fi
  1164     fi
  1165 }
  1166 
  1167 dnl Check for QNX photon video driver
  1168 CheckPHOTON()
  1169 {
  1170     AC_ARG_ENABLE(video-photon,
  1171 AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
  1172                   , enable_video_photon=yes)
  1173     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
  1174         AC_MSG_CHECKING(for QNX Photon support)
  1175         video_photon=no
  1176         AC_TRY_COMPILE([
  1177           #include <Ph.h>
  1178           #include <Pt.h>
  1179           #include <photon/Pg.h>
  1180           #include <photon/PdDirect.h>
  1181         ],[
  1182          PgDisplaySettings_t *visual;
  1183         ],[
  1184         video_photon=yes
  1185         ])
  1186         AC_MSG_RESULT($video_photon)
  1187         if test x$video_photon = xyes; then
  1188             AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
  1189             SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
  1190             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph -lphrender"
  1191             have_video=yes
  1192 
  1193             CheckOpenGLQNX
  1194         fi
  1195     fi
  1196 }
  1197 
  1198 dnl Check for QNX photon video driver
  1199 CheckQNXGF()
  1200 {
  1201     AC_ARG_ENABLE(video-qnxgf,
  1202                   AC_HELP_STRING([--enable-video-qnxgf], [use QNX GF video driver [[default=yes]]]),
  1203                   , enable_video_qnxgf=yes)
  1204     if test x$enable_video = xyes -a x$enable_video_qnxgf = xyes; then
  1205         AC_MSG_CHECKING(for QNX GF support)
  1206         video_qnxgf=no
  1207         AC_TRY_COMPILE([
  1208           #include <gf/gf.h>
  1209           #include <gf/gf3d.h>
  1210         ],[
  1211          gf_3d_config_info_t* gfinfo;
  1212         ],[
  1213         video_qnxgf=yes
  1214         ])
  1215         AC_MSG_RESULT($video_qnxgf)
  1216         if test x$video_qnxgf = xyes; then
  1217             AC_DEFINE(SDL_VIDEO_DRIVER_QNXGF)
  1218             SOURCES="$SOURCES $srcdir/src/video/qnxgf/*.c"
  1219             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lgf"
  1220 
  1221             # Add HIDDI library for HID support using GF
  1222             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lhiddi"
  1223 
  1224             have_video=yes
  1225 
  1226             CheckOpenGLESQNX
  1227         fi
  1228     fi
  1229 }
  1230 
  1231 dnl Set up the BWindow video driver if enabled
  1232 CheckBWINDOW()
  1233 {
  1234     if test x$enable_video = xyes; then
  1235         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
  1236         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1237         have_video=yes
  1238     fi
  1239 }
  1240 
  1241 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1242 CheckCOCOA()
  1243 {
  1244     AC_ARG_ENABLE(video-cocoa,
  1245 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1246                   , enable_video_cocoa=yes)
  1247     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1248         save_CFLAGS="$CFLAGS"
  1249         dnl work around that we don't have Objective-C support in autoconf
  1250         CFLAGS="$CFLAGS -x objective-c"
  1251         AC_MSG_CHECKING(for Cocoa framework)
  1252         have_cocoa=no
  1253         AC_TRY_COMPILE([
  1254           #import <Cocoa/Cocoa.h>
  1255         ],[
  1256         ],[
  1257         have_cocoa=yes
  1258         ])
  1259         AC_MSG_RESULT($have_cocoa)
  1260         CFLAGS="$save_CFLAGS"
  1261         if test x$have_cocoa = xyes; then
  1262             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA)
  1263             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1264             have_video=yes
  1265         fi
  1266     fi
  1267 }
  1268 
  1269 dnl Find the framebuffer console includes
  1270 CheckFBCON()
  1271 {
  1272     AC_ARG_ENABLE(video-fbcon,
  1273 AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=no]]]),
  1274                   , enable_video_fbcon=no)
  1275     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
  1276         AC_MSG_CHECKING(for framebuffer console support)
  1277         video_fbcon=no
  1278         AC_TRY_COMPILE([
  1279          #include <linux/fb.h>
  1280          #include <linux/kd.h>
  1281          #include <linux/keyboard.h>
  1282         ],[
  1283         ],[
  1284         video_fbcon=yes
  1285         ])
  1286         AC_MSG_RESULT($video_fbcon)
  1287         if test x$video_fbcon = xyes; then
  1288             AC_CHECK_FUNCS(getpagesize)
  1289             AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
  1290             SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
  1291             have_video=yes
  1292         fi
  1293     fi
  1294 }
  1295 
  1296 dnl Find DirectFB
  1297 CheckDirectFB()
  1298 {
  1299     AC_ARG_ENABLE(video-directfb,
  1300 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1301                   , enable_video_directfb=no)
  1302     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1303         video_directfb=no
  1304 
  1305         DIRECTFB_REQUIRED_VERSION=1.0.0
  1306 
  1307         AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
  1308         if test x$DIRECTFBCONFIG = xno; then
  1309             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1310             if test x$PKG_CONFIG != xno; then
  1311                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1312                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1313                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1314                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1315                     video_directfb=yes
  1316                 fi
  1317             fi
  1318         else
  1319             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1320             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1321             set -- `directfb-config --version | sed 's/\./ /g'`
  1322             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1323             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1324                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1325                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1326                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1327                 video_directfb=yes
  1328             fi
  1329         fi
  1330         if test x$video_directfb = xyes; then
  1331             # SuSE 11.1 installs directfb-config without directfb-devel
  1332             save_CFLAGS="$CFLAGS"
  1333             CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
  1334             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1335             CFLAGS="$save_CFLAGS"
  1336             video_directfb=$have_directfb_hdr
  1337         fi
  1338         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1339         AC_MSG_RESULT($video_directfb)
  1340 
  1341         if test x$video_directfb = xyes; then
  1342             AC_ARG_ENABLE(directfb-shared,
  1343 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1344                               , enable_directfb_shared=yes)
  1345 
  1346             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
  1347             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1348             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1349 
  1350             AC_MSG_CHECKING(for directfb dynamic loading support)
  1351             directfb_shared=no
  1352             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1353 
  1354             if test x$have_loadso != xyes && \
  1355                test x$enable_directfb_shared = xyes; then
  1356                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1357             fi
  1358             if test x$have_loadso = xyes && \
  1359                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1360                 directfb_shared=yes
  1361                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1362                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib")
  1363             else
  1364                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1365             fi
  1366             AC_MSG_RESULT($directfb_shared)
  1367             have_video=yes
  1368         fi
  1369     fi
  1370 }
  1371 
  1372 dnl Find FusionSound
  1373 CheckFusionSound()
  1374 {
  1375     AC_ARG_ENABLE(fusionsound,
  1376 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1377                   , enable_fusionsound=no)
  1378     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1379         fusionsound=no
  1380 
  1381         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1382 
  1383         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1384         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1385         if test x$PKG_CONFIG != xno; then
  1386             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1387                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1388                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1389                 fusionsound=yes
  1390             fi
  1391         fi
  1392         AC_MSG_RESULT($fusionsound)
  1393 
  1394         if test x$fusionsound = xyes; then
  1395             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND)
  1396             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1397             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1398             
  1399             AC_ARG_ENABLE(fusionsound-shared,
  1400 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1401                           , enable_fusionsound_shared=yes)
  1402             fusionsound_shared=no
  1403             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1404             if test x$have_loadso != xyes && \
  1405                test x$enable_fusionsound_shared = xyes; then
  1406                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1407             fi
  1408             if test x$have_loadso = xyes && \
  1409                test x$enable_fusionsound_shared = xyes; then
  1410                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so")
  1411                 fusionsound_shared=yes
  1412             else
  1413                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1414             fi
  1415             AC_MSG_RESULT($fusionsound_shared)
  1416             
  1417             have_audio=yes
  1418         fi
  1419     fi
  1420 }
  1421 
  1422 dnl See if we're running on PlayStation 2 hardware
  1423 CheckPS2GS()
  1424 {
  1425     AC_ARG_ENABLE(video-ps2gs,
  1426 AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=no]]]),
  1427                   , enable_video_ps2gs=no)
  1428     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
  1429         AC_MSG_CHECKING(for PlayStation 2 GS support)
  1430         video_ps2gs=no
  1431         AC_TRY_COMPILE([
  1432          #include <linux/ps2/dev.h>
  1433          #include <linux/ps2/gs.h>
  1434         ],[
  1435         ],[
  1436         video_ps2gs=yes
  1437         ])
  1438         AC_MSG_RESULT($video_ps2gs)
  1439         if test x$video_ps2gs = xyes; then
  1440             AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
  1441             SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
  1442             have_video=yes
  1443         fi
  1444     fi
  1445 }
  1446 
  1447 dnl See if we're running on PlayStation 3 Cell hardware
  1448 CheckPS3()
  1449 {
  1450   AC_ARG_ENABLE(video-ps3,
  1451                 AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
  1452                 , enable_video_ps3=yes)
  1453   if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then 
  1454     video_ps3=no
  1455     AC_CHECK_HEADER([linux/fb.h])
  1456     AC_CHECK_HEADER([asm/ps3fb.h], [have_ps3fb_hdr=yes], [],
  1457             [#ifndef _LINUX_TYPES_H
  1458                 #include <linux/types.h>
  1459             #endif])
  1460     AC_CHECK_HEADER([libspe2.h], have_libspe2_hdr=yes)
  1461     AC_CHECK_LIB([spe2], spe_context_create, have_spe2_lib=yes)
  1462 
  1463     AC_CHECK_PROGS(SPU_GCC, [spu-gcc])
  1464     AC_CHECK_PROGS(EMBEDSPU, [embedspu])
  1465 
  1466     have_spu_libs=yes
  1467     AC_CHECK_LIB([fb_writer_spu], [main], [], [have_spu_libs=no])
  1468     AC_CHECK_LIB([yuv2rgb_spu], [main], [], [have_spu_libs=no])
  1469     AC_CHECK_LIB([bilin_scaler_spu], [main], [], [have_spu_libs=no])
  1470     if test x$have_ps3fb_hdr = xyes -a x$have_libspe2_hdr = xyes -a x$have_spe2_lib = xyes -a "$SPU_GCC" -a "$EMBEDSPU"; then
  1471         AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
  1472         video_ps3=yes
  1473         have_video=yes
  1474         SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
  1475         EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
  1476         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/cell/sdk/usr/lib -lspe2 -lfb_writer_spu -lyuv2rgb_spu -lbilin_scaler_spu"
  1477 
  1478         if test x$have_spu_libs = xno; then 
  1479               AC_MSG_WARN([ps3libs missing, please run make ps3libs])
  1480         fi
  1481     fi
  1482     AC_MSG_CHECKING([for PlayStation 3 Cell support])
  1483     AC_MSG_RESULT([$video_ps3])
  1484   fi
  1485 }
  1486 
  1487 dnl Find the SVGAlib includes and libraries
  1488 CheckSVGA()
  1489 {
  1490     AC_ARG_ENABLE(video-svga,
  1491 AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=no]]]),
  1492                   , enable_video_svga=no)
  1493     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
  1494         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
  1495         video_svga=no
  1496         AC_TRY_COMPILE([
  1497          #include <vga.h>
  1498          #include <vgamouse.h>
  1499          #include <vgakeyboard.h>
  1500         ],[
  1501          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
  1502              exit(0);
  1503          }
  1504         ],[
  1505         video_svga=yes
  1506         ])
  1507         AC_MSG_RESULT($video_svga)
  1508         if test x$video_svga = xyes; then
  1509             AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
  1510             SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
  1511             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
  1512             have_video=yes
  1513         fi
  1514     fi
  1515 }
  1516 
  1517 dnl rcg04172001 Set up the Null video driver.
  1518 CheckDummyVideo()
  1519 {
  1520     AC_ARG_ENABLE(video-dummy,
  1521 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1522                   , enable_video_dummy=yes)
  1523     if test x$enable_video_dummy = xyes; then
  1524         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1525         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1526         have_video=yes
  1527     fi
  1528 }
  1529 
  1530 dnl Check to see if OpenGL support is desired
  1531 AC_ARG_ENABLE(video-opengl,
  1532 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1533               , enable_video_opengl=yes)
  1534 
  1535 dnl Find OpenGL
  1536 CheckOpenGLX11()
  1537 {
  1538     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1539         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1540         video_opengl=no
  1541         AC_TRY_COMPILE([
  1542          #include <GL/gl.h>
  1543          #include <GL/glx.h>
  1544          #include <GL/glu.h>
  1545         ],[
  1546         ],[
  1547         video_opengl=yes
  1548         ])
  1549         AC_MSG_RESULT($video_opengl)
  1550         if test x$video_opengl = xyes; then
  1551             AC_DEFINE(SDL_VIDEO_OPENGL)
  1552             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1553             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1554         fi
  1555     fi
  1556 }
  1557 
  1558 dnl Find QNX 6.x Software OpenGL
  1559 CheckOpenGLQNX()
  1560 {
  1561     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1562         AC_MSG_CHECKING(for QNX 6.x Photon OpenGL support)
  1563         video_opengl=no
  1564         AC_TRY_COMPILE([
  1565          #include <GL/gl.h>
  1566         ],[
  1567         ],[
  1568         video_opengl=yes
  1569         ])
  1570         AC_MSG_RESULT($video_opengl)
  1571         if test x$video_opengl = xyes; then
  1572             AC_DEFINE(SDL_VIDEO_OPENGL)
  1573             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1574             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1575         fi
  1576     fi
  1577 }
  1578 
  1579 dnl Find QNX 6.3 and above OpenGL ES implementation
  1580 CheckOpenGLESQNX()
  1581 {
  1582     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1583         AC_MSG_CHECKING(for QNX OpenGL ES (CM) support)
  1584         video_opengl=no
  1585         AC_TRY_COMPILE([
  1586          #include <GLES/egl.h>
  1587         ],[
  1588         ],[
  1589         video_opengl=yes
  1590         ])
  1591         AC_MSG_RESULT($video_opengl)
  1592         if test x$video_opengl = xyes; then
  1593             AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1594             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1595             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
  1596         else
  1597             AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
  1598             video_opengl=no
  1599             AC_TRY_COMPILE([
  1600              #define COMMON_LITE
  1601              #include <GLES/egl.h>
  1602             ],[
  1603             ],[
  1604             video_opengl=yes
  1605             ])
  1606             AC_MSG_RESULT($video_opengl)
  1607             if test x$video_opengl = xyes; then
  1608                 AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1609                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1610                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CLS"
  1611             fi
  1612         fi
  1613     fi
  1614 }
  1615 
  1616 
  1617 dnl Check for Win32 OpenGL
  1618 CheckWIN32GL()
  1619 {
  1620     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1621         AC_DEFINE(SDL_VIDEO_OPENGL)
  1622         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1623         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1624     fi
  1625 }
  1626 
  1627 dnl Check for BeOS OpenGL
  1628 CheckBeGL()
  1629 {
  1630     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1631         AC_DEFINE(SDL_VIDEO_OPENGL)
  1632         AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
  1633         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1634         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1635     fi
  1636 }
  1637 
  1638 dnl Check for MacOS OpenGL
  1639 CheckMacGL()
  1640 {
  1641     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1642         AC_DEFINE(SDL_VIDEO_OPENGL)
  1643         AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
  1644         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1645         case "$host" in
  1646             *-*-darwin*)
  1647                 if test x$enable_video_cocoa = xyes; then
  1648                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1649                 fi
  1650         esac
  1651     fi
  1652 }
  1653 
  1654 dnl See if we can use the new unified event interface in Linux 2.4
  1655 CheckInputEvents()
  1656 {
  1657     dnl Check for Linux 2.4 unified input event interface support
  1658     AC_ARG_ENABLE(input-events,
  1659 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1660                   , enable_input_events=yes)
  1661     if test x$enable_input_events = xyes; then
  1662         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1663         use_input_events=no
  1664         AC_TRY_COMPILE([
  1665           #include <linux/input.h>
  1666         ],[
  1667           #ifndef EVIOCGNAME
  1668           #error EVIOCGNAME() ioctl not available
  1669           #endif
  1670         ],[
  1671         use_input_events=yes
  1672         ])
  1673         AC_MSG_RESULT($use_input_events)
  1674         if test x$use_input_events = xyes; then
  1675             AC_DEFINE(SDL_INPUT_LINUXEV)
  1676         fi
  1677     fi
  1678 }
  1679 
  1680 dnl See if we can use the Touchscreen input library
  1681 CheckTslib()
  1682 {
  1683     AC_ARG_ENABLE(input-tslib,
  1684 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1685                   , enable_input_tslib=yes)
  1686     if test x$enable_input_tslib = xyes; then
  1687         AC_MSG_CHECKING(for Touchscreen library support)
  1688         enable_input_tslib=no
  1689         AC_TRY_COMPILE([
  1690           #include "tslib.h"
  1691         ],[
  1692         ],[
  1693         enable_input_tslib=yes
  1694         ])
  1695         AC_MSG_RESULT($enable_input_tslib)
  1696         if test x$enable_input_tslib = xyes; then
  1697             AC_DEFINE(SDL_INPUT_TSLIB)
  1698             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1699         fi
  1700     fi
  1701 }
  1702 
  1703 dnl See if we can use GNU pth library for threads
  1704 CheckPTH()
  1705 {
  1706     dnl Check for pth support
  1707     AC_ARG_ENABLE(pth,
  1708 AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
  1709                   , enable_pth=yes)
  1710     if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  1711         AC_PATH_PROG(PTH_CONFIG, pth-config, no)
  1712         if test "$PTH_CONFIG" = "no"; then
  1713             use_pth=no
  1714         else
  1715             use_pth=yes
  1716         fi
  1717         AC_MSG_CHECKING(pth)
  1718         AC_MSG_RESULT($use_pth)
  1719         if test "x$use_pth" = xyes; then
  1720             AC_DEFINE(SDL_THREAD_PTH)
  1721             SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
  1722             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1723             SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
  1724             SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
  1725             have_threads=yes
  1726         fi
  1727     fi
  1728 }
  1729 
  1730 dnl See what type of thread model to use on Linux and Solaris
  1731 CheckPTHREAD()
  1732 {
  1733     dnl Check for pthread support
  1734     AC_ARG_ENABLE(pthreads,
  1735 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1736                   , enable_pthreads=yes)
  1737     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1738     AC_ARG_ENABLE(pthread-sem,
  1739 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1740                   , enable_pthread_sem=yes)
  1741     case "$host" in
  1742         *-*-linux*|*-*-uclinux*)
  1743             pthread_cflags="-D_REENTRANT"
  1744             pthread_lib="-lpthread"
  1745             ;;
  1746         *-*-bsdi*)
  1747             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1748             pthread_lib=""
  1749             ;;
  1750         *-*-darwin*)
  1751             pthread_cflags="-D_THREAD_SAFE"
  1752 # causes Carbon.p complaints?
  1753 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1754             ;;
  1755         *-*-freebsd*|*-*-dragonfly*)
  1756             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1757             pthread_lib="-pthread"
  1758             ;;
  1759         *-*-netbsd*)
  1760             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1761             pthread_lib="-lpthread"
  1762             ;;
  1763         *-*-openbsd*)
  1764             pthread_cflags="-D_REENTRANT"
  1765             pthread_lib="-pthread"
  1766             ;;
  1767         *-*-solaris*)
  1768             pthread_cflags="-D_REENTRANT"
  1769             pthread_lib="-lpthread -lposix4"
  1770             ;;
  1771         *-*-sysv5*)
  1772             pthread_cflags="-D_REENTRANT -Kthread"
  1773             pthread_lib=""
  1774             ;;
  1775         *-*-irix*)
  1776             pthread_cflags="-D_SGI_MP_SOURCE"
  1777             pthread_lib="-lpthread"
  1778             ;;
  1779         *-*-aix*)
  1780             pthread_cflags="-D_REENTRANT -mthreads"
  1781             pthread_lib="-lpthread"
  1782             ;;
  1783         *-*-hpux11*)
  1784             pthread_cflags="-D_REENTRANT"
  1785             pthread_lib="-L/usr/lib -lpthread"
  1786             ;;
  1787         *-*-qnx*)
  1788             pthread_cflags=""
  1789             pthread_lib=""
  1790             ;;
  1791         *-*-osf*)
  1792             pthread_cflags="-D_REENTRANT"
  1793             if test x$ac_cv_prog_gcc = xyes; then
  1794                 pthread_lib="-lpthread -lrt"
  1795             else
  1796                 pthread_lib="-lpthread -lexc -lrt"
  1797             fi
  1798             ;;
  1799         *)
  1800             pthread_cflags="-D_REENTRANT"
  1801             pthread_lib="-lpthread"
  1802             ;;
  1803     esac
  1804     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1805         # Save the original compiler flags and libraries
  1806         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1807         # Add the pthread compiler flags and libraries
  1808         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1809         # Check to see if we have pthread support on this system
  1810         AC_MSG_CHECKING(for pthreads)
  1811         use_pthreads=no
  1812         AC_TRY_LINK([
  1813          #include <pthread.h>
  1814         ],[
  1815          pthread_attr_t type;
  1816          pthread_attr_init(&type);
  1817         ],[
  1818         use_pthreads=yes
  1819         ])
  1820         AC_MSG_RESULT($use_pthreads)
  1821         # Restore the compiler flags and libraries
  1822         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1823 
  1824         # Do futher testing if we have pthread support...
  1825         if test x$use_pthreads = xyes; then
  1826             AC_DEFINE(SDL_THREAD_PTHREAD)
  1827             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1828             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1829             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1830             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1831 
  1832             # Save the original compiler flags and libraries
  1833             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1834             # Add the pthread compiler flags and libraries
  1835             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1836 
  1837             # Check to see if recursive mutexes are available
  1838             AC_MSG_CHECKING(for recursive mutexes)
  1839             has_recursive_mutexes=no
  1840             if test x$has_recursive_mutexes = xno; then
  1841                 AC_TRY_COMPILE([
  1842                   #include <pthread.h>
  1843                 ],[
  1844                   pthread_mutexattr_t attr;
  1845                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1846                 ],[
  1847                 has_recursive_mutexes=yes
  1848                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1849                 ])
  1850             fi
  1851             if test x$has_recursive_mutexes = xno; then
  1852                 AC_TRY_COMPILE([
  1853                   #include <pthread.h>
  1854                 ],[
  1855                   pthread_mutexattr_t attr;
  1856                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1857                 ],[
  1858                 has_recursive_mutexes=yes
  1859                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1860                 ])
  1861             fi
  1862             AC_MSG_RESULT($has_recursive_mutexes)
  1863 
  1864             # Check to see if pthread semaphore support is missing
  1865             if test x$enable_pthread_sem = xyes; then
  1866                 AC_MSG_CHECKING(for pthread semaphores)
  1867                 have_pthread_sem=no
  1868                 AC_TRY_COMPILE([
  1869                   #include <pthread.h>
  1870                   #include <semaphore.h>
  1871                 ],[
  1872                 ],[
  1873                 have_pthread_sem=yes
  1874                 ])
  1875                 AC_MSG_RESULT($have_pthread_sem)
  1876             fi
  1877 
  1878             # Restore the compiler flags and libraries
  1879             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1880 
  1881             # Basic thread creation functions
  1882             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1883 
  1884             # Semaphores
  1885             # We can fake these with mutexes and condition variables if necessary
  1886             if test x$have_pthread_sem = xyes; then
  1887                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1888             else
  1889                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1890             fi
  1891 
  1892             # Mutexes
  1893             # We can fake these with semaphores if necessary
  1894             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1895 
  1896             # Condition variables
  1897             # We can fake these with semaphores and mutexes if necessary
  1898             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1899 
  1900             have_threads=yes
  1901         else
  1902             CheckPTH
  1903         fi
  1904     fi
  1905 }
  1906 
  1907 dnl Determine whether the compiler can produce Win32 executables
  1908 CheckWIN32()
  1909 {
  1910     AC_MSG_CHECKING(Win32 compiler)
  1911     have_win32_gcc=no
  1912     AC_TRY_COMPILE([
  1913      #include <windows.h>
  1914     ],[
  1915     ],[
  1916     have_win32_gcc=yes
  1917     ])
  1918     AC_MSG_RESULT($have_win32_gcc)
  1919     if test x$have_win32_gcc != xyes; then
  1920        AC_MSG_ERROR([
  1921 *** Your compiler ($CC) does not produce Win32 executables!
  1922        ])
  1923     fi
  1924 
  1925     AC_MSG_CHECKING(Windows CE)
  1926     have_wince=no
  1927     AC_TRY_COMPILE([
  1928 #ifndef _WIN32_WCE
  1929 #error This is not Windows CE
  1930 #endif
  1931     ],[
  1932     ],[
  1933     have_wince=yes
  1934     ])
  1935     AC_MSG_RESULT($have_wince)
  1936 
  1937     dnl See if the user wants to redirect standard output to files
  1938     AC_ARG_ENABLE(stdio-redirect,
  1939 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
  1940                   , enable_stdio_redirect=yes)
  1941     if test x$enable_stdio_redirect != xyes; then
  1942         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
  1943     fi
  1944 }
  1945 
  1946 dnl Find the DirectX includes and libraries
  1947 CheckDIRECTX()
  1948 {
  1949     AC_ARG_ENABLE(directx,
  1950 AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
  1951                   , enable_directx=yes)
  1952     if test x$enable_directx = xyes; then
  1953         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  1954         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  1955         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  1956         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  1957     fi
  1958 }
  1959 
  1960 dnl Check for the dlfcn.h interface for dynamically loading objects
  1961 CheckDLOPEN()
  1962 {
  1963     AC_ARG_ENABLE(sdl-dlopen,
  1964 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  1965                   , enable_sdl_dlopen=yes)
  1966     if test x$enable_sdl_dlopen = xyes; then
  1967         AC_MSG_CHECKING(for dlopen)
  1968         have_dlopen=no
  1969         AC_TRY_COMPILE([
  1970          #include <dlfcn.h>
  1971         ],[
  1972          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  1973          #error Use dlcompat for Mac OS X 10.2 compatibility
  1974          #endif
  1975         ],[
  1976         have_dlopen=yes
  1977         ])
  1978         AC_MSG_RESULT($have_dlopen)
  1979 
  1980         if test x$have_dlopen = xyes; then
  1981             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  1982                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  1983                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  1984             AC_DEFINE(SDL_LOADSO_DLOPEN)
  1985             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  1986             have_loadso=yes
  1987         fi
  1988     fi
  1989 }
  1990 
  1991 dnl Check for the usbhid(3) library on *BSD
  1992 CheckUSBHID()
  1993 {
  1994     if test x$enable_joystick = xyes; then
  1995         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  1996         if test x$have_libusbhid = xyes; then
  1997             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  1998             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  1999             USB_LIBS="$USB_LIBS -lusbhid"
  2000         else
  2001             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2002             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2003             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2004         fi
  2005             
  2006         save_CFLAGS="$CFLAGS"
  2007         CFLAGS="$CFLAGS $USB_CFLAGS"
  2008 
  2009         AC_MSG_CHECKING(for usbhid)
  2010         have_usbhid=no
  2011         AC_TRY_COMPILE([
  2012           #include <sys/types.h>
  2013           #if defined(HAVE_USB_H)
  2014           #include <usb.h>
  2015           #endif
  2016           #ifdef __DragonFly__
  2017           # include <bus/usb/usb.h>
  2018           # include <bus/usb/usbhid.h>
  2019           #else
  2020           # include <dev/usb/usb.h>
  2021           # include <dev/usb/usbhid.h>
  2022           #endif
  2023           #if defined(HAVE_USBHID_H)
  2024           #include <usbhid.h>
  2025           #elif defined(HAVE_LIBUSB_H)
  2026           #include <libusb.h>
  2027           #elif defined(HAVE_LIBUSBHID_H)
  2028           #include <libusbhid.h>
  2029           #endif
  2030         ],[
  2031           struct report_desc *repdesc;
  2032           struct usb_ctl_report *repbuf;
  2033           hid_kind_t hidkind;
  2034         ],[
  2035         have_usbhid=yes
  2036         ])
  2037         AC_MSG_RESULT($have_usbhid)
  2038 
  2039         if test x$have_usbhid = xyes; then
  2040             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2041             have_usbhid_ucr_data=no
  2042             AC_TRY_COMPILE([
  2043               #include <sys/types.h>
  2044               #if defined(HAVE_USB_H)
  2045               #include <usb.h>
  2046               #endif
  2047               #ifdef __DragonFly__
  2048               # include <bus/usb/usb.h>
  2049               # include <bus/usb/usbhid.h>
  2050               #else
  2051               # include <dev/usb/usb.h>
  2052               # include <dev/usb/usbhid.h>
  2053               #endif
  2054               #if defined(HAVE_USBHID_H)
  2055               #include <usbhid.h>
  2056               #elif defined(HAVE_LIBUSB_H)
  2057               #include <libusb.h>
  2058               #elif defined(HAVE_LIBUSBHID_H)
  2059               #include <libusbhid.h>
  2060               #endif
  2061             ],[
  2062               struct usb_ctl_report buf;
  2063               if (buf.ucr_data) { }
  2064             ],[
  2065             have_usbhid_ucr_data=yes
  2066             ])
  2067             if test x$have_usbhid_ucr_data = xyes; then
  2068                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2069             fi
  2070             AC_MSG_RESULT($have_usbhid_ucr_data)
  2071             
  2072             AC_MSG_CHECKING(for new usbhid API)
  2073             have_usbhid_new=no
  2074             AC_TRY_COMPILE([
  2075               #include <sys/types.h>
  2076               #if defined(HAVE_USB_H)
  2077               #include <usb.h>
  2078               #endif
  2079               #ifdef __DragonFly__
  2080               #include <bus/usb/usb.h>
  2081               #include <bus/usb/usbhid.h>
  2082               #else
  2083               #include <dev/usb/usb.h>
  2084               #include <dev/usb/usbhid.h>
  2085               #endif
  2086               #if defined(HAVE_USBHID_H)
  2087               #include <usbhid.h>
  2088               #elif defined(HAVE_LIBUSB_H)
  2089               #include <libusb.h>
  2090               #elif defined(HAVE_LIBUSBHID_H)
  2091               #include <libusbhid.h>
  2092               #endif
  2093             ],[
  2094               report_desc_t d;
  2095               hid_start_parse(d, 1, 1);
  2096             ],[
  2097             have_usbhid_new=yes
  2098             ])
  2099             if test x$have_usbhid_new = xyes; then
  2100                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2101             fi
  2102             AC_MSG_RESULT($have_usbhid_new)
  2103 
  2104             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2105             have_machine_joystick=no
  2106             AC_TRY_COMPILE([
  2107               #include <machine/joystick.h>
  2108             ],[
  2109               struct joystick t;
  2110             ],[
  2111             have_machine_joystick=yes
  2112             ])
  2113             if test x$have_machine_joystick = xyes; then
  2114                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  2115             fi
  2116             AC_MSG_RESULT($have_machine_joystick)
  2117 
  2118             AC_DEFINE(SDL_JOYSTICK_USBHID)
  2119             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2120             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2121             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2122             have_joystick=yes
  2123         fi
  2124         CFLAGS="$save_CFLAGS"
  2125     fi
  2126 }
  2127 
  2128 dnl Check for clock_gettime()
  2129 CheckClockGettime()
  2130 {
  2131     AC_ARG_ENABLE(clock_gettime,
  2132 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  2133                   , enable_clock_gettime=no)
  2134     if test x$enable_clock_gettime = xyes; then
  2135         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2136         if test x$have_clock_gettime = xyes; then
  2137             AC_DEFINE(HAVE_CLOCK_GETTIME)
  2138             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2139         else
  2140             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2141             if test x$have_clock_gettime = xyes; then
  2142                AC_DEFINE(HAVE_CLOCK_GETTIME)
  2143                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2144             fi
  2145         fi
  2146     fi
  2147 }
  2148 
  2149 dnl Check for a valid linux/version.h
  2150 CheckLinuxVersion()
  2151 {
  2152     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2153     if test x$have_linux_version_h = xyes; then
  2154         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2155     fi
  2156 }
  2157 
  2158 dnl Check if we want to use RPATH
  2159 CheckRPATH()
  2160 {
  2161     AC_ARG_ENABLE(rpath,
  2162 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2163                   , enable_rpath=yes)
  2164 }
  2165 
  2166 dnl Set up the configuration based on the host platform!
  2167 case "$host" in
  2168     arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
  2169         ARCH=linux
  2170         CheckDummyVideo
  2171         CheckIPod
  2172         # Set up files for the timer library
  2173         if test x$enable_timers = xyes; then
  2174             AC_DEFINE(SDL_TIMER_UNIX)
  2175             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2176             have_timers=yes
  2177         fi
  2178         ;;
  2179     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*|*-*-minix*)
  2180         case "$host" in
  2181             *-*-linux*)         ARCH=linux ;;
  2182             *-*-uclinux*)       ARCH=linux ;;
  2183             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2184             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2185             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2186             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2187             *-*-bsdi*)          ARCH=bsdi ;;
  2188             *-*-freebsd*)       ARCH=freebsd ;;
  2189             *-*-dragonfly*)     ARCH=freebsd ;;
  2190             *-*-netbsd*)        ARCH=netbsd ;;
  2191             *-*-openbsd*)       ARCH=openbsd ;;
  2192             *-*-sysv5*)         ARCH=sysv5 ;;
  2193             *-*-solaris*)       ARCH=solaris ;;
  2194             *-*-hpux*)          ARCH=hpux ;;
  2195             *-*-irix*)          ARCH=irix ;;
  2196             *-*-aix*)           ARCH=aix ;;
  2197             *-*-osf*)           ARCH=osf ;;
  2198             *-*-minix*)         ARCH=minix ;;
  2199         esac
  2200         CheckVisibilityHidden
  2201         CheckDummyVideo
  2202         CheckDiskAudio
  2203         CheckDummyAudio
  2204         CheckDLOPEN
  2205         CheckOSS
  2206         CheckDMEDIA
  2207         CheckMME
  2208         CheckALSA
  2209         CheckPulseAudio
  2210         CheckARTSC
  2211         CheckESD
  2212         CheckNAS
  2213         CheckX11
  2214         CheckFBCON
  2215         CheckDirectFB
  2216         CheckFusionSound
  2217         CheckPS2GS
  2218         CheckPS3
  2219         CheckSVGA
  2220         CheckOpenGLX11
  2221         CheckInputEvents
  2222         CheckTslib
  2223         CheckUSBHID
  2224         CheckPTHREAD
  2225         CheckClockGettime
  2226         CheckLinuxVersion
  2227         CheckRPATH
  2228         # Set up files for the audio library
  2229         if test x$enable_audio = xyes; then
  2230           case $ARCH in
  2231             sysv5|solaris|hpux)
  2232                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2233                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2234                 have_audio=yes
  2235             ;;
  2236             netbsd|openbsd)
  2237                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2238                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2239                 have_audio=yes
  2240             ;;
  2241             aix)
  2242                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO)
  2243                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2244                 have_audio=yes
  2245             ;;
  2246           esac
  2247         fi
  2248         # Set up files for the atomic operations library
  2249         if test x$enable_atomic = xyes; then
  2250           case $ARCH in
  2251             linux)
  2252                 AC_DEFINE(SDL_ATOMIC_LINUX)
  2253                 SOURCES="$SOURCES $srcdir/src/atomic/linux/*.c"
  2254                 have_atomic=yes
  2255             ;;
  2256           esac
  2257         fi
  2258         # Set up files for the joystick library
  2259         if test x$enable_joystick = xyes; then
  2260           case $ARCH in
  2261             linux)
  2262                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2263                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2264                 have_joystick=yes
  2265             ;;
  2266           esac
  2267         fi
  2268         # Set up files for the haptic library
  2269         if test x$enable_haptic = xyes; then
  2270            if test x$use_input_events = xyes; then
  2271              case $ARCH in
  2272                linux)
  2273                    AC_DEFINE(SDL_HAPTIC_LINUX)
  2274                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2275                    have_haptic=yes
  2276                ;;
  2277              esac
  2278            fi
  2279         fi
  2280         # Set up files for the power library
  2281         if test x$enable_power = xyes; then
  2282              case $ARCH in
  2283                linux)
  2284                    AC_DEFINE(SDL_POWER_LINUX)
  2285                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2286                    have_power=yes
  2287                ;;
  2288              esac
  2289         fi
  2290         # Set up files for the thread library
  2291         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2292             AC_DEFINE(SDL_THREAD_SPROC)
  2293             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2294             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2295             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2296             have_threads=yes
  2297         fi
  2298         # Set up files for the timer library
  2299         if test x$enable_timers = xyes; then
  2300             AC_DEFINE(SDL_TIMER_UNIX)
  2301             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2302             have_timers=yes
  2303         fi
  2304         ;;
  2305     *-*-qnx*)
  2306 
  2307         EXTRA_CFLAGS="-I/usr/include $CFLAGS"
  2308         EXTRA_LDLAGS="-L/usr/lib $LDFLAGS"
  2309 
  2310         ARCH=qnx
  2311         CheckVisibilityHidden
  2312         CheckDummyVideo
  2313         CheckDiskAudio
  2314         CheckDummyAudio
  2315         CheckDLOPEN
  2316         CheckPulseAudio
  2317         CheckESD
  2318         CheckNAS
  2319         CheckPHOTON
  2320         CheckQNXGF
  2321         CheckX11
  2322         CheckOpenGLX11
  2323         CheckPTHREAD
  2324         CheckClockGettime
  2325 
  2326 
  2327         # Set up files for the audio library
  2328         if test x$enable_audio = xyes; then
  2329             AC_DEFINE(SDL_AUDIO_DRIVER_QSA)
  2330             SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
  2331             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2332             have_audio=yes
  2333         fi
  2334         # Set up files for the timer library
  2335         if test x$enable_timers = xyes; then
  2336             AC_DEFINE(SDL_TIMER_UNIX)
  2337             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2338             have_timers=yes
  2339         fi
  2340         # Setup files for the atomic operations
  2341         if test x$enable_atomic = xyes; then
  2342                 AC_DEFINE(SDL_ATOMIC_QNX)
  2343                 SOURCES="$SOURCES $srcdir/src/atomic/qnx/*.c"
  2344                 have_atomic=yes
  2345         fi
  2346         # Set up dummy files for the joystick for now
  2347         if test x$enable_joystick = xyes; then
  2348             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2349             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2350             have_joystick=yes
  2351         fi
  2352         # Set up dummy files for the haptic for now
  2353         if test x$enable_haptic = xyes; then
  2354             AC_DEFINE(SDL_HAPTIC_DUMMY)
  2355             SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2356             have_haptic=yes
  2357         fi
  2358         ;;
  2359     *-wince* | *-mingw32ce)
  2360         ARCH=win32
  2361         CheckDummyVideo
  2362         CheckDiskAudio
  2363         CheckDummyAudio
  2364         CheckWIN32
  2365         #SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
  2366         #AC_DEFINE(SDL_VIDEO_DRIVER_GAPI)
  2367         if test x$enable_video = xyes; then
  2368             AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
  2369             SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
  2370             have_video=yes
  2371             AC_ARG_ENABLE(render-gdi,
  2372 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2373                                 , enable_render_gdi=yes)
  2374             if test x$enable_render_gdi = xyes; then
  2375                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2376             fi
  2377             AC_ARG_ENABLE(render-gapi,
  2378 AC_HELP_STRING([--enable-render-gapi], [enable the GAPI/RAWFRAMEBUFFER render driver [[default=yes]]]),
  2379                                 , enable_render_gapi=yes)
  2380             if test x$enable_render_gapi = xyes -a x$have_wince = xyes; then
  2381                 AC_DEFINE(SDL_VIDEO_RENDER_GAPI)
  2382             fi
  2383             AC_ARG_ENABLE(render-ddraw,
  2384 AC_HELP_STRING([--enable-render-ddraw], [enable the Mobile DirectDraw render driver [[default=yes]]]),
  2385                                 , enable_render_ddraw=yes)
  2386             if test x$enable_render_ddraw = xyes -a x$have_wince = xyes -a x$have_ddraw = xyes; then
  2387                 AC_DEFINE(SDL_VIDEO_RENDER_DDRAW)
  2388             fi
  2389             AC_ARG_ENABLE(render-d3d,
  2390 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2391                                 , enable_render_d3d=yes)
  2392             enable_render_d3d=no
  2393             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2394                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2395             fi
  2396         fi
  2397         # Set up files for the audio library
  2398         if test x$enable_audio = xyes; then
  2399             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2400             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2401             if test x$have_dsound = xyes; then
  2402                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2403                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2404             fi
  2405             have_audio=yes
  2406         fi
  2407         # Set up files for the thread library
  2408         if test x$enable_threads = xyes; then
  2409             AC_DEFINE(SDL_THREAD_WIN32)
  2410             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2411             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2412             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2413             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2414             have_threads=yes
  2415         fi
  2416         # Set up files for the timer library
  2417         if test x$enable_timers = xyes; then
  2418             AC_DEFINE(SDL_TIMER_WINCE)
  2419             SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
  2420             have_timers=yes
  2421         fi
  2422         # Set up files for the shared object loading library
  2423         if test x$enable_loadso = xyes; then
  2424             AC_DEFINE(SDL_LOADSO_WIN32)
  2425             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2426             have_loadso=yes
  2427         fi
  2428         # Set up files for the system power library
  2429         if test x$enable_power = xyes; then
  2430             AC_DEFINE(SDL_POWER_WINDOWS)
  2431             SOURCES="$SOURCES $srcdir/src/power/windows/*.c"
  2432             have_power=yes
  2433         fi
  2434         # Set up the system libraries we need
  2435         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
  2436         # The Win32 platform requires special setup
  2437         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2438         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
  2439         SDL_LIBS="-lSDLmain $SDL_LIBS"
  2440         ;;
  2441     *-*-cygwin* | *-*-mingw32*)
  2442         ARCH=win32
  2443         if test "$build" != "$host"; then # cross-compiling
  2444             # Default cross-compile location
  2445             ac_default_prefix=/usr/local/cross-tools/i386-mingw32
  2446         else
  2447             # Look for the location of the tools and install there
  2448             if test "$BUILD_PREFIX" != ""; then
  2449                 ac_default_prefix=$BUILD_PREFIX
  2450             fi
  2451         fi
  2452         CheckDummyVideo
  2453         CheckDiskAudio
  2454         CheckDummyAudio
  2455         CheckWIN32
  2456         CheckWIN32GL
  2457         CheckDIRECTX
  2458         # Set up files for the video library
  2459         if test x$enable_video = xyes; then
  2460             AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
  2461             SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
  2462             have_video=yes
  2463             AC_ARG_ENABLE(render-gdi,
  2464 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2465                                 , enable_render_gdi=yes)
  2466             if test x$enable_render_gdi = xyes; then
  2467                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2468             fi
  2469             AC_ARG_ENABLE(render-d3d,
  2470 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2471                                 , enable_render_d3d=yes)
  2472             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2473                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2474             fi
  2475         fi
  2476         # Set up files for the audio library
  2477         if test x$enable_audio = xyes; then
  2478             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2479             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2480             if test x$have_dsound = xyes; then
  2481                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2482                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2483             fi
  2484             have_audio=yes
  2485         fi
  2486         # Set up files for the atomic operations library
  2487         if test x$enable_atomic = xyes; then
  2488             AC_DEFINE(SDL_ATOMIC_WIN32)
  2489             SOURCES="$SOURCES $srcdir/src/atomic/win32/*.c"
  2490             have_atomic=yes
  2491         fi
  2492         # Set up files for the joystick library
  2493         if test x$enable_joystick = xyes; then
  2494             if test x$have_dinput = xyes; then
  2495                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
  2496                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
  2497                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8 -lole32"
  2498             else
  2499                 AC_DEFINE(SDL_JOYSTICK_WINMM)
  2500                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
  2501             fi
  2502             have_joystick=yes
  2503         fi
  2504         if test x$enable_haptic = xyes; then
  2505             if test x$have_dinput = xyes; then
  2506                 AC_DEFINE(SDL_HAPTIC_DINPUT)
  2507                 SOURCES="$SOURCES $srcdir/src/haptic/win32/SDL_syshaptic.c"
  2508                 have_haptic=yes
  2509             fi
  2510         fi
  2511         if test x$enable_power = xyes; then
  2512             AC_DEFINE(SDL_POWER_WINDOWS)
  2513             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2514             have_power=yes
  2515         fi
  2516         # Set up files for the thread library
  2517         if test x$enable_threads = xyes; then
  2518             AC_DEFINE(SDL_THREAD_WIN32)
  2519             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2520             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2521             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2522             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2523             have_threads=yes
  2524         fi
  2525         # Set up files for the timer library
  2526         if test x$enable_timers = xyes; then
  2527             AC_DEFINE(SDL_TIMER_WIN32)
  2528             SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
  2529             have_timers=yes
  2530         fi
  2531         # Set up files for the shared object loading library
  2532         if test x$enable_loadso = xyes; then
  2533             AC_DEFINE(SDL_LOADSO_WIN32)
  2534             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2535             have_loadso=yes
  2536         fi
  2537         # Set up the system libraries we need
  2538         # SDL 1.3 is unicode, and unicows emulates this on Windows 98/ME
  2539         # You can get this here: http://libunicows.sourceforge.net/
  2540         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
  2541         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
  2542         # The Win32 platform requires special setup
  2543         VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
  2544         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2545         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2546         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2547         ;;
  2548     *-*-beos* | *-*-haiku*)
  2549         ARCH=beos
  2550         ac_default_prefix=/boot/develop/tools/gnupro
  2551         CheckDummyVideo
  2552         CheckDiskAudio
  2553         CheckDummyAudio
  2554         CheckBWINDOW
  2555         CheckBeGL
  2556         # Set up files for the audio library
  2557         if test x$enable_audio = xyes; then
  2558             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
  2559             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2560             have_audio=yes
  2561         fi
  2562         # Set up files for the joystick library
  2563         if test x$enable_joystick = xyes; then
  2564             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2565             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2566             have_joystick=yes
  2567         fi
  2568         # Set up files for the thread library
  2569         if test x$enable_threads = xyes; then
  2570             AC_DEFINE(SDL_THREAD_BEOS)
  2571             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2572             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2573             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2574             have_threads=yes
  2575         fi
  2576         # Set up files for the timer library
  2577         if test x$enable_timers = xyes; then
  2578             AC_DEFINE(SDL_TIMER_BEOS)
  2579             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2580             have_timers=yes
  2581         fi
  2582         # Set up files for the shared object loading library
  2583         if test x$enable_loadso = xyes; then
  2584             AC_DEFINE(SDL_LOADSO_BEOS)
  2585             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2586             have_loadso=yes
  2587         fi
  2588         # Set up files for the system power library
  2589         if test x$enable_power = xyes; then
  2590             AC_DEFINE(SDL_POWER_BEOS)
  2591             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2592             have_power=yes
  2593         fi
  2594         # The BeOS platform requires special setup.
  2595         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2596         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2597         ;;
  2598     *-*-darwin* )
  2599         # This could be either full "Mac OS X", or plain "Darwin" which is
  2600         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2601         # Next line is broken, and a few files below require Mac OS X (full)
  2602         ARCH=macosx
  2603 
  2604         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2605         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2606         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2607 
  2608         # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
  2609         # is -lm which is not needed under Mac OS X. But for some reasons it
  2610         # also tends to contain spurious -L switches, which we don't want to
  2611         # use here or in sdl-config. Hence we reset it.
  2612         EXTRA_LDFLAGS=""
  2613 
  2614         CheckVisibilityHidden
  2615         CheckDummyVideo
  2616         CheckDiskAudio
  2617         CheckDummyAudio
  2618         CheckDLOPEN
  2619 
  2620         # Set up files for the shared object loading library
  2621         # (this needs to be done before the dynamic X11 check)
  2622         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2623             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2624             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2625             have_loadso=yes
  2626         fi
  2627 
  2628         CheckCOCOA
  2629         CheckX11
  2630         CheckMacGL
  2631         CheckOpenGLX11
  2632         CheckPTHREAD
  2633 
  2634         # Good optimization on Mac OS X, yes...
  2635         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2636 
  2637         # Need this or things might misbuild on a G3.
  2638         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2639 
  2640         # Set up files for the audio library
  2641         if test x$enable_audio = xyes; then
  2642             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2643             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2644             have_audio=yes
  2645         fi
  2646         # Set up files for the atomic operations library
  2647         if test x$enable_atomic = xyes; then
  2648             AC_DEFINE(SDL_ATOMIC_MACOSX)
  2649             SOURCES="$SOURCES $srcdir/src/atomic/macosx/*.c"
  2650             have_atomic=yes
  2651         fi
  2652         # Set up files for the joystick library
  2653         if test x$enable_joystick = xyes; then
  2654             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2655             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2656             have_joystick=yes
  2657         fi
  2658         # Set up files for the haptic library
  2659         if test x$enable_haptic = xyes; then
  2660             AC_DEFINE(SDL_HAPTIC_IOKIT)
  2661             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2662             have_haptic=yes
  2663             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2664         fi
  2665         # Set up files for the power library
  2666         if test x$enable_power = xyes; then
  2667             AC_DEFINE(SDL_POWER_MACOSX)
  2668             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2669             have_power=yes
  2670         fi
  2671         # Set up files for the timer library
  2672         if test x$enable_timers = xyes; then
  2673             AC_DEFINE(SDL_TIMER_UNIX)
  2674             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2675             have_timers=yes
  2676         fi
  2677         # The Mac OS X platform requires special setup.
  2678         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2679         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2680         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2681         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2682         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2683         # If either the audio or CD driver is used, add the AudioUnit framework
  2684         if test x$enable_audio = xyes; then
  2685             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2686         fi
  2687         ;;
  2688     *-riscos)
  2689         ARCH=riscos
  2690         CheckOSS
  2691         CheckPTHREAD
  2692         # Set up files for the video library
  2693         if test x$enable_video = xyes; then
  2694             AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
  2695             SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
  2696             SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
  2697             have_video=yes
  2698         fi
  2699         # Set up files for the joystick library
  2700         if test x$enable_joystick = xyes; then
  2701             AC_DEFINE(SDL_JOYSTICK_RISCOS)
  2702             SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
  2703             have_joystick=yes
  2704         fi
  2705         # Set up files for the timer library
  2706         if test x$enable_timers = xyes; then
  2707             AC_DEFINE(SDL_TIMER_RISCOS)
  2708             SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
  2709             have_timers=yes
  2710         fi
  2711         # The RISC OS platform requires special setup.
  2712         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
  2713         ;;
  2714     *)
  2715         AC_MSG_ERROR([
  2716 *** Unsupported host:  Please add to configure.in
  2717         ])
  2718         ;;
  2719 esac
  2720 
  2721 # Verify that we have all the platform specific files we need
  2722 
  2723 if test x$have_joystick != xyes; then
  2724     if test x$enable_joystick = xyes; then
  2725         AC_DEFINE(SDL_JOYSTICK_DISABLED)
  2726     fi
  2727     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2728 fi
  2729 if test x$have_haptic != xyes; then
  2730     if test x$enable_haptic = xyes; then
  2731         AC_DEFINE(SDL_HAPTIC_DISABLED)
  2732     fi
  2733     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2734 fi
  2735 if test x$have_threads != xyes; then
  2736     if test x$enable_threads = xyes; then
  2737         AC_DEFINE(SDL_THREADS_DISABLED)
  2738     fi
  2739     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2740 fi
  2741 if test x$have_timers != xyes; then
  2742     if test x$enable_timers = xyes; then
  2743         AC_DEFINE(SDL_TIMERS_DISABLED)
  2744     fi
  2745     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2746 fi
  2747 if test x$have_loadso != xyes; then
  2748     if test x$enable_loadso = xyes; then
  2749         AC_DEFINE(SDL_LOADSO_DISABLED)
  2750     fi
  2751     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2752 fi
  2753 if test x$SDLMAIN_SOURCES = x; then
  2754     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2755 fi
  2756 
  2757 OBJECTS=`echo $SOURCES`
  2758 DEPENDS=`echo $SOURCES`
  2759 for EXT in asm cc m c S; do
  2760     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2761     DEPENDS=`echo "$DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT,\\\\
  2762 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2763 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2764 done
  2765 
  2766 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2767 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2768 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2769 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2770 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2771 	\\$(WINDRES) \\$< \\$@,g"`
  2772 
  2773 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2774 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2775 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2776 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2777 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2778 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2779 
  2780 # Set runtime shared library paths as needed
  2781 
  2782 if test "x$enable_rpath" = "xyes"; then
  2783   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
  2784     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2785   fi
  2786   if test $ARCH = solaris; then
  2787     SDL_RLD_FLAGS="-R\${libdir}"
  2788   fi
  2789 else
  2790   SDL_RLD_FLAGS=""
  2791 fi
  2792 
  2793 case "$ARCH" in
  2794   macosx)
  2795     # Evil hack to allow static linking on Mac OS X
  2796     SDL_STATIC_LIBS="\${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2797     ;;
  2798   *)
  2799     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2800     ;;
  2801 esac
  2802 
  2803 dnl Expand the cflags and libraries needed by apps using SDL
  2804 AC_SUBST(SDL_CFLAGS)
  2805 AC_SUBST(SDL_LIBS)
  2806 AC_SUBST(SDL_STATIC_LIBS)
  2807 AC_SUBST(SDL_RLD_FLAGS)
  2808 if test x$enable_shared = xyes; then
  2809     ENABLE_SHARED_TRUE=
  2810     ENABLE_SHARED_FALSE="#"
  2811 else
  2812     ENABLE_SHARED_TRUE="#"
  2813     ENABLE_SHARED_FALSE=
  2814 fi
  2815 if test x$enable_static = xyes; then
  2816     ENABLE_STATIC_TRUE=
  2817     ENABLE_STATIC_FALSE="#"
  2818 else
  2819     ENABLE_STATIC_TRUE="#"
  2820     ENABLE_STATIC_FALSE=
  2821 fi
  2822 AC_SUBST(ENABLE_SHARED_TRUE)
  2823 AC_SUBST(ENABLE_SHARED_FALSE)
  2824 AC_SUBST(ENABLE_STATIC_TRUE)
  2825 AC_SUBST(ENABLE_STATIC_FALSE)
  2826 
  2827 dnl Expand the sources and objects needed to build the library
  2828 AC_SUBST(ac_aux_dir)
  2829 AC_SUBST(INCLUDE)
  2830 AC_SUBST(OBJECTS)
  2831 AC_SUBST(DEPENDS)
  2832 AC_SUBST(VERSION_OBJECTS)
  2833 AC_SUBST(VERSION_DEPENDS)
  2834 AC_SUBST(SDLMAIN_OBJECTS)
  2835 AC_SUBST(SDLMAIN_DEPENDS)
  2836 AC_SUBST(BUILD_CFLAGS)
  2837 AC_SUBST(EXTRA_CFLAGS)
  2838 AC_SUBST(BUILD_LDFLAGS)
  2839 AC_SUBST(EXTRA_LDFLAGS)
  2840 AC_SUBST(WINDRES)
  2841 
  2842 AC_OUTPUT([
  2843     Makefile sdl-config SDL.spec sdl.pc
  2844 ])