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