changes autoconf ICU tests to report -DHAVE_ICU=1 as ICU_CPPFLAGS
[m4-moved-to-github.git] / ac_check_icu.m4
1 ##### http://autoconf-archive.cryp.to/ac_check_icu.html
2 #
3 # SYNOPSIS
4 #
5 #   AC_CHECK_ICU(version, action-if, action-if-not)
6 #
7 # DESCRIPTION
8 #
9 #   Defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS. See icu-config(1) man
10 #   page.
11 #
12 # LAST MODIFICATION
13 #
14 #   2005-09-20
15 #
16 # COPYLEFT
17 #
18 #   Copyright (c) 2005 Akos Maroy <darkeye@tyrell.hu>
19 #
20 #   Copying and distribution of this file, with or without
21 #   modification, are permitted in any medium without royalty provided
22 #   the copyright notice and this notice are preserved.
23
24 AC_DEFUN([AC_CHECK_ICU], [
25   succeeded=no
26
27   if test -z "$ICU_CONFIG"; then
28     AC_PATH_PROG(ICU_CONFIG, icu-config, no)
29   fi
30
31   if test "$ICU_CONFIG" = "no" ; then
32     echo "*** The icu-config script could not be found. Make sure it is"
33     echo "*** in your path, and that taglib is properly installed."
34     echo "*** Or see http://ibm.com/software/globalization/icu/"
35
36             # added 2007-04-27 Marc Cromme
37             HAVE_ICU=0
38             # end added
39   else
40     ICU_VERSION=`$ICU_CONFIG --version`
41     AC_MSG_CHECKING(for ICU >= $1)
42         VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
43         if test "$VERSION_CHECK" = "1" ; then
44             AC_MSG_RESULT(yes)
45             succeeded=yes
46
47             # added 2007-04-27 Marc Cromme
48             HAVE_ICU=1
49
50             AC_MSG_CHECKING(ICU_CPPFLAGS)
51             ICU_CPPFLAGS=`$ICU_CONFIG --cppflags`" -DHAVE_ICU=1"
52             AC_MSG_RESULT($ICU_CPPFLAGS)
53             # end added
54
55             AC_MSG_CHECKING(ICU_CFLAGS)
56             ICU_CFLAGS=`$ICU_CONFIG --cflags`
57             AC_MSG_RESULT($ICU_CFLAGS)
58
59             AC_MSG_CHECKING(ICU_CXXFLAGS)
60             ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
61             AC_MSG_RESULT($ICU_CXXFLAGS)
62
63             AC_MSG_CHECKING(ICU_LIBS)
64             ICU_LIBS=`$ICU_CONFIG --ldflags`
65             AC_MSG_RESULT($ICU_LIBS)
66         else
67             # added 2007-04-27 Marc Cromme
68             ICU_CPPFLAGS=""
69             # end added
70             ICU_CFLAGS=""
71             ICU_CXXFLAGS=""
72             ICU_LIBS=""
73             ## If we have a custom action on failure, don't print errors, but
74             ## do set a variable so people can do so.
75             ifelse([$3], ,echo "can't find ICU >= $1",)
76         fi
77
78         # added 2007-04-27 Marc Cromme
79         AC_SUBST(HAVE_ICU)
80         AC_SUBST(ICU_CPPFLAGS)
81         # end added
82         AC_SUBST(ICU_CFLAGS)
83         AC_SUBST(ICU_CXXFLAGS)
84         AC_SUBST(ICU_LIBS)
85   fi
86
87   if test $succeeded = yes; then
88      ifelse([$2], , :, [$2])
89   else
90      ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
91   fi
92 ])