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