-if test "x$enable_aspell" = "xyes" -a "x$have_iso_codes" != "xyes"; then
- AC_MSG_ERROR([You must have iso-codes with the iso-639 domain to use aspell.])
-fi
-
-if test "x$enable_aspell" != "xno" -a "x$have_iso_codes" = "xyes"; then
- AC_CHECK_LIB(aspell, aspell_speller_check,have_aspell=yes,have_aspell=no,)
-
- if test "x$have_aspell" = "xyes"; then
- AC_DEFINE(HAVE_ASPELL, 1, [Define if we have aspell])
- EMPATHY_LIBS="$EMPATHY_LIBS -laspell"
- else
- have_aspell=no
+if test "x$enable_spell" != "xno"; then
+ PKG_CHECK_MODULES(ENCHANT,
+ [
+ enchant >= $ENCHANT_REQUIRED,
+ iso-codes >= $ISO_CODES_REQUIRED
+ ], have_enchant="yes", have_enchant="no")
+
+ if test "x$have_enchant" = "xyes"; then
+ AC_MSG_CHECKING([whether iso-codes has iso-639 and iso-3166 domains])
+ if $PKG_CONFIG --variable=domains iso-codes | grep 639 > /dev/null && \
+ $PKG_CONFIG --variable=domains iso-codes | grep 3166 > /dev/null ; then
+ AC_DEFINE_UNQUOTED(ISO_CODES_PREFIX, ["`$PKG_CONFIG --variable=prefix iso-codes`"], [ISO codes prefix])
+ AC_DEFINE(HAVE_ENCHANT, 1, [Define if you have libenchant])
+ result=yes
+ else
+ result=no
+ have_enchant="no"
+ fi
+ AC_MSG_RESULT([$result])