Fixed bug #522
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Oct 2009 18:09:12 +0000
changeset 33403d75acd08339
parent 3339 62d208fd5f49
child 3341 710139a1692d
Fixed bug #522

Mike Frysinger 2007-12-10 16:47:36 PST

it's much easier to manage .pc files for cross-compiling setups than it is for
random *-config scripts ... the cross-compiled pkg-config files can all be
easily/tightly controlled and separate from the host pkg-config files. the
*-config files however are to be found in $PATH and can easily pick the wrong
one.

can we get the sdl.m4 macro updated so that it checks for libsdl.pc first via
the standard PKG_CHECK_MODULES() m4 macro, and if that fails, fall back to the
normal sdl-config voodoo.
sdl.m4
     1.1 --- a/sdl.m4	Sun Oct 04 16:26:34 2009 +0000
     1.2 +++ b/sdl.m4	Sun Oct 04 18:09:12 2009 +0000
     1.3 @@ -19,47 +19,62 @@
     1.4  AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
     1.5  		    , enable_sdltest=yes)
     1.6  
     1.7 -  if test x$sdl_exec_prefix != x ; then
     1.8 -    sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
     1.9 -    if test x${SDL_CONFIG+set} != xset ; then
    1.10 -      SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
    1.11 +  min_sdl_version=ifelse([$1], ,1.2.0,$1)
    1.12 +
    1.13 +  if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
    1.14 +    PKG_CHECK_MODULES(SDL, [sdl >= $min_sdl_version],
    1.15 +           [sdl_pc=yes],
    1.16 +           [dnl
    1.17 +             AC_MSG_RESULT(no)
    1.18 +             sdl_pc=no
    1.19 +           ])
    1.20 +  else
    1.21 +    sdl_pc=no
    1.22 +    if test x$sdl_exec_prefix != x ; then
    1.23 +      sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
    1.24 +      if test x${SDL_CONFIG+set} != xset ; then
    1.25 +        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
    1.26 +      fi
    1.27      fi
    1.28 -  fi
    1.29 -  if test x$sdl_prefix != x ; then
    1.30 -    sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
    1.31 -    if test x${SDL_CONFIG+set} != xset ; then
    1.32 -      SDL_CONFIG=$sdl_prefix/bin/sdl-config
    1.33 +    if test x$sdl_prefix != x ; then
    1.34 +      sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
    1.35 +      if test x${SDL_CONFIG+set} != xset ; then
    1.36 +        SDL_CONFIG=$sdl_prefix/bin/sdl-config
    1.37 +      fi
    1.38      fi
    1.39    fi
    1.40  
    1.41 -  as_save_PATH="$PATH"
    1.42 -  if test "x$prefix" != xNONE; then
    1.43 -    PATH="$prefix/bin:$prefix/usr/bin:$PATH"
    1.44 -  fi
    1.45 -  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
    1.46 -  PATH="$as_save_PATH"
    1.47 -  min_sdl_version=ifelse([$1], ,0.11.0,$1)
    1.48 -  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
    1.49 -  no_sdl=""
    1.50 -  if test "$SDL_CONFIG" = "no" ; then
    1.51 -    no_sdl=yes
    1.52 +  if test "x$sdl_pc" = xyes ; then
    1.53 +    no_sdl=""
    1.54    else
    1.55 -    SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
    1.56 -    SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
    1.57 +    as_save_PATH="$PATH"
    1.58 +    if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
    1.59 +      PATH="$prefix/bin:$prefix/usr/bin:$PATH"
    1.60 +    fi
    1.61 +    AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
    1.62 +    PATH="$as_save_PATH"
    1.63 +    AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
    1.64 +    no_sdl=""
    1.65  
    1.66 -    sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.67 -           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    1.68 -    sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.69 -           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    1.70 -    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.71 -           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    1.72 -    if test "x$enable_sdltest" = "xyes" ; then
    1.73 -      ac_save_CFLAGS="$CFLAGS"
    1.74 -      ac_save_CXXFLAGS="$CXXFLAGS"
    1.75 -      ac_save_LIBS="$LIBS"
    1.76 -      CFLAGS="$CFLAGS $SDL_CFLAGS"
    1.77 -      CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
    1.78 -      LIBS="$LIBS $SDL_LIBS"
    1.79 +    if test "$SDL_CONFIG" = "no" ; then
    1.80 +      no_sdl=yes
    1.81 +    else
    1.82 +      SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
    1.83 +      SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
    1.84 +
    1.85 +      sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.86 +             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    1.87 +      sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.88 +             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    1.89 +      sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
    1.90 +             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    1.91 +      if test "x$enable_sdltest" = "xyes" ; then
    1.92 +        ac_save_CFLAGS="$CFLAGS"
    1.93 +        ac_save_CXXFLAGS="$CXXFLAGS"
    1.94 +        ac_save_LIBS="$LIBS"
    1.95 +        CFLAGS="$CFLAGS $SDL_CFLAGS"
    1.96 +        CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
    1.97 +        LIBS="$LIBS $SDL_LIBS"
    1.98  dnl
    1.99  dnl Now check if the installed SDL is sufficiently new. (Also sanity
   1.100  dnl checks the results of sdl-config to some extent
   1.101 @@ -123,16 +138,20 @@
   1.102  }
   1.103  
   1.104  ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
   1.105 -       CFLAGS="$ac_save_CFLAGS"
   1.106 -       CXXFLAGS="$ac_save_CXXFLAGS"
   1.107 -       LIBS="$ac_save_LIBS"
   1.108 -     fi
   1.109 +        CFLAGS="$ac_save_CFLAGS"
   1.110 +        CXXFLAGS="$ac_save_CXXFLAGS"
   1.111 +        LIBS="$ac_save_LIBS"
   1.112 +      fi
   1.113 +    fi
   1.114 +    if test "x$no_sdl" = x ; then
   1.115 +      AC_MSG_RESULT(yes)
   1.116 +    else
   1.117 +      AC_MSG_RESULT(no)
   1.118 +    fi
   1.119    fi
   1.120    if test "x$no_sdl" = x ; then
   1.121 -     AC_MSG_RESULT(yes)
   1.122 -     ifelse([$2], , :, [$2])     
   1.123 +     ifelse([$2], , :, [$2])
   1.124    else
   1.125 -     AC_MSG_RESULT(no)
   1.126       if test "$SDL_CONFIG" = "no" ; then
   1.127         echo "*** The sdl-config script installed by SDL could not be found"
   1.128         echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"