Add automated test on delayed return value handling in ExternalInterface.call().
[gnash.git] / macros / sdl.m4
blobfa873cef8d6ddf1063735758f7fc0c5e70a399dc
1 dnl  
2 dnl  Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl  2011 Free Software Foundation, Inc.
4 dnl  
5 dnl  This program is free software; you can redistribute it and/or modify
6 dnl  it under the terms of the GNU General Public License as published by
7 dnl  the Free Software Foundation; either version 3 of the License, or
8 dnl  (at your option) any later version.
9 dnl  
10 dnl  This program is distributed in the hope that it will be useful,
11 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl  GNU General Public License for more details.
14 dnl  You should have received a copy of the GNU General Public License
15 dnl  along with this program; if not, write to the Free Software
16 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 AC_DEFUN([GNASH_PATH_SDL], [
20   has_sdl=no
21   dnl Lool for the header
22   AC_ARG_WITH(sdl-incl, AC_HELP_STRING([--with-sdl-incl], [directory where sdl header is]), with_sdl_incl=${withval})
23   AC_CACHE_VAL(ac_cv_path_sdl_incl, [
24     if test x"${with_sdl_incl}" != x ; then
25       if test -f ${with_sdl_incl}/SDL.h ; then
26         ac_cv_path_sdl_incl="-I`(cd ${with_sdl_incl}; pwd)`"
27       else
28         AC_MSG_ERROR([${with_sdl_incl} directory doesn't contain SDL.h])
29       fi
30     fi
31   ])
32   if test x${cross_compiling} = xno; then
33     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_sdl_incl}" = x; then
34             $PKG_CONFIG --exists sdl && ac_cv_path_sdl_incl=`$PKG_CONFIG --cflags sdl` 
35     fi
36   fi
38   dnl Attempt to find the top level directory, which unfortunately has a
39   dnl version number attached. At least on Debain based systems, this
40   dnl doesn't seem to get a directory that is unversioned.
42   if test x${cross_compiling} = xno; then
43     if test x"$PKG_CONFIG" != x; then
44       dnl What's the point of checking for SDL version here if we wipe out that info below ?? .. dropping the check
45       dnl AC_MSG_CHECKING([for the SDL Version])  
46       dnl $PKG_CONFIG --exists sdl && gnash_sdl_version=`$PKG_CONFIG --modversion sdl`
47       $PKG_CONFIG --exists sdl && ac_cv_path_sdl_incl=`$PKG_CONFIG --cflags sdl`
48       dnl AC_MSG_RESULT(${gnash_sdl_version})
49     fi
50   fi
52   AC_PATH_PROG(SDL_CONFIG, sdl-config, , ,[${pathlist}])
53   if test "x$SDL_CONFIG" != "x" ; then
54     if test "x$SDL_CFLAGS" = "x" ; then
55       SDL_CFLAGS=`$SDL_CONFIG --cflags`
56         if test x${cross_compiling} = xno; then
57                 ac_cv_path_sdl_incl=$SDL_CFLAGS
58         fi
59     fi
60     if test "x$SDL_LIBS" = "x" ; then
61       SDL_LIBS=`$SDL_CONFIG --libs | sed -e 's:-L/usr/lib/.* ::'`
62         if test x${cross_compiling} = xno; then
63                 ac_cv_path_sdl_lib=$SDL_LIBS
64         fi
65     fi
66   fi
68   gnash_sdl_topdir=""
69   gnash_sdl_version=""
70   if test x"${ac_cv_path_sdl_incl}" = x; then
71     AC_MSG_CHECKING([for SDL header])  
72     for i in ${incllist}; do
73       for j in `ls -dr $i/SDL* 2>/dev/null`; do
74         if test -f $j/SDL.h; then
75           gnash_sdl_topdir=`basename $j`
76           gnash_sdl_version=`echo ${gnash_sdl_topdir} | sed -e 's:SDL::' -e 's:-::'`
77           ac_cv_path_sdl_incl="-I$j"
78           break
79         fi
80       done
81       if test x"${ac_cv_path_sdl_incl}" != x; then
82         break
83       fi
84     done
85     if test x"${ac_cv_path_sdl_incl}" != x; then
86         AC_MSG_RESULT(${ac_cv_path_sdl_incl})
87     else
88         AC_MSG_RESULT([not found in incllist])
89     fi
90   fi
92   dnl This is sorta bogus atm.
93   SDL_CFLAGS=""
94   if test x"${ac_cv_path_sdl_incl}" = x ; then
95     AC_CHECK_HEADERS(SDL.h, [ac_cv_path_sdl_incl=""])
96   else
97     if test x"${ac_cv_path_sdl_incl}" != x"/usr/include"; then
98       ac_cv_path_sdl_incl="${ac_cv_path_sdl_incl}"
99     else
100       ac_cv_path_sdl_incl=""
101     fi
102   fi
103   
104   dnl Look for the library
105   AC_ARG_WITH(sdl_lib, AC_HELP_STRING([--with-sdl-lib], [directory where sdl library is]), with_sdl_lib=${withval})
106 dnl  AC_MSG_CHECKING([for sdl library])
107   AC_CACHE_VAL(ac_cv_path_sdl_lib, [
108     if test x"${with_sdl_lib}" != x ; then
109       if test -f ${with_sdl_lib}/libSDL.a -o -f ${with_sdl_lib}/libSDL.${shlibext}; then
110         ac_cv_path_sdl_lib="-L`(cd ${with_sdl_lib}; pwd)` -lSDL"
111       else
112         if test -f ${with_sdl_lib}/libSDL-1.1.a -o -f ${with_sdl_lib}/libSDL-1.1.${shlibext}; then
113           ac_cv_path_sdl_lib="-L`(cd ${with_sdl_lib}; pwd)` -lSDL"
114         else
115           AC_MSG_ERROR([${with_sdl_lib} directory doesn't contain libSDL])
116         fi
117       fi
118     fi
119   ])
121   SDL_LIBS=""
122   if test x${cross_compiling} = xno; then
123     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_sdl_lib}" = x; then
124       $PKG_CONFIG --exists sdl && ac_cv_path_sdl_lib=`$PKG_CONFIG --libs sdl`
125       if test x"$ac_cv_path_sdl_lib" != x; then
126         has_sdl=yes
127       fi
128     fi
129   fi
130   
131   if test x"${ac_cv_path_sdl_lib}" = x ; then
132     for i in $libslist; do
133       if test -f $i/libSDL.a -o -f $i/libSDL.${shlibext}; then
134         if test ! x"$i" = x"/usr/lib" -o x"$i" = x"/usr/lib64"; then
135           ac_cv_path_sdl_lib="-L$i -lSDL"
136           dnl AC_MSG_RESULT(${ac_cv_path_sdl_lib})
137           break
138         else
139           ac_cv_path_sdl_lib="-lSDL"
140           dnl AC_MSG_RESULT([yes])
141           has_sdl=yes
142           break
143         fi
144       else
145         if test -f $i/libSDL-1.1.a -o -f $i/libSDL-1.1.${shlibext}; then
146           if test ! x"$i" = x"/usr/lib" -o x"$i" = x"/usr/lib64"; then
147             ac_cv_path_sdl_lib="-L$i -lSDL-1.1"
148             dnl AC_MSG_RESULT(${ac_cv_path_sdl_lib})
149             break
150           else
151             ac_cv_path_sdl_lib="-lSDL-1.1"
152             dnl AC_MSG_RESULT([yes])
153             has_sdl=yes
154             break
155           fi
156         fi
157       fi
158     done
159   fi
160   if test x"${ac_cv_path_sdl_lib}" = x ; then
161     AC_CHECK_LIB(SDL, SDL_Init, [ac_cv_path_sdl_lib="-lSDL"])
162   fi  
163   dnl AC_MSG_CHECKING([for SDL library])
164   dnl AC_MSG_RESULT(${ac_cv_path_sdl_lib}) 
165   if test x"${ac_cv_path_sdl_incl}" != x ; then
166     SDL_CFLAGS="${ac_cv_path_sdl_incl}"
167   fi
168   if test x"${ac_cv_path_sdl_lib}" != x ; then
169     SDL_LIBS="${ac_cv_path_sdl_lib}"
170     has_sdl=yes
171     AC_DEFINE(HAVE_SDL_H, [1], [We have SDL support])
172   else
173     has_sdl=no
174   fi
175   AC_SUBST(SDL_CFLAGS)
176   AC_SUBST(SDL_LIBS)
179 # Local Variables:
180 # c-basic-offset: 2
181 # tab-width: 2
182 # indent-tabs-mode: nil
183 # End: