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