Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gnulib-local / m4 / libcroco.m4
1 # libcroco.m4 serial 2 (gettext-0.17)
2 dnl Copyright (C) 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Bruno Haible.
8
9 AC_DEFUN([gl_LIBCROCO],
10 [
11   dnl libcroco depends on libglib.
12   AC_REQUIRE([gl_LIBGLIB])
13
14   AC_MSG_CHECKING([whether included libcroco is requested])
15   AC_ARG_WITH([included-libcroco],
16     [  --with-included-libcroco  use the libcroco included here],
17     [gl_cv_libcroco_force_included=$withval],
18     [gl_cv_libcroco_force_included=no])
19   AC_MSG_RESULT([$gl_cv_libcroco_force_included])
20
21   gl_cv_libcroco_use_included="$gl_cv_libcroco_force_included"
22   LIBCROCO=
23   LTLIBCROCO=
24   INCCROCO=
25   if test "$gl_cv_libcroco_use_included" != yes; then
26     dnl Figure out whether we can use a preinstalled libcroco-0.6, or have to
27     dnl use the included one.
28     AC_CACHE_VAL([gl_cv_libcroco], [
29       gl_cv_libcroco=no
30       gl_cv_LIBCROCO=
31       gl_cv_LTLIBCROCO=
32       gl_cv_INCCROCO=
33       gl_save_LIBS="$LIBS"
34       dnl Search for libcroco and define LIBCROCO_0_6, LTLIBCROCO_0_6 and
35       dnl INCCROCO_0_6 accordingly.
36       dnl Don't use croco-0.6-config nor pkg-config, since it doesn't work when
37       dnl cross-compiling or when the C compiler in use is different from the
38       dnl one that built the library.
39       AC_LIB_LINKFLAGS_BODY([croco-0.6], [glib-2.0])
40       LIBS="$gl_save_LIBS $LIBCROCO_0_6"
41       AC_TRY_LINK([#include <libcroco-config.h>],
42         [const char *version = LIBCROCO_VERSION; return !version;],
43         [gl_cv_libcroco=yes
44          gl_cv_LIBCROCO="$LIBCROCO_0_6"
45          gl_cv_LTLIBCROCO="$LTLIBCROCO_0_6"
46         ])
47       if test "$gl_cv_libcroco" != yes; then
48         gl_save_CPPFLAGS="$CPPFLAGS"
49         CPPFLAGS="$CPPFLAGS $INCCROCO_0_6"
50         AC_TRY_LINK([#include <libcroco-config.h>],
51           [const char *version = LIBCROCO_VERSION; return !version;],
52           [gl_cv_libcroco=yes
53            gl_cv_LIBCROCO="$LIBCROCO_0_6"
54            gl_cv_LTLIBCROCO="$LTLIBCROCO_0_6"
55            gl_cv_INCCROCO="$INCCROCO_0_6"
56           ])
57         if test "$gl_cv_libcroco" != yes; then
58           dnl Often the include files are installed in
59           dnl /usr/include/libcroco-0.6/libcroco.
60           AC_TRY_LINK([#include <libcroco-0.6/libcroco/libcroco-config.h>],
61             [const char *version = LIBCROCO_VERSION; return !version;],
62             [gl_ABSOLUTE_HEADER([libcroco-0.6/libcroco/libcroco-config.h])
63              libcroco_include_dir=`echo "$gl_cv_absolute_libcroco_0_6_libcroco_libcroco_config_h" | sed -e 's,.libcroco-config\.h$,,'`
64              if test -d "$libcroco_include_dir"; then
65                gl_cv_libcroco=yes
66                gl_cv_LIBCROCO="$LIBCROCO_0_6"
67                gl_cv_LTLIBCROCO="$LTLIBCROCO_0_6"
68                gl_cv_INCCROCO="-I$libcroco_include_dir"
69              fi
70             ])
71         fi
72         CPPFLAGS="$gl_save_CPPFLAGS"
73       fi
74       LIBS="$gl_save_LIBS"
75     ])
76     AC_MSG_CHECKING([for libcroco])
77     AC_MSG_RESULT([$gl_cv_libcroco])
78     if test $gl_cv_libcroco = yes; then
79       LIBCROCO="$gl_cv_LIBCROCO"
80       LTLIBCROCO="$gl_cv_LTLIBCROCO"
81       INCCROCO="$gl_cv_INCCROCO"
82     else
83       gl_cv_libcroco_use_included=yes
84     fi
85   fi
86   AC_SUBST([LIBCROCO])
87   AC_SUBST([LTLIBCROCO])
88   AC_SUBST([INCCROCO])
89   AC_MSG_CHECKING([whether to use the included libcroco])
90   AC_MSG_RESULT([$gl_cv_libcroco_use_included])
91
92   AM_CONDITIONAL([INCLUDED_LIBCROCO],
93     [test "$gl_cv_libcroco_use_included" = yes])
94 ])