From f32ca329d664aceeac95d5ebe2e5b9e86efa9ff0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 14 Jan 2012 13:21:19 -0500 Subject: [PATCH] Make sure that we use consistent configuration options on platforms like Windows so that command line builds and IDE builds have ABI compatibility. Make sure we don't clobber SDL_revision.h when building from Mercurial --- .hgignore | 1 + Makefile.in | 11 ++++++++-- configure | 21 ++++++++++++------- configure.in | 14 ++++++------- include/SDL_config.h | 8 +++++-- ..._config.h.in => SDL_config_generated.h.in} | 0 src/SDL_assert.c | 1 + src/atomic/SDL_atomic.c | 2 +- src/atomic/SDL_spinlock.c | 2 +- src/main/dummy/SDL_dummy_main.c | 1 + 10 files changed, 40 insertions(+), 21 deletions(-) rename include/{SDL_config.h.in => SDL_config_generated.h.in} (100%) diff --git a/.hgignore b/.hgignore index dce4e9a6c..ef76ddaea 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,7 @@ sdl-config SDL.spec SDL.qpg build +include/SDL_config_generated.h # for Xcode *.orig diff --git a/Makefile.in b/Makefile.in index 43bab3dda..a8313a519 100644 --- a/Makefile.in +++ b/Makefile.in @@ -46,6 +46,13 @@ HDRS = \ SDL_audio.h \ SDL_blendmode.h \ SDL_clipboard.h \ + SDL_config.h \ + SDL_config_android.h \ + SDL_config_iphoneos.h \ + SDL_config_macosx.h \ + SDL_config_minimal.h \ + SDL_config_nintendods.h \ + SDL_config_windows.h \ SDL_compat.h \ SDL_cpuinfo.h \ SDL_endian.h \ @@ -130,7 +137,7 @@ install-hdrs: update-revision for file in $(HDRS); do \ $(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL/$$file; \ done - $(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL/SDL_config.h + $(INSTALL) -m 644 include/SDL_config_generated.h $(DESTDIR)$(includedir)/SDL/SDL_config_generated.h if test -f include/SDL_revision.h; then \ $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h; \ else \ @@ -155,7 +162,7 @@ uninstall-hdrs: for file in $(HDRS); do \ rm -f $(DESTDIR)$(includedir)/SDL/$$file; \ done - rm -f $(DESTDIR)$(includedir)/SDL/SDL_config.h + rm -f $(DESTDIR)$(includedir)/SDL/SDL_config_generated.h rm -f $(DESTDIR)$(includedir)/SDL/SDL_revision.h -rmdir $(DESTDIR)$(includedir)/SDL uninstall-lib: diff --git a/configure b/configure index 9e39a2df3..3717666f1 100755 --- a/configure +++ b/configure @@ -2025,7 +2025,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_headers="$ac_config_headers include/SDL_config.h" +ac_config_headers="$ac_config_headers include/SDL_config_generated.h" cat >>confdefs.h <<\_ACEOF @@ -15525,12 +15525,17 @@ fi INCLUDE="-I$srcdir/include" if test x$srcdir != x.; then - # Remove SDL_config.h from the source directory, since it's the - # default one, and we want to include the one that we generate. - if test -f $srcdir/include/SDL_config.h; then - rm $srcdir/include/SDL_config.h - fi INCLUDE="-Iinclude $INCLUDE" +elif test -d .hg; then + { { echo "$as_me:$LINENO: error: +*** When building from Mercurial you should configure and build in a + separate directory so you don't clobber SDL_revision.h +" >&5 +echo "$as_me: error: +*** When building from Mercurial you should configure and build in a + separate directory so you don't clobber SDL_revision.h +" >&2;} + { (exit 1); exit 1; }; } fi case "$host" in *-*-cygwin*) @@ -15546,7 +15551,7 @@ esac # Uncomment the following line if you want to force SDL and applications # built with it to be compiled for a particular architecture. #AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]") -BUILD_CFLAGS="$CFLAGS $CPPFLAGS" +BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DGENERATED_CONFIG_H" # The default optimization for SDL 1.3 is -O3 (Bug #31) if test x$orig_CFLAGS = x; then BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'` @@ -28805,7 +28810,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case $ac_config_target in - "include/SDL_config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/SDL_config.h" ;; + "include/SDL_config_generated.h") CONFIG_HEADERS="$CONFIG_HEADERS include/SDL_config_generated.h" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in:Makefile.rules" ;; "sdl-config") CONFIG_FILES="$CONFIG_FILES sdl-config" ;; diff --git a/configure.in b/configure.in index 9e6b5c2ee..501114941 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(README) -AC_CONFIG_HEADER(include/SDL_config.h) +AC_CONFIG_HEADER(include/SDL_config_generated.h) AC_GNU_SOURCE AC_CONFIG_AUX_DIR(build-scripts) AC_CONFIG_MACRO_DIR([acinclude]) @@ -61,12 +61,12 @@ AC_CHECK_TOOL(WINDRES, [windres], [:]) dnl Set up the compiler and linker flags INCLUDE="-I$srcdir/include" if test x$srcdir != x.; then - # Remove SDL_config.h from the source directory, since it's the - # default one, and we want to include the one that we generate. - if test -f $srcdir/include/SDL_config.h; then - rm $srcdir/include/SDL_config.h - fi INCLUDE="-Iinclude $INCLUDE" +elif test -d .hg; then + AC_MSG_ERROR([ +*** When building from Mercurial you should configure and build in a + separate directory so you don't clobber SDL_revision.h +]) fi case "$host" in *-*-cygwin*) @@ -82,7 +82,7 @@ esac # Uncomment the following line if you want to force SDL and applications # built with it to be compiled for a particular architecture. #AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]") -BUILD_CFLAGS="$CFLAGS $CPPFLAGS" +BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DGENERATED_CONFIG_H" # The default optimization for SDL 1.3 is -O3 (Bug #31) if test x$orig_CFLAGS = x; then BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'` diff --git a/include/SDL_config.h b/include/SDL_config.h index bbeb6631d..fff8014a7 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -26,8 +26,6 @@ /** * \file SDL_config.h - * - * SDL_config.h for any platform that doesn't build using the configure system. */ /* Add any platform that doesn't build using the configure system. */ @@ -42,7 +40,13 @@ #elif defined(__NINTENDODS__) #include "SDL_config_nintendods.h" #else +#ifdef MINIMAL_CONFIG_H +/* This is a minimal configuration just to get SDL running on new platforms */ #include "SDL_config_minimal.h" +#else +/* This is generated by configure for your platform */ +#include "SDL_config_generated.h" +#endif #endif /* platform config */ #endif /* _SDL_config_h */ diff --git a/include/SDL_config.h.in b/include/SDL_config_generated.h.in similarity index 100% rename from include/SDL_config.h.in rename to include/SDL_config_generated.h.in diff --git a/src/SDL_assert.c b/src/SDL_assert.c index c1d46bb60..97a19bc71 100755 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -18,6 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" #include "SDL.h" #include "SDL_atomic.h" diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index 64720f4ce..d8be4c89d 100755 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -18,7 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_stdinc.h" +#include "SDL_config.h" #include "SDL_atomic.h" diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 8ee96dd45..ab3c5cb31 100755 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -18,7 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_stdinc.h" +#include "SDL_config.h" #include "SDL_atomic.h" #include "SDL_mutex.h" diff --git a/src/main/dummy/SDL_dummy_main.c b/src/main/dummy/SDL_dummy_main.c index e5a1351f1..87955239a 100644 --- a/src/main/dummy/SDL_dummy_main.c +++ b/src/main/dummy/SDL_dummy_main.c @@ -1,5 +1,6 @@ /* Include the SDL main definition header */ +#include "SDL_config.h" #include "SDL_main.h" #ifdef main