From 1f43cfd729bdec2011f7294dc50682b218a684cf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 13 Jun 2013 22:10:10 -0700 Subject: [PATCH] Fixed SDL building with the minimal configuration --- configure | 9 +++------ configure.in | 9 +++------ include/SDL_config.h.in | 5 +++-- include/SDL_config_minimal.h | 12 ++++++++---- include/SDL_stdinc.h | 2 +- src/SDL_log.c | 4 +++- src/joystick/SDL_joystick.c | 2 +- src/thread/generic/SDL_syssem.c | 10 +++++----- test/testpower.c | 2 +- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/configure b/configure index 133c2a7ec..8258c396f 100755 --- a/configure +++ b/configure @@ -16936,7 +16936,10 @@ SOURCES="$SOURCES $srcdir/src/audio/*.c" SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c" SOURCES="$SOURCES $srcdir/src/events/*.c" SOURCES="$SOURCES $srcdir/src/file/*.c" +SOURCES="$SOURCES $srcdir/src/haptic/*.c" +SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" +SOURCES="$SOURCES $srcdir/src/power/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -17016,8 +17019,6 @@ if test x$enable_joystick != xyes; then $as_echo "#define SDL_JOYSTICK_DISABLED 1" >>confdefs.h -else - SOURCES="$SOURCES $srcdir/src/joystick/*.c" fi # Check whether --enable-haptic was given. if test "${enable_haptic+set}" = set; then : @@ -17030,8 +17031,6 @@ if test x$enable_haptic != xyes; then $as_echo "#define SDL_HAPTIC_DISABLED 1" >>confdefs.h -else - SOURCES="$SOURCES $srcdir/src/haptic/*.c" fi # Check whether --enable-power was given. if test "${enable_power+set}" = set; then : @@ -17044,8 +17043,6 @@ if test x$enable_power != xyes; then $as_echo "#define SDL_POWER_DISABLED 1" >>confdefs.h -else - SOURCES="$SOURCES $srcdir/src/power/*.c" fi # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : diff --git a/configure.in b/configure.in index 25668e3fd..2889c5106 100644 --- a/configure.in +++ b/configure.in @@ -297,7 +297,10 @@ SOURCES="$SOURCES $srcdir/src/audio/*.c" SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c" SOURCES="$SOURCES $srcdir/src/events/*.c" SOURCES="$SOURCES $srcdir/src/file/*.c" +SOURCES="$SOURCES $srcdir/src/haptic/*.c" +SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" +SOURCES="$SOURCES $srcdir/src/power/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -342,24 +345,18 @@ AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes , enable_joystick=yes) if test x$enable_joystick != xyes; then AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ]) -else - SOURCES="$SOURCES $srcdir/src/joystick/*.c" fi AC_ARG_ENABLE(haptic, AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]), , enable_haptic=yes) if test x$enable_haptic != xyes; then AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ]) -else - SOURCES="$SOURCES $srcdir/src/haptic/*.c" fi AC_ARG_ENABLE(power, AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]), , enable_power=yes) if test x$enable_power != xyes; then AC_DEFINE(SDL_POWER_DISABLED, 1, [ ]) -else - SOURCES="$SOURCES $srcdir/src/power/*.c" fi AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]), diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index b9ba3ffd4..5d5252fe6 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -158,8 +158,9 @@ #undef HAVE_SEM_TIMEDWAIT #else -/* We may need some replacement for stdarg.h here */ -#include +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 #endif /* HAVE_LIBC */ /* SDL internal assertion support */ diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index cadfcaa5e..fe3cebc7e 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -30,10 +30,12 @@ * This is the minimal configuration that can be used to build SDL. */ -#include -#include +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 -#if !defined(_STDINT_H_) && !defined(_STDINT_H) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +/* Here are some reasonable defaults */ typedef unsigned int size_t; typedef signed char int8_t; typedef unsigned char uint8_t; @@ -44,7 +46,9 @@ typedef unsigned int uint32_t; typedef signed long long int64_t; typedef unsigned long long uint64_t; typedef unsigned long uintptr_t; -#endif /* if (stdint.h isn't available) */ +#else +#define HAVE_STDINT_H 1 +#endif /* Visual Studio 2008 */ #ifdef __GNUC__ #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index a53044517..3e36dcd2e 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -359,7 +359,7 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t len) extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); -#if defined(__MACOSX__) +#if defined(__MACOSX__) && defined(HAVE_MEMCPY) SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len) { /* We can count on memcpy existing on Mac OS X and being well-tuned. */ diff --git a/src/SDL_log.c b/src/SDL_log.c index 5a51fcf34..6cbfaf0e9 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -369,7 +369,9 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); __android_log_write(SDL_android_priority[priority], tag, message); } -#elif defined(__APPLE__) +#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA) + /* Technically we don't need SDL_VIDEO_DRIVER_COCOA, but that's where this function is defined for now. + */ extern void SDL_NSLog(const char *text); { char *text; diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 0c28ca504..375636c65 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -611,7 +611,7 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state) /* We ignore events if we don't have keyboard focus, except for button * release. */ - if (event.type == SDL_JOYBUTTONDOWN && SDL_PrivateJoystickShouldIgnoreEvent()) { + if (state == SDL_PRESSED && SDL_PrivateJoystickShouldIgnoreEvent()) { return 0; } diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index fc4e1fcc7..bfb011dda 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -32,7 +32,7 @@ SDL_sem * SDL_CreateSemaphore(Uint32 initial_value) { - SDL_SetError("SDL not configured with thread support"); + SDL_SetError("SDL not built with thread support"); return (SDL_sem *) 0; } @@ -44,19 +44,19 @@ SDL_DestroySemaphore(SDL_sem * sem) int SDL_SemTryWait(SDL_sem * sem) { - return SDL_SetError("SDL not configured with thread support"); + return SDL_SetError("SDL not built with thread support"); } int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { - return SDL_SetError("SDL not configured with thread support"); + return SDL_SetError("SDL not built with thread support"); } int SDL_SemWait(SDL_sem * sem) { - return SDL_SetError("SDL not configured with thread support"); + return SDL_SetError("SDL not built with thread support"); } Uint32 @@ -68,7 +68,7 @@ SDL_SemValue(SDL_sem * sem) int SDL_SemPost(SDL_sem * sem) { - return SDL_SetError("SDL not configured with thread support"); + return SDL_SetError("SDL not built with thread support"); } #else diff --git a/test/testpower.c b/test/testpower.c index 031381219..6e6832a39 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -63,7 +63,7 @@ report_power(void) int main(int argc, char *argv[]) { - if (SDL_Init(SDL_INIT_VIDEO) == -1) { + if (SDL_Init(0) == -1) { fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); return 1; }