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