This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
Re: [Ready for test/1.5.0] libiconv & gettext (many)
- From: "Charles Wilson" <cygwin at cwilson dot fastmail dot fm>
- To: cygwin-apps at cygwin dot com
- Date: Wed, 16 Jul 2003 23:57:56 -0400
- Subject: Re: [Ready for test/1.5.0] libiconv & gettext (many)
Corinna Vinschen wrote:
> On Tue, Jul 15, 2003 at 08:42:04PM -0400, Charles Wilson wrote:
>
>>Real fix: figure out why sharutils thinks it needs access to that
>>variable, and use the public API to do the same thing. If possible.
>
>
> shar just uses the value to print it to stdout if the option
> --print-text-domain-dir is given.
>
> AFAICS, printing this value is even wrong. The correct value is the
> one returned by a former call to bindtextdomain(), right? So I'd
> guess the correct solution would be to store the return value of
> bindtextdomain() and to use this to print:
>
> localedir = bindtextdomain (PACKAGE, LOCALEDIR);
> ...
> puts (localedir);
>
> Am I right here? I had not much to do with libintl so far so please
> excuse my questions.
No, I think that actually SETS the localedir to the appropriate
subdirectory under the specified LOCALEDIR. You want to know where it
would look by *default*, so instead of (for instance) /usr/share/locale
[the value of _nl_default_dirname, you get
"LOCALEDIR/<domain>/PACKAGE.po"
Believe it or not, here's how gettext.exe determines the default value of
the localdir (under which there are languauge-secific subdirectories, etc
etc). This code snippet is from the section that generates the --help
output:
"...
Standard search directory: %s\n"),
getenv ("IN_HELP2MAN") == NULL ? LOCALEDIR : "@localedir@");
See that? It actually relies on autoconf to HARDCODE the correct value!
(But it doesn't illegally access dcigettext's _nl_default_dirname
variable) -- or it uses LOCALDIR, which is a define passed in via the
makefile (gcc -DLOCALEDIR=\"$(localedir)\" ...)
And, of course, in dcigettext, _nl_default_dirname[] itself is
initialized with
const char _nl_default_dirname[] = LOCALEDIR;
So it appears there really is no way to get this value, except by
accessing _nl_default_dirname.
But you don't know if it is there or not -- it might be _nl_... if the
gettext in question is part of the libc; or if you're using an external
library (like libintl or cygintl) then it might be libintl_nl_...
The only way to automatically figure this out is to, within configure,
piggyback on the internal variables set by the stuff from gettext.m4:
--- in configure.ac ---
if test "$gt_cv_func_gnugettext_lib" == yes; then
NL_DEFAULT_DIRNAME_VAR=_nl_default_dirname
else
NL_DEFAULT_DIRNAME_VAR=libintl_nl_default_dirname
fi
AC_SUBST([NL_DEFAULT_DIRNAME_VAR])
------------------------
--- in Makefile.am/.in ---
nl_default_dirname_var = @NL_DEFAULT_DIRNAME_VAR@
DEFS = -D_nl_default_dirname=$(nl_default_dirname_var) @DEFS@
--------------------------
BTW, the following is the configure.ac incantation that I use in order to
force NOT build and NOT link against the local intl/ directory:
AM_GNU_GETTEXT(external,[],[])
BUILD_INCLUDED_LIBINTL=no
USE_INCLUDED_LIBINTL=no
AC_SUBST(BUILD_INCLUDED_LIBINTL)
AC_SUBST(USE_INCLUDED_LIBINTL)
--Chuck
--
Charles Wilson
cygwin at removespam cwilson dot fastmail dot fm