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