2 dnl Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
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.
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 dnl Generic macros for finding and setting include-paths and library-path
19 dnl for packages. Implements GNASH_PKG_INCLUDES() and GNASH_PKG_LIBS().
23 dnl - always run AC_CHECK_HEADERS and AC_CHECK_LIB so that config.h end
24 dnl up with correct information about what's available and what not
25 dnl and every provided info is verified before acceptance.
27 dnl - Document the interface of the macro !!
30 AC_DEFUN([GNASH_PKG_INCLUDES],
32 pushdef([UP], translit([$1], [a-z], [A-Z]))dnl Uppercase
33 pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl Lowercase
34 pushdef([DASHDOWN], translit([$1], [A-Z_], [a-z-]))dnl Lowercase
35 pushdef([UPHEADER], translit([$2], [a-z./-], [A-Z___]))dnl Uppercase header
44 dnl Look for the header
45 if test x"${$1}" = x"yes"; then
46 AC_ARG_WITH($1_incl, AC_HELP_STRING([--with-$1-incl], [directory where $2 is]), with_$1_incl=${withval})
47 AC_CACHE_VAL(ac_cv_path_$1_incl, [
48 if test x"${with_$1_incl}" != x ; then
49 AC_MSG_CHECKING([for $2 header in specified directory])
50 if test -f ${with_$1_incl}/$2 ; then
51 ac_cv_path_$1_incl="-I`(cd ${with_$1_incl}; pwd)`"
55 AC_MSG_ERROR([${with_$1_incl} directory doesn't contain $2.])
61 if test x$cross_compiling = xno; then
62 if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_$1_incl}" = x; then
63 AC_MSG_CHECKING([for $2 header using pkg-config])
64 $PKG_CONFIG --exists [lib]DASHDOWN && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags [lib]DASHDOWN`"
65 $PKG_CONFIG --exists DASHDOWN[] && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags DASHDOWN[]`"
66 $PKG_CONFIG --exists lib$name && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags lib$name`"
67 $PKG_CONFIG --exists $name && ac_cv_path_$1_incl="`$PKG_CONFIG --cflags $name`"
68 if test x"${ac_cv_path_$1_incl}" != x; then
69 AC_MSG_RESULT(${ac_cv_path_$1_incl})
72 AC_MSG_RESULT([not found])
75 if test x"${ac_cv_path_$1_incl}" = x; then
76 AC_PATH_PROG(UP[]_CONFIG, $1-config)
77 if test x"${UP[]_CONFIG}" != x; then
78 AC_MSG_CHECKING([for $2 header using $1-config])
79 ac_cv_path_$1_incl="`${UP[]_CONFIG} --cxxflags 2>/dev/null`"
80 if test x"${ac_cv_path_$1_incl}" = x; then
81 ac_cv_path_$1_incl="`${UP[]_CONFIG} --cflags 2>/dev/null`"
83 if test x"${ac_cv_path_$1_incl}" != x; then
84 AC_MSG_RESULT(${ac_cv_path_$1_incl})
87 AC_MSG_RESULT([not found])
93 dnl If the path hasn't been specified, go look for it.
94 if test x"${ac_cv_path_$1_incl}" = x; then
95 AC_CHECK_HEADER($2, [ac_cv_path_$1_incl=""; found_$1_incl="yes"], [
96 AC_CHECK_HEADER($1/$2, [ac_cv_path_$1_incl="-I/usr/include/$1"; found_$1_incl="yes"], [
97 AC_CHECK_HEADER($name/$2, [ac_cv_path_$1_incl="-I/usr/include/$name"; found_$1_incl="yes"], [
98 AC_CHECK_HEADER($2, [ac_cv_path_$1_incl="-I/usr/include/$2"; found_$1_incl="yes"], [
99 if test x"${ac_cv_path_$1_incl}" = x; then
100 for i in $incllist; do
101 if test -f $i/$name; then
103 if test x"$i" != x"/usr/include"; then
104 ac_cv_path_$1_incl="-I$i"
106 ac_cv_path_$1_incl=""
110 if test -f $i/$name/$2; then
112 ac_cv_path_$1_incl="-I$i/$name"
115 if test -f $i/$2; then
117 ac_cv_path_$1_incl="-I$i"
130 AC_MSG_CHECKING([for $2 header])
131 if test x"${found_$1_incl}" = "xyes"; then
133 dnl It seems we need to explicitly call AC_DEFINE as AC_CHECK_HEADER doesn't
134 dnl do this automatically. AC_CHECK_HEADERS (not the final S) would do it.
135 AC_DEFINE([HAVE_]UPHEADER, 1, [Define if you have the $2 header])
136 AC_MSG_RESULT(${ac_cv_path_$1_incl})
137 if test x"${ac_cv_path_$1_incl}" != x -a x"${ac_cv_path_$1_incl}" != x"-I/usr/include"; then
138 UP[]_CFLAGS="${ac_cv_path_$1_incl}"
143 AC_MSG_RESULT([not found])
146 AC_SUBST(UP[]_CFLAGS)
154 AC_DEFUN([GNASH_PKG_LIBS], dnl GNASH_PKG_LIBS(cairo, cairo_status, [cairo render library.])
156 pushdef([UP], translit([$1], [a-z], [A-Z]))dnl Uppercase
157 pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl Lowercase
158 pushdef([DASHDOWN], translit([$1], [A-Z_], [a-z-]))dnl Lowercase
163 if test x"${$1}" = x"yes"; then
164 dnl Look for the library
165 AC_ARG_WITH($1_lib, AC_HELP_STRING([--with-$1-lib], [directory where $1 library is]), with_$1_lib=${withval})
166 AC_CACHE_VAL(ac_cv_path_$1_lib,[
167 if test x"${with_$1_lib}" != x ; then
168 AC_MSG_CHECKING([for lib$1 library in specified directory])
169 if test -f ${with_$1_lib}/lib$name.a -o -f ${with_$1_lib}/lib$name.${shlibext}; then
170 tmp="`(cd ${with_$1_lib}; pwd)`"
171 ac_cv_path_$1_lib="-L${tmp} -l$name"
174 AC_MSG_ERROR([${with_$1_lib} directory doesn't contain library $name.])
180 dnl If the header doesn't exist, there is no point looking for the library.
181 if test x$cross_compiling = xno; then
182 if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_$1_lib}" = x; then
183 AC_MSG_CHECKING([for lib$1 library using pkg-config])
184 $PKG_CONFIG --exists [lib]DASHDOWN && ac_cv_path_$1_lib="`$PKG_CONFIG --libs [lib]DASHDOWN`"
185 $PKG_CONFIG --exists DASHDOWN && ac_cv_path_$1_lib="`$PKG_CONFIG --libs DASHDOWN`"
186 $PKG_CONFIG --exists lib$name && ac_cv_path_$1_lib="`$PKG_CONFIG --libs lib$name`"
187 $PKG_CONFIG --exists $name && ac_cv_path_$1_lib="`$PKG_CONFIG --libs $name`"
188 if test x"${ac_cv_path_$1_lib}" != x; then
189 AC_MSG_RESULT(${ac_cv_path_$1_lib})
192 AC_MSG_RESULT([not found])
195 if test x"${ac_cv_path_$1_lib}" = x; then
196 AC_PATH_PROG(UP[]_CONFIG, $1-config)
197 if test x"${UP[]_CONFIG}" != x; then
198 AC_MSG_CHECKING([for lib$1 library using $1-config])
199 ac_cv_path_$1_lib="`${UP[]_CONFIG} --libs`"
200 AC_MSG_RESULT(${ac_cv_path_$1_lib})
202 if test x"${ac_cv_path_$1_lib}" = x; then
208 if test x"${ac_manual}" != xyes -a x"${ac_cv_path_$1_lib}" = x; then
212 if test x"${ac_cv_path_$1_lib}" = x; then
215 for i in $libslist; do
216 if test -f $i/lib$1.a -o -f $i/lib$1.${shlibext}; then
217 if test -f "$i/lib$1.a" -o -f "$i/lib$1.${shlibext}"; then
218 if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
219 ac_cv_path_$1_lib="-L$i -l$1 $5"
221 ac_cv_path_$1_lib="-l$1 $5"
226 if test -f "$i/lib$name.a" -o -f "$i/lib$name.${shlibext}"; then
227 if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
228 ac_cv_path_$1_lib="-L$i -l$name $5"
230 ac_cv_path_$1_lib="-l$name $5"
239 if test x"${ac_cv_path_$1_lib}" = x ; then
240 AC_SEARCH_LIBS($2, $1 $name, [ac_cv_path_$1_lib="$LIBS $5"])
243 if test x"${ac_manual}" = xyes ; then
244 AC_MSG_CHECKING([for lib$1 library])
245 if test x"${ac_cv_path_$1_lib}" != x ; then
246 AC_MSG_RESULT(${ac_cv_path_$1_lib})
248 AC_MSG_RESULT([not found])
252 if test x"${ac_cv_path_$1_lib}" != x ; then
253 UP[]_LIBS="${ac_cv_path_$1_lib}"
267 dnl Example: GNASH_PKG_FIND(fltk, [FL_API.h], [fltk gui], fl_xmap, [], [-lfltk_gl])
268 AC_DEFUN([GNASH_PKG_FIND],
270 GNASH_PKG_INCLUDES($1, $2, $3, $5)
271 GNASH_PKG_LIBS($1, $4, $3, $5, $6)
277 # indent-tabs-mode: nil