added ICU M4 macros for autoconf
[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   else
36     ICU_VERSION=`$ICU_CONFIG --version`
37     AC_MSG_CHECKING(for ICU >= $1)
38         VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
39         if test "$VERSION_CHECK" = "1" ; then
40             AC_MSG_RESULT(yes)
41             succeeded=yes
42
43             AC_MSG_CHECKING(ICU_CFLAGS)
44             ICU_CFLAGS=`$ICU_CONFIG --cflags`
45             AC_MSG_RESULT($ICU_CFLAGS)
46
47             AC_MSG_CHECKING(ICU_CXXFLAGS)
48             ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
49             AC_MSG_RESULT($ICU_CXXFLAGS)
50
51             AC_MSG_CHECKING(ICU_LIBS)
52             ICU_LIBS=`$ICU_CONFIG --ldflags`
53             AC_MSG_RESULT($ICU_LIBS)
54         else
55             ICU_CFLAGS=""
56             ICU_CXXFLAGS=""
57             ICU_LIBS=""
58             ## If we have a custom action on failure, don't print errors, but
59             ## do set a variable so people can do so.
60             ifelse([$3], ,echo "can't find ICU >= $1",)
61         fi
62
63         AC_SUBST(ICU_CFLAGS)
64         AC_SUBST(ICU_CXXFLAGS)
65         AC_SUBST(ICU_LIBS)
66   fi
67
68   if test $succeeded = yes; then
69      ifelse([$2], , :, [$2])
70   else
71      ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
72   fi
73 ])