Fixed building with cygwin

Note that building with cygwin gcc results in a DLL that depends on cygwin1.dll
This commit is contained in:
Sam Lantinga 2013-07-21 23:01:01 -07:00
parent 588e67304c
commit ef291a943f
4 changed files with 116 additions and 15 deletions

84
configure vendored
View file

@ -15802,15 +15802,45 @@ elif test -d .hg; then
separate directory so you don't clobber SDL_config.h, SDL_revision.h separate directory so you don't clobber SDL_config.h, SDL_revision.h
" "$LINENO" 5 " "$LINENO" 5
fi fi
BASE_CFLAGS=""
BASE_LDFLAGS=""
case "$host" in case "$host" in
*-*-cygwin*) *-*-cygwin*)
# We build SDL on cygwin without the UNIX emulation layer # We build SDL on cygwin without the UNIX emulation layer
BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin" save_CFLAGS="$CFLAGS"
have_no_cygwin=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mno-cygwin option" >&5
$as_echo_n "checking for GCC -mno-cygwin option... " >&6; }
CFLAGS="$save_CFLAGS -mno-cygwin"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_no_cygwin=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_cygwin" >&5
$as_echo "$have_no_cygwin" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_no_cygwin = xyes; then
BASE_CFLAGS="-mno-cygwin"
BASE_LDFLAGS="-mno-cygwin" BASE_LDFLAGS="-mno-cygwin"
;; fi
*) BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
BASE_CFLAGS=""
BASE_LDFLAGS=""
;; ;;
esac esac
# Uncomment the following line if you want to force SDL and applications # Uncomment the following line if you want to force SDL and applications
@ -22428,7 +22458,49 @@ $as_echo "#define SDL_LOADSO_WINDOWS 1" >>confdefs.h
VERSION_SOURCES="$srcdir/src/main/windows/*.rc" VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c" SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main" SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows" SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
# Check to see if this is a mingw or cygwin build
have_mingw32=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmingw32" >&5
$as_echo_n "checking for main in -lmingw32... " >&6; }
if ${ac_cv_lib_mingw32_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmingw32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mingw32_main=yes
else
ac_cv_lib_mingw32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mingw32_main" >&5
$as_echo "$ac_cv_lib_mingw32_main" >&6; }
if test "x$ac_cv_lib_mingw32_main" = xyes; then :
have_mingw32=yes
fi
if test x$have_mingw32 = xyes; then
SDL_LIBS="-lmingw32 $SDL_LIBS"
else
SDL_LIBS="-lcygwin $SDL_LIBS"
fi
;; ;;
*-*-beos* | *-*-haiku*) *-*-beos* | *-*-haiku*)
ARCH=beos ARCH=beos

View file

@ -70,15 +70,29 @@ elif test -d .hg; then
separate directory so you don't clobber SDL_config.h, SDL_revision.h separate directory so you don't clobber SDL_config.h, SDL_revision.h
]) ])
fi fi
BASE_CFLAGS=""
BASE_LDFLAGS=""
case "$host" in case "$host" in
*-*-cygwin*) *-*-cygwin*)
# We build SDL on cygwin without the UNIX emulation layer # We build SDL on cygwin without the UNIX emulation layer
BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin" save_CFLAGS="$CFLAGS"
have_no_cygwin=no
AC_MSG_CHECKING(for GCC -mno-cygwin option)
CFLAGS="$save_CFLAGS -mno-cygwin"
AC_TRY_COMPILE([
],[
],[
have_no_cygwin=yes
])
AC_MSG_RESULT($have_no_cygwin)
CFLAGS="$save_CFLAGS"
if test x$have_no_cygwin = xyes; then
BASE_CFLAGS="-mno-cygwin"
BASE_LDFLAGS="-mno-cygwin" BASE_LDFLAGS="-mno-cygwin"
;; fi
*) BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
BASE_CFLAGS=""
BASE_LDFLAGS=""
;; ;;
esac esac
# Uncomment the following line if you want to force SDL and applications # Uncomment the following line if you want to force SDL and applications
@ -2511,7 +2525,16 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
VERSION_SOURCES="$srcdir/src/main/windows/*.rc" VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c" SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main" SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows" SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
# Check to see if this is a mingw or cygwin build
have_mingw32=
AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
if test x$have_mingw32 = xyes; then
SDL_LIBS="-lmingw32 $SDL_LIBS"
else
SDL_LIBS="-lcygwin $SDL_LIBS"
fi
;; ;;
*-*-beos* | *-*-haiku*) *-*-beos* | *-*-haiku*)
ARCH=beos ARCH=beos

View file

@ -114,7 +114,7 @@
#undef __SOLARIS__ #undef __SOLARIS__
#define __SOLARIS__ 1 #define __SOLARIS__ 1
#endif #endif
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
#undef __WIN32__ #undef __WIN32__
#define __WIN32__ 1 #define __WIN32__ 1
#endif #endif

6
src/thread/windows/SDL_systhread.c Normal file → Executable file
View file

@ -106,6 +106,12 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread) pfnSDL_CurrentEndThread pfnEndThread)
{ {
#elif defined(__CYGWIN__)
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
pfnSDL_CurrentEndThread pfnEndThread = NULL;
#else #else
int int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args) SDL_SYS_CreateThread(SDL_Thread * thread, void *args)