configure.in
author Sam Lantinga <slouken@libsdl.org>
Mon, 28 Feb 2011 09:06:29 -0800
changeset 5410 12bc832d3fa8
parent 5408 35a63789c3f2
child 5411 e76c379a80ef
permissions -rw-r--r--
IRIX is not supported anymore. :)
     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_lock_test_and_set(&x, y);
   305     __sync_fetch_and_add(&a, 1);
   306     __sync_bool_compare_and_swap(&a, 5, 10);
   307     __sync_bool_compare_and_swap(&x, y, z);
   308     ],[
   309     have_gcc_atomics=yes
   310     ])
   311     AC_MSG_RESULT($have_gcc_atomics)
   312 
   313     if test x$have_gcc_atomics = xyes; then
   314         AC_DEFINE(HAVE_GCC_ATOMICS)
   315     else
   316         # See if we have the minimum operation needed for GCC atomics
   317         AC_TRY_LINK([
   318         ],[
   319         int a;
   320         __sync_lock_test_and_set(&a, 1);
   321         __sync_lock_release(&a);
   322         ],[
   323         have_gcc_sync_lock_test_and_set=yes
   324         ])
   325         if test x$have_gcc_sync_lock_test_and_set = xyes; then
   326             AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
   327         fi
   328     fi
   329 fi
   330 
   331 # Standard C sources
   332 SOURCES="$SOURCES $srcdir/src/*.c"
   333 SOURCES="$SOURCES $srcdir/src/atomic/*.c"
   334 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   335 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   336 SOURCES="$SOURCES $srcdir/src/events/*.c"
   337 SOURCES="$SOURCES $srcdir/src/file/*.c"
   338 SOURCES="$SOURCES $srcdir/src/render/*.c"
   339 SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   340 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   341 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   342 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   343 SOURCES="$SOURCES $srcdir/src/video/*.c"
   344 
   345 dnl Enable/disable various subsystems of the SDL library
   346 
   347 AC_ARG_ENABLE(atomic,
   348 AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
   349               , enable_atomic=yes)
   350 if test x$enable_atomic != xyes; then
   351     AC_DEFINE(SDL_ATOMIC_DISABLED)
   352 fi
   353 AC_ARG_ENABLE(audio,
   354 AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
   355               , enable_audio=yes)
   356 if test x$enable_audio != xyes; then
   357     AC_DEFINE(SDL_AUDIO_DISABLED)
   358 fi
   359 AC_ARG_ENABLE(video,
   360 AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
   361               , enable_video=yes)
   362 if test x$enable_video != xyes; then
   363     AC_DEFINE(SDL_VIDEO_DISABLED)
   364 fi
   365 AC_ARG_ENABLE(render,
   366 AC_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
   367               , enable_render=yes)
   368 if test x$enable_render != xyes; then
   369     AC_DEFINE(SDL_RENDER_DISABLED)
   370 fi
   371 AC_ARG_ENABLE(events,
   372 AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
   373               , enable_events=yes)
   374 if test x$enable_events != xyes; then
   375     AC_DEFINE(SDL_EVENTS_DISABLED)
   376 fi
   377 AC_ARG_ENABLE(joystick,
   378 AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
   379               , enable_joystick=yes)
   380 if test x$enable_joystick != xyes; then
   381     AC_DEFINE(SDL_JOYSTICK_DISABLED)
   382 else
   383     SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   384 fi
   385 AC_ARG_ENABLE(haptic,
   386 AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
   387               , enable_haptic=yes)
   388 if test x$enable_haptic != xyes; then
   389     AC_DEFINE(SDL_HAPTIC_DISABLED)
   390 else
   391     SOURCES="$SOURCES $srcdir/src/haptic/*.c"
   392 fi
   393 AC_ARG_ENABLE(power,
   394 AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
   395               , enable_power=yes)
   396 if test x$enable_power != xyes; then
   397     AC_DEFINE(SDL_POWER_DISABLED)
   398 else
   399     SOURCES="$SOURCES $srcdir/src/power/*.c"
   400 fi
   401 AC_ARG_ENABLE(threads,
   402 AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
   403               , enable_threads=yes)
   404 if test x$enable_threads != xyes; then
   405     AC_DEFINE(SDL_THREADS_DISABLED)
   406 fi
   407 AC_ARG_ENABLE(timers,
   408 AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
   409               , enable_timers=yes)
   410 if test x$enable_timers != xyes; then
   411     AC_DEFINE(SDL_TIMERS_DISABLED)
   412 fi
   413 AC_ARG_ENABLE(file,
   414 AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
   415               , enable_file=yes)
   416 if test x$enable_file != xyes; then
   417     AC_DEFINE(SDL_FILE_DISABLED)
   418 fi
   419 AC_ARG_ENABLE(loadso,
   420 AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
   421               , enable_loadso=yes)
   422 if test x$enable_loadso != xyes; then
   423     AC_DEFINE(SDL_LOADSO_DISABLED)
   424 fi
   425 AC_ARG_ENABLE(cpuinfo,
   426 AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
   427               , enable_cpuinfo=yes)
   428 if test x$enable_cpuinfo != xyes; then
   429     AC_DEFINE(SDL_CPUINFO_DISABLED)
   430 fi
   431 AC_ARG_ENABLE(atomic,
   432 AC_HELP_STRING([--enable-atomic], [Enable the atomic operations [[default=yes]]]),
   433               , enable_atomic=yes)
   434 if test x$enable_atomic != xyes; then
   435     AC_DEFINE(SDL_ATOMIC_DISABLED)
   436 fi
   437 AC_ARG_ENABLE(assembly,
   438 AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
   439               , enable_assembly=yes)
   440 if test x$enable_assembly = xyes; then
   441     AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
   442 
   443     # Make sure that we don't generate floating point code that would
   444     # cause illegal instruction exceptions on older processors
   445     case "$host" in
   446         *-*-darwin*)
   447             # Don't need to worry about Apple hardware, it's all SSE capable
   448             default_ssemath=yes
   449             ;;
   450         *64-*-*)
   451             # x86 64-bit architectures all have SSE instructions
   452             default_ssemath=yes
   453             ;;
   454         *)
   455             default_ssemath=no
   456             ;;
   457     esac
   458     AC_ARG_ENABLE(ssemath,
   459 AC_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=no]]]),
   460                   , enable_ssemath=$default_ssemath)
   461     if test x$enable_ssemath = xno; then
   462         if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes; then
   463             EXTRA_CFLAGS="$EXTRA_CFLAGS -mfpmath=387"
   464         fi
   465     fi
   466 
   467     dnl Check for various instruction support
   468     AC_ARG_ENABLE(mmx,
   469 AC_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
   470                   , enable_mmx=yes)
   471     if test x$enable_mmx = xyes; then
   472         save_CFLAGS="$CFLAGS"
   473         have_gcc_mmx=no
   474         AC_MSG_CHECKING(for GCC -mmmx option)
   475         mmx_CFLAGS="-mmmx"
   476         CFLAGS="$save_CFLAGS $mmx_CFLAGS"
   477 
   478         AC_TRY_COMPILE([
   479         #ifdef __MINGW32__
   480         #include <_mingw.h>
   481         #ifdef __MINGW64_VERSION_MAJOR
   482         #include <intrin.h>
   483         #else
   484         #include <mmintrin.h>
   485         #endif
   486         #else
   487         #include <mmintrin.h>
   488         #endif
   489         #ifndef __MMX__
   490         #error Assembler CPP flag not enabled
   491         #endif
   492         ],[
   493         ],[
   494         have_gcc_mmx=yes
   495         ])
   496         AC_MSG_RESULT($have_gcc_mmx)
   497         CFLAGS="$save_CFLAGS"
   498 
   499         if test x$have_gcc_mmx = xyes; then
   500             EXTRA_CFLAGS="$EXTRA_CFLAGS $mmx_CFLAGS"
   501         fi
   502     fi
   503 
   504     AC_ARG_ENABLE(3dnow,
   505 AC_HELP_STRING([--enable-3dnow], [use MMX assembly routines [[default=yes]]]),
   506                   , enable_3dnow=yes)
   507     if test x$enable_3dnow = xyes; then
   508         save_CFLAGS="$CFLAGS"
   509         have_gcc_3dnow=no
   510         AC_MSG_CHECKING(for GCC -m3dnow option)
   511         amd3dnow_CFLAGS="-m3dnow"
   512         CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
   513 
   514         AC_TRY_COMPILE([
   515         #include <mm3dnow.h>
   516         #ifndef __3dNOW__
   517         #error Assembler CPP flag not enabled
   518         #endif
   519         ],[
   520         ],[
   521         have_gcc_3dnow=yes
   522         ])
   523         AC_MSG_RESULT($have_gcc_3dnow)
   524         CFLAGS="$save_CFLAGS"
   525 
   526         if test x$have_gcc_3dnow = xyes; then
   527             EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
   528         fi
   529     fi
   530 
   531     AC_ARG_ENABLE(sse,
   532 AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
   533                   , enable_sse=yes)
   534     if test x$enable_sse = xyes; then
   535         save_CFLAGS="$CFLAGS"
   536         have_gcc_sse=no
   537         AC_MSG_CHECKING(for GCC -msse option)
   538         sse_CFLAGS="-msse"
   539         CFLAGS="$save_CFLAGS $sse_CFLAGS"
   540 
   541         AC_TRY_COMPILE([
   542         #ifdef __MINGW32__
   543         #include <_mingw.h>
   544         #ifdef __MINGW64_VERSION_MAJOR
   545         #include <intrin.h>
   546         #else
   547         #include <xmmintrin.h>
   548         #endif
   549         #else
   550         #include <xmmintrin.h>
   551         #endif
   552         #ifndef __SSE__
   553         #error Assembler CPP flag not enabled
   554         #endif
   555         ],[
   556         ],[
   557         have_gcc_sse=yes
   558         ])
   559         AC_MSG_RESULT($have_gcc_sse)
   560         CFLAGS="$save_CFLAGS"
   561 
   562         if test x$have_gcc_sse = xyes; then
   563             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse_CFLAGS"
   564         fi
   565     fi
   566 
   567     AC_ARG_ENABLE(sse2,
   568 AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
   569                   , enable_sse2=$default_ssemath)
   570     if test x$enable_sse2 = xyes; then
   571         save_CFLAGS="$CFLAGS"
   572         have_gcc_sse2=no
   573         AC_MSG_CHECKING(for GCC -msse2 option)
   574         sse2_CFLAGS="-msse2"
   575         CFLAGS="$save_CFLAGS $sse2_CFLAGS"
   576 
   577         AC_TRY_COMPILE([
   578         #ifdef __MINGW32__
   579         #include <_mingw.h>
   580         #ifdef __MINGW64_VERSION_MAJOR
   581         #include <intrin.h>
   582         #else
   583         #include <emmintrin.h>
   584         #endif
   585         #else
   586         #include <emmintrin.h>
   587         #endif
   588         #ifndef __SSE2__
   589         #error Assembler CPP flag not enabled
   590         #endif
   591         ],[
   592         ],[
   593         have_gcc_sse2=yes
   594         ])
   595         AC_MSG_RESULT($have_gcc_sse2)
   596         CFLAGS="$save_CFLAGS"
   597 
   598         if test x$have_gcc_sse2 = xyes; then
   599             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
   600         fi
   601     fi
   602 
   603     AC_ARG_ENABLE(altivec,
   604 AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
   605                   , enable_altivec=yes)
   606     if test x$enable_altivec = xyes; then
   607         save_CFLAGS="$CFLAGS"
   608         have_gcc_altivec=no
   609         have_altivec_h_hdr=no
   610         altivec_CFLAGS="-maltivec"
   611         CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   612 
   613         AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
   614         AC_TRY_COMPILE([
   615         #include <altivec.h>
   616         vector unsigned int vzero() {
   617             return vec_splat_u32(0);
   618         }
   619         ],[
   620         ],[
   621         have_gcc_altivec=yes
   622         have_altivec_h_hdr=yes
   623         ])
   624         AC_MSG_RESULT($have_gcc_altivec)
   625 
   626         if test x$have_gcc_altivec = xno; then
   627             AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
   628             AC_TRY_COMPILE([
   629             vector unsigned int vzero() {
   630                 return vec_splat_u32(0);
   631             }
   632             ],[
   633             ],[
   634             have_gcc_altivec=yes
   635             ])
   636             AC_MSG_RESULT($have_gcc_altivec)
   637         fi
   638 
   639         if test x$have_gcc_altivec = xno; then
   640             AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
   641             altivec_CFLAGS="-faltivec"
   642             CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   643             AC_TRY_COMPILE([
   644             #include <altivec.h>
   645             vector unsigned int vzero() {
   646                 return vec_splat_u32(0);
   647             }
   648             ],[
   649             ],[
   650             have_gcc_altivec=yes
   651             have_altivec_h_hdr=yes
   652             ])
   653             AC_MSG_RESULT($have_gcc_altivec)
   654         fi
   655 
   656         if test x$have_gcc_altivec = xno; then
   657             AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
   658             AC_TRY_COMPILE([
   659             vector unsigned int vzero() {
   660                 return vec_splat_u32(0);
   661             }
   662             ],[
   663             ],[
   664             have_gcc_altivec=yes
   665             ])
   666             AC_MSG_RESULT($have_gcc_altivec)
   667         fi
   668         CFLAGS="$save_CFLAGS"
   669 
   670         if test x$have_gcc_altivec = xyes; then
   671             AC_DEFINE(SDL_ALTIVEC_BLITTERS)
   672             if test x$have_altivec_h_hdr = xyes; then
   673               AC_DEFINE(HAVE_ALTIVEC_H)
   674             fi
   675             EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
   676         fi
   677     fi
   678 fi
   679 
   680 dnl See if the OSS audio interface is supported
   681 CheckOSS()
   682 {
   683     AC_ARG_ENABLE(oss,
   684 AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=yes]]]),
   685                   , enable_oss=yes)
   686     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   687         AC_MSG_CHECKING(for OSS audio support)
   688         have_oss=no
   689         if test x$have_oss != xyes; then
   690             AC_TRY_COMPILE([
   691               #include <sys/soundcard.h>
   692             ],[
   693               int arg = SNDCTL_DSP_SETFRAGMENT;
   694             ],[
   695             have_oss=yes
   696             ])
   697         fi
   698         if test x$have_oss != xyes; then
   699             AC_TRY_COMPILE([
   700               #include <soundcard.h>
   701             ],[
   702               int arg = SNDCTL_DSP_SETFRAGMENT;
   703             ],[
   704             have_oss=yes
   705             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
   706             ])
   707         fi
   708         AC_MSG_RESULT($have_oss)
   709         if test x$have_oss = xyes; then
   710             AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
   711             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   712             SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
   713             have_audio=yes
   714 
   715             # We may need to link with ossaudio emulation library
   716             case "$host" in
   717                 *-*-openbsd*|*-*-netbsd*)
   718                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
   719             esac
   720         fi
   721     fi
   722 }
   723 
   724 dnl See if the ALSA audio interface is supported
   725 CheckALSA()
   726 {
   727     AC_ARG_ENABLE(alsa,
   728 AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
   729                   , enable_alsa=yes)
   730     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   731         AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
   732         # Restore all flags from before the ALSA detection runs
   733         CFLAGS="$alsa_save_CFLAGS"
   734         LDFLAGS="$alsa_save_LDFLAGS"
   735         LIBS="$alsa_save_LIBS"
   736         if test x$have_alsa = xyes; then
   737             AC_ARG_ENABLE(alsa-shared,
   738 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
   739                           , enable_alsa_shared=yes)
   740             alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   741 
   742             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
   743             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   744             EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
   745             if test x$have_loadso != xyes && \
   746                test x$enable_alsa_shared = xyes; then
   747                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
   748             fi
   749             if test x$have_loadso = xyes && \
   750                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   751                 echo "-- dynamic libasound -> $alsa_lib"
   752                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
   753             else
   754                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
   755             fi
   756             have_audio=yes
   757         fi
   758     fi
   759 }
   760 
   761 dnl Check whether we want to use Tru64 UNIX native audio or not
   762 CheckMME()
   763 {
   764     dnl Make sure we are running on an Tru64 UNIX
   765     case $ARCH in
   766         osf)
   767             ;;
   768         *)
   769             return
   770             ;;
   771     esac
   772     if test x$enable_audio = xyes; then
   773         AC_MSG_CHECKING(for MME audio support)
   774         MME_CFLAGS="-I/usr/include/mme"
   775         MME_LIBS="-lmme"
   776         have_mme=no
   777         save_CFLAGS="$CFLAGS"
   778         CFLAGS="$CFLAGS $MME_CFLAGS"
   779         AC_TRY_COMPILE([
   780           #include <mme_api.h>
   781         ],[
   782           HWAVEOUT sound;
   783         ],[
   784         have_mme=yes
   785         ])
   786         CFLAGS="$save_CFLAGS"
   787         AC_MSG_RESULT($have_mme)
   788         # Set up files for the audio library
   789         if test x$have_mme = xyes; then
   790             AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
   791             SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
   792             EXTRA_CFLAGS="$EXTRA_CFLAGS $MME_CFLAGS"
   793             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MME_LIBS"
   794             have_audio=yes
   795         fi
   796     fi
   797 }
   798 
   799 dnl Find the ESD includes and libraries
   800 CheckESD()
   801 {
   802     AC_ARG_ENABLE(esd,
   803 AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
   804                   , enable_esd=yes)
   805     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   806         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   807         if test x$have_esd = xyes; then
   808             AC_ARG_ENABLE(esd-shared,
   809 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
   810                           , enable_esd_shared=yes)
   811             esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   812 
   813             AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
   814             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   815             EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
   816             if test x$have_loadso != xyes && \
   817                test x$enable_esd_shared = xyes; then
   818                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
   819             fi
   820             if test x$have_loadso = xyes && \
   821                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   822                 echo "-- dynamic libesd -> $esd_lib"
   823                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
   824             else
   825                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
   826             fi
   827             have_audio=yes
   828         fi
   829     fi
   830 }
   831 
   832 dnl Find PulseAudio
   833 CheckPulseAudio()
   834 {
   835     AC_ARG_ENABLE(pulseaudio,
   836 AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
   837                   , enable_pulseaudio=yes)
   838     if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
   839         audio_pulseaudio=no
   840 
   841         PULSEAUDIO_REQUIRED_VERSION=0.9
   842 
   843         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   844         AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support)
   845         if test x$PKG_CONFIG != xno; then
   846         if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
   847                 PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
   848                 PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
   849                 audio_pulseaudio=yes
   850             fi
   851         fi
   852         AC_MSG_RESULT($audio_pulseaudio)
   853 
   854         if test x$audio_pulseaudio = xyes; then
   855             AC_ARG_ENABLE(pulseaudio-shared,
   856 AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
   857                           , enable_pulseaudio_shared=yes)
   858             pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   859 
   860             AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO)
   861             SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
   862             EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
   863             if test x$have_loadso != xyes && \
   864                test x$enable_pulseaudio_shared = xyes; then
   865                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
   866             fi
   867             if test x$have_loadso = xyes && \
   868                test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
   869                 echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
   870                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib")
   871             else
   872                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
   873             fi
   874             have_audio=yes
   875         fi
   876     fi
   877 }
   878 
   879 CheckARTSC()
   880 {
   881     AC_ARG_ENABLE(arts,
   882 AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
   883                   , enable_arts=yes)
   884     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
   885         AC_PATH_PROG(ARTSCONFIG, artsc-config)
   886         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
   887             : # arts isn't installed
   888         else
   889             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
   890             ARTS_LIBS=`$ARTSCONFIG --libs`
   891             AC_MSG_CHECKING(for aRts development environment)
   892             audio_arts=no
   893             save_CFLAGS="$CFLAGS"
   894             CFLAGS="$CFLAGS $ARTS_CFLAGS"
   895             AC_TRY_COMPILE([
   896              #include <artsc.h>
   897             ],[
   898              arts_stream_t stream;
   899             ],[
   900             audio_arts=yes
   901             ])
   902             CFLAGS="$save_CFLAGS"
   903             AC_MSG_RESULT($audio_arts)
   904             if test x$audio_arts = xyes; then
   905                 AC_ARG_ENABLE(arts-shared,
   906 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
   907                               , enable_arts_shared=yes)
   908                 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   909 
   910                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
   911                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
   912                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
   913                 if test x$have_loadso != xyes && \
   914                    test x$enable_arts_shared = xyes; then
   915                     AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
   916                 fi
   917                 if test x$have_loadso = xyes && \
   918                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
   919                     echo "-- dynamic libartsc -> $arts_lib"
   920                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
   921                 else
   922                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
   923                 fi
   924                 have_audio=yes
   925             fi
   926         fi
   927     fi
   928 }
   929 
   930 dnl See if the NAS audio interface is supported
   931 CheckNAS()
   932 {
   933     AC_ARG_ENABLE(nas,
   934 AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
   935                   , enable_nas=yes)
   936     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
   937         AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
   938         AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
   939 
   940         AC_MSG_CHECKING(for NAS audio support)
   941         have_nas=no
   942 
   943         if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
   944             have_nas=yes
   945             NAS_LIBS="-laudio"
   946 
   947         elif test -r /usr/X11R6/include/audio/audiolib.h; then
   948             have_nas=yes
   949             NAS_CFLAGS="-I/usr/X11R6/include/"
   950             NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
   951 
   952         fi
   953 
   954         AC_MSG_RESULT($have_nas)
   955 
   956         if test x$have_nas = xyes; then
   957             AC_ARG_ENABLE(nas-shared,
   958 AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
   959                           , enable_nas_shared=yes)
   960             nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   961 
   962             if test x$have_loadso != xyes && \
   963                test x$enable_nas_shared = xyes; then
   964                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
   965             fi
   966             if test x$have_loadso = xyes && \
   967                test x$enable_nas_shared = xyes && test x$nas_lib != x; then
   968                 echo "-- dynamic libaudio -> $nas_lib"
   969                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
   970             else
   971                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
   972             fi
   973 
   974             AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
   975             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
   976             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
   977             have_audio=yes
   978         fi
   979     fi
   980 }
   981 
   982 dnl rcg07142001 See if the user wants the disk writer audio driver...
   983 CheckDiskAudio()
   984 {
   985     AC_ARG_ENABLE(diskaudio,
   986 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
   987                   , enable_diskaudio=yes)
   988     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
   989         AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
   990         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
   991     fi
   992 }
   993 
   994 dnl rcg03142006 See if the user wants the dummy audio driver...
   995 CheckDummyAudio()
   996 {
   997     AC_ARG_ENABLE(dummyaudio,
   998 AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
   999                   , enable_dummyaudio=yes)
  1000     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
  1001         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY)
  1002         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
  1003     fi
  1004 }
  1005 
  1006 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
  1007 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
  1008 CheckVisibilityHidden()
  1009 {
  1010     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
  1011     have_gcc_fvisibility=no
  1012 
  1013     visibility_CFLAGS="-fvisibility=hidden"
  1014     save_CFLAGS="$CFLAGS"
  1015     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
  1016     AC_TRY_COMPILE([
  1017     #if !defined(__GNUC__) || __GNUC__ < 4
  1018     #error SDL only uses visibility attributes in GCC 4 or newer
  1019     #endif
  1020     ],[
  1021     ],[
  1022     have_gcc_fvisibility=yes
  1023     ])
  1024     AC_MSG_RESULT($have_gcc_fvisibility)
  1025     CFLAGS="$save_CFLAGS"
  1026 
  1027     if test x$have_gcc_fvisibility = xyes; then
  1028         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
  1029     fi
  1030 }
  1031 
  1032 
  1033 dnl Find the X11 include and library directories
  1034 CheckX11()
  1035 {
  1036 
  1037 
  1038     AC_ARG_ENABLE(video-x11,
  1039 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1040                   , enable_video_x11=yes)
  1041     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1042         case "$host" in
  1043             *-*-darwin*)
  1044                 # This isn't necessary for X11, but fixes GLX detection
  1045                 if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
  1046                     x_includes="/usr/X11R6/include"
  1047                     x_libraries="/usr/X11R6/lib"
  1048                 fi
  1049                 ;;
  1050         esac
  1051         AC_PATH_X
  1052         AC_PATH_XTRA
  1053         if test x$have_x = xyes; then
  1054             # Only allow dynamically loaded X11 if the X11 function pointers
  1055             # will not end up in the global namespace, which causes problems
  1056             # with other libraries calling X11 functions.
  1057             x11_symbols_private=$have_gcc_fvisibility
  1058 
  1059             AC_ARG_ENABLE(x11-shared,
  1060 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1061                           , enable_x11_shared=maybe)
  1062 
  1063             case "$host" in
  1064                 *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
  1065                     x11_symbols_private=yes
  1066                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
  1067                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
  1068                     xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
  1069                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
  1070                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
  1071                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
  1072                     xss_lib='/usr/X11R6/lib/libXss.1.dylib'
  1073                     xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
  1074                     ;;
  1075                 *-*-osf*)
  1076                     x11_lib='libX11.so'
  1077                     x11ext_lib='libXext.so'
  1078                     ;;
  1079                 *)
  1080                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1081                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1082                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1083                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1084                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1085                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1086                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1087                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1088                     ;;
  1089             esac
  1090 
  1091             if test x$ac_cv_func_shmat != xyes; then
  1092                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1093             fi
  1094             CFLAGS="$CFLAGS $X_CFLAGS"
  1095             LDFLAGS="$LDFLAGS $X_LIBS"
  1096 
  1097             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
  1098             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1099             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1100 
  1101             if test x$enable_x11_shared = xmaybe; then
  1102                 enable_x11_shared=$x11_symbols_private
  1103             fi
  1104             if test x$have_loadso != xyes && \
  1105                test x$enable_x11_shared = xyes; then
  1106                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1107                 enable_x11_shared=no
  1108             fi
  1109             if test x$x11_symbols_private != xyes && \
  1110                test x$enable_x11_shared = xyes; then
  1111                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1112                 enable_x11_shared=no
  1113             fi
  1114 
  1115             if test x$have_loadso = xyes && \
  1116                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1117                 echo "-- dynamic libX11 -> $x11_lib"
  1118                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1119                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
  1120                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
  1121             else
  1122                 enable_x11_shared=no
  1123                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1124             fi
  1125             have_video=yes
  1126 
  1127             AC_ARG_ENABLE(video-x11-xinerama,
  1128 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1129                             , enable_video_x11_xinerama=yes)
  1130             if test x$enable_video_x11_xinerama = xyes; then
  1131                 definitely_enable_video_x11_xinerama=no
  1132                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1133                                 have_xinerama_h_hdr=yes,
  1134                                 have_xinerama_h_hdr=no,
  1135                                 [#include <X11/Xlib.h>
  1136                                 ])
  1137                 if test x$have_xinerama_h_hdr = xyes; then
  1138                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1139                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1140                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib")
  1141                         definitely_enable_video_x11_xinerama=yes
  1142                     else
  1143                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1144                         if test x$have_xinerama_lib = xyes ; then
  1145                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1146                             definitely_enable_video_x11_xinerama=yes
  1147                         fi
  1148                     fi
  1149                 fi
  1150             fi
  1151             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1152                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
  1153             fi
  1154             AC_ARG_ENABLE(video-x11-xinput,
  1155 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1156                             , enable_video_x11_xinput=yes)
  1157             if test x$enable_video_x11_xinput = xyes; then
  1158                 definitely_enable_video_x11_xinput=no
  1159                 AC_CHECK_HEADER(X11/extensions/XInput.h,
  1160                                 have_xinput_h_hdr=yes,
  1161                                 have_xinput_h_hdr=no,
  1162                                 [#include <X11/Xlib.h>
  1163                                 ])
  1164                 if test x$have_xinput_h_hdr = xyes; then
  1165                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1166                         echo "-- dynamic libXi -> $xinput_lib"
  1167                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT, "$xinput_lib")
  1168                         definitely_enable_video_x11_xinput=yes
  1169                     else
  1170                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1171                         if test x$have_xinput_lib = xyes ; then
  1172                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1173                             definitely_enable_video_x11_xinput=yes
  1174                         fi
  1175                     fi
  1176                 fi
  1177             fi
  1178             if test x$definitely_enable_video_x11_xinput = xyes; then
  1179                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT)
  1180             fi
  1181             AC_ARG_ENABLE(video-x11-xrandr,
  1182 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1183                             , enable_video_x11_xrandr=yes)
  1184             if test x$enable_video_x11_xrandr = xyes; then
  1185                 definitely_enable_video_x11_xrandr=no
  1186                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1187                                 have_xrandr_h_hdr=yes,
  1188                                 have_xrandr_h_hdr=no,
  1189                                 [#include <X11/Xlib.h>
  1190                                 ])
  1191                 if test x$have_xrandr_h_hdr = xyes; then
  1192                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1193                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1194                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
  1195                         definitely_enable_video_x11_xrandr=yes
  1196                     else
  1197                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1198                         if test x$have_xrandr_lib = xyes ; then
  1199                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1200                             definitely_enable_video_x11_xrandr=yes
  1201                         fi
  1202                     fi
  1203                 fi
  1204             fi
  1205             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1206                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
  1207             fi
  1208             AC_ARG_ENABLE(video-x11-scrnsaver,
  1209 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1210                             , enable_video_x11_scrnsaver=yes)
  1211             if test x$enable_video_x11_scrnsaver = xyes; then
  1212                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1213                                 have_scrnsaver_h_hdr=yes,
  1214                                 have_scrnsaver_h_hdr=no,
  1215                                 [#include <X11/Xlib.h>
  1216                                 ])
  1217                 if test x$have_scrnsaver_h_hdr = xyes; then
  1218                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1219                         echo "-- dynamic libXss -> $xss_lib"
  1220                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib")
  1221                         definitely_enable_video_x11_scrnsaver=yes
  1222                     else
  1223                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1224                         if test x$have_xss_lib = xyes ; then
  1225                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1226                             definitely_enable_video_x11_scrnsaver=yes
  1227                         fi
  1228                     fi
  1229                 fi
  1230             fi
  1231             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1232                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER)
  1233             fi
  1234             AC_ARG_ENABLE(video-x11-xshape,
  1235 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1236                             , enable_video_x11_xshape=yes)
  1237             if test x$enable_video_x11_xshape = xyes; then
  1238                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1239                                 have_shape_h_hdr=yes,
  1240                                 have_shape_h_hdr=no,
  1241                                 [#include <X11/Xlib.h>
  1242                                 ])
  1243                 if test x$have_shape_h_hdr = xyes; then
  1244                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE)
  1245                 fi
  1246             fi
  1247             AC_ARG_ENABLE(video-x11-vm,
  1248 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1249                             , enable_video_x11_vm=yes)
  1250             if test x$enable_video_x11_vm = xyes; then
  1251                 definitely_enable_video_x11_vm=no
  1252                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1253                                 have_vm_h_hdr=yes,
  1254                                 have_vm_h_hdr=no,
  1255                                 [#include <X11/Xlib.h>
  1256                                 ])
  1257                 if test x$have_vm_h_hdr = xyes; then
  1258                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1259                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1260                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib")
  1261                         definitely_enable_video_x11_vm=yes
  1262                     else
  1263                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1264                         if test x$have_vm_lib = xyes ; then
  1265                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1266                             definitely_enable_video_x11_vm=yes
  1267                         fi
  1268                     fi
  1269                 fi
  1270             fi
  1271             if test x$definitely_enable_video_x11_vm = xyes; then
  1272                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE)
  1273             fi
  1274         fi
  1275     fi
  1276 }
  1277 
  1278 dnl Set up the BWindow video driver if enabled
  1279 CheckBWINDOW()
  1280 {
  1281     if test x$enable_video = xyes; then
  1282         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
  1283         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1284         have_video=yes
  1285     fi
  1286 }
  1287 
  1288 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1289 CheckCOCOA()
  1290 {
  1291     AC_ARG_ENABLE(video-cocoa,
  1292 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1293                   , enable_video_cocoa=yes)
  1294     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1295         save_CFLAGS="$CFLAGS"
  1296         dnl work around that we don't have Objective-C support in autoconf
  1297         CFLAGS="$CFLAGS -x objective-c"
  1298         AC_MSG_CHECKING(for Cocoa framework)
  1299         have_cocoa=no
  1300         AC_TRY_COMPILE([
  1301           #import <Cocoa/Cocoa.h>
  1302         ],[
  1303         ],[
  1304         have_cocoa=yes
  1305         ])
  1306         AC_MSG_RESULT($have_cocoa)
  1307         CFLAGS="$save_CFLAGS"
  1308         if test x$have_cocoa = xyes; then
  1309             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA)
  1310             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1311             have_video=yes
  1312         fi
  1313     fi
  1314 }
  1315 
  1316 dnl Find DirectFB
  1317 CheckDirectFB()
  1318 {
  1319     AC_ARG_ENABLE(video-directfb,
  1320 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1321                   , enable_video_directfb=no)
  1322     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1323         video_directfb=no
  1324 
  1325         DIRECTFB_REQUIRED_VERSION=1.0.0
  1326         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  1327         if test x$DIRECTFBCONFIG = xno; then
  1328             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1329             if test x$PKG_CONFIG != xno; then
  1330                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1331                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1332                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1333                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1334                     video_directfb=yes
  1335                 fi
  1336             fi
  1337         else
  1338             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1339             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1340             set -- `directfb-config --version | sed 's/\./ /g'`
  1341             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1342             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1343                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1344                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1345                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1346                 video_directfb=yes
  1347             fi
  1348         fi
  1349         if test x$video_directfb = xyes; then
  1350             # SuSE 11.1 installs directfb-config without directfb-devel
  1351             save_CPPFLAGS="$CPPFLAGS"
  1352             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1353             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1354             CPPFLAGS="$save_CPPFLAGS"
  1355             video_directfb=$have_directfb_hdr
  1356         fi
  1357         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1358         AC_MSG_RESULT($video_directfb)
  1359 
  1360         if test x$video_directfb = xyes; then
  1361             AC_ARG_ENABLE(directfb-shared,
  1362 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1363                               , enable_directfb_shared=yes)
  1364 
  1365             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
  1366             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB)
  1367             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1368             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1369 
  1370             AC_MSG_CHECKING(for directfb dynamic loading support)
  1371             directfb_shared=no
  1372             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
  1373             # | sed 's/.*\/\(.*\)/\1/; q'`]
  1374 AC_MSG_WARN("directfb $directfb_lib")
  1375             if test x$have_loadso != xyes && \
  1376                test x$enable_directfb_shared = xyes; then
  1377                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1378             fi
  1379             if test x$have_loadso = xyes && \
  1380                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1381                 directfb_shared=yes
  1382                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1383                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib")
  1384             else
  1385                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1386             fi
  1387             AC_MSG_RESULT($directfb_shared)
  1388             have_video=yes
  1389         fi
  1390     fi
  1391 }
  1392 
  1393 dnl Find FusionSound
  1394 CheckFusionSound()
  1395 {
  1396     AC_ARG_ENABLE(fusionsound,
  1397 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1398                   , enable_fusionsound=no)
  1399     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1400         fusionsound=no
  1401 
  1402         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1403 
  1404         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1405         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1406         if test x$PKG_CONFIG != xno; then
  1407             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1408                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1409                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1410                 fusionsound=yes
  1411             fi
  1412         fi
  1413         AC_MSG_RESULT($fusionsound)
  1414 
  1415         if test x$fusionsound = xyes; then
  1416             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND)
  1417             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1418             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1419             
  1420             AC_ARG_ENABLE(fusionsound-shared,
  1421 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1422                           , enable_fusionsound_shared=yes)
  1423             fusionsound_shared=no
  1424             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1425             if test x$have_loadso != xyes && \
  1426                test x$enable_fusionsound_shared = xyes; then
  1427                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1428             fi
  1429             if test x$have_loadso = xyes && \
  1430                test x$enable_fusionsound_shared = xyes; then
  1431                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so")
  1432                 fusionsound_shared=yes
  1433             else
  1434                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1435             fi
  1436             AC_MSG_RESULT($fusionsound_shared)
  1437             
  1438             have_audio=yes
  1439         fi
  1440     fi
  1441 }
  1442 
  1443 dnl rcg04172001 Set up the Null video driver.
  1444 CheckDummyVideo()
  1445 {
  1446     AC_ARG_ENABLE(video-dummy,
  1447 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1448                   , enable_video_dummy=yes)
  1449     if test x$enable_video_dummy = xyes; then
  1450         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1451         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1452         have_video=yes
  1453     fi
  1454 }
  1455 
  1456 dnl Check to see if OpenGL support is desired
  1457 AC_ARG_ENABLE(video-opengl,
  1458 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1459               , enable_video_opengl=yes)
  1460 
  1461 dnl Find OpenGL
  1462 CheckOpenGLX11()
  1463 {
  1464     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1465         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1466         video_opengl=no
  1467         AC_TRY_COMPILE([
  1468          #include <GL/gl.h>
  1469          #include <GL/glx.h>
  1470         ],[
  1471         ],[
  1472         video_opengl=yes
  1473         ])
  1474         AC_MSG_RESULT($video_opengl)
  1475         if test x$video_opengl = xyes; then
  1476             AC_DEFINE(SDL_VIDEO_OPENGL)
  1477             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1478             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1479         fi
  1480     fi
  1481 }
  1482 
  1483 dnl Check for Windows OpenGL
  1484 CheckWINDOWSGL()
  1485 {
  1486     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1487         AC_DEFINE(SDL_VIDEO_OPENGL)
  1488         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1489         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1490     fi
  1491 }
  1492 
  1493 dnl Check for BeOS OpenGL
  1494 CheckBeGL()
  1495 {
  1496     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1497         AC_DEFINE(SDL_VIDEO_OPENGL)
  1498         AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
  1499         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1500         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1501     fi
  1502 }
  1503 
  1504 dnl Check for MacOS OpenGL
  1505 CheckMacGL()
  1506 {
  1507     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1508         AC_DEFINE(SDL_VIDEO_OPENGL)
  1509         AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
  1510         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1511         case "$host" in
  1512             *-*-darwin*)
  1513                 if test x$enable_video_cocoa = xyes; then
  1514                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1515                 fi
  1516         esac
  1517     fi
  1518 }
  1519 
  1520 dnl See if we can use the new unified event interface in Linux 2.4
  1521 CheckInputEvents()
  1522 {
  1523     dnl Check for Linux 2.4 unified input event interface support
  1524     AC_ARG_ENABLE(input-events,
  1525 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1526                   , enable_input_events=yes)
  1527     if test x$enable_input_events = xyes; then
  1528         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1529         use_input_events=no
  1530         AC_TRY_COMPILE([
  1531           #include <linux/input.h>
  1532         ],[
  1533           #ifndef EVIOCGNAME
  1534           #error EVIOCGNAME() ioctl not available
  1535           #endif
  1536         ],[
  1537         use_input_events=yes
  1538         ])
  1539         AC_MSG_RESULT($use_input_events)
  1540         if test x$use_input_events = xyes; then
  1541             AC_DEFINE(SDL_INPUT_LINUXEV)
  1542         fi
  1543     fi
  1544 }
  1545 
  1546 dnl See if we can use the Touchscreen input library
  1547 CheckTslib()
  1548 {
  1549     AC_ARG_ENABLE(input-tslib,
  1550 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1551                   , enable_input_tslib=yes)
  1552     if test x$enable_input_tslib = xyes; then
  1553         AC_MSG_CHECKING(for Touchscreen library support)
  1554         enable_input_tslib=no
  1555         AC_TRY_COMPILE([
  1556           #include "tslib.h"
  1557         ],[
  1558         ],[
  1559         enable_input_tslib=yes
  1560         ])
  1561         AC_MSG_RESULT($enable_input_tslib)
  1562         if test x$enable_input_tslib = xyes; then
  1563             AC_DEFINE(SDL_INPUT_TSLIB)
  1564             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1565         fi
  1566     fi
  1567 }
  1568 
  1569 dnl See what type of thread model to use on Linux and Solaris
  1570 CheckPTHREAD()
  1571 {
  1572     dnl Check for pthread support
  1573     AC_ARG_ENABLE(pthreads,
  1574 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1575                   , enable_pthreads=yes)
  1576     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1577     AC_ARG_ENABLE(pthread-sem,
  1578 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1579                   , enable_pthread_sem=yes)
  1580     case "$host" in
  1581         *-*-linux*|*-*-uclinux*)
  1582             pthread_cflags="-D_REENTRANT"
  1583             pthread_lib="-lpthread"
  1584             ;;
  1585         *-*-bsdi*)
  1586             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1587             pthread_lib=""
  1588             ;;
  1589         *-*-darwin*)
  1590             pthread_cflags="-D_THREAD_SAFE"
  1591 # causes Carbon.p complaints?
  1592 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1593             ;;
  1594         *-*-freebsd*|*-*-dragonfly*)
  1595             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1596             pthread_lib="-pthread"
  1597             ;;
  1598         *-*-netbsd*)
  1599             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1600             pthread_lib="-lpthread"
  1601             ;;
  1602         *-*-openbsd*)
  1603             pthread_cflags="-D_REENTRANT"
  1604             pthread_lib="-pthread"
  1605             ;;
  1606         *-*-solaris*)
  1607             pthread_cflags="-D_REENTRANT"
  1608             pthread_lib="-lpthread -lposix4"
  1609             ;;
  1610         *-*-sysv5*)
  1611             pthread_cflags="-D_REENTRANT -Kthread"
  1612             pthread_lib=""
  1613             ;;
  1614         *-*-aix*)
  1615             pthread_cflags="-D_REENTRANT -mthreads"
  1616             pthread_lib="-lpthread"
  1617             ;;
  1618         *-*-hpux11*)
  1619             pthread_cflags="-D_REENTRANT"
  1620             pthread_lib="-L/usr/lib -lpthread"
  1621             ;;
  1622         *-*-osf*)
  1623             pthread_cflags="-D_REENTRANT"
  1624             if test x$ac_cv_prog_gcc = xyes; then
  1625                 pthread_lib="-lpthread -lrt"
  1626             else
  1627                 pthread_lib="-lpthread -lexc -lrt"
  1628             fi
  1629             ;;
  1630         *)
  1631             pthread_cflags="-D_REENTRANT"
  1632             pthread_lib="-lpthread"
  1633             ;;
  1634     esac
  1635     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1636         # Save the original compiler flags and libraries
  1637         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1638         # Add the pthread compiler flags and libraries
  1639         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1640         # Check to see if we have pthread support on this system
  1641         AC_MSG_CHECKING(for pthreads)
  1642         use_pthreads=no
  1643         AC_TRY_LINK([
  1644          #include <pthread.h>
  1645         ],[
  1646          pthread_attr_t type;
  1647          pthread_attr_init(&type);
  1648         ],[
  1649         use_pthreads=yes
  1650         ])
  1651         AC_MSG_RESULT($use_pthreads)
  1652         # Restore the compiler flags and libraries
  1653         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1654 
  1655         # Do futher testing if we have pthread support...
  1656         if test x$use_pthreads = xyes; then
  1657             AC_DEFINE(SDL_THREAD_PTHREAD)
  1658             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1659             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1660             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1661             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1662 
  1663             # Save the original compiler flags and libraries
  1664             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1665             # Add the pthread compiler flags and libraries
  1666             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1667 
  1668             # Check to see if recursive mutexes are available
  1669             AC_MSG_CHECKING(for recursive mutexes)
  1670             has_recursive_mutexes=no
  1671             if test x$has_recursive_mutexes = xno; then
  1672                 AC_TRY_COMPILE([
  1673                   #include <pthread.h>
  1674                 ],[
  1675                   pthread_mutexattr_t attr;
  1676                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1677                 ],[
  1678                 has_recursive_mutexes=yes
  1679                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1680                 ])
  1681             fi
  1682             if test x$has_recursive_mutexes = xno; then
  1683                 AC_TRY_COMPILE([
  1684                   #include <pthread.h>
  1685                 ],[
  1686                   pthread_mutexattr_t attr;
  1687                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1688                 ],[
  1689                 has_recursive_mutexes=yes
  1690                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1691                 ])
  1692             fi
  1693             AC_MSG_RESULT($has_recursive_mutexes)
  1694 
  1695             # Check to see if pthread semaphore support is missing
  1696             if test x$enable_pthread_sem = xyes; then
  1697                 AC_MSG_CHECKING(for pthread semaphores)
  1698                 have_pthread_sem=no
  1699                 AC_TRY_COMPILE([
  1700                   #include <pthread.h>
  1701                   #include <semaphore.h>
  1702                 ],[
  1703                 ],[
  1704                 have_pthread_sem=yes
  1705                 ])
  1706                 AC_MSG_RESULT($have_pthread_sem)
  1707             fi
  1708 
  1709             # Restore the compiler flags and libraries
  1710             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1711 
  1712             # Basic thread creation functions
  1713             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1714 
  1715             # Semaphores
  1716             # We can fake these with mutexes and condition variables if necessary
  1717             if test x$have_pthread_sem = xyes; then
  1718                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1719             else
  1720                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1721             fi
  1722 
  1723             # Mutexes
  1724             # We can fake these with semaphores if necessary
  1725             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1726 
  1727             # Condition variables
  1728             # We can fake these with semaphores and mutexes if necessary
  1729             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1730 
  1731             have_threads=yes
  1732         fi
  1733     fi
  1734 }
  1735 
  1736 dnl Determine whether the compiler can produce Windows executables
  1737 CheckWINDOWS()
  1738 {
  1739     AC_MSG_CHECKING(Windows compiler)
  1740     have_win32_gcc=no
  1741     AC_TRY_COMPILE([
  1742      #include <windows.h>
  1743     ],[
  1744     ],[
  1745     have_win32_gcc=yes
  1746     ])
  1747     AC_MSG_RESULT($have_win32_gcc)
  1748     if test x$have_win32_gcc != xyes; then
  1749        AC_MSG_ERROR([
  1750 *** Your compiler ($CC) does not produce Windows executables!
  1751        ])
  1752     fi
  1753 
  1754     AC_MSG_CHECKING(Windows CE)
  1755     have_wince=no
  1756     AC_TRY_COMPILE([
  1757 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  1758 #error This is not Windows CE
  1759 #endif
  1760     ],[
  1761     ],[
  1762     have_wince=yes
  1763     ])
  1764     AC_MSG_RESULT($have_wince)
  1765 }
  1766 
  1767 dnl Find the DirectX includes and libraries
  1768 CheckDIRECTX()
  1769 {
  1770     AC_ARG_ENABLE(directx,
  1771 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  1772                   , enable_directx=yes)
  1773     if test x$enable_directx = xyes; then
  1774         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  1775         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  1776         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  1777         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  1778     fi
  1779 }
  1780 
  1781 dnl Check for the dlfcn.h interface for dynamically loading objects
  1782 CheckDLOPEN()
  1783 {
  1784     AC_ARG_ENABLE(sdl-dlopen,
  1785 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  1786                   , enable_sdl_dlopen=yes)
  1787     if test x$enable_sdl_dlopen = xyes; then
  1788         AC_MSG_CHECKING(for dlopen)
  1789         have_dlopen=no
  1790         AC_TRY_COMPILE([
  1791          #include <dlfcn.h>
  1792         ],[
  1793          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  1794          #error Use dlcompat for Mac OS X 10.2 compatibility
  1795          #endif
  1796         ],[
  1797         have_dlopen=yes
  1798         ])
  1799         AC_MSG_RESULT($have_dlopen)
  1800 
  1801         if test x$have_dlopen = xyes; then
  1802             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  1803                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  1804                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  1805             AC_DEFINE(SDL_LOADSO_DLOPEN)
  1806             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  1807             have_loadso=yes
  1808         fi
  1809     fi
  1810 }
  1811 
  1812 dnl Check for the usbhid(3) library on *BSD
  1813 CheckUSBHID()
  1814 {
  1815     if test x$enable_joystick = xyes; then
  1816         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  1817         if test x$have_libusbhid = xyes; then
  1818             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  1819             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  1820             USB_LIBS="$USB_LIBS -lusbhid"
  1821         else
  1822             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  1823             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  1824             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  1825         fi
  1826             
  1827         save_CFLAGS="$CFLAGS"
  1828         CFLAGS="$CFLAGS $USB_CFLAGS"
  1829 
  1830         AC_MSG_CHECKING(for usbhid)
  1831         have_usbhid=no
  1832         AC_TRY_COMPILE([
  1833           #include <sys/types.h>
  1834           #if defined(HAVE_USB_H)
  1835           #include <usb.h>
  1836           #endif
  1837           #ifdef __DragonFly__
  1838           # include <bus/usb/usb.h>
  1839           # include <bus/usb/usbhid.h>
  1840           #else
  1841           # include <dev/usb/usb.h>
  1842           # include <dev/usb/usbhid.h>
  1843           #endif
  1844           #if defined(HAVE_USBHID_H)
  1845           #include <usbhid.h>
  1846           #elif defined(HAVE_LIBUSB_H)
  1847           #include <libusb.h>
  1848           #elif defined(HAVE_LIBUSBHID_H)
  1849           #include <libusbhid.h>
  1850           #endif
  1851         ],[
  1852           struct report_desc *repdesc;
  1853           struct usb_ctl_report *repbuf;
  1854           hid_kind_t hidkind;
  1855         ],[
  1856         have_usbhid=yes
  1857         ])
  1858         AC_MSG_RESULT($have_usbhid)
  1859 
  1860         if test x$have_usbhid = xyes; then
  1861             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  1862             have_usbhid_ucr_data=no
  1863             AC_TRY_COMPILE([
  1864               #include <sys/types.h>
  1865               #if defined(HAVE_USB_H)
  1866               #include <usb.h>
  1867               #endif
  1868               #ifdef __DragonFly__
  1869               # include <bus/usb/usb.h>
  1870               # include <bus/usb/usbhid.h>
  1871               #else
  1872               # include <dev/usb/usb.h>
  1873               # include <dev/usb/usbhid.h>
  1874               #endif
  1875               #if defined(HAVE_USBHID_H)
  1876               #include <usbhid.h>
  1877               #elif defined(HAVE_LIBUSB_H)
  1878               #include <libusb.h>
  1879               #elif defined(HAVE_LIBUSBHID_H)
  1880               #include <libusbhid.h>
  1881               #endif
  1882             ],[
  1883               struct usb_ctl_report buf;
  1884               if (buf.ucr_data) { }
  1885             ],[
  1886             have_usbhid_ucr_data=yes
  1887             ])
  1888             if test x$have_usbhid_ucr_data = xyes; then
  1889                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  1890             fi
  1891             AC_MSG_RESULT($have_usbhid_ucr_data)
  1892             
  1893             AC_MSG_CHECKING(for new usbhid API)
  1894             have_usbhid_new=no
  1895             AC_TRY_COMPILE([
  1896               #include <sys/types.h>
  1897               #if defined(HAVE_USB_H)
  1898               #include <usb.h>
  1899               #endif
  1900               #ifdef __DragonFly__
  1901               #include <bus/usb/usb.h>
  1902               #include <bus/usb/usbhid.h>
  1903               #else
  1904               #include <dev/usb/usb.h>
  1905               #include <dev/usb/usbhid.h>
  1906               #endif
  1907               #if defined(HAVE_USBHID_H)
  1908               #include <usbhid.h>
  1909               #elif defined(HAVE_LIBUSB_H)
  1910               #include <libusb.h>
  1911               #elif defined(HAVE_LIBUSBHID_H)
  1912               #include <libusbhid.h>
  1913               #endif
  1914             ],[
  1915               report_desc_t d;
  1916               hid_start_parse(d, 1, 1);
  1917             ],[
  1918             have_usbhid_new=yes
  1919             ])
  1920             if test x$have_usbhid_new = xyes; then
  1921                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  1922             fi
  1923             AC_MSG_RESULT($have_usbhid_new)
  1924 
  1925             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  1926             have_machine_joystick=no
  1927             AC_TRY_COMPILE([
  1928               #include <machine/joystick.h>
  1929             ],[
  1930               struct joystick t;
  1931             ],[
  1932             have_machine_joystick=yes
  1933             ])
  1934             if test x$have_machine_joystick = xyes; then
  1935                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  1936             fi
  1937             AC_MSG_RESULT($have_machine_joystick)
  1938 
  1939             AC_DEFINE(SDL_JOYSTICK_USBHID)
  1940             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  1941             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  1942             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  1943             have_joystick=yes
  1944         fi
  1945         CFLAGS="$save_CFLAGS"
  1946     fi
  1947 }
  1948 
  1949 dnl Check for clock_gettime()
  1950 CheckClockGettime()
  1951 {
  1952     AC_ARG_ENABLE(clock_gettime,
  1953 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  1954                   , enable_clock_gettime=no)
  1955     if test x$enable_clock_gettime = xyes; then
  1956         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  1957         if test x$have_clock_gettime = xyes; then
  1958             AC_DEFINE(HAVE_CLOCK_GETTIME)
  1959             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  1960         else
  1961             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  1962             if test x$have_clock_gettime = xyes; then
  1963                AC_DEFINE(HAVE_CLOCK_GETTIME)
  1964                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  1965             fi
  1966         fi
  1967     fi
  1968 }
  1969 
  1970 dnl Check for a valid linux/version.h
  1971 CheckLinuxVersion()
  1972 {
  1973     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  1974     if test x$have_linux_version_h = xyes; then
  1975         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  1976     fi
  1977 }
  1978 
  1979 dnl Check if we want to use RPATH
  1980 CheckRPATH()
  1981 {
  1982     AC_ARG_ENABLE(rpath,
  1983 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  1984                   , enable_rpath=yes)
  1985 }
  1986 
  1987 dnl Set up the configuration based on the host platform!
  1988 case "$host" in
  1989     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-osf*|*-*-minix*)
  1990         case "$host" in
  1991             *-*-linux*)         ARCH=linux ;;
  1992             *-*-uclinux*)       ARCH=linux ;;
  1993             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  1994             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  1995             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  1996             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  1997             *-*-bsdi*)          ARCH=bsdi ;;
  1998             *-*-freebsd*)       ARCH=freebsd ;;
  1999             *-*-dragonfly*)     ARCH=freebsd ;;
  2000             *-*-netbsd*)        ARCH=netbsd ;;
  2001             *-*-openbsd*)       ARCH=openbsd ;;
  2002             *-*-sysv5*)         ARCH=sysv5 ;;
  2003             *-*-solaris*)       ARCH=solaris ;;
  2004             *-*-hpux*)          ARCH=hpux ;;
  2005             *-*-aix*)           ARCH=aix ;;
  2006             *-*-osf*)           ARCH=osf ;;
  2007             *-*-minix*)         ARCH=minix ;;
  2008         esac
  2009         CheckVisibilityHidden
  2010         CheckDummyVideo
  2011         CheckDiskAudio
  2012         CheckDummyAudio
  2013         CheckDLOPEN
  2014         CheckOSS
  2015         CheckMME
  2016         CheckALSA
  2017         CheckPulseAudio
  2018         CheckARTSC
  2019         CheckESD
  2020         CheckNAS
  2021         CheckX11
  2022         CheckDirectFB
  2023         CheckFusionSound
  2024         CheckOpenGLX11
  2025         CheckInputEvents
  2026         CheckTslib
  2027         CheckUSBHID
  2028         CheckPTHREAD
  2029         CheckClockGettime
  2030         CheckLinuxVersion
  2031         CheckRPATH
  2032         # Set up files for the audio library
  2033         if test x$enable_audio = xyes; then
  2034           case $ARCH in
  2035             sysv5|solaris|hpux)
  2036                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2037                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2038                 have_audio=yes
  2039             ;;
  2040             netbsd|openbsd)
  2041                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2042                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2043                 have_audio=yes
  2044             ;;
  2045             aix)
  2046                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO)
  2047                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2048                 have_audio=yes
  2049             ;;
  2050           esac
  2051         fi
  2052         # Set up files for the joystick library
  2053         if test x$enable_joystick = xyes; then
  2054           case $ARCH in
  2055             linux)
  2056                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2057                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2058                 have_joystick=yes
  2059             ;;
  2060           esac
  2061         fi
  2062         # Set up files for the haptic library
  2063         if test x$enable_haptic = xyes; then
  2064            if test x$use_input_events = xyes; then
  2065              case $ARCH in
  2066                linux)
  2067                    AC_DEFINE(SDL_HAPTIC_LINUX)
  2068                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2069                    have_haptic=yes
  2070                ;;
  2071              esac
  2072            fi
  2073         fi
  2074         # Set up files for the power library
  2075         if test x$enable_power = xyes; then
  2076              case $ARCH in
  2077                linux)
  2078                    AC_DEFINE(SDL_POWER_LINUX)
  2079                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2080                    have_power=yes
  2081                ;;
  2082              esac
  2083         fi
  2084         # Set up files for the timer library
  2085         if test x$enable_timers = xyes; then
  2086             AC_DEFINE(SDL_TIMER_UNIX)
  2087             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2088             have_timers=yes
  2089         fi
  2090         ;;
  2091     *-wince* | *-mingw32ce)
  2092         ARCH=win32
  2093         CheckDummyVideo
  2094         CheckDiskAudio
  2095         CheckDummyAudio
  2096         CheckWINDOWS
  2097         if test x$enable_video = xyes; then
  2098             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
  2099             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2100             have_video=yes
  2101             AC_ARG_ENABLE(render-d3d,
  2102 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2103                                 , enable_render_d3d=yes)
  2104             enable_render_d3d=no
  2105             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2106                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2107             fi
  2108         fi
  2109         # Set up files for the audio library
  2110         if test x$enable_audio = xyes; then
  2111             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2112             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2113             if test x$have_dsound = xyes; then
  2114                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2115                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2116             fi
  2117             have_audio=yes
  2118         fi
  2119         # Set up dummy files for the joystick for now
  2120         if test x$enable_joystick = xyes; then
  2121             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2122             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2123             have_joystick=yes
  2124         fi
  2125         # Set up files for the thread library
  2126         if test x$enable_threads = xyes; then
  2127             AC_DEFINE(SDL_THREAD_WINDOWS)
  2128             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2129             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2130             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2131             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2132             have_threads=yes
  2133         fi
  2134         # Set up files for the timer library
  2135         if test x$enable_timers = xyes; then
  2136             AC_DEFINE(SDL_TIMER_WINCE)
  2137             SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
  2138             have_timers=yes
  2139         fi
  2140         # Set up files for the shared object loading library
  2141         if test x$enable_loadso = xyes; then
  2142             AC_DEFINE(SDL_LOADSO_WINDOWS)
  2143             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2144             have_loadso=yes
  2145         fi
  2146         # Set up the system libraries we need
  2147         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
  2148 
  2149 	# mingw32ce library
  2150 	case "$host" in
  2151     	    *-mingw32ce)
  2152     		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmingwex"
  2153     		;;
  2154     	    *)
  2155         	;;
  2156 	esac
  2157 
  2158         # The Windows platform requires special setup
  2159         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2160         EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
  2161         EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
  2162         ;;
  2163     *-*-cygwin* | *-*-mingw32*)
  2164         ARCH=win32
  2165         if test "$build" != "$host"; then # cross-compiling
  2166             # Default cross-compile location
  2167             ac_default_prefix=/usr/local/cross-tools/$host
  2168         else
  2169             # Look for the location of the tools and install there
  2170             if test "$BUILD_PREFIX" != ""; then
  2171                 ac_default_prefix=$BUILD_PREFIX
  2172             fi
  2173         fi
  2174         CheckDummyVideo
  2175         CheckDiskAudio
  2176         CheckDummyAudio
  2177         CheckWINDOWS
  2178         CheckWINDOWSGL
  2179         CheckDIRECTX
  2180 
  2181         # Set up the core platform files
  2182         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2183 
  2184         # Set up files for the video library
  2185         if test x$enable_video = xyes; then
  2186             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
  2187             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2188             have_video=yes
  2189             AC_ARG_ENABLE(render-d3d,
  2190 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2191                                 , enable_render_d3d=yes)
  2192             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2193                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2194             fi
  2195         fi
  2196         # Set up files for the audio library
  2197         if test x$enable_audio = xyes; then
  2198             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2199             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2200             if test x$have_dsound = xyes; then
  2201                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2202                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2203             fi
  2204             have_audio=yes
  2205         fi
  2206         # Set up files for the joystick library
  2207         if test x$enable_joystick = xyes; then
  2208             if test x$have_dinput = xyes; then
  2209                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
  2210                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2211                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2212             else
  2213                 AC_DEFINE(SDL_JOYSTICK_WINMM)
  2214                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2215             fi
  2216             have_joystick=yes
  2217         fi
  2218         if test x$enable_haptic = xyes; then
  2219             if test x$have_dinput = xyes; then
  2220                 AC_DEFINE(SDL_HAPTIC_DINPUT)
  2221                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2222                 have_haptic=yes
  2223             fi
  2224         fi
  2225         if test x$enable_power = xyes; then
  2226             AC_DEFINE(SDL_POWER_WINDOWS)
  2227             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2228             have_power=yes
  2229         fi
  2230         # Set up files for the thread library
  2231         if test x$enable_threads = xyes; then
  2232             AC_DEFINE(SDL_THREAD_WINDOWS)
  2233             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2234             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2235             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2236             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2237             have_threads=yes
  2238         fi
  2239         # Set up files for the timer library
  2240         if test x$enable_timers = xyes; then
  2241             AC_DEFINE(SDL_TIMER_WINDOWS)
  2242             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2243             have_timers=yes
  2244         fi
  2245         # Set up files for the shared object loading library
  2246         if test x$enable_loadso = xyes; then
  2247             AC_DEFINE(SDL_LOADSO_WINDOWS)
  2248             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2249             have_loadso=yes
  2250         fi
  2251         # Set up the system libraries we need
  2252         # SDL 1.3 is unicode, and unicows emulates this on Windows 98/ME
  2253         # You can get this here: http://libunicows.sourceforge.net/
  2254         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
  2255         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
  2256         # The Windows platform requires special setup
  2257         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2258         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2259         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2260         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2261         ;;
  2262     *-*-beos* | *-*-haiku*)
  2263         ARCH=beos
  2264         ac_default_prefix=/boot/develop/tools/gnupro
  2265         CheckDummyVideo
  2266         CheckDiskAudio
  2267         CheckDummyAudio
  2268         CheckBWINDOW
  2269         CheckBeGL
  2270         # Set up files for the audio library
  2271         if test x$enable_audio = xyes; then
  2272             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
  2273             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2274             have_audio=yes
  2275         fi
  2276         # Set up files for the joystick library
  2277         if test x$enable_joystick = xyes; then
  2278             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2279             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2280             have_joystick=yes
  2281         fi
  2282         # Set up files for the thread library
  2283         if test x$enable_threads = xyes; then
  2284             AC_DEFINE(SDL_THREAD_BEOS)
  2285             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2286             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2287             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2288             have_threads=yes
  2289         fi
  2290         # Set up files for the timer library
  2291         if test x$enable_timers = xyes; then
  2292             AC_DEFINE(SDL_TIMER_BEOS)
  2293             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2294             have_timers=yes
  2295         fi
  2296         # Set up files for the shared object loading library
  2297         if test x$enable_loadso = xyes; then
  2298             AC_DEFINE(SDL_LOADSO_BEOS)
  2299             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2300             have_loadso=yes
  2301         fi
  2302         # Set up files for the system power library
  2303         if test x$enable_power = xyes; then
  2304             AC_DEFINE(SDL_POWER_BEOS)
  2305             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2306             have_power=yes
  2307         fi
  2308         # The BeOS platform requires special setup.
  2309         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2310         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2311         ;;
  2312     *-*-darwin* )
  2313         # This could be either full "Mac OS X", or plain "Darwin" which is
  2314         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2315         # Next line is broken, and a few files below require Mac OS X (full)
  2316         ARCH=macosx
  2317 
  2318         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2319         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2320         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2321 
  2322         CheckVisibilityHidden
  2323         CheckDummyVideo
  2324         CheckDiskAudio
  2325         CheckDummyAudio
  2326         CheckDLOPEN
  2327 
  2328         # Set up files for the shared object loading library
  2329         # (this needs to be done before the dynamic X11 check)
  2330         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2331             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2332             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2333             have_loadso=yes
  2334         fi
  2335 
  2336         CheckCOCOA
  2337         CheckX11
  2338         CheckMacGL
  2339         CheckOpenGLX11
  2340         CheckPTHREAD
  2341 
  2342         # Good optimization on Mac OS X, yes...
  2343         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2344 
  2345         # Need this or things might misbuild on a G3.
  2346         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2347 
  2348         # Set up files for the audio library
  2349         if test x$enable_audio = xyes; then
  2350             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2351             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2352             have_audio=yes
  2353         fi
  2354         # Set up files for the joystick library
  2355         if test x$enable_joystick = xyes; then
  2356             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2357             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2358             have_joystick=yes
  2359         fi
  2360         # Set up files for the haptic library
  2361         if test x$enable_haptic = xyes; then
  2362             AC_DEFINE(SDL_HAPTIC_IOKIT)
  2363             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2364             have_haptic=yes
  2365             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2366         fi
  2367         # Set up files for the power library
  2368         if test x$enable_power = xyes; then
  2369             AC_DEFINE(SDL_POWER_MACOSX)
  2370             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2371             have_power=yes
  2372         fi
  2373         # Set up files for the timer library
  2374         if test x$enable_timers = xyes; then
  2375             AC_DEFINE(SDL_TIMER_UNIX)
  2376             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2377             have_timers=yes
  2378         fi
  2379         # Set up additional files for the file library
  2380         if test x$enable_file = xyes; then
  2381             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2382         fi
  2383         # The Mac OS X platform requires special setup.
  2384         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2385         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2386         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2387         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2388         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2389         # If audio is used, add the AudioUnit framework
  2390         if test x$enable_audio = xyes; then
  2391             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2392         fi
  2393         ;;
  2394     *)
  2395         AC_MSG_ERROR([
  2396 *** Unsupported host:  Please add to configure.in
  2397         ])
  2398         ;;
  2399 esac
  2400 
  2401 # Verify that we have all the platform specific files we need
  2402 
  2403 if test x$have_joystick != xyes; then
  2404     if test x$enable_joystick = xyes; then
  2405         AC_DEFINE(SDL_JOYSTICK_DISABLED)
  2406     fi
  2407     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2408 fi
  2409 if test x$have_haptic != xyes; then
  2410     if test x$enable_haptic = xyes; then
  2411         AC_DEFINE(SDL_HAPTIC_DISABLED)
  2412     fi
  2413     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2414 fi
  2415 if test x$have_threads != xyes; then
  2416     if test x$enable_threads = xyes; then
  2417         AC_DEFINE(SDL_THREADS_DISABLED)
  2418     fi
  2419     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2420 fi
  2421 if test x$have_timers != xyes; then
  2422     if test x$enable_timers = xyes; then
  2423         AC_DEFINE(SDL_TIMERS_DISABLED)
  2424     fi
  2425     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2426 fi
  2427 if test x$have_loadso != xyes; then
  2428     if test x$enable_loadso = xyes; then
  2429         AC_DEFINE(SDL_LOADSO_DISABLED)
  2430     fi
  2431     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2432 fi
  2433 if test x$SDLMAIN_SOURCES = x; then
  2434     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2435 fi
  2436 
  2437 OBJECTS=`echo $SOURCES`
  2438 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  2439 for EXT in asm cc m c S; do
  2440     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2441     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  2442 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2443 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2444 done
  2445 
  2446 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2447 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2448 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2449 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2450 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2451 	\\$(WINDRES) \\$< \\$@,g"`
  2452 
  2453 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2454 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2455 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2456 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2457 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2458 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2459 
  2460 # Set runtime shared library paths as needed
  2461 
  2462 if test "x$enable_rpath" = "xyes"; then
  2463   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  2464     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2465   fi
  2466   if test $ARCH = solaris; then
  2467     SDL_RLD_FLAGS="-R\${libdir}"
  2468   fi
  2469 else
  2470   SDL_RLD_FLAGS=""
  2471 fi
  2472 
  2473 case "$ARCH" in
  2474   macosx)
  2475     # Evil hack to allow static linking on Mac OS X
  2476     SDL_STATIC_LIBS="\${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2477     ;;
  2478   *)
  2479     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2480     ;;
  2481 esac
  2482 
  2483 dnl Expand the cflags and libraries needed by apps using SDL
  2484 AC_SUBST(SDL_CFLAGS)
  2485 AC_SUBST(SDL_LIBS)
  2486 AC_SUBST(SDL_STATIC_LIBS)
  2487 AC_SUBST(SDL_RLD_FLAGS)
  2488 if test x$enable_shared = xyes; then
  2489     ENABLE_SHARED_TRUE=
  2490     ENABLE_SHARED_FALSE="#"
  2491 else
  2492     ENABLE_SHARED_TRUE="#"
  2493     ENABLE_SHARED_FALSE=
  2494 fi
  2495 if test x$enable_static = xyes; then
  2496     ENABLE_STATIC_TRUE=
  2497     ENABLE_STATIC_FALSE="#"
  2498 else
  2499     ENABLE_STATIC_TRUE="#"
  2500     ENABLE_STATIC_FALSE=
  2501 fi
  2502 AC_SUBST(ENABLE_SHARED_TRUE)
  2503 AC_SUBST(ENABLE_SHARED_FALSE)
  2504 AC_SUBST(ENABLE_STATIC_TRUE)
  2505 AC_SUBST(ENABLE_STATIC_FALSE)
  2506 
  2507 dnl Expand the sources and objects needed to build the library
  2508 AC_SUBST(ac_aux_dir)
  2509 AC_SUBST(INCLUDE)
  2510 AC_SUBST(OBJECTS)
  2511 AC_SUBST(VERSION_OBJECTS)
  2512 AC_SUBST(SDLMAIN_OBJECTS)
  2513 AC_SUBST(BUILD_CFLAGS)
  2514 AC_SUBST(EXTRA_CFLAGS)
  2515 AC_SUBST(BUILD_LDFLAGS)
  2516 AC_SUBST(EXTRA_LDFLAGS)
  2517 AC_SUBST(WINDRES)
  2518 
  2519 cat >Makefile.rules <<__EOF__
  2520 
  2521 # Build rules for objects
  2522 -include \$(OBJECTS:.lo=.d)
  2523 
  2524 # Special dependency for SDL.c, since it depends on SDL_revision.h
  2525 $srcdir/src/SDL.c: update-revision
  2526 $DEPENDS
  2527 $VERSION_DEPENDS
  2528 $SDLMAIN_DEPENDS
  2529 __EOF__
  2530 
  2531 AC_CONFIG_FILES([
  2532     Makefile:Makefile.in:Makefile.rules sdl-config SDL.spec sdl.pc
  2533 ])
  2534 AC_OUTPUT