1*4882a593SmuzhiyunRather than code which doesn't even work properly when cross compiling,
2*4882a593Smuzhiyunlets just use pkg-config instead. Its a little simpler.
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunRP 2014/6/20
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunUpstream-Status: Pending
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunIndex: SDL-1.2.15/sdl.m4
9*4882a593Smuzhiyun===================================================================
10*4882a593Smuzhiyun--- SDL-1.2.15.orig/sdl.m4
11*4882a593Smuzhiyun+++ SDL-1.2.15/sdl.m4
12*4882a593Smuzhiyun@@ -12,174 +12,8 @@ dnl Test for SDL, and define SDL_CFLAGS
13*4882a593Smuzhiyun dnl
14*4882a593Smuzhiyun AC_DEFUN([AM_PATH_SDL],
15*4882a593Smuzhiyun [dnl
16*4882a593Smuzhiyun-dnl Get the cflags and libraries from the sdl-config script
17*4882a593Smuzhiyun-dnl
18*4882a593Smuzhiyun-AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
19*4882a593Smuzhiyun-            sdl_prefix="$withval", sdl_prefix="")
20*4882a593Smuzhiyun-AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
21*4882a593Smuzhiyun-            sdl_exec_prefix="$withval", sdl_exec_prefix="")
22*4882a593Smuzhiyun-AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
23*4882a593Smuzhiyun-		    , enable_sdltest=yes)
24*4882a593Smuzhiyun-
25*4882a593Smuzhiyun-  if test x$sdl_exec_prefix != x ; then
26*4882a593Smuzhiyun-    sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
27*4882a593Smuzhiyun-    if test x${SDL_CONFIG+set} != xset ; then
28*4882a593Smuzhiyun-      SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
29*4882a593Smuzhiyun-    fi
30*4882a593Smuzhiyun-  fi
31*4882a593Smuzhiyun-  if test x$sdl_prefix != x ; then
32*4882a593Smuzhiyun-    sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
33*4882a593Smuzhiyun-    if test x${SDL_CONFIG+set} != xset ; then
34*4882a593Smuzhiyun-      SDL_CONFIG=$sdl_prefix/bin/sdl-config
35*4882a593Smuzhiyun-    fi
36*4882a593Smuzhiyun-  fi
37*4882a593Smuzhiyun-
38*4882a593Smuzhiyun-  as_save_PATH="$PATH"
39*4882a593Smuzhiyun-  if test "x$prefix" != xNONE; then
40*4882a593Smuzhiyun-    PATH="$prefix/bin:$prefix/usr/bin:$PATH"
41*4882a593Smuzhiyun-  fi
42*4882a593Smuzhiyun-  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
43*4882a593Smuzhiyun-  PATH="$as_save_PATH"
44*4882a593Smuzhiyun   min_sdl_version=ifelse([$1], ,0.11.0,$1)
45*4882a593Smuzhiyun-  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
46*4882a593Smuzhiyun-  no_sdl=""
47*4882a593Smuzhiyun-  if test "$SDL_CONFIG" = "no" ; then
48*4882a593Smuzhiyun-    no_sdl=yes
49*4882a593Smuzhiyun-  else
50*4882a593Smuzhiyun-    SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
51*4882a593Smuzhiyun-    SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
52*4882a593Smuzhiyun-
53*4882a593Smuzhiyun-    sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
54*4882a593Smuzhiyun-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
55*4882a593Smuzhiyun-    sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
56*4882a593Smuzhiyun-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
57*4882a593Smuzhiyun-    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
58*4882a593Smuzhiyun-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
59*4882a593Smuzhiyun-    if test "x$enable_sdltest" = "xyes" ; then
60*4882a593Smuzhiyun-      ac_save_CFLAGS="$CFLAGS"
61*4882a593Smuzhiyun-      ac_save_CXXFLAGS="$CXXFLAGS"
62*4882a593Smuzhiyun-      ac_save_LIBS="$LIBS"
63*4882a593Smuzhiyun-      CFLAGS="$CFLAGS $SDL_CFLAGS"
64*4882a593Smuzhiyun-      CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
65*4882a593Smuzhiyun-      LIBS="$LIBS $SDL_LIBS"
66*4882a593Smuzhiyun-dnl
67*4882a593Smuzhiyun-dnl Now check if the installed SDL is sufficiently new. (Also sanity
68*4882a593Smuzhiyun-dnl checks the results of sdl-config to some extent
69*4882a593Smuzhiyun-dnl
70*4882a593Smuzhiyun-      rm -f conf.sdltest
71*4882a593Smuzhiyun-      AC_TRY_RUN([
72*4882a593Smuzhiyun-#include <stdio.h>
73*4882a593Smuzhiyun-#include <stdlib.h>
74*4882a593Smuzhiyun-#include <string.h>
75*4882a593Smuzhiyun-#include "SDL.h"
76*4882a593Smuzhiyun-
77*4882a593Smuzhiyun-char*
78*4882a593Smuzhiyun-my_strdup (char *str)
79*4882a593Smuzhiyun-{
80*4882a593Smuzhiyun-  char *new_str;
81*4882a593Smuzhiyun-
82*4882a593Smuzhiyun-  if (str)
83*4882a593Smuzhiyun-    {
84*4882a593Smuzhiyun-      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
85*4882a593Smuzhiyun-      strcpy (new_str, str);
86*4882a593Smuzhiyun-    }
87*4882a593Smuzhiyun-  else
88*4882a593Smuzhiyun-    new_str = NULL;
89*4882a593Smuzhiyun-
90*4882a593Smuzhiyun-  return new_str;
91*4882a593Smuzhiyun-}
92*4882a593Smuzhiyun-
93*4882a593Smuzhiyun-int main (int argc, char *argv[])
94*4882a593Smuzhiyun-{
95*4882a593Smuzhiyun-  int major, minor, micro;
96*4882a593Smuzhiyun-  char *tmp_version;
97*4882a593Smuzhiyun-
98*4882a593Smuzhiyun-  /* This hangs on some systems (?)
99*4882a593Smuzhiyun-  system ("touch conf.sdltest");
100*4882a593Smuzhiyun-  */
101*4882a593Smuzhiyun-  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
102*4882a593Smuzhiyun-
103*4882a593Smuzhiyun-  /* HP/UX 9 (%@#!) writes to sscanf strings */
104*4882a593Smuzhiyun-  tmp_version = my_strdup("$min_sdl_version");
105*4882a593Smuzhiyun-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
106*4882a593Smuzhiyun-     printf("%s, bad version string\n", "$min_sdl_version");
107*4882a593Smuzhiyun-     exit(1);
108*4882a593Smuzhiyun-   }
109*4882a593Smuzhiyun-
110*4882a593Smuzhiyun-   if (($sdl_major_version > major) ||
111*4882a593Smuzhiyun-      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
112*4882a593Smuzhiyun-      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
113*4882a593Smuzhiyun-    {
114*4882a593Smuzhiyun-      return 0;
115*4882a593Smuzhiyun-    }
116*4882a593Smuzhiyun-  else
117*4882a593Smuzhiyun-    {
118*4882a593Smuzhiyun-      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
119*4882a593Smuzhiyun-      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
120*4882a593Smuzhiyun-      printf("*** best to upgrade to the required version.\n");
121*4882a593Smuzhiyun-      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
122*4882a593Smuzhiyun-      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
123*4882a593Smuzhiyun-      printf("*** config.cache before re-running configure\n");
124*4882a593Smuzhiyun-      return 1;
125*4882a593Smuzhiyun-    }
126*4882a593Smuzhiyun-}
127*4882a593Smuzhiyun-
128*4882a593Smuzhiyun-],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
129*4882a593Smuzhiyun-       CFLAGS="$ac_save_CFLAGS"
130*4882a593Smuzhiyun-       CXXFLAGS="$ac_save_CXXFLAGS"
131*4882a593Smuzhiyun-       LIBS="$ac_save_LIBS"
132*4882a593Smuzhiyun-     fi
133*4882a593Smuzhiyun-  fi
134*4882a593Smuzhiyun-  if test "x$no_sdl" = x ; then
135*4882a593Smuzhiyun-     AC_MSG_RESULT(yes)
136*4882a593Smuzhiyun-     ifelse([$2], , :, [$2])
137*4882a593Smuzhiyun-  else
138*4882a593Smuzhiyun-     AC_MSG_RESULT(no)
139*4882a593Smuzhiyun-     if test "$SDL_CONFIG" = "no" ; then
140*4882a593Smuzhiyun-       echo "*** The sdl-config script installed by SDL could not be found"
141*4882a593Smuzhiyun-       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
142*4882a593Smuzhiyun-       echo "*** your path, or set the SDL_CONFIG environment variable to the"
143*4882a593Smuzhiyun-       echo "*** full path to sdl-config."
144*4882a593Smuzhiyun-     else
145*4882a593Smuzhiyun-       if test -f conf.sdltest ; then
146*4882a593Smuzhiyun-        :
147*4882a593Smuzhiyun-       else
148*4882a593Smuzhiyun-          echo "*** Could not run SDL test program, checking why..."
149*4882a593Smuzhiyun-          CFLAGS="$CFLAGS $SDL_CFLAGS"
150*4882a593Smuzhiyun-          CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
151*4882a593Smuzhiyun-          LIBS="$LIBS $SDL_LIBS"
152*4882a593Smuzhiyun-          AC_TRY_LINK([
153*4882a593Smuzhiyun-#include <stdio.h>
154*4882a593Smuzhiyun-#include "SDL.h"
155*4882a593Smuzhiyun-
156*4882a593Smuzhiyun-int main(int argc, char *argv[])
157*4882a593Smuzhiyun-{ return 0; }
158*4882a593Smuzhiyun-#undef  main
159*4882a593Smuzhiyun-#define main K_and_R_C_main
160*4882a593Smuzhiyun-],      [ return 0; ],
161*4882a593Smuzhiyun-        [ echo "*** The test program compiled, but did not run. This usually means"
162*4882a593Smuzhiyun-          echo "*** that the run-time linker is not finding SDL or finding the wrong"
163*4882a593Smuzhiyun-          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
164*4882a593Smuzhiyun-          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
165*4882a593Smuzhiyun-          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
166*4882a593Smuzhiyun-          echo "*** is required on your system"
167*4882a593Smuzhiyun-	  echo "***"
168*4882a593Smuzhiyun-          echo "*** If you have an old version installed, it is best to remove it, although"
169*4882a593Smuzhiyun-          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
170*4882a593Smuzhiyun-        [ echo "*** The test program failed to compile or link. See the file config.log for the"
171*4882a593Smuzhiyun-          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
172*4882a593Smuzhiyun-          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
173*4882a593Smuzhiyun-          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
174*4882a593Smuzhiyun-          CFLAGS="$ac_save_CFLAGS"
175*4882a593Smuzhiyun-          CXXFLAGS="$ac_save_CXXFLAGS"
176*4882a593Smuzhiyun-          LIBS="$ac_save_LIBS"
177*4882a593Smuzhiyun-       fi
178*4882a593Smuzhiyun-     fi
179*4882a593Smuzhiyun-     SDL_CFLAGS=""
180*4882a593Smuzhiyun-     SDL_LIBS=""
181*4882a593Smuzhiyun-     ifelse([$3], , :, [$3])
182*4882a593Smuzhiyun-  fi
183*4882a593Smuzhiyun+  PKG_CHECK_MODULES([SDL], [sdl >= $min_sdl_version])
184*4882a593Smuzhiyun   AC_SUBST(SDL_CFLAGS)
185*4882a593Smuzhiyun   AC_SUBST(SDL_LIBS)
186*4882a593Smuzhiyun-  rm -f conf.sdltest
187*4882a593Smuzhiyun ])
188