From 37e70109a43634eabae4d44f593b74c6154b2e2f Mon Sep 17 00:00:00 2001
From: hniksic <devnull@localhost>
Date: Fri, 10 Oct 2003 06:02:56 -0700
Subject: [PATCH] [svn] Prefer gettext with explicitly linked libintl, so
 non-standard libintl's get picked up along with their includes.

---
 ChangeLog  |  6 ++++++
 aclocal.m4 | 21 +++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a150389e..c22d3479 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-10  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* aclocal.m4 (WGET_WITH_NLS): First check for gettext in libintl,
+	then use the libc version.  That way systems that get libintl.h
+	from /usr/local/include will get the matching gettext.
+
 2003-10-10  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* po/tr.po: Ditto.
diff --git a/aclocal.m4 b/aclocal.m4
index f55b502f..753ad2ab 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -278,14 +278,19 @@ AC_DEFUN(WGET_WITH_NLS,
 
       AC_CHECK_HEADERS(locale.h libintl.h)
 
-      AC_CHECK_FUNCS(gettext, [], [
-	AC_CHECK_LIB(intl, gettext, [
-          dnl gettext is in libintl; announce the fact manually.
-          LIBS="-lintl $LIBS"
-	  AC_DEFINE(HAVE_GETTEXT)
-        ], [
-	  AC_MSG_RESULT(
-	    [gettext not found; disabling NLS])
+      dnl Prefer gettext found in -lintl to the one in libc.
+      dnl Otherwise it can happen that we include libintl.h from
+      dnl /usr/local/lib, but fail to specify -lintl, which results in
+      dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
+      dnl not found at link-time.)
+
+      AC_CHECK_LIB(intl, gettext, [
+        dnl gettext is in libintl; announce the fact manually.
+        LIBS="-lintl $LIBS"
+	AC_DEFINE(HAVE_GETTEXT)
+      ], [
+        AC_CHECK_FUNCS(gettext, [], [
+          AC_MSG_RESULT([gettext not found; disabling NLS])
           HAVE_NLS=no
         ])
       ])