free the answer from, getaddrinfo
[gnash.git] / macros / x11.m4
blob8125f016955f607be603cb618ccb0d0c2a70cb3c
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_X11],
22   has_x11=no
24   dnl Look for the header
25   AC_ARG_WITH(x11_incl, AC_HELP_STRING([--with-x11-incl], [Directory where x11 header is]), with_x11_incl=${withval})
26   AC_CACHE_VAL(ac_cv_path_x11_incl, [
27     if test x"${with_x11_incl}" != x ; then
28       if test -f ${with_x11_incl}/X11/X.h ; then
29        ac_cv_path_x11_incl="-I`(cd ${with_x11_incl}; pwd)`"
30       else
31        AC_MSG_ERROR([${with_x11_incl} directory doesn't contain X.h])
32       fi
33     fi
34   ])
36   dnl If the path hasn't been specified, go look for it.
37   if test x"${ac_cv_path_x11_incl}" = x ; then
38     newlist="/Developer/SDKs/MacOSX10.6*.sdk/usr/include /Developer/SDKs/MacOSX10.5*.sdk/usr/include /Developer/SDKs/MacOSX10.4*.sdk/usr/include ${incllist}"
39     for i in $newlist; do
40         if test -f $i/X11/X.h; then
41             ac_cv_path_x11_incl="-I$i"
42         AC_DEFINE(HAVE_X11_X_H, [1], [Have the X11 X.h header file])
43         break
44         fi
45     done
46   fi
48   dnl We want to know whether the headers for XShm exist.
49   if test x"${ac_cv_path_x11_incl}" != x ; then
50     includedirfound=`echo "${ac_cv_path_x11_incl}" | cut -b 3-`
51     if test -f "$includedirfound/X11/extensions/Xv.h"; then
52       xv_incl=yes
53     fi
54   fi
56   AC_MSG_CHECKING([for X11 headers])
57   if test x"${ac_cv_path_x11_incl}" != x ; then
58     dnl Don't pass -I/usr/include
59     if test x"${ac_cv_path_x11_incl}" != "x-I/usr/include"; then
60        X11_CFLAGS="${ac_cv_path_x11_incl}"
61     fi
62     x11_incl=yes
63     AC_MSG_RESULT(${ac_cv_path_x11_incl})
64   else
65     x11_incl=""
66     X11_CFLAGS=""
67     AC_MSG_RESULT(none)
68   fi
70   dnl Look for the library
71   AC_ARG_WITH(x11_lib, AC_HELP_STRING([--with-x11-lib], [directory where x11 library is]), with_x11_lib=${withval})
72   AC_CACHE_VAL(ac_cv_path_x11_lib,[
73     if test x"${with_x11_lib}" != x ; then
74       if test -f ${with_x11_lib}/libX11.a -o -f ${with_x11_lib}/libX11.${shlibext}; then
75        ac_cv_path_x11_lib="-L`(cd ${with_x11_lib}; pwd)`"
76       else
77        AC_MSG_ERROR([${with_x11_lib} directory doesn't contain libx11.])
78       fi
79     fi
80   ])
82   dnl If the header doesn't exist, there is no point looking for the library.
83   if test x"${ac_cv_path_x11_incl}" != x ; then
84     newlist="/Developer/SDKs/MacOSX10.6*.sdk/usr/lib /Developer/SDKs/MacOSX10.6*.sdk/usr/X11R6/lib /Developer/SDKs/MacOSX10.5*.sdk/usr/lib /Developer/SDKs/MacOSX10.5*.sdk/usr/X11R6/lib /Developer/SDKs/MacOSX10.4*.sdk/usr/lib /Developer/SDKs/MacOSX10.4*.sdk/usr/X11R6/lib ${libslist}"
85     for i in $newlist; do
86       if test -f $i/libX11.a -o -f $i/libX11.${shlibext}; then
87         if test ! x"${i}" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
88           ac_cv_path_x11_lib="-L$i -lX11"
89         else
90           ac_cv_path_x11_lib="-lX11"
91         fi
92         if test -f $i/libXinerama.a -o -f $i/libXinerama.${shlibext}; then
93           ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lXinerama"
94         fi
95         if test -f $i/libXext.a -o -f $i/libXext.${shlibext}; then
96           ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lXext"
97         fi
98         if test -f $i/libSM.a -o -f $i/libSM.${shlibext}; then
99           ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lSM"
100         fi
101         if test -f $i/libICE.a -o -f $i/libICE.${shlibext}; then
102           ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lICE"
103         fi
104         if test -f $i/libXv.a -o -f $i/libXv.${shlibext}; then
105           ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lXv"
106           xv_lib=yes
107         fi
108         break
109       fi
110     done
111   fi
113   for i in $newlist; do
114     if test -f $i/libXplugin.a -o -f $i/libXplugin.${shlibext}; then
115       if test ! x"${i}" = x"/usr/lib" -o x"$i" = x"/usr/lib64"; then
116         ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -L$i -lXplugin"
117       else
118         ac_cv_path_x11_lib="${ac_cv_path_x11_lib} -lXplugin"
119       fi
120       break
121     fi
122   done
124   if test x"${ac_cv_path_x11_lib}" = x ; then
125     AC_CHECK_LIB(X11, x11_mem_init, [ac_cv_path_x11_lib=""])
126   fi
128   AC_MSG_CHECKING([for X11 library])
129   if test x"${ac_cv_path_x11_lib}" != x ; then
130     X11_LIBS="${ac_cv_path_x11_lib}"
131     AC_MSG_RESULT(${ac_cv_path_x11_lib})
132     has_x11=yes
133   else
134     X11_LIBS=""
135     AC_MSG_RESULT(none)
136   fi
138   if test "x$has_x11" = xyes; then
139     AC_DEFINE(HAVE_X11, [1], [X11 headers and libraries])
140   fi
141   
142   if test x"$xv_incl" != x -a x"$xv_lib" != x; then
143     AC_DEFINE(HAVE_XV, [1], [X Video extension header and library])
144   fi
145   AM_CONDITIONAL(HAVE_XV, [ test x"$xv_incl" != x -a x"$xv_lib" != x ])
147   AC_SUBST(X11_CFLAGS)
148   AC_SUBST(X11_LIBS)
151 # Local Variables:
152 # c-basic-offset: 2
153 # tab-width: 2
154 # indent-tabs-mode: nil
155 # End: