Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Mar 19, 2006
1 parent 15f8ee0 commit 7f1c142
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
28 changes: 14 additions & 14 deletions configure.in
Expand Up @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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*)
;;
*)
Expand Down Expand Up @@ -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__";;
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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 ;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions sdl.m4
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -170,7 +170,6 @@ int main(int argc, char *argv[])
fi
fi
SDL_CFLAGS=""
SDL_CXXFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
Expand Down
3 changes: 1 addition & 2 deletions test/acinclude.m4
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -170,7 +170,6 @@ int main(int argc, char *argv[])
fi
fi
SDL_CFLAGS=""
SDL_CXXFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
Expand Down
6 changes: 3 additions & 3 deletions 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

Expand All @@ -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=""
Expand Down

0 comments on commit 7f1c142

Please sign in to comment.