Add automated test on delayed return value handling in ExternalInterface.call().
[gnash.git] / macros / gtk2.m4
blobf7326dcba85ec9c8ae15d8d3c2410dbe9cf2eb79
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
20 AC_DEFUN([GNASH_PATH_GTK2],
23 if test x"$windows" = x"yes"; then
24   gtklib="libgtk-win32-2.0"
25   gdklib="libgdk-win32-2.0"
26 else
27   gtklib="libgtk-x11-2.0"
28   gdklib="libgdk-x11-2.0"
31   dnl Look for the header
32   AC_ARG_WITH(gtk2_incl, AC_HELP_STRING([--with-gtk2-incl], [directory where libgtk2 header is]), with_gtk2_incl=${withval})
33     AC_CACHE_VAL(ac_cv_path_gtk2_incl,[
34     if test x"${with_gtk2_incl}" != x ; then
35       if test -f ${with_gtk2_incl}/gtk/gtk.h; then
36         ac_cv_path_gtk2_incl="-I`(cd ${with_gtk2_incl}; pwd)`"
37       else
38         AC_MSG_ERROR([${with_gtk2_incl} directory doesn't contain gtk/gtk.h])
39       fi
40     fi
41   ])
44   if test x$cross_compiling = xno; then
45     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_gtk2_incl}" = x; then
46       $PKG_CONFIG --exists gtk+-2.0 && ac_cv_path_gtk2_incl="`$PKG_CONFIG --cflags gtk+-2.0`"
47       $PKG_CONFIG --exists gtk+-2.0 && gnash_gtk2_version="`$PKG_CONFIG --modversion gtk+-2.0`"
48     fi
49   fi
51   dnl Attempt to find the top level directory, which unfortunately has a
52   dnl version number attached. At least on Debain based systems, this
53   dnl doesn't seem to get a directory that is unversioned.
55   AC_MSG_CHECKING([for the gtk2 header])
56   if test x"${gnash_gtk2_version}" = x; then
57     gnash_gtk2_topdir=""
58     gnash_gtk2_version=""
59     for i in $incllist; do
60       for j in `ls -dr $i/gtk-[[2-9]].[[0-9]] 2>/dev/null`; do
61         if test -f $j/gtk/gtk.h; then
62           gnash_gtk2_topdir="`basename $j`"
63           gnash_gtk2_version="`echo ${gnash_gtk2_topdir} | sed -e 's:gtk-::'`"
64           ac_cv_path_gtk2_incl="-I$i/${gnash_gtk2_topdir}"
65           break
66         fi
67       done
68       if test x$gnash_gtk2_version != x; then
69         break;
70       fi
71     done
72   fi
73   if test x"${ac_cv_path_gtk2_incl}" = x; then
74     AC_MSG_RESULT([not found, trying again])
75     AC_CHECK_HEADERS(gtk/gtk.h)
76   else
77     AC_MSG_RESULT($ac_cv_path_gtk2_incl)
78   fi
80   dnl Look for the library
81   AC_ARG_WITH(gtk2_lib,
82         AC_HELP_STRING([--with-gtk2-lib], [directory where gtk2 library is]),
83         with_gtk2_lib=${withval})
85     AC_CACHE_VAL(ac_cv_path_gtk2_lib,[
86     if test x"${with_gtk2_lib}" != x ; then
87       if test -f ${with_gtk2_lib}/${gtklib}.${shlibext} -o -f ${with_gtk2_lib}/${gtklib}.a; then
88         if test -f ${with_gtk2_lib}/${gdklib}.${shlibext} -o -f ${with_gtk2_lib}/${gdklib}.a; then
89                 ac_cv_path_gtk2_lib="-I`(cd ${with_gtk2_lib}; pwd)`"
90         else
91                 AC_MSG_ERROR([${with_gtk2_lib} directory doesn't contain ${gdklib}.${shlibext}])
92         fi
93       else
94         AC_MSG_ERROR([${with_gtk2_lib} directory doesn't contain ${gtklib}.${shlibext}])
95       fi
96     fi
97   ])
99   if test x$cross_compiling = xno; then
100     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_gtk2_lib}" = x; then
101       $PKG_CONFIG --exists gtk+-2.0 && ac_cv_path_gtk2_lib="`$PKG_CONFIG --libs-only-l gtk+-2.0`"
102     fi
103   fi
105 dnl If the header doesn't exist, there is no point looking for
106 dnl the library. 
107   AC_MSG_CHECKING([for libgtk2 library])
108   if test x"${ac_cv_path_gtk2_incl}" != x -a x"${ac_cv_path_gtk2_lib}" = x; then
109     for i in $libslist; do
110       if test -f $i/${gtklib}.a -o -f $i/${gtklib}.${shlibext}; then
111         if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
112           if test x"$windows" = x"yes"; then
113             ac_cv_path_gtk2_lib="-L$i -lgtk-win32-2.0 -lgdk-win32-2.0 -lgobject-2.0 -lgmodule-2.0"
114           else
115             ac_cv_path_gtk2_lib="-L$i -lgtk-x11-2.0 -lgdk-x11-2.0 -lgobject-2.0 -lgmodule-2.0"
116           fi
117           break
118         else
119           if test x"$windows" = x"yes"; then
120             ac_cv_path_gtk2_lib="-lgtk-win32-2.0 -lgdk-win32-2.0 -lgobject-2.0 -lgmodule-2.0 "
121           else
122             ac_cv_path_gtk2_lib="-lgtk-x11-2.0 -lgdk-x11-2.0 -lgobject-2.0 -lgmodule-2.0 "
123           fi
124           break
125         fi
126       fi
127     done
128   fi
130   if test x"${ac_cv_path_gtk2_lib}" = x; then
131     if test x"$windows" = x"yes"; then
132       AC_CHECK_LIB([gtk-win32-2.0], [gtk_init], [ac_cv_path_gtk2_lib="-lgtk-win32-2.0 -lgdk-win32-2.0 -lgobject-2.0 -lgmodule-2.0"])
133     else
134       AC_CHECK_LIB([gtk-x11-2.0], [gtk_init], [ac_cv_path_gtk2_lib="-lgtk-x11-2.0 -lgdk-x11-2.0 -lgobject-2.0 -lgmodule-2.0"])
135     fi
136   fi
137   AC_MSG_RESULT($ac_cv_path_gtk2_lib)
139   if test x"${ac_cv_path_gtk2_incl}" != x; then
140     for i in $libslist; do
141       if test -f $i/gtk-${gnash_gtk2_version}/include/gdkconfig.h; then
142          GTK2_CFLAGS="-I${i}/gtk-${gnash_gtk2_version}/include"
143          break
144       fi
145     done
146     if test x"${ac_cv_path_gtk2_incl}" = x"yes"; then
147       GTK2_CFLAGS="$GTK2_CFLAGS"
148     else
149       GTK2_CFLAGS="${ac_cv_path_gtk2_incl} $GTK2_CFLAGS"
150     fi
151     AC_DEFINE([HAVE_GTK2], [1], [Use GTK2 for windowing])
152   else
153     GTK2_CFLAGS=""
154   fi
156   if test x"${ac_cv_path_gtk2_lib}" != x ; then
157     GTK2_LIBS="${ac_cv_path_gtk2_lib}"
158     has_gtk2=yes
159   else
160     GTK2_LIBS=""
161     has_gtk2=no
162   fi
164   AC_SUBST(GTK2_CFLAGS)
165   AC_SUBST(GTK2_LIBS)
168 # Local Variables:
169 # c-basic-offset: 2
170 # tab-width: 2
171 # indent-tabs-mode: nil
172 # End: