Add build system fallback to icu-config

Ubuntu doesn't (or didn't until recently?) ship icu pkg-config
files.  That's quite unfortunate.  Work around it.

Bug 57608 - ICU Detection fallback for non-pkgconfig systems
diff --git a/configure.ac b/configure.ac
index 061880f..c1d10b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,25 @@
 dnl ==========================================================================
 
 PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, have_icu=false)
+dnl Fallback to icu-config if ICU pkg-config files could not be found
+if test "$have_icu" != "true"; then
+	AC_PATH_PROG(icu_config, icu-config, no)
+	AC_MSG_CHECKING([for ICU by using icu-config fallback])
+	if test "$icu_config" != "no"; then
+		have_icu=true
+		# We don't use --cflags as this gives us a lot of things that we don't
+		# necessarily want, like debugging and optimization flags
+		# See man (1) icu-config for more info.
+		ICU_CFLAGS=`$icu_config --cppflags`
+		ICU_LIBS=`$icu_config --ldflags-libsonly`
+		AC_SUBST(ICU_CFLAGS)
+		AC_SUBST(ICU_LIBS)
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+	fi
+fi
+
 if $have_icu; then
 	CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
 	AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
@@ -182,6 +201,24 @@
 dnl ==========================================================================
 
 PKG_CHECK_MODULES(ICU_LE, icu-le icu-uc, have_icu_le=true, have_icu_le=false)
+dnl Fallback to icu-config if ICU pkg-config files could not be found
+if test "$have_icu_le" != "true"; then
+	AC_PATH_PROG(icu_config, icu-config, no)
+	AC_MSG_CHECKING([for ICU_LE by using icu-config fallback])
+	if test "$icu_config" != "no"; then
+		have_icu_le=true
+		# We don't use --cflags as this gives us a lot of things that we don't
+		# necessarily want, like debugging and optimization flags
+		# See man (1) icu-config for more info.
+		ICU_LE_CFLAGS=`$icu_config --cppflags`
+		ICU_LE_LIBS=`$icu_config --ldflags-libsonly --ldflags-layout`
+		AC_SUBST(ICU_LE_CFLAGS)
+		AC_SUBST(ICU_LE_LIBS)
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+	fi
+fi
 if $have_icu_le; then
 	AC_DEFINE(HAVE_ICU_LE, 1, [Have ICU Layout Engine library])
 fi