Fixed building with cygwin
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 23:01:01 -0700
changeset 7498bda3639deecc
parent 7497 109f37bca7cc
child 7499 228320dcda31
Fixed building with cygwin
Note that building with cygwin gcc results in a DLL that depends on cygwin1.dll
configure
configure.in
include/SDL_platform.h
src/thread/windows/SDL_systhread.c
     1.1 --- a/configure	Sun Jul 21 22:09:00 2013 +0200
     1.2 +++ b/configure	Sun Jul 21 23:01:01 2013 -0700
     1.3 @@ -15802,15 +15802,45 @@
     1.4      separate directory so you don't clobber SDL_config.h, SDL_revision.h
     1.5  " "$LINENO" 5
     1.6  fi
     1.7 +BASE_CFLAGS=""
     1.8 +BASE_LDFLAGS=""
     1.9  case "$host" in
    1.10      *-*-cygwin*)
    1.11          # We build SDL on cygwin without the UNIX emulation layer
    1.12 -        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
    1.13 -        BASE_LDFLAGS="-mno-cygwin"
    1.14 -        ;;
    1.15 -    *)
    1.16 -        BASE_CFLAGS=""
    1.17 -        BASE_LDFLAGS=""
    1.18 +        save_CFLAGS="$CFLAGS"
    1.19 +        have_no_cygwin=no
    1.20 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mno-cygwin option" >&5
    1.21 +$as_echo_n "checking for GCC -mno-cygwin option... " >&6; }
    1.22 +        CFLAGS="$save_CFLAGS -mno-cygwin"
    1.23 +
    1.24 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    1.25 +/* end confdefs.h.  */
    1.26 +
    1.27 +
    1.28 +int
    1.29 +main ()
    1.30 +{
    1.31 +
    1.32 +
    1.33 +  ;
    1.34 +  return 0;
    1.35 +}
    1.36 +_ACEOF
    1.37 +if ac_fn_c_try_compile "$LINENO"; then :
    1.38 +
    1.39 +        have_no_cygwin=yes
    1.40 +
    1.41 +fi
    1.42 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    1.43 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_cygwin" >&5
    1.44 +$as_echo "$have_no_cygwin" >&6; }
    1.45 +        CFLAGS="$save_CFLAGS"
    1.46 +
    1.47 +        if test x$have_no_cygwin = xyes; then
    1.48 +            BASE_CFLAGS="-mno-cygwin"
    1.49 +            BASE_LDFLAGS="-mno-cygwin"
    1.50 +        fi
    1.51 +        BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
    1.52          ;;
    1.53  esac
    1.54  # Uncomment the following line if you want to force SDL and applications
    1.55 @@ -22428,7 +22458,49 @@
    1.56          VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
    1.57          SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
    1.58          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
    1.59 -        SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows"
    1.60 +        SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
    1.61 +
    1.62 +        # Check to see if this is a mingw or cygwin build
    1.63 +        have_mingw32=
    1.64 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmingw32" >&5
    1.65 +$as_echo_n "checking for main in -lmingw32... " >&6; }
    1.66 +if ${ac_cv_lib_mingw32_main+:} false; then :
    1.67 +  $as_echo_n "(cached) " >&6
    1.68 +else
    1.69 +  ac_check_lib_save_LIBS=$LIBS
    1.70 +LIBS="-lmingw32  $LIBS"
    1.71 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    1.72 +/* end confdefs.h.  */
    1.73 +
    1.74 +
    1.75 +int
    1.76 +main ()
    1.77 +{
    1.78 +return main ();
    1.79 +  ;
    1.80 +  return 0;
    1.81 +}
    1.82 +_ACEOF
    1.83 +if ac_fn_c_try_link "$LINENO"; then :
    1.84 +  ac_cv_lib_mingw32_main=yes
    1.85 +else
    1.86 +  ac_cv_lib_mingw32_main=no
    1.87 +fi
    1.88 +rm -f core conftest.err conftest.$ac_objext \
    1.89 +    conftest$ac_exeext conftest.$ac_ext
    1.90 +LIBS=$ac_check_lib_save_LIBS
    1.91 +fi
    1.92 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mingw32_main" >&5
    1.93 +$as_echo "$ac_cv_lib_mingw32_main" >&6; }
    1.94 +if test "x$ac_cv_lib_mingw32_main" = xyes; then :
    1.95 +  have_mingw32=yes
    1.96 +fi
    1.97 +
    1.98 +        if test x$have_mingw32 = xyes; then
    1.99 +            SDL_LIBS="-lmingw32 $SDL_LIBS"
   1.100 +        else
   1.101 +            SDL_LIBS="-lcygwin $SDL_LIBS"
   1.102 +        fi
   1.103          ;;
   1.104      *-*-beos* | *-*-haiku*)
   1.105          ARCH=beos
     2.1 --- a/configure.in	Sun Jul 21 22:09:00 2013 +0200
     2.2 +++ b/configure.in	Sun Jul 21 23:01:01 2013 -0700
     2.3 @@ -70,15 +70,29 @@
     2.4      separate directory so you don't clobber SDL_config.h, SDL_revision.h
     2.5  ])
     2.6  fi
     2.7 +BASE_CFLAGS=""
     2.8 +BASE_LDFLAGS=""
     2.9  case "$host" in
    2.10      *-*-cygwin*)
    2.11          # We build SDL on cygwin without the UNIX emulation layer
    2.12 -        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
    2.13 -        BASE_LDFLAGS="-mno-cygwin"
    2.14 -        ;;
    2.15 -    *)
    2.16 -        BASE_CFLAGS=""
    2.17 -        BASE_LDFLAGS=""
    2.18 +        save_CFLAGS="$CFLAGS"
    2.19 +        have_no_cygwin=no
    2.20 +        AC_MSG_CHECKING(for GCC -mno-cygwin option)
    2.21 +        CFLAGS="$save_CFLAGS -mno-cygwin"
    2.22 +
    2.23 +        AC_TRY_COMPILE([
    2.24 +        ],[
    2.25 +        ],[
    2.26 +        have_no_cygwin=yes
    2.27 +        ])
    2.28 +        AC_MSG_RESULT($have_no_cygwin)
    2.29 +        CFLAGS="$save_CFLAGS"
    2.30 +
    2.31 +        if test x$have_no_cygwin = xyes; then
    2.32 +            BASE_CFLAGS="-mno-cygwin"
    2.33 +            BASE_LDFLAGS="-mno-cygwin"
    2.34 +        fi
    2.35 +        BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
    2.36          ;;
    2.37  esac
    2.38  # Uncomment the following line if you want to force SDL and applications
    2.39 @@ -2511,7 +2525,16 @@
    2.40          VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
    2.41          SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
    2.42          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
    2.43 -        SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows"
    2.44 +        SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
    2.45 +
    2.46 +        # Check to see if this is a mingw or cygwin build
    2.47 +        have_mingw32=
    2.48 +        AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
    2.49 +        if test x$have_mingw32 = xyes; then
    2.50 +            SDL_LIBS="-lmingw32 $SDL_LIBS"
    2.51 +        else
    2.52 +            SDL_LIBS="-lcygwin $SDL_LIBS"
    2.53 +        fi
    2.54          ;;
    2.55      *-*-beos* | *-*-haiku*)
    2.56          ARCH=beos
     3.1 --- a/include/SDL_platform.h	Sun Jul 21 22:09:00 2013 +0200
     3.2 +++ b/include/SDL_platform.h	Sun Jul 21 23:01:01 2013 -0700
     3.3 @@ -114,7 +114,7 @@
     3.4  #undef __SOLARIS__
     3.5  #define __SOLARIS__ 1
     3.6  #endif
     3.7 -#if defined(WIN32) || defined(_WIN32)
     3.8 +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
     3.9  #undef __WIN32__
    3.10  #define __WIN32__   1
    3.11  #endif
     4.1 --- a/src/thread/windows/SDL_systhread.c	Sun Jul 21 22:09:00 2013 +0200
     4.2 +++ b/src/thread/windows/SDL_systhread.c	Sun Jul 21 23:01:01 2013 -0700
     4.3 @@ -106,6 +106,12 @@
     4.4                       pfnSDL_CurrentBeginThread pfnBeginThread,
     4.5                       pfnSDL_CurrentEndThread pfnEndThread)
     4.6  {
     4.7 +#elif defined(__CYGWIN__)
     4.8 +int
     4.9 +SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
    4.10 +{
    4.11 +    pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
    4.12 +    pfnSDL_CurrentEndThread pfnEndThread = NULL;
    4.13  #else
    4.14  int
    4.15  SDL_SYS_CreateThread(SDL_Thread * thread, void *args)