2 dnl Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl 2011 Free Software Foundation, Inc.
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.
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 dnl Generic macros for finding and setting include-paths and library-path
20 dnl for packages. Implements GNASH_PKG_INCLUDES() and GNASH_PKG_LIBS().
24 dnl - always run AC_CHECK_HEADERS and AC_CHECK_LIB so that config.h end
25 dnl up with correct information about what's available and what not
26 dnl and every provided info is verified before acceptance.
28 dnl - Document the interface of the macro !!
31 AC_DEFUN([GNASH_PKG_INCLUDES],
33 pushdef([UP], translit([$1], [a-z], [A-Z]))dnl Uppercase
34 pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl Lowercase
35 pushdef([DASHDOWN], translit([$1], [A-Z_], [a-z-]))dnl Lowercase
36 pushdef([UPHEADER], translit([$2], [a-z./-], [A-Z___]))dnl Uppercase header
45 dnl Look for the header
46 if test x"${$1}" = x"yes"; then
47 AC_ARG_WITH($1_incl, AC_HELP_STRING([--with-$1-incl], [directory where $2 is]), with_$1_incl=${withval})
48 AC_CACHE_VAL(ac_cv_path_$1_incl, [
49 if test x"${with_$1_incl}" != x ; then
50 AC_MSG_CHECKING([for $2 header in specified directory])
51 if test -f ${with_$1_incl}/$2 ; then
52 ac_cv_path_$1_incl="-I`(cd ${with_$1_incl}; pwd)`"
56 AC_MSG_ERROR([${with_$1_incl} directory doesn't contain $2.])
62 if test x$cross_compiling = xno; then
63 if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_$1_incl}" = x; then
64 AC_MSG_CHECKING([for $2 header using pkg-config])
65 $PKG_CONFIG --exists [lib]DASHDOWN && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags [lib]DASHDOWN`"
66 $PKG_CONFIG --exists DASHDOWN[] && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags DASHDOWN[]`"
67 $PKG_CONFIG --exists lib$name && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags lib$name`"
68 $PKG_CONFIG --exists $name && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags $name`"
69 if test x"${ac_cv_path_$1_incl}" != x; then
70 AC_MSG_RESULT(${ac_cv_path_$1_incl})
73 AC_MSG_RESULT([not found])
76 if test x"${ac_cv_path_$1_incl}" = x; then
77 AC_PATH_PROG(UP[]_CONFIG, $1-config)
78 if test x"${UP[]_CONFIG}" != x; then
79 AC_MSG_CHECKING([for $2 header using $1-config])
80 ac_cv_path_$1_incl="`${UP[]_CONFIG} --cxxflags 2>/dev/null`"
81 if test x"${ac_cv_path_$1_incl}" = x; then
82 ac_cv_path_$1_incl="`${UP[]_CONFIG} --cflags 2>/dev/null`"
84 if test x"${ac_cv_path_$1_incl}" != x; then
85 AC_MSG_RESULT(${ac_cv_path_$1_incl})
88 AC_MSG_RESULT([not found])
94 dnl If the path hasn't been specified, go look for it.
95 if test x"${ac_cv_path_$1_incl}" = x; then
96 AC_CHECK_HEADER($2, [ac_cv_path_$1_incl=""; found_$1_incl="yes"], [
97 AC_CHECK_HEADER($1/$2, [ac_cv_path_$1_incl="-I/usr/include/$1"; found_$1_incl="yes"], [
98 AC_CHECK_HEADER($name/$2, [ac_cv_path_$1_incl="-I/usr/include/$name"; found_$1_incl="yes"], [
99 AC_CHECK_HEADER($2, [ac_cv_path_$1_incl="-I/usr/include/$2"; found_$1_incl="yes"], [
100 if test x"${ac_cv_path_$1_incl}" = x; then
101 for i in $incllist; do
102 if test -f $i/$name; then
104 if test x"$i" != x"/usr/include"; then
105 ac_cv_path_$1_incl="-I$i"
107 ac_cv_path_$1_incl=""
111 if test -f $i/$name/$2; then
113 ac_cv_path_$1_incl="-I$i/$name"
116 if test -f $i/$2; then
118 ac_cv_path_$1_incl="-I$i"
131 AC_MSG_CHECKING([for $2 header])
132 if test x"${found_$1_incl}" = "xyes"; then
134 dnl It seems we need to explicitly call AC_DEFINE as AC_CHECK_HEADER doesn't
135 dnl do this automatically. AC_CHECK_HEADERS (not the final S) would do it.
136 AC_DEFINE([HAVE_]UPHEADER, 1, [Define if you have the $2 header])
137 AC_MSG_RESULT(${ac_cv_path_$1_incl})
138 if test x"${ac_cv_path_$1_incl}" != x -a x"${ac_cv_path_$1_incl}" != x"-I/usr/include"; then
139 UP[]_CFLAGS="${ac_cv_path_$1_incl}"
144 AC_MSG_RESULT([not found])
147 AC_SUBST(UP[]_CFLAGS)
155 AC_DEFUN([GNASH_PKG_LIBS], dnl GNASH_PKG_LIBS(cairo, cairo_status, [cairo render library.])
157 pushdef([UP], translit([$1], [a-z], [A-Z]))dnl Uppercase
158 pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl Lowercase
159 pushdef([DASHDOWN], translit([$1], [A-Z_], [a-z-]))dnl Lowercase
164 if test x"${$1}" = x"yes" -a x"${found_$1_incl}" = "xyes"; then
165 dnl Look for the library
166 AC_ARG_WITH($1_lib, AC_HELP_STRING([--with-$1-lib], [directory where $1 library is]), with_$1_lib=${withval})
167 AC_CACHE_VAL(ac_cv_path_$1_lib,[
168 if test x"${with_$1_lib}" != x ; then
169 AC_MSG_CHECKING([for lib$1 library in specified directory])
170 if test -f ${with_$1_lib}/lib$name.a -o -f ${with_$1_lib}/lib$name.${shlibext}; then
171 tmp="`(cd ${with_$1_lib}; pwd)`"
172 ac_cv_path_$1_lib="-L${tmp} -l$name"
175 AC_MSG_ERROR([${with_$1_lib} directory doesn't contain library $name.])
181 dnl If the header doesn't exist, there is no point looking for the library.
182 if test x$cross_compiling = xno; then
183 if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_$1_lib}" = x; then
184 AC_MSG_CHECKING([for lib$1 library using pkg-config])
185 $PKG_CONFIG --exists [lib]DASHDOWN && ac_cv_path_$1_lib="`$PKG_CONFIG --libs [lib]DASHDOWN`"
186 $PKG_CONFIG --exists DASHDOWN && ac_cv_path_$1_lib="`$PKG_CONFIG --libs DASHDOWN`"
187 $PKG_CONFIG --exists lib$name && ac_cv_path_$1_lib="`$PKG_CONFIG --libs lib$name`"
188 $PKG_CONFIG --exists $name && ac_cv_path_$1_lib="`$PKG_CONFIG --libs $name`"
189 if test x"${ac_cv_path_$1_lib}" != x; then
190 AC_MSG_RESULT(${ac_cv_path_$1_lib})
193 AC_MSG_RESULT([not found])
196 if test x"${ac_cv_path_$1_lib}" = x; then
197 AC_PATH_PROG(UP[]_CONFIG, $1-config)
198 if test x"${UP[]_CONFIG}" != x; then
199 AC_MSG_CHECKING([for lib$1 library using $1-config])
200 ac_cv_path_$1_lib="`${UP[]_CONFIG} --libs`"
201 AC_MSG_RESULT(${ac_cv_path_$1_lib})
203 if test x"${ac_cv_path_$1_lib}" = x; then
209 if test x"${ac_manual}" != xyes -a x"${ac_cv_path_$1_lib}" = x; then
213 if test x"${ac_cv_path_$1_lib}" = x; then
216 for i in $libslist; do
217 if test -f $i/lib$1.a -o -f $i/lib$1.${shlibext}; then
218 if test -f "$i/lib$1.a" -o -f "$i/lib$1.${shlibext}"; then
219 if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
220 ac_cv_path_$1_lib="-L$i -l$1 $5"
222 ac_cv_path_$1_lib="-l$1 $5"
227 if test -f "$i/lib$name.a" -o -f "$i/lib$name.${shlibext}"; then
228 if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
229 ac_cv_path_$1_lib="-L$i -l$name $5"
231 ac_cv_path_$1_lib="-l$name $5"
240 if test x"${ac_cv_path_$1_lib}" = x ; then
241 AC_SEARCH_LIBS($2, $1 $name, [ac_cv_path_$1_lib="$LIBS $5"])
244 if test x"${ac_manual}" = xyes ; then
245 AC_MSG_CHECKING([for lib$1 library])
246 if test x"${ac_cv_path_$1_lib}" != x ; then
247 AC_MSG_RESULT(${ac_cv_path_$1_lib})
249 AC_MSG_RESULT([not found])
253 if test x"${ac_cv_path_$1_lib}" != x ; then
254 UP[]_LIBS="${ac_cv_path_$1_lib}"
268 dnl Example: GNASH_PKG_FIND(fltk, [FL_API.h], [fltk gui], fl_xmap, [], [-lfltk_gl])
269 AC_DEFUN([GNASH_PKG_FIND],
271 GNASH_PKG_INCLUDES($1, $2, $3, $5)
272 GNASH_PKG_LIBS($1, $4, $3, $5, $6)
278 # indent-tabs-mode: nil