From 7f1c142d6d67947898319060c0b9530cf316e214 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 19 Mar 2006 05:27:22 +0000 Subject: [PATCH] Fixed bug #166 From the autoconf obsolete macros documentation: Macro: AC_CANONICAL_SYSTEM Determine the system type and set output variables to the names of the canonical system types. See section Getting the Canonical System Type, for details about the variables this macro sets. The user is encouraged to use either AC_CANONICAL_BUILD, or AC_CANONICAL_HOST, or AC_CANONICAL_TARGET, depending on the needs. Using AC_CANONICAL_TARGET is enough to run the two other macros. From the documentation for the canonical environments: case $target in i386-*-mach* | i386-*-gnu*) obj_format=aout emulation=mach bfd_gas=yes ;; i960-*-bout) obj_format=bout ;; esac Note that the above example uses $target because it's taken from a tool which can be built on some architecture ($build), run on another ($host), but yet handle data for a third architecture ($target). Such tools are usually part of a compiler suite, they generate code for a specific $target. However $target should be meaningless for most packages. If you want to base a decision on the system where your program will be run, make sure you use the $host variable. --- configure.in | 28 ++++++++++++++-------------- sdl.m4 | 3 +-- test/acinclude.m4 | 3 +-- test/configure.in | 6 +++--- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/configure.in b/configure.in index 5a6b8ff67..1a4a5fd24 100644 --- a/configure.in +++ b/configure.in @@ -39,9 +39,9 @@ AC_SUBST(LT_CURRENT) AC_SUBST(LT_REVISION) AC_SUBST(LT_AGE) -dnl Detect the canonical host and target build environment +dnl Detect the canonical build and host environments AC_CONFIG_AUX_DIRS($srcdir/build-scripts) -AC_CANONICAL_SYSTEM +AC_CANONICAL_HOST AC_C_BIGENDIAN if test x$ac_cv_c_bigendian = xyes; then AC_DEFINE(SDL_BYTEORDER, 4321) @@ -54,7 +54,7 @@ INCLUDE="-I$srcdir/include" if test x$srcdir != x.; then INCLUDE="-Iinclude $INCLUDE" fi -case "$target" in +case "$host" in *-*-cygwin*) # We build SDL on cygwin without the UNIX emulation layer BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin" @@ -285,7 +285,7 @@ AC_HELP_STRING([--enable-oss], [support the OSS audio API [default=yes]]), have_audio=yes # OpenBSD needs linking with ossaudio emulation library - case "$target" in + case "$host" in *-*-openbsd*|*-*-netbsd*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";; esac @@ -569,7 +569,7 @@ dnl See if we can use x86 assembly blitters CheckNASM() { dnl Make sure we are running on an x86 platform - case $target in + case $host in i?86*) ;; *) @@ -600,7 +600,7 @@ AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [default=yes] AC_SUBST(NASM) AC_SUBST(NASMFLAGS) - case "$target" in + case "$host" in # this line is needed for QNX, because it's not defined the __ELF__ *-*-qnx*) EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";; @@ -753,7 +753,7 @@ AC_HELP_STRING([--enable-video-x11], [use X11 video driver [default=yes]]), AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=yes]]), , enable_x11_shared=yes) - case "$target" in + case "$host" in *-*-darwin*) x11_lib='/usr/X11R6/lib/libX11.6.dylib' x11ext_lib='/usr/X11R6/lib/libXext.6.dylib' @@ -1353,7 +1353,7 @@ CheckMacGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) - case "$target" in + case "$host" in *-*-darwin*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -framework OpenGL" # The following is probably not available in Darwin: @@ -1485,7 +1485,7 @@ AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [defa AC_ARG_ENABLE(pthread-sem, AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [default=yes]]), , enable_pthread_sem=yes) - case "$target" in + case "$host" in *-*-linux*) pthread_cflags="-D_REENTRANT" pthread_lib="-lpthread" @@ -1894,8 +1894,8 @@ AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [default=yes]]), , enable_rpath=yes) } -dnl Set up the configuration based on the target platform! -case "$target" in +dnl Set up the configuration based on the host platform! +case "$host" in arm-*-elf*) # FIXME: Can we get more specific for iPodLinux? ARCH=linux CheckDummyVideo @@ -1908,7 +1908,7 @@ case "$target" in fi ;; *-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*) - case "$target" in + case "$host" in *-*-linux*) ARCH=linux ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;; @@ -2072,7 +2072,7 @@ case "$target" in ;; *-*-cygwin* | *-*-mingw32*) ARCH=win32 - if test "$build" != "$target"; then # cross-compiling + if test "$build" != "$host"; then # cross-compiling # Default cross-compile location ac_default_prefix=/usr/local/cross-tools/i386-mingw32msvc else @@ -2335,7 +2335,7 @@ case "$target" in ;; *) AC_MSG_ERROR([ -*** Unsupported target: Please add to configure.in +*** Unsupported host: Please add to configure.in ]) ;; esac diff --git a/sdl.m4 b/sdl.m4 index 09b72e448..a5db82d32 100644 --- a/sdl.m4 +++ b/sdl.m4 @@ -32,7 +32,6 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run fi fi - AC_REQUIRE([AC_CANONICAL_TARGET]) PATH="$prefix/bin:$prefix/usr/bin:$PATH" AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) min_sdl_version=ifelse([$1], ,0.11.0,$1) @@ -121,6 +120,7 @@ int main (int argc, char *argv[]) ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi @@ -170,7 +170,6 @@ int main(int argc, char *argv[]) fi fi SDL_CFLAGS="" - SDL_CXXFLAGS="" SDL_LIBS="" ifelse([$3], , :, [$3]) fi diff --git a/test/acinclude.m4 b/test/acinclude.m4 index 09b72e448..a5db82d32 100644 --- a/test/acinclude.m4 +++ b/test/acinclude.m4 @@ -32,7 +32,6 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run fi fi - AC_REQUIRE([AC_CANONICAL_TARGET]) PATH="$prefix/bin:$prefix/usr/bin:$PATH" AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) min_sdl_version=ifelse([$1], ,0.11.0,$1) @@ -121,6 +120,7 @@ int main (int argc, char *argv[]) ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi @@ -170,7 +170,6 @@ int main(int argc, char *argv[]) fi fi SDL_CFLAGS="" - SDL_CXXFLAGS="" SDL_LIBS="" ifelse([$3], , :, [$3]) fi diff --git a/test/configure.in b/test/configure.in index b1ab7c080..9499ad5ab 100644 --- a/test/configure.in +++ b/test/configure.in @@ -1,9 +1,9 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(README) -dnl Detect the canonical host and target build environment +dnl Detect the canonical build and host environments AC_CONFIG_AUX_DIRS($srcdir/../build-scripts) -AC_CANONICAL_SYSTEM +AC_CANONICAL_HOST dnl Check for tools @@ -14,7 +14,7 @@ dnl Check for compiler environment AC_C_CONST dnl Figure out which math library to use -case "$target" in +case "$host" in *-*-cygwin* | *-*-mingw32*) EXE=".exe" MATHLIB=""