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