use the VERSION instead of master in the revno.h generated from a src tarball
[gnash.git] / macros / glib.m4
blobd104f05b15e382ce3888ae0fe534dc639ff1b727
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_GLIB],
20     dnl Look for the header
21   AC_ARG_WITH(glib_incl, AC_HELP_STRING([--with-glib-incl], [directory where libglib header is]), with_glib_incl=${withval})
22   AC_CACHE_VAL(ac_cv_path_glib_incl,[
23     if test x"${with_glib_incl}" != x ; then
24       if test -f ${with_glib_incl}/glib.h ; then
25         ac_cv_path_glib_incl="-I`(cd ${with_glib_incl}; pwd)`"
26         gnash_glib_topdir=`basename ${with_glib_incl}`
27         gnash_glib_version=`echo ${gnash_glib_topdir} | sed -e 's:glib-::'`
28       else
29           AC_MSG_ERROR([${with_glib_incl} directory doesn't contain glib.h])
30       fi
31     fi
32   ])
34   dnl Try with pkg-config
35   if test x${cross_compiling} = xno; then
36     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_glib_incl}" = x; then
37             $PKG_CONFIG --exists glib-2.0 && gnash_glib_version=`$PKG_CONFIG --modversion glib-2.0`
38             $PKG_CONFIG --exists glib-2.0 && ac_cv_path_glib_incl=`$PKG_CONFIG --cflags glib-2.0`
39     fi
40   fi
42   dnl Attempt to find the top level directory, which unfortunately has a
43   dnl version number attached. At least on Debain based systems, this
44   dnl doesn't seem to get a directory that is unversioned.
45   AC_MSG_CHECKING([for Glib header])  
46   if test x"${ac_cv_path_glib_incl}" = x -a x"${gnash_glib_version}" = x; then
47     gnash_glib_topdir=""
48     gnash_glib_version=""
49     for i in $incllist; do
50       for j in `ls -dr $i/glib-[[0-9]].[[0-9]] $i/glib/glib-[[0-9]].[[0-9]] 2>/dev/null`; do
51         if test -f $j/glib.h; then
52           gnash_glib_topdir=`basename $j`
53           gnash_glib_version=`echo ${gnash_glib_topdir} | sed -e 's:glib-::'`
54           ac_cv_path_glib_incl="-I$j"
55           gnash_glib_config=`echo $j | sed -e 's:include:lib:' -e 's:lib/glib/:lib/:'`
56           if test -f ${gnash_glib_config}/include/glibconfig.h; then
57             ac_cv_path_glib_incl="${ac_cv_path_glib_incl} -I${gnash_glib_config}/include"
58           fi
59           break
60         fi
61       done
62     done
63   fi
65   if test x"${ac_cv_path_glib_incl}" = x; then
66     AC_MSG_RESULT(no)
67   else
68     AC_MSG_RESULT(${ac_cv_path_glib_incl})      
69   fi
72   dnl Look for the library
73   AC_ARG_WITH(glib_lib, AC_HELP_STRING([--with-glib-lib], [directory where glib library is]), with_glib_lib=${withval})
74   AC_CACHE_VAL(ac_cv_path_glib_lib,[
75     if test x"${with_glib_lib}" != x ; then
76       if test -f ${with_glib_lib}/libglib-${gnash_glib_version}.a -o -f ${with_glib_lib}/libglib-${gnash_glib_version}.${shlibext}; then
77         ac_cv_path_glib_lib="-L`(cd ${with_glib_lib}; pwd)` -lglib-${gnash_glib_version}"
78       else
79         AC_MSG_ERROR([${with_glib_lib} directory doesn't contain libglib.])
80       fi
81     fi
82   ])
84   if test x${cross_compiling} = xno; then
85     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_glib_lib}" = x; then
86       $PKG_CONFIG --exists glib-2.0 && ac_cv_path_glib_lib=`$PKG_CONFIG --libs glib-2.0`
87     fi
88   fi
90   AC_MSG_CHECKING([for glib library])
91   if test x"${ac_cv_path_glib_lib}" = x; then
92     for i in $libslist; do
93       if test -f $i/libglib-${gnash_glib_version}.a -o -f $i/libglib-${gnash_glib_version}.${shlibext}; then
94         if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64" -a ! x"$i" = x"/usr"; then
95           ac_cv_path_glib_lib="-L$i -lglib-${gnash_glib_version}"
96           break
97         else
98           ac_cv_path_glib_lib="-lglib-${gnash_glib_version}"
99           break
100         fi
101       fi
102     done
103   fi
104   AC_MSG_RESULT(${ac_cv_path_glib_lib})
106   if test x"${ac_cv_path_glib_incl}" != x; then
107           GLIB_CFLAGS="${ac_cv_path_glib_incl} $GLIB_CFLAGS"
108           AC_DEFINE([HAVE_GLIB], [1], [Has GLIB library installed])
109   else
110           GLIB_CFLAGS=""
111   fi
113   if test x"${ac_cv_path_glib_lib}" != x ; then
114           GLIB_LIBS="${ac_cv_path_glib_lib}"
115   else
116         GLIB_LIBS=""
117   fi
119   AC_SUBST(GLIB_CFLAGS)
120   AC_SUBST(GLIB_LIBS)
123 # Local Variables:
124 # c-basic-offset: 2
125 # tab-width: 2
126 # indent-tabs-mode: nil
127 # End: