Subject: [PATCH] Problem with gettext on Debian Linux
To: None <tech-pkg@netbsd.org>
From: Eric Gillespie <epg@netbsd.org>
List: tech-pkg
Date: 04/16/2005 18:41:13
This is an old problem, but today i finally had the time and
inclination to look into it.  It's possible it only manifests
when the gettext tools are not installed, as they aren't on my
Debian systems (they're just way too old).

When installing devel/gettext, gettext-m4 and gettext-lib
successfully install, and then you get this error when make
returns to the gettext build:

===> Returning to build of gettext-0.11.5nb5
===> Required package libiconv>=1.9.1: NOT found
===> Verifying reinstall for ../../converters/libiconv
===> libiconv-1.9.2nb1 is not needed for Linux; it is included in GNU libc.

Oddly enough, if you now re-run make, it will properly see that
it doesn't need libiconv and go ahead with the build.  This is
because of all the iconv logic in gettext-lib/builtin.mk.  When
gettext-lib is installed, it correctly determines that you don't
need libiconv; when it's not installed, it mistakenly determines
that you do.  When starting at devel/gettext, with no gettext
packages installed at all, you get the latter case.

Maybe the solution is to fix all the iconv stuff in
gettext-lib/builtin.mk, but i can't make a dent in it.
Furthermore, it seems completely wrong that
gettext-lib/builtin.mk try to decide whether or not to use the
builtin iconv.  That's libiconv/builtin.mk's job, and it already
does it correctly.

This seems to have its origins in r1.17 of
gettext-lib/buildlink2.mk.  I suppose the point of this was not
to pull in iconv when not built-in unless newer gettext (that
needs iconv) is being used, but hopefully by now we're
comfortable just pulling it in.  gettext has needed it since
0.10.36 four years ago, after all.

So, i propose removing all the iconv stuff from
gettext-lib/builtin.mk and simply including
libiconv/buildlink3.mk in gettext-lib/buildlink3.mk.

Index: buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/gettext-lib/buildlink3.mk,v
retrieving revision 1.21
diff -a -u -r1.21 buildlink3.mk
--- buildlink3.mk	3 Oct 2004 00:13:27 -0000	1.21
+++ buildlink3.mk	16 Apr 2005 22:29:53 -0000
@@ -16,7 +16,6 @@
 BUILDLINK_PKGSRCDIR.gettext?=	../../devel/gettext-lib
 .endif	# GETTEXT_BUILDLINK3_MK
 
-# libiconv/buildlink3.mk is included by gettext-lib/builtin.mk
-#.include "../../converters/libiconv/buildlink3.mk"
+.include "../../converters/libiconv/buildlink3.mk"
 
 BUILDLINK_DEPTH:=	${BUILDLINK_DEPTH:S/+$//}
Index: builtin.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/gettext-lib/builtin.mk,v
retrieving revision 1.17
diff -a -u -r1.17 builtin.mk
--- builtin.mk	11 Dec 2004 00:32:16 -0000	1.17
+++ builtin.mk	16 Apr 2005 22:29:53 -0000
@@ -37,10 +37,6 @@
 .  endif
 .endif	# IS_BUILTIN.gettext
 
-#.if defined(USE_BUILTIN.iconv) && !empty(USE_BUILTIN.iconv:M[nN][oO])
-#USE_BUILTIN.gettext=	no
-#.endif
-
 .if !defined(USE_BUILTIN.gettext)
 USE_BUILTIN.gettext?=	${IS_BUILTIN.gettext}
 PREFER.gettext?=		pkgsrc
@@ -82,7 +78,7 @@
 # XXX By default, assume the native gettext on Linux systems using GLIBC
 # XXX supports the GNU gettext API, and use it.
 # XXX
-.    if (${OPSYS} == "Linux") && exists(${_LIBICONV_H})
+.    if (${OPSYS} == "Linux")
 USE_BUILTIN.gettext!=	\
 	if ${GREP} -q "This file is part of the GNU C Library" ${_LIBINTL_H}; then \
 		${ECHO} "yes";						\
@@ -130,41 +126,6 @@
 ######################################################################
 .if !empty(USE_BUILTIN.gettext:M[nN][oO])
 _BLNK_LIBINTL=		-lintl
-#
-# Determine if we need to include the libiconv buildlink3.mk file.
-# We need to if we're using the pkgsrc gettext, and the version is
-# at least gettext>=0.11.5nb1.
-#
-_GETTEXT_ICONV_DEPENDS=	gettext-lib>=0.11.5nb1
-.  if !defined(_GETTEXT_NEEDS_ICONV)
-_GETTEXT_NEEDS_ICONV?=	no
-.    for _depend_ in ${BUILDLINK_DEPENDS.gettext}
-.      if !empty(_GETTEXT_NEEDS_ICONV:M[nN][oO])
-_GETTEXT_NEEDS_ICONV!=	\
-	if ${PKG_INFO} -qe '${_depend_}'; then				\
-		pkg=`${PKG_BEST_EXISTS} '${_depend_}'`;			\
-		if ${PKG_INFO} -qN "$$pkg" | ${GREP} -q "libiconv-[0-9]"; then \
-			${ECHO} "yes";					\
-		else							\
-			${ECHO} "no";					\
-		fi;							\
-	else								\
-		${ECHO} "yes";						\
-	fi
-.      endif
-.    endfor
-.  endif
-.  if !empty(_GETTEXT_NEEDS_ICONV:M[yY][eE][sS])
-.    for _mkfile_ in buildlink3.mk builtin.mk
-.      if exists(../../converters/libiconv/${_mkfile_})
-BUILDLINK_DEPTH:=	${BUILDLINK_DEPTH}+
-.        include "../../converters/libiconv/${_mkfile_}"
-BUILDLINK_DEPTH:=	${BUILDLINK_DEPTH:S/+$//}
-.      endif
-.    endfor
-BUILDLINK_DEPENDS.gettext+=	${_GETTEXT_ICONV_DEPENDS}
-_BLNK_LIBINTL+=			${BUILDLINK_LDADD.iconv}
-.  endif
 .endif
 
 BUILDLINK_LDADD.gettext?=	${_BLNK_LIBINTL}
@@ -174,7 +135,7 @@
 # "-lintl" to the linker command line.
 #
 # If BROKEN_GETTEXT_DETECTION is "yes", then automatically add "-lintl"
-# (and "-liconv" if necessary) to LIBS to workaround this brokenness.
+# to LIBS to workaround this brokenness.
 #
 # XXX Nowadays, most packages' GNU configure scripts correctly detect
 # XXX -lintl, so this should really default to "no", but we'll leave it