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