[v2,1/2] *: add modern gettext support

Message ID 20230926004300.1716711-3-arsen@aarsen.me
State New
Headers
Series Replace intl/ with out-of-tree GNU gettext |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed

Commit Message

Arsen Arsenović Sept. 26, 2023, 12:17 a.m. UTC
  ChangeLog:

	* .gitignore: Add '/gettext*'.
	* configure.ac (host_libs): Replace intl with gettext.
	(hbaseargs, bbaseargs, baseargs): Split baseargs into {h,b}baseargs.
	(skip_barg): New flag.  Skips appending current flag to bbaseargs.
	<library exemptions>: Exempt --with-libintl-{type,prefix} from
	target and build machine argument passing.
	* configure: Regenerate.
	* Makefile.def (host_modules): Replace intl module with gettext
	module.
	(configure-ld): Depend on configure-gettext.
	* Makefile.in: Regenerate.

config/ChangeLog:

	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
	* gettext.m4: Sync with gettext-0.22 (serial 77).
	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
	* iconv.m4: Sync with gettext-0.22 (serial 26).

gas/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.

gold/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.

gprof/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.

ld/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libctf/ChangeLog:

	* Makefile.am (SUBDIRS): Define to empty to suppress a check in
	Automake.
	* Makefile.in: Regenerate.
	* configure.ac (CTF_LIBADD): Use LTLIBINTL rather than LIBINTL.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

opcodes/ChangeLog:

	* aclocal.m4: Regenerate.
	* po/Make-in ($(srcdir)/$(PACKAGE).pot): Output to a .pot
	temporary file to suppress xgettext checking charset names.
	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
	* configure: Regenerate.

bfd/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
	* configure: Regenerate.

binutils/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.
---
 .gitignore               |   1 +
 Makefile.def             |  72 ++++----
 bfd/configure.ac         |   2 +-
 config/gettext-sister.m4 |  35 ++--
 config/gettext.m4        | 357 +++++++++++++++++----------------------
 config/iconv.m4          | 313 ++++++++++++++++++++++++++--------
 config/intlmacosx.m4     |  65 +++++++
 configure.ac             |  44 +++--
 gdb/acinclude.m4         |   3 +-
 gdbsupport/Makefile.am   |   5 +
 libctf/Makefile.am       |   5 +
 libctf/configure.ac      |   2 +-
 opcodes/configure.ac     |   2 +-
 13 files changed, 569 insertions(+), 337 deletions(-)
 create mode 100644 config/intlmacosx.m4
  

Comments

Kevin Buettner Sept. 26, 2023, 2:12 a.m. UTC | #1
On Tue, 26 Sep 2023 02:17:33 +0200
Arsen Arsenović via Binutils <binutils@sourceware.org> wrote:

>  gdb/acinclude.m4         |   3 +-
>  gdbsupport/Makefile.am   |   5 +
[...]
> diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
> index 173e40b440a..d505fbbb267 100644
> --- a/gdb/acinclude.m4
> +++ b/gdb/acinclude.m4
> @@ -235,7 +235,8 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
>    # always want our bfd.
>    CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
>    LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
> -  intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
> +  # LTLIBINTL because we use libtool as CC below.
> +  intl="$(echo "$LTLIBINTL" | sed 's,\$[[{(]top_builddir[)}]]/,,')"
>    LIBS="-lbfd -liberty $intl $LIBS"
>    CC="./libtool --quiet --mode=link $CC"
>    AC_CACHE_CHECK(
> diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
> index 00524e9a566..f1a641308fe 100644
> --- a/gdbsupport/Makefile.am
> +++ b/gdbsupport/Makefile.am
> @@ -20,6 +20,11 @@
>  AUTOMAKE_OPTIONS = no-dist foreign
>  ACLOCAL_AMFLAGS = -I . -I ../config
>  
> +# Suppress 'configure.ac: error: AM_GNU_GETTEXT used but SUBDIRS not defined'
> +# from Automake, as gdbsupport uses AM_GNU_GETTEXT through
> +# ZW_GNU_GETTEXT_SISTER_DIR, but doesn't have any translations (currently).
> +SUBDIRS =
> +
>  AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../gdb \
>      -I../gnulib/import -I$(srcdir)/../gnulib/import \
>      -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd \

The GDB portions look reasonable to me, so those parts are approved.  You'll
still need to get approval for all of the other areas though.

Approved-by: Kevin Buettner <kevinb@redhat.com> (GDB portions only.)
  
Jan Beulich Sept. 26, 2023, 7:03 a.m. UTC | #2
On 26.09.2023 02:17, Arsen Arsenović via Binutils wrote:
> ChangeLog:
> 
> 	* .gitignore: Add '/gettext*'.
> 	* configure.ac (host_libs): Replace intl with gettext.
> 	(hbaseargs, bbaseargs, baseargs): Split baseargs into {h,b}baseargs.
> 	(skip_barg): New flag.  Skips appending current flag to bbaseargs.
> 	<library exemptions>: Exempt --with-libintl-{type,prefix} from
> 	target and build machine argument passing.
> 	* configure: Regenerate.
> 	* Makefile.def (host_modules): Replace intl module with gettext
> 	module.
> 	(configure-ld): Depend on configure-gettext.
> 	* Makefile.in: Regenerate.
> 
> config/ChangeLog:
> 
> 	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
> 	* gettext.m4: Sync with gettext-0.22 (serial 77).
> 	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
> 	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
> 	* iconv.m4: Sync with gettext-0.22 (serial 26).
> 
> gas/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.
> 
> gold/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.
> 
> gprof/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.
> 
> ld/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.
> 
> libctf/ChangeLog:
> 
> 	* Makefile.am (SUBDIRS): Define to empty to suppress a check in
> 	Automake.
> 	* Makefile.in: Regenerate.
> 	* configure.ac (CTF_LIBADD): Use LTLIBINTL rather than LIBINTL.
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.
> 
> opcodes/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* po/Make-in ($(srcdir)/$(PACKAGE).pot): Output to a .pot
> 	temporary file to suppress xgettext checking charset names.
> 	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
> 	* configure: Regenerate.
> 
> bfd/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
> 	* configure: Regenerate.
> 
> binutils/ChangeLog:
> 
> 	* aclocal.m4: Regenerate.
> 	* configure: Regenerate.

May I please ask that a change like this come with a real description? The
ChangeLog entries certainly describe - purely mechanically - what is done
to the files, but to be honest I cannot really read out of the (large)
patch what the overall behavioral change is. I'm therefore only getting
the impression that you make gettext 0.22(?) a prereq to building binutils
and gdb. Which in turn may make it impossible to (easily) build either on
older systems (it would certainly limit [remove?] my ability to test 32-bit
builds of binutils, as the newer distros I use all only come in 64-bit
flavors; there may be ways to configure as 32-bit, but past experience has
shown that such is potentially fragile / only partially functioning).

Jan
  
Iain Sandoe Sept. 26, 2023, 7:54 a.m. UTC | #3
Hi Jan,

> On 26 Sep 2023, at 08:03, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 26.09.2023 02:17, Arsen Arsenović via Binutils wrote:
>> ChangeLog:
>> 
>> 	* .gitignore: Add '/gettext*'.
>> 	* configure.ac (host_libs): Replace intl with gettext.
>> 	(hbaseargs, bbaseargs, baseargs): Split baseargs into {h,b}baseargs.
>> 	(skip_barg): New flag.  Skips appending current flag to bbaseargs.
>> 	<library exemptions>: Exempt --with-libintl-{type,prefix} from
>> 	target and build machine argument passing.
>> 	* configure: Regenerate.
>> 	* Makefile.def (host_modules): Replace intl module with gettext
>> 	module.
>> 	(configure-ld): Depend on configure-gettext.
>> 	* Makefile.in: Regenerate.
>> 
>> config/ChangeLog:
>> 
>> 	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
>> 	* gettext.m4: Sync with gettext-0.22 (serial 77).
>> 	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
>> 	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
>> 	* iconv.m4: Sync with gettext-0.22 (serial 26).
>> 
>> gas/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
>> 
>> gold/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
>> 
>> gprof/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
>> 
>> ld/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
>> 
>> libctf/ChangeLog:
>> 
>> 	* Makefile.am (SUBDIRS): Define to empty to suppress a check in
>> 	Automake.
>> 	* Makefile.in: Regenerate.
>> 	* configure.ac (CTF_LIBADD): Use LTLIBINTL rather than LIBINTL.
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
>> 
>> opcodes/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* po/Make-in ($(srcdir)/$(PACKAGE).pot): Output to a .pot
>> 	temporary file to suppress xgettext checking charset names.
>> 	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
>> 	* configure: Regenerate.
>> 
>> bfd/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure.ac (SHARED_LIBADD): Use LTLIBINTL rather than LIBINTL.
>> 	* configure: Regenerate.
>> 
>> binutils/ChangeLog:
>> 
>> 	* aclocal.m4: Regenerate.
>> 	* configure: Regenerate.
> 
> May I please ask that a change like this come with a real description? The
> ChangeLog entries certainly describe - purely mechanically - what is done
> to the files, but to be honest I cannot really read out of the (large)
> patch what the overall behavioral change is. I'm therefore only getting
> the impression that you make gettext 0.22(?) a prereq to building binutils
> and gdb.

I’ll leave to Arsen to expand upon this ^

> Which in turn may make it impossible to (easily) build either on
> older systems (it would certainly limit [remove?] my ability to test 32-bit
> builds of binutils, as the newer distros I use all only come in 64-bit
> flavors; there may be ways to configure as 32-bit, but past experience has
> shown that such is potentially fragile / only partially functioning).

I have one datum at least:

In this context, gettext is a host library, so the concern is about the oldest,
least capable, hosts you might wish to support.

* AFAIU, if your host already has libintl installed you do not need to do
anything (unless you happen to want a newer version).

* My oldest (regularly-tested) 32b host is Darwin9 (2007):
 - it has no installed libintl
 - it is not even ELF.

Here:
 * if I do nothing, binutils builds without NLS support.
 * If I symlink (or copy) gettext 0.22 into the root source dir then it builds
along with the other sources and I get NLS support.

HTH (at least as some reassurance that we have tested in older environments)
Iain

$ LANG=ja_JP /opt/iains/i686-apple-darwin9/binutils-gdb-master/bin/objdump fff
使用法: /opt/iains/i686-apple-darwin9/binutils-gdb-master/bin/objdump <option(s)> <file(s)>
 オブジェクトファイル <file(s)> の情報を表示する
 下記のスイッチの中で最低一つは指定しなければいけません:
  
Arsen Arsenović Sept. 26, 2023, 2:44 p.m. UTC | #4
Hi,

Jan Beulich <jbeulich@suse.com> writes:

> May I please ask that a change like this come with a real description? The
> ChangeLog entries certainly describe - purely mechanically - what is done
> to the files, but to be honest I cannot really read out of the (large)
> patch what the overall behavioral change is.

Hopefully, none.  Building without gettext in-tree or on the system
should result in a working build with no localization, with gettext
in-tree and on the system it should result in the usage of the system
gettext, with gettext on the tree but _not_ on the system, it should
result in a new (static) copy being built and linked into the tools,
with working localization, and with no gettext in tree but in system
(either in libc or in libintl) should result in a localized build using
the system gettext facilities.

The behavior for the in-tree but also on the system case (e.g. building
with gettext in-tree on a GNU system) can be overridden with
--with-included-gettext (which is a configure flag for gettext-runtime,
and was a configure flag for intl/ before that).

I've updated the commit message to add:

> This patch updates gettext.m4 and related .m4 files and adds
> gettext-runtime as a gmp/mpfr/... style host library, allowing newer
> libintl to be used.
> 
> This patch /does not/ add build-time tools required for
> internationalizing (msgfmt et al), instead, it just updates the
> runtime library.  The result should be a distribution that acts
> exactly the same when a copy of gettext is present, and disables
> internationalization otherwise.
> 
> There should be no changes in behavior when gettext is included
> in-tree.  When gettext is not included in tree, nor available on the
> system, the programs will be built without localization.

I hope this clarifies it.

Would you like to see anything else in the description?

Apologies for not adding context initially, I've been finishing this
patch on-and-off for a long time (due to being quite busy), and so, what
context is and isn't present (and what is and isn't known) got lost on
me.

Jan Beulich <jbeulich@suse.com> writes:

> I'm therefore only getting the impression that you make gettext
> 0.22(?) a prereq to building binutils and gdb.

No, it's still optional.  0.22 is only a prerequisite for building
in-tree, otherwise, quite old versions of gettext from the system should
work, too.

> Which in turn may make it impossible to (easily) build either on older
> systems (it would certainly limit [remove?] my ability to test 32-bit
> builds of binutils, as the newer distros I use all only come in 64-bit
> flavors; there may be ways to configure as 32-bit, but past experience
> has shown that such is potentially fragile / only partially
> functioning).

A localized build should work fine on a 32-bit system (ISTR Iain testing
32-bit targets by dropping a copy of gettext in-tree, but don't quote me
on that).  A build of binutils or gdb (or gcc, for that matter) which
has a gettext/ tree included in the toplevel should behave as it does
today.

In any case, non-localized builds should always work.
  
Jan Beulich Sept. 27, 2023, 7:11 a.m. UTC | #5
On 26.09.2023 16:44, Arsen Arsenović wrote:
> Hi,
> 
> Jan Beulich <jbeulich@suse.com> writes:
> 
>> May I please ask that a change like this come with a real description? The
>> ChangeLog entries certainly describe - purely mechanically - what is done
>> to the files, but to be honest I cannot really read out of the (large)
>> patch what the overall behavioral change is.
> 
> Hopefully, none.  Building without gettext in-tree or on the system
> should result in a working build with no localization, with gettext
> in-tree and on the system it should result in the usage of the system
> gettext, with gettext on the tree but _not_ on the system, it should
> result in a new (static) copy being built and linked into the tools,
> with working localization, and with no gettext in tree but in system
> (either in libc or in libintl) should result in a localized build using
> the system gettext facilities.
> 
> The behavior for the in-tree but also on the system case (e.g. building
> with gettext in-tree on a GNU system) can be overridden with
> --with-included-gettext (which is a configure flag for gettext-runtime,
> and was a configure flag for intl/ before that).
> 
> I've updated the commit message to add:
> 
>> This patch updates gettext.m4 and related .m4 files and adds
>> gettext-runtime as a gmp/mpfr/... style host library, allowing newer
>> libintl to be used.
>>
>> This patch /does not/ add build-time tools required for
>> internationalizing (msgfmt et al), instead, it just updates the
>> runtime library.  The result should be a distribution that acts
>> exactly the same when a copy of gettext is present, and disables
>> internationalization otherwise.
>>
>> There should be no changes in behavior when gettext is included
>> in-tree.  When gettext is not included in tree, nor available on the
>> system, the programs will be built without localization.
> 
> I hope this clarifies it.
> 
> Would you like to see anything else in the description?

This looks sufficient to me, thanks. I don't feel qualified though to
approve the binutils side of the change, sorry. I merely wanted to make
sure there won't be sudden (and unmentioned) regressions as to where
binutils can(not) be built.

Jan
  
Arsen Arsenović Sept. 27, 2023, 1:06 p.m. UTC | #6
Jan Beulich <jbeulich@suse.com> writes:

> This looks sufficient to me, thanks. I don't feel qualified though to
> approve the binutils side of the change, sorry. I merely wanted to make
> sure there won't be sudden (and unmentioned) regressions as to where
> binutils can(not) be built.

It is important not to regress platform support, thank you for making
sure.

Have a lovely day!
  
Nick Clifton Sept. 27, 2023, 3:19 p.m. UTC | #7
Hi Arsen,

   This all looks good to me, and I can (and do) approve it for the
   Binutils parts of the patch.

Cheers
   Nick
  
Arsen Arsenović Sept. 27, 2023, 5:43 p.m. UTC | #8
Hi Nick,

Nick Clifton <nickc@redhat.com> writes:

> Hi Arsen,
>
>   This all looks good to me, and I can (and do) approve it for the
>   Binutils parts of the patch.

Thanks for the review.  I don't have push rights in binutils-gdb.git, so
I'll send you a patchset with an updated commit message (see
https://inbox.sourceware.org/864jjhrm73.fsf@aarsen.me/) off-list when
this patchset is reviewed on the GCC side also, so that you can push it.

> Cheers
>   Nick

Thanks again, have a lovely day.
  
Nick Clifton Sept. 28, 2023, 9:43 a.m. UTC | #9
Hi Arsen,

> Thanks for the review.  I don't have push rights in binutils-gdb.git, so
> I'll send you a patchset with an updated commit message (see
> https://inbox.sourceware.org/864jjhrm73.fsf@aarsen.me/) off-list when
> this patchset is reviewed on the GCC side also, so that you can push it.

That works for me.

Cheers
   Nick
  
Bruno Haible Sept. 29, 2023, 3:58 p.m. UTC | #10
Arsen Arsenović wrote:
> Building without gettext in-tree or on the system
> should result in a working build with no localization, with gettext
> in-tree and on the system it should result in the usage of the system
> gettext, with gettext on the tree but _not_ on the system, it should
> result in a new (static) copy being built and linked into the tools,
> with working localization, and with no gettext in tree but in system
> (either in libc or in libintl) should result in a localized build using
> the system gettext facilities.
> 
> The behavior for the in-tree but also on the system case (e.g. building
> with gettext in-tree on a GNU system) can be overridden with
> --with-included-gettext (which is a configure flag for gettext-runtime,
> and was a configure flag for intl/ before that).

This information is more intelligible when presented as a table. I think
the table is like this, right?

                 Situation                                 ||   Effect
                                                           ||
gettext  |  libintl  | libc has   |         Option         ||   Working
sources  | installed | *gettext() |--with-included-gettext || Localization
in-tree  | on system | functions  |                        ||
---------+-----------+------------+------------------------++----------------------
   -     |     -     |     -      |       (ignored)        ||     No
   -     |     -     |     Y      |       (ignored)        ||  Yes (libc)
   -     |     Y     |     -      |       (ignored)        ||  Yes (libintl)
   -     |     Y     |     Y      |       (ignored)        ||  Yes (libintl)
   Y     |     -     |     -      |           -            ||  Yes (static libintl)
   Y     |     -     |     -      |           Y            ||  Yes (static libintl)
   Y     |     -     |     Y      |           -            ||  Yes (libc)
   Y     |     -     |     Y      |           Y            ||  Yes (static libintl)
   Y     |     Y     |     -      |           -            ||  Yes (libintl)
   Y     |     Y     |     -      |           Y            ||  Yes (static libintl)
   Y     |     Y     |     Y      |           -            ||  Yes (libintl)
   Y     |     Y     |     Y      |           Y            ||  Yes (static libintl)
---------+-----------+------------+------------------------++----------------------

In all of these cases, the localization can be turned off through the
configure option --disable-nls or by the user, at runtime, by choosing the
"C" locale.

I would find it useful to add this table to the documentation or
at least as some internal comments.

Bruno
  
Arsen Arsenović Sept. 29, 2023, 4:27 p.m. UTC | #11
Bruno Haible <bruno@clisp.org> writes:

> Arsen Arsenović wrote:
>> Building without gettext in-tree or on the system
>> should result in a working build with no localization, with gettext
>> in-tree and on the system it should result in the usage of the system
>> gettext, with gettext on the tree but _not_ on the system, it should
>> result in a new (static) copy being built and linked into the tools,
>> with working localization, and with no gettext in tree but in system
>> (either in libc or in libintl) should result in a localized build using
>> the system gettext facilities.
>> 
>> The behavior for the in-tree but also on the system case (e.g. building
>> with gettext in-tree on a GNU system) can be overridden with
>> --with-included-gettext (which is a configure flag for gettext-runtime,
>> and was a configure flag for intl/ before that).
>
> This information is more intelligible when presented as a table. I think
> the table is like this, right?
>
>                  Situation                                 ||   Effect
>                                                            ||
> gettext  |  libintl  | libc has   |         Option         ||   Working
> sources  | installed | *gettext() |--with-included-gettext || Localization
> in-tree  | on system | functions  |                        ||
> ---------+-----------+------------+------------------------++----------------------
>    -     |     -     |     -      |       (ignored)        ||     No
>    -     |     -     |     Y      |       (ignored)        ||  Yes (libc)
>    -     |     Y     |     -      |       (ignored)        ||  Yes (libintl)
>    -     |     Y     |     Y      |       (ignored)        ||  Yes (libintl)
>    Y     |     -     |     -      |           -            ||  Yes (static libintl)
>    Y     |     -     |     -      |           Y            ||  Yes (static libintl)
>    Y     |     -     |     Y      |           -            ||  Yes (libc)
>    Y     |     -     |     Y      |           Y            ||  Yes (static libintl)
>    Y     |     Y     |     -      |           -            ||  Yes (libintl)
>    Y     |     Y     |     -      |           Y            ||  Yes (static libintl)
>    Y     |     Y     |     Y      |           -            ||  Yes (libintl)
>    Y     |     Y     |     Y      |           Y            ||  Yes (static libintl)
> ---------+-----------+------------+------------------------++----------------------
>
> In all of these cases, the localization can be turned off through the
> configure option --disable-nls or by the user, at runtime, by choosing the
> "C" locale.
>
> I would find it useful to add this table to the documentation or
> at least as some internal comments.

Indeed, it feels like tabular data.  I'm unsure what the proper place
for inclusion of this information is for the binutils-gdb tree (but
I'll see about adding it to gcc/doc/install.texi shortly).

Any suggestions?
  
Kévin Le Gouguec Nov. 20, 2023, 4:42 p.m. UTC | #12
Hello!

Do I understand correctly that this patch, committed as

  2023-11-15 "Finalized intl-update patches" (862776f26a5)

specifically the bits quoted below, remove the support for in-tree
libiconv introduced in

  2015-08-24 "Missing parts of fixes for in-tree libiconv" (cfe101c6a82)

?  If so, was this intentional?

Arsen Arsenović <arsen@aarsen.me> writes:

> […]
> config/ChangeLog:
>
> 	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
> 	* gettext.m4: Sync with gettext-0.22 (serial 77).
> 	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
> 	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
> 	* iconv.m4: Sync with gettext-0.22 (serial 26).
> […]
> diff --git a/config/iconv.m4 b/config/iconv.m4
> index f1e54c5aedc..ff5d5261139 100644
> --- a/config/iconv.m4
> +++ b/config/iconv.m4
> […]
> -    CPPFLAGS="$am_save_CPPFLAGS"
> -
> -    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
> -      for _libs in .libs _libs; do
> -        am_save_CPPFLAGS="$CPPFLAGS"
> -        am_save_LIBS="$LIBS"
> -        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
> -        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
> -        AC_TRY_LINK([#include <stdlib.h>
> -#include <iconv.h>],
> -          [iconv_t cd = iconv_open("","");
> +    AC_LINK_IFELSE(
> +      [AC_LANG_PROGRAM(
> +         [[
> +#include <stdlib.h>
> +#include <iconv.h>
> +         ]],
> +         [[iconv_t cd = iconv_open("","");
>             iconv(cd,NULL,NULL,NULL,NULL);
> -           iconv_close(cd);],
> -          INCICONV="-I../libiconv/include"
> -          LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
> -          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
> -          am_cv_lib_iconv=yes
> -          am_cv_func_iconv=yes)
> -        CPPFLAGS="$am_save_CPPFLAGS"
> -        LIBS="$am_save_LIBS"
> -        if test "$am_cv_func_iconv" = "yes"; then
> -          break
> -        fi
> -      done
> -    fi
> -
> […]
  
Arsen Arsenović Nov. 20, 2023, 8:30 p.m. UTC | #13
Kévin Le Gouguec <legouguec@adacore.com> writes:

> Hello!
>
> Do I understand correctly that this patch, committed as
>
>   2023-11-15 "Finalized intl-update patches" (862776f26a5)
>
> specifically the bits quoted below, remove the support for in-tree
> libiconv introduced in
>
>   2015-08-24 "Missing parts of fixes for in-tree libiconv" (cfe101c6a82)
>
> ?  If so, was this intentional?

It was not.  I did not realize that the in-tree iconv.m4 was modified,
and simply updated it.

Bruno, should these modifications just be restored, or do you think
there's some preferable way to add sibling libiconv discovery?  I am
fine with either.

> Arsen Arsenović <arsen@aarsen.me> writes:
>
>> […]
>> config/ChangeLog:
>>
>> 	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
>> 	* gettext.m4: Sync with gettext-0.22 (serial 77).
>> 	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
>> 	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
>> 	* iconv.m4: Sync with gettext-0.22 (serial 26).
>> […]
>> diff --git a/config/iconv.m4 b/config/iconv.m4
>> index f1e54c5aedc..ff5d5261139 100644
>> --- a/config/iconv.m4
>> +++ b/config/iconv.m4
>> […]
>> -    CPPFLAGS="$am_save_CPPFLAGS"
>> -
>> -    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
>> -      for _libs in .libs _libs; do
>> -        am_save_CPPFLAGS="$CPPFLAGS"
>> -        am_save_LIBS="$LIBS"
>> -        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
>> -        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
>> -        AC_TRY_LINK([#include <stdlib.h>
>> -#include <iconv.h>],
>> -          [iconv_t cd = iconv_open("","");
>> +    AC_LINK_IFELSE(
>> +      [AC_LANG_PROGRAM(
>> +         [[
>> +#include <stdlib.h>
>> +#include <iconv.h>
>> +         ]],
>> +         [[iconv_t cd = iconv_open("","");
>>             iconv(cd,NULL,NULL,NULL,NULL);
>> -           iconv_close(cd);],
>> -          INCICONV="-I../libiconv/include"
>> -          LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
>> -          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
>> -          am_cv_lib_iconv=yes
>> -          am_cv_func_iconv=yes)
>> -        CPPFLAGS="$am_save_CPPFLAGS"
>> -        LIBS="$am_save_LIBS"
>> -        if test "$am_cv_func_iconv" = "yes"; then
>> -          break
>> -        fi
>> -      done
>> -    fi
>> -
>> […]
  
Bruno Haible Nov. 20, 2023, 9:28 p.m. UTC | #14
Hi Arsen,
> >   2015-08-24 "Missing parts of fixes for in-tree libiconv" (cfe101c6a82)
> ...
> Bruno, should these modifications just be restored, or do you think
> there's some preferable way to add sibling libiconv discovery?  I am
> fine with either.

As libiconv does not have a 'uninstalled-config.sh.in' script like
gettext-runtime has, the simplest solution is to just restore the modifications
(i.e. upgrade to the gnulib iconv.m4 + said modifications).

Bruno
  

Patch

diff --git a/.gitignore b/.gitignore
index d44f60295d0..716271029ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -72,3 +72,4 @@  stamp-*
 /mpc*
 /gmp*
 /isl*
+/gettext*
diff --git a/Makefile.def b/Makefile.def
index 870150183b9..db081951f13 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -74,8 +74,14 @@  host_modules= { module= isl; lib_path=.libs; bootstrap=true;
 host_modules= { module= gold; bootstrap=true; };
 host_modules= { module= gprof; };
 host_modules= { module= gprofng; };
-// intl acts on 'host_shared' directly, and does not support --with-pic.
-host_modules= { module= intl; bootstrap=true; };
+host_modules= { module= gettext; bootstrap=true; no_install=true;
+                module_srcdir= "gettext/gettext-runtime";
+		// We always build gettext with pic, because some packages (e.g. gdbserver)
+		// need it in some configuratons, which is determined via nontrivial tests.
+		// Always enabling pic seems to make sense for something tied to
+		// user-facing output.
+                extra_configure_flags='--disable-shared --disable-java --disable-csharp --with-pic';
+                lib_path=intl/.libs; };
 host_modules= { module= tcl;
                 missing=mostlyclean; };
 host_modules= { module= itcl; };
@@ -345,7 +351,7 @@  dependencies = { module=all-build-fixincludes; on=all-build-libiberty; };
 dependencies = { module=all-build-libcpp; on=all-build-libiberty; };
 
 // Host modules specific to gcc.
-dependencies = { module=configure-gcc; on=configure-intl; };
+dependencies = { module=configure-gcc; on=configure-gettext; };
 dependencies = { module=configure-gcc; on=all-gmp; };
 dependencies = { module=configure-gcc; on=all-mpfr; };
 dependencies = { module=configure-gcc; on=all-mpc; };
@@ -357,7 +363,7 @@  dependencies = { module=configure-gcc; on=all-ld; };
 dependencies = { module=configure-gcc; on=all-gold; };
 dependencies = { module=configure-gcc; on=all-libiconv; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
-dependencies = { module=all-gcc; on=all-intl; };
+dependencies = { module=all-gcc; on=all-gettext; };
 dependencies = { module=all-gcc; on=all-mpfr; };
 dependencies = { module=all-gcc; on=all-mpc; };
 dependencies = { module=all-gcc; on=all-isl; };
@@ -386,10 +392,10 @@  dependencies = { module=install-strip-gcc ; on=install-strip-fixincludes; };
 dependencies = { module=install-strip-gcc ; on=install-strip-lto-plugin; };
 
 dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
-dependencies = { module=configure-libcpp; on=configure-intl; };
+dependencies = { module=configure-libcpp; on=configure-gettext; };
 dependencies = { module=configure-libcpp; on=all-libiconv; };
 dependencies = { module=all-libcpp; on=all-libiberty; hard=true; };
-dependencies = { module=all-libcpp; on=all-intl; };
+dependencies = { module=all-libcpp; on=all-gettext; };
 dependencies = { module=all-libcpp; on=all-libiconv; };
 
 dependencies = { module=all-fixincludes; on=all-libiberty; };
@@ -411,16 +417,16 @@  dependencies = { module=all-gotools; on=all-target-libgo; };
 
 dependencies = { module=all-utils; on=all-libiberty; };
 
-dependencies = { module=configure-intl; on=all-libiconv; };
+dependencies = { module=configure-gettext; on=all-libiconv; };
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
 dependencies = { module=configure-isl; on=all-gmp; };
-dependencies = { module=all-intl; on=all-libiconv; };
+dependencies = { module=all-gettext; on=all-libiconv; };
 
 // Host modules specific to gdb.
 dependencies = { module=configure-gdb; on=all-gmp; };
 dependencies = { module=configure-gdb; on=all-mpfr; };
-dependencies = { module=configure-gdb; on=all-intl; };
+dependencies = { module=configure-gdb; on=all-gettext; };
 dependencies = { module=configure-gdb; on=configure-sim; };
 dependencies = { module=configure-gdb; on=all-bfd; };
 dependencies = { module=configure-gdb; on=all-gnulib; };
@@ -454,17 +460,17 @@  dependencies = { module=all-libgui; on=all-tk; };
 dependencies = { module=all-libgui; on=all-itcl; };
 
 dependencies = { module=configure-gdbsupport; on=configure-gnulib; };
-dependencies = { module=configure-gdbsupport; on=configure-intl; };
+dependencies = { module=configure-gdbsupport; on=configure-gettext; };
 dependencies = { module=all-gdbsupport; on=all-gnulib; };
-dependencies = { module=all-gdbsupport; on=all-intl; };
+dependencies = { module=all-gdbsupport; on=all-gettext; };
 
 // Host modules specific to binutils.
 // build libsframe before bfd for encoder/decoder support for linking
 // SFrame sections
 dependencies = { module=configure-bfd; on=configure-libiberty; hard=true; };
-dependencies = { module=configure-bfd; on=configure-intl; };
+dependencies = { module=configure-bfd; on=configure-gettext; };
 dependencies = { module=all-bfd; on=all-libiberty; };
-dependencies = { module=all-bfd; on=all-intl; };
+dependencies = { module=all-bfd; on=all-gettext; };
 dependencies = { module=all-bfd; on=all-zlib; };
 dependencies = { module=all-bfd; on=all-libsframe; };
 dependencies = { module=configure-opcodes; on=configure-libiberty; hard=true; };
@@ -473,13 +479,13 @@  dependencies = { module=all-opcodes; on=all-libiberty; };
 // We must build gas before binutils, gprof, ld and gold to avoid race
 // condition in the prev-gcc/as script during bootstrap of combined tree
 // with GCC and binutils.  See PR gas/14899 for details.
-dependencies = { module=configure-binutils; on=configure-intl; };
+dependencies = { module=configure-binutils; on=configure-gettext; };
 dependencies = { module=all-binutils; on=all-libiberty; };
 dependencies = { module=all-binutils; on=all-opcodes; };
 dependencies = { module=all-binutils; on=all-bfd; };
 dependencies = { module=all-binutils; on=all-build-flex; };
 dependencies = { module=all-binutils; on=all-build-bison; };
-dependencies = { module=all-binutils; on=all-intl; };
+dependencies = { module=all-binutils; on=all-gettext; };
 dependencies = { module=all-binutils; on=all-gas; };
 dependencies = { module=all-binutils; on=all-libctf; };
 dependencies = { module=all-ld; on=all-libctf; };
@@ -508,51 +514,51 @@  dependencies = { module=configure-opcodes; on=configure-bfd; hard=true; };
 dependencies = { module=install-opcodes; on=install-bfd; };
 dependencies = { module=install-strip-opcodes; on=install-strip-bfd; };
 
-dependencies = { module=configure-gas; on=configure-intl; };
+dependencies = { module=configure-gas; on=configure-gettext; };
 dependencies = { module=all-gas; on=all-libiberty; };
 dependencies = { module=all-gas; on=all-opcodes; };
 dependencies = { module=all-gas; on=all-bfd; };
-dependencies = { module=all-gas; on=all-intl; };
-dependencies = { module=configure-gprof; on=configure-intl; };
+dependencies = { module=all-gas; on=all-gettext; };
+dependencies = { module=configure-gprof; on=configure-gettext; };
 dependencies = { module=all-gprof; on=all-libiberty; };
 dependencies = { module=all-gprof; on=all-bfd; };
 dependencies = { module=all-gprof; on=all-opcodes; };
-dependencies = { module=all-gprof; on=all-intl; };
+dependencies = { module=all-gprof; on=all-gettext; };
 dependencies = { module=all-gprof; on=all-gas; };
 
-dependencies = { module=configure-gprofng; on=configure-intl; };
+dependencies = { module=configure-gprofng; on=configure-gettext; };
 dependencies = { module=all-gprofng; on=all-libiberty; };
 dependencies = { module=all-gprofng; on=all-bfd; };
 dependencies = { module=all-gprofng; on=all-opcodes; };
-dependencies = { module=all-gprofng; on=all-intl; };
+dependencies = { module=all-gprofng; on=all-gettext; };
 dependencies = { module=all-gprofng; on=all-gas; };
 dependencies = { module=install-gprofng; on=install-opcodes; };
 dependencies = { module=install-gprofng; on=install-bfd; };
 
-dependencies = { module=configure-ld; on=configure-intl; };
+dependencies = { module=configure-ld; on=configure-gettext; };
 dependencies = { module=all-ld; on=all-libiberty; };
 dependencies = { module=all-ld; on=all-bfd; };
 dependencies = { module=all-ld; on=all-opcodes; };
 dependencies = { module=all-ld; on=all-build-bison; };
 dependencies = { module=all-ld; on=all-build-flex; };
-dependencies = { module=all-ld; on=all-intl; };
+dependencies = { module=all-ld; on=all-gettext; };
 dependencies = { module=all-ld; on=all-gas; };
 dependencies = { module=all-ld; on=all-binutils; };
 dependencies = { module=install-ld; on=install-gold; };
 dependencies = { module=install-strip-ld; on=install-strip-gold; };
-dependencies = { module=configure-gold; on=configure-intl; };
+dependencies = { module=configure-gold; on=configure-gettext; };
 dependencies = { module=all-gold; on=all-libiberty; };
-dependencies = { module=all-gold; on=all-intl; };
+dependencies = { module=all-gold; on=all-gettext; };
 dependencies = { module=all-gold; on=all-bfd; };
 dependencies = { module=all-gold; on=all-build-bison; };
 dependencies = { module=all-gold; on=all-gas; };
 dependencies = { module=check-gold; on=all-binutils; };
 dependencies = { module=check-gold; on=all-gas; };
 
-dependencies = { module=configure-opcodes; on=configure-intl; };
+dependencies = { module=configure-opcodes; on=configure-gettext; };
 dependencies = { module=all-opcodes; on=all-bfd; };
 dependencies = { module=all-opcodes; on=all-libiberty; };
-dependencies = { module=all-opcodes; on=all-intl; };
+dependencies = { module=all-opcodes; on=all-gettext; };
 
 // Other host modules in the 'src' repository.
 dependencies = { module=all-dejagnu; on=all-tcl; };
@@ -586,8 +592,8 @@  dependencies = { module=install-sid; on=install-tk; };
 dependencies = { module=install-strip-sid; on=install-strip-tk; };
 
 dependencies = { module=configure-sim; on=all-gnulib; };
-dependencies = { module=configure-sim; on=configure-intl; };
-dependencies = { module=all-sim; on=all-intl; };
+dependencies = { module=configure-sim; on=configure-gettext; };
+dependencies = { module=all-sim; on=all-gettext; };
 dependencies = { module=all-sim; on=all-libiberty; };
 dependencies = { module=all-sim; on=all-bfd; };
 dependencies = { module=all-sim; on=all-opcodes; };
@@ -602,7 +608,7 @@  dependencies = { module=all-libctf; on=all-bfd; };
 dependencies = { module=all-libctf; on=all-zlib; };
 // So that checking for ELF support in BFD from libctf configure is possible.
 dependencies = { module=configure-libctf; on=all-bfd; };
-dependencies = { module=configure-libctf; on=all-intl; };
+dependencies = { module=configure-libctf; on=all-gettext; };
 dependencies = { module=configure-libctf; on=all-zlib; };
 dependencies = { module=configure-libctf; on=all-libiconv; };
 dependencies = { module=check-libctf; on=all-ld; };
@@ -614,13 +620,13 @@  dependencies = { module=distclean-gnulib; on=distclean-gdb; };
 dependencies = { module=distclean-gnulib; on=distclean-gdbserver; };
 
 // Warning, these are not well tested.
-dependencies = { module=all-bison; on=all-intl; };
+dependencies = { module=all-bison; on=all-gettext; };
 dependencies = { module=all-bison; on=all-build-texinfo; };
 dependencies = { module=all-flex; on=all-build-bison; };
-dependencies = { module=all-flex; on=all-intl; };
+dependencies = { module=all-flex; on=all-gettext; };
 dependencies = { module=all-flex; on=all-m4; };
 dependencies = { module=all-flex; on=all-build-texinfo; };
-dependencies = { module=all-m4; on=all-intl; };
+dependencies = { module=all-m4; on=all-gettext; };
 dependencies = { module=all-m4; on=all-build-texinfo; };
 
 // Target modules.  These can also have dependencies on the language
diff --git a/bfd/configure.ac b/bfd/configure.ac
index d1e7e3a4bf3..a76bb5a1558 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -278,7 +278,7 @@  changequote([,])dnl
   fi
 fi
 
-SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
+SHARED_LIBADD="$SHARED_LIBADD $LTLIBINTL"
 
 if test "$enable_shared" = "yes"; then
   case "${host}" in
diff --git a/config/gettext-sister.m4 b/config/gettext-sister.m4
index e8e6b668416..5bb385fd0de 100644
--- a/config/gettext-sister.m4
+++ b/config/gettext-sister.m4
@@ -10,19 +10,30 @@ 
 # the necessary substitutions and definitions for this directory.
 
 AC_DEFUN([ZW_GNU_GETTEXT_SISTER_DIR],
-[# If we haven't got the data from the intl directory,
-# assume NLS is disabled.
-USE_NLS=no	AC_SUBST(USE_NLS)
-LIBINTL=	AC_SUBST(LIBINTL)
-LIBINTL_DEP=	AC_SUBST(LIBINTL_DEP)
-INCINTL=	AC_SUBST(INCINTL)
-XGETTEXT=	AC_SUBST(XGETTEXT)
-GMSGFMT=	AC_SUBST(GMSGFMT)
-POSUB=		AC_SUBST(POSUB)
-
-if test -f  ifelse([$1],,[../intl],[$1])/config.intl; then
-  .  ifelse([$1],,[../intl],[$1])/config.intl
+[
+m4_pushdef([gettext_builddir],
+           m4_default([$1], [../gettext]))
+m4_pushdef([gettext_cfg],
+           gettext_builddir[/uninstalled-config.sh])
+if test -f gettext_cfg; then
+  relative_builddir='[$(top_builddir)/]gettext_builddir'
+  .  gettext_cfg
+else
+  # The sister gettext directory doesn't exist and won't collect information on
+  # using gettext for us.  Call a bundled AM_GNU_GETTEXT.
+  AM_GNU_GETTEXT([external])
 fi
+m4_popdef([gettext_cfg])
+m4_popdef([gettext_builddir])
+
+AC_SUBST([USE_NLS])
+AC_SUBST([LIBINTL])
+AC_SUBST([LIBINTL_DEP])
+AC_SUBST([INCINTL])
+AC_SUBST([XGETTEXT])
+AC_SUBST([GMSGFMT])
+AC_SUBST([POSUB])
+
 AC_MSG_CHECKING([whether NLS is requested])
 if test x"$USE_NLS" != xyes; then
   AC_MSG_RESULT(no)
diff --git a/config/gettext.m4 b/config/gettext.m4
index 5b42bb16523..f4492405bd2 100644
--- a/config/gettext.m4
+++ b/config/gettext.m4
@@ -1,43 +1,39 @@ 
-# gettext.m4 serial 20 (gettext-0.12)
-dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
-dnl This file is free software, distributed under the terms of the GNU
-dnl General Public License.  As a special exception to the GNU General
-dnl Public License, this file may be distributed as part of a program
-dnl that contains a configuration script generated by Autoconf, under
-dnl the same distribution terms as the rest of that program.
+# gettext.m4 serial 72 (gettext-0.21.1)
+dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
 dnl
-dnl This file can can be used in projects which are not available under
-dnl the GNU General Public License or the GNU Library General Public
+dnl This file can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Lesser General Public
 dnl License but which still want to provide support for the GNU gettext
 dnl functionality.
 dnl Please note that the actual code of the GNU gettext library is covered
-dnl by the GNU Library General Public License, and the rest of the GNU
-dnl gettext package package is covered by the GNU General Public License.
+dnl by the GNU Lesser General Public License, and the rest of the GNU
+dnl gettext package is covered by the GNU General Public License.
 dnl They are *not* in the public domain.
 
 dnl Authors:
 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
-dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
 
 dnl Macro to add for using GNU gettext.
 
 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
-dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
-dnl    default (if it is not specified or empty) is 'no-libtool'.
-dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
-dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
+dnl INTLSYMBOL must be one of 'external', 'use-libtool'.
+dnl    INTLSYMBOL should be 'external' for packages other than GNU gettext, and
+dnl    'use-libtool' for the packages 'gettext-runtime' and 'gettext-tools'.
 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
-dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
-dnl    $(top_builddir)/intl/libintl.a will be created.
+dnl    AM-DISABLE-SHARED).
 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
 dnl    implementations (in libc or libintl) without the ngettext() function
 dnl    will be ignored.  If NEEDSYMBOL is specified and is
 dnl    'need-formatstring-macros', then GNU gettext implementations that don't
 dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
 dnl INTLDIR is used to find the intl libraries.  If empty,
-dnl    the value `$(top_builddir)/intl/' is used.
+dnl    the value '$(top_builddir)/intl/' is used.
 dnl
 dnl The result of the configuration is one of three cases:
 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
@@ -59,17 +55,22 @@  dnl
 AC_DEFUN([AM_GNU_GETTEXT],
 [
   dnl Argument checking.
-  ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
+  m4_if([$1], [], , [m4_if([$1], [external], , [m4_if([$1], [use-libtool], ,
     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
-])])])])])
-  ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
+])])])])
+  m4_if(m4_if([$1], [], [old])[]m4_if([$1], [no-libtool], [old]), [old],
+    [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported.
+])])
+  m4_if([$2], [], , [m4_if([$2], [need-ngettext], , [m4_if([$2], [need-formatstring-macros], ,
     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
 ])])])])
-  define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
-  define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
+  define([gt_included_intl],
+    m4_if([$1], [external], [no], [yes]))
+  gt_NEEDS_INIT
+  AM_GNU_GETTEXT_NEED([$2])
 
   AC_REQUIRE([AM_PO_SUBDIRS])dnl
-  ifelse(gt_included_intl, yes, [
+  m4_if(gt_included_intl, yes, [
     AC_REQUIRE([AM_INTL_SUBDIR])dnl
   ])
 
@@ -80,22 +81,24 @@  AC_DEFUN([AM_GNU_GETTEXT],
   dnl Sometimes libintl requires libiconv, so first search for libiconv.
   dnl Ideally we would do this search only after the
   dnl      if test "$USE_NLS" = "yes"; then
-  dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
-  dnl tests. But if configure.ac invokes AM_ICONV after AM_GNU_GETTEXT
+  dnl        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+  dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
   dnl the configure script would need to contain the same shell code
   dnl again, outside any 'if'. There are two solutions:
   dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
   dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
-  dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
-  dnl documented, we avoid it.
-  ifelse(gt_included_intl, yes, , [
+  dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it.
+  m4_if(gt_included_intl, yes, , [
     AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
   ])
 
+  dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
+  gt_INTL_MACOSX
+
   dnl Set USE_NLS.
-  AM_NLS
+  AC_REQUIRE([AM_NLS])
 
-  ifelse(gt_included_intl, yes, [
+  m4_if(gt_included_intl, yes, [
     BUILD_INCLUDED_LIBINTL=no
     USE_INCLUDED_LIBINTL=no
   ])
@@ -103,16 +106,25 @@  AC_DEFUN([AM_GNU_GETTEXT],
   LTLIBINTL=
   POSUB=
 
+  dnl Add a version number to the cache macros.
+  case " $gt_needs " in
+    *" need-formatstring-macros "*) gt_api_version=3 ;;
+    *" need-ngettext "*) gt_api_version=2 ;;
+    *) gt_api_version=1 ;;
+  esac
+  gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
+  gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
+
   dnl If we use NLS figure out what method
   if test "$USE_NLS" = "yes"; then
     gt_use_preinstalled_gnugettext=no
-    ifelse(gt_included_intl, yes, [
+    m4_if(gt_included_intl, yes, [
       AC_MSG_CHECKING([whether included gettext is requested])
-      AC_ARG_WITH(included-gettext,
+      AC_ARG_WITH([included-gettext],
         [  --with-included-gettext use the GNU gettext library included here],
         nls_cv_force_use_gnu_gettext=$withval,
         nls_cv_force_use_gnu_gettext=no)
-      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
+      AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
 
       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
@@ -121,13 +133,29 @@  AC_DEFUN([AM_GNU_GETTEXT],
         dnl to use.  If GNU gettext is available we use this.  Else we have
         dnl to fall back to GNU NLS library.
 
-        dnl Add a version number to the cache macros.
-        define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
-        define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
-        define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
+        if test $gt_api_version -ge 3; then
+          gt_revision_test_code='
+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
+#endif
+changequote(,)dnl
+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
+changequote([,])dnl
+'
+        else
+          gt_revision_test_code=
+        fi
+        if test $gt_api_version -ge 2; then
+          gt_expression_test_code=' + * ngettext ("", "", 0)'
+        else
+          gt_expression_test_code=
+        fi
 
-        AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
-         [AC_TRY_LINK([#include <libintl.h>
+        AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
+         [AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM(
+               [[
+#include <libintl.h>
 #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 extern int _nl_msg_cat_cntr;
 extern int *_nl_domain_bindings;
@@ -135,22 +163,18 @@  extern int *_nl_domain_bindings;
 #else
 #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
 #endif
-]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
-#endif
-changequote(,)dnl
-typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], []),
-            [bindtextdomain ("", "");
-return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + __GNU_GETTEXT_SYMBOL_EXPRESSION],
-            gt_cv_func_gnugettext_libc=yes,
-            gt_cv_func_gnugettext_libc=no)])
+$gt_revision_test_code
+               ]],
+               [[
+bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
+               ]])],
+            [eval "$gt_func_gnugettext_libc=yes"],
+            [eval "$gt_func_gnugettext_libc=no"])])
 
-        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
+        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
           dnl Sometimes libintl requires libiconv, so first search for libiconv.
-          ifelse(gt_included_intl, yes, , [
+          m4_if(gt_included_intl, yes, , [
             AM_ICONV_LINK
           ])
           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
@@ -159,65 +183,63 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
           dnl even if libiconv doesn't exist.
           AC_LIB_LINKFLAGS_BODY([intl])
           AC_CACHE_CHECK([for GNU gettext in libintl],
-            gt_cv_func_gnugettext_libintl,
+            [$gt_func_gnugettext_libintl],
            [gt_save_CPPFLAGS="$CPPFLAGS"
             CPPFLAGS="$CPPFLAGS $INCINTL"
             gt_save_LIBS="$LIBS"
             LIBS="$LIBS $LIBINTL"
             dnl Now see whether libintl exists and does not depend on libiconv.
-            AC_TRY_LINK([#include <libintl.h>
+            AC_LINK_IFELSE(
+              [AC_LANG_PROGRAM(
+                 [[
+#include <libintl.h>
 #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
 #endif
-const char *_nl_expand_alias ();
-#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (0))
+const char *_nl_expand_alias (const char *);
+#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
 #else
 #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
 #endif
-]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
-#endif
-changequote(,)dnl
-typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], []),
-              [bindtextdomain ("", "");
-return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + __GNU_GETTEXT_SYMBOL_EXPRESSION],
-              gt_cv_func_gnugettext_libintl=yes,
-              gt_cv_func_gnugettext_libintl=no)
+$gt_revision_test_code
+                 ]],
+                 [[
+bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
+                 ]])],
+              [eval "$gt_func_gnugettext_libintl=yes"],
+              [eval "$gt_func_gnugettext_libintl=no"])
             dnl Now see whether libintl exists and depends on libiconv.
-            if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
+            if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
               LIBS="$LIBS $LIBICONV"
-              AC_TRY_LINK([#include <libintl.h>
+              AC_LINK_IFELSE(
+                [AC_LANG_PROGRAM(
+                   [[
+#include <libintl.h>
 #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
 #endif
-const char *_nl_expand_alias ();
-#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (0))
+const char *_nl_expand_alias (const char *);
+#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
 #else
 #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
 #endif
-]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
-#endif
-changequote(,)dnl
-typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], []),
-                [bindtextdomain ("", "");
-return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + __GNU_GETTEXT_SYMBOL_EXPRESSION],
-               [LIBINTL="$LIBINTL $LIBICONV"
-                LTLIBINTL="$LTLIBINTL $LTLIBICONV"
-                gt_cv_func_gnugettext_libintl=yes
-               ])
+$gt_revision_test_code
+                   ]],
+                   [[
+bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
+                   ]])],
+                [LIBINTL="$LIBINTL $LIBICONV"
+                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
+                 eval "$gt_func_gnugettext_libintl=yes"
+                ])
             fi
             CPPFLAGS="$gt_save_CPPFLAGS"
             LIBS="$gt_save_LIBS"])
@@ -227,8 +249,8 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
         dnl use it.  But if this macro is used in GNU gettext, and GNU
         dnl gettext is already preinstalled in libintl, we update this
         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
-        if test "$gt_cv_func_gnugettext_libc" = "yes" \
-           || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
+        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
+           || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
                 && test "$PACKAGE" != gettext-runtime \
                 && test "$PACKAGE" != gettext-tools; }; then
           gt_use_preinstalled_gnugettext=yes
@@ -239,7 +261,7 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
           INCINTL=
         fi
 
-    ifelse(gt_included_intl, yes, [
+    m4_if(gt_included_intl, yes, [
         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
           dnl GNU gettext is not found in the C library.
           dnl Fall back on included GNU gettext library.
@@ -251,11 +273,12 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
         dnl Mark actions used to generate GNU NLS library.
         BUILD_INCLUDED_LIBINTL=yes
         USE_INCLUDED_LIBINTL=yes
-        LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
-        LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
+        LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
+        LTLIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD"
         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
       fi
 
+      CATOBJEXT=
       if test "$gt_use_preinstalled_gnugettext" = "yes" \
          || test "$nls_cv_use_gnu_gettext" = "yes"; then
         dnl Mark actions to use GNU gettext tools.
@@ -263,9 +286,18 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
       fi
     ])
 
+    if test -n "$INTL_MACOSX_LIBS"; then
+      if test "$gt_use_preinstalled_gnugettext" = "yes" \
+         || test "$nls_cv_use_gnu_gettext" = "yes"; then
+        dnl Some extra flags are needed during linking.
+        LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
+        LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
+      fi
+    fi
+
     if test "$gt_use_preinstalled_gnugettext" = "yes" \
        || test "$nls_cv_use_gnu_gettext" = "yes"; then
-      AC_DEFINE(ENABLE_NLS, 1,
+      AC_DEFINE([ENABLE_NLS], [1],
         [Define to 1 if translation of program messages to the user's native language
    is requested.])
     else
@@ -278,7 +310,7 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
   if test "$USE_NLS" = "yes"; then
     AC_MSG_CHECKING([where the gettext function comes from])
     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
-      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
+      if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
         gt_source="external libintl"
       else
         gt_source="libc"
@@ -292,16 +324,16 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
   if test "$USE_NLS" = "yes"; then
 
     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
-      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
+      if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
         AC_MSG_CHECKING([how to link with libintl])
         AC_MSG_RESULT([$LIBINTL])
         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
       fi
 
       dnl For backward compatibility. Some packages may be using this.
-      AC_DEFINE(HAVE_GETTEXT, 1,
+      AC_DEFINE([HAVE_GETTEXT], [1],
        [Define if the GNU gettext() function is already present or preinstalled.])
-      AC_DEFINE(HAVE_DCGETTEXT, 1,
+      AC_DEFINE([HAVE_DCGETTEXT], [1],
        [Define if the GNU dcgettext() function is already present or preinstalled.])
     fi
 
@@ -309,125 +341,46 @@  return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
     POSUB=po
   fi
 
-  ifelse(gt_included_intl, yes, [
-    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
-    dnl to 'yes' because some of the testsuite requires it.
-    if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
-      BUILD_INCLUDED_LIBINTL=yes
-    fi
+  m4_if(gt_included_intl, yes, [
+    dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes'
+    dnl because some of the testsuite requires it.
+    BUILD_INCLUDED_LIBINTL=yes
 
     dnl Make all variables we use known to autoconf.
-    AC_SUBST(BUILD_INCLUDED_LIBINTL)
-    AC_SUBST(USE_INCLUDED_LIBINTL)
-    AC_SUBST(CATOBJEXT)
-
-    dnl For backward compatibility. Some configure.acs may be using this.
-    nls_cv_header_intl=
-    nls_cv_header_libgt=
-
-    dnl For backward compatibility. Some Makefiles may be using this.
-    DATADIRNAME=share
-    AC_SUBST(DATADIRNAME)
-
-    dnl For backward compatibility. Some Makefiles may be using this.
-    INSTOBJEXT=.mo
-    AC_SUBST(INSTOBJEXT)
-
-    dnl For backward compatibility. Some Makefiles may be using this.
-    GENCAT=gencat
-    AC_SUBST(GENCAT)
-
-    dnl For backward compatibility. Some Makefiles may be using this.
-    if test "$USE_INCLUDED_LIBINTL" = yes; then
-      INTLOBJS="\$(GETTOBJS)"
-    fi
-    AC_SUBST(INTLOBJS)
-
-    dnl Enable libtool support if the surrounding package wishes it.
-    INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
-    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
+    AC_SUBST([BUILD_INCLUDED_LIBINTL])
+    AC_SUBST([USE_INCLUDED_LIBINTL])
+    AC_SUBST([CATOBJEXT])
   ])
 
   dnl For backward compatibility. Some Makefiles may be using this.
   INTLLIBS="$LIBINTL"
-  AC_SUBST(INTLLIBS)
+  AC_SUBST([INTLLIBS])
 
   dnl Make all documented variables known to autoconf.
-  AC_SUBST(LIBINTL)
-  AC_SUBST(LTLIBINTL)
-  AC_SUBST(POSUB)
+  AC_SUBST([LIBINTL])
+  AC_SUBST([LTLIBINTL])
+  AC_SUBST([POSUB])
 ])
 
 
-dnl Checks for all prerequisites of the intl subdirectory,
-dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
-dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
-AC_DEFUN([AM_INTL_SUBDIR],
+dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
+m4_define([gt_NEEDS_INIT],
 [
-  AC_REQUIRE([AC_PROG_INSTALL])dnl
-  AC_REQUIRE([AM_MKINSTALLDIRS])dnl
-  AC_REQUIRE([AC_PROG_CC])dnl
-  AC_REQUIRE([AC_CANONICAL_HOST])dnl
-  AC_REQUIRE([AC_PROG_RANLIB])dnl
-  AC_REQUIRE([AC_ISC_POSIX])dnl
-  AC_REQUIRE([AC_HEADER_STDC])dnl
-  AC_REQUIRE([AC_C_CONST])dnl
-  AC_REQUIRE([AC_C_INLINE])dnl
-  AC_REQUIRE([AC_TYPE_OFF_T])dnl
-  AC_REQUIRE([AC_TYPE_SIZE_T])dnl
-  AC_REQUIRE([AC_FUNC_ALLOCA])dnl
-  AC_REQUIRE([AC_FUNC_MMAP])dnl
-  AC_REQUIRE([jm_GLIBC21])dnl
-  AC_REQUIRE([gt_INTDIV0])dnl
-  AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
-  AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
-  AC_REQUIRE([gt_INTTYPES_PRI])dnl
-
-  AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
-stdlib.h string.h unistd.h sys/param.h])
-  AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
-geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
-strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
-__fsetlocking])
+  m4_divert_text([DEFAULTS], [gt_needs=])
+  m4_define([gt_NEEDS_INIT], [])
+])
 
-  AM_ICONV
-  AM_LANGINFO_CODESET
-  if test $ac_cv_header_locale_h = yes; then
-    AM_LC_MESSAGES
-  fi
 
-  dnl intl/plural.c is generated from intl/plural.y. It requires bison,
-  dnl because plural.y uses bison specific features. It requires at least
-  dnl bison-1.26 because earlier versions generate a plural.c that doesn't
-  dnl compile.
-  dnl bison is only needed for the maintainer (who touches plural.y). But in
-  dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
-  dnl the rule in general Makefile. Now, some people carelessly touch the
-  dnl files or have a broken "make" program, hence the plural.c rule will
-  dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
-  dnl present or too old.
-  AC_CHECK_PROGS([INTLBISON], [bison])
-  if test -z "$INTLBISON"; then
-    ac_verc_fail=yes
-  else
-    dnl Found it, now check the version.
-    AC_MSG_CHECKING([version of bison])
-changequote(<<,>>)dnl
-    ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
-    case $ac_prog_version in
-      '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
-      1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
-changequote([,])dnl
-         ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
-      *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
-    esac
-    AC_MSG_RESULT([$ac_prog_version])
-  fi
-  if test $ac_verc_fail = yes; then
-    INTLBISON=:
-  fi
+dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
+AC_DEFUN([AM_GNU_GETTEXT_NEED],
+[
+  m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
 ])
 
 
 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
+
+
+dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version])
+AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])
diff --git a/config/iconv.m4 b/config/iconv.m4
index f1e54c5aedc..ff5d5261139 100644
--- a/config/iconv.m4
+++ b/config/iconv.m4
@@ -1,13 +1,17 @@ 
-# iconv.m4 serial AM4 (gettext-0.11.3)
-dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
-dnl This file is free software, distributed under the terms of the GNU
-dnl General Public License.  As a special exception to the GNU General
-dnl Public License, this file may be distributed as part of a program
-dnl that contains a configuration script generated by Autoconf, under
-dnl the same distribution terms as the rest of that program.
+# iconv.m4 serial 26
+dnl Copyright (C) 2000-2002, 2007-2014, 2016-2023 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
-dnl with modifications to support building with in-tree libiconv
+
+AC_PREREQ([2.64])
+
+dnl Note: AM_ICONV is documented in the GNU gettext manual
+dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>.
+dnl Don't make changes that are incompatible with that documentation!
 
 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
 [
@@ -24,107 +28,266 @@  AC_DEFUN([AM_ICONV_LINK],
 [
   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
   dnl those with the standalone portable GNU libiconv installed).
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
   dnl accordingly.
   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
 
-  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+  dnl because if the user has installed libiconv and not disabled its use
+  dnl via --without-libiconv-prefix, he wants to use it. The first
+  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
+  am_save_CPPFLAGS="$CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
+
+  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
-    dnl Add $INCICONV to CPPFLAGS before performing the first check,
-    dnl because if the user has installed libiconv and not disabled its use
-    dnl via --without-libiconv-prefix, he wants to use it. This first
-    dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
-    am_save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS $INCICONV"
-    AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
-      [iconv_t cd = iconv_open("","");
-       iconv(cd,NULL,NULL,NULL,NULL);
-       iconv_close(cd);],
-      am_cv_func_iconv=yes)
-    CPPFLAGS="$am_save_CPPFLAGS"
-
-    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
-      for _libs in .libs _libs; do
-        am_save_CPPFLAGS="$CPPFLAGS"
-        am_save_LIBS="$LIBS"
-        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
-        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
-        AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
-          [iconv_t cd = iconv_open("","");
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[
+#include <stdlib.h>
+#include <iconv.h>
+         ]],
+         [[iconv_t cd = iconv_open("","");
            iconv(cd,NULL,NULL,NULL,NULL);
-           iconv_close(cd);],
-          INCICONV="-I../libiconv/include"
-          LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
-          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
-          am_cv_lib_iconv=yes
-          am_cv_func_iconv=yes)
-        CPPFLAGS="$am_save_CPPFLAGS"
-        LIBS="$am_save_LIBS"
-        if test "$am_cv_func_iconv" = "yes"; then
-          break
-        fi
-      done
-    fi
-
+           iconv_close(cd);]])],
+      [am_cv_func_iconv=yes])
     if test "$am_cv_func_iconv" != yes; then
-      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
-      CPPFLAGS="$CPPFLAGS $INCICONV"
       LIBS="$LIBS $LIBICONV"
-      AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
-        [iconv_t cd = iconv_open("","");
-         iconv(cd,NULL,NULL,NULL,NULL);
-         iconv_close(cd);],
-        am_cv_lib_iconv=yes
-        am_cv_func_iconv=yes)
-      CPPFLAGS="$am_save_CPPFLAGS"
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[
+#include <stdlib.h>
+#include <iconv.h>
+           ]],
+           [[iconv_t cd = iconv_open("","");
+             iconv(cd,NULL,NULL,NULL,NULL);
+             iconv_close(cd);]])],
+        [am_cv_lib_iconv=yes]
+        [am_cv_func_iconv=yes])
       LIBS="$am_save_LIBS"
     fi
   ])
   if test "$am_cv_func_iconv" = yes; then
-    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
+      dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
+      dnl Solaris 10.
+      am_save_LIBS="$LIBS"
+      if test $am_cv_lib_iconv = yes; then
+        LIBS="$LIBS $LIBICONV"
+      fi
+      am_cv_func_iconv_works=no
+      for ac_iconv_const in '' 'const'; do
+        AC_RUN_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[
+#include <iconv.h>
+#include <string.h>
+
+#ifndef ICONV_CONST
+# define ICONV_CONST $ac_iconv_const
+#endif
+             ]],
+             [[int result = 0;
+  /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
+     successful returns.  This is even documented in
+     <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
+  {
+    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
+    if (cd_utf8_to_88591 != (iconv_t)(-1))
+      {
+        static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
+        char buf[10];
+        ICONV_CONST char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_utf8_to_88591,
+                            &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          result |= 1;
+        iconv_close (cd_utf8_to_88591);
+      }
+  }
+  /* Test against Solaris 10 bug: Failures are not distinguishable from
+     successful returns.  */
+  {
+    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+    if (cd_ascii_to_88591 != (iconv_t)(-1))
+      {
+        static ICONV_CONST char input[] = "\263";
+        char buf[10];
+        ICONV_CONST char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_ascii_to_88591,
+                            &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          result |= 2;
+        iconv_close (cd_ascii_to_88591);
+      }
+  }
+  /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
+  {
+    iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
+    if (cd_88591_to_utf8 != (iconv_t)(-1))
+      {
+        static ICONV_CONST char input[] = "\304";
+        static char buf[2] = { (char)0xDE, (char)0xAD };
+        ICONV_CONST char *inptr = input;
+        size_t inbytesleft = 1;
+        char *outptr = buf;
+        size_t outbytesleft = 1;
+        size_t res = iconv (cd_88591_to_utf8,
+                            &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
+          result |= 4;
+        iconv_close (cd_88591_to_utf8);
+      }
+  }
+#if 0 /* This bug could be worked around by the caller.  */
+  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
+  {
+    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
+    if (cd_88591_to_utf8 != (iconv_t)(-1))
+      {
+        static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+        char buf[50];
+        ICONV_CONST char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_88591_to_utf8,
+                            &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if ((int)res > 0)
+          result |= 8;
+        iconv_close (cd_88591_to_utf8);
+      }
+  }
+#endif
+  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+     provided.  */
+  {
+    /* Try standardized names.  */
+    iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
+    /* Try IRIX, OSF/1 names.  */
+    iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
+    /* Try AIX names.  */
+    iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
+    /* Try HP-UX names.  */
+    iconv_t cd4 = iconv_open ("utf8", "eucJP");
+    if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
+        && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
+      result |= 16;
+    if (cd1 != (iconv_t)(-1))
+      iconv_close (cd1);
+    if (cd2 != (iconv_t)(-1))
+      iconv_close (cd2);
+    if (cd3 != (iconv_t)(-1))
+      iconv_close (cd3);
+    if (cd4 != (iconv_t)(-1))
+      iconv_close (cd4);
+  }
+  return result;
+]])],
+          [am_cv_func_iconv_works=yes], ,
+          [case "$host_os" in
+             aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+             *)            am_cv_func_iconv_works="guessing yes" ;;
+           esac])
+        test "$am_cv_func_iconv_works" = no || break
+      done
+      LIBS="$am_save_LIBS"
+    ])
+    case "$am_cv_func_iconv_works" in
+      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
+      *)   am_func_iconv=yes ;;
+    esac
+  else
+    am_func_iconv=no am_cv_lib_iconv=no
+  fi
+  if test "$am_func_iconv" = yes; then
+    AC_DEFINE([HAVE_ICONV], [1],
+      [Define if you have the iconv() function and it works.])
   fi
   if test "$am_cv_lib_iconv" = yes; then
-    AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
     AC_MSG_CHECKING([how to link with libiconv])
     AC_MSG_RESULT([$LIBICONV])
   else
+    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
+    dnl either.
+    CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
-  AC_SUBST(LIBICONV)
-  AC_SUBST(LTLIBICONV)
+  AC_SUBST([LIBICONV])
+  AC_SUBST([LTLIBICONV])
 ])
 
-AC_DEFUN([AM_ICONV],
+dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like
+dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
+AC_DEFUN_ONCE([AM_ICONV],
 [
   AM_ICONV_LINK
   if test "$am_cv_func_iconv" = yes; then
-    AC_MSG_CHECKING([for iconv declaration])
-    AC_CACHE_VAL(am_cv_proto_iconv, [
-      AC_TRY_COMPILE([
+    AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature],
+      [gl_cv_iconv_nonconst],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[
 #include <stdlib.h>
 #include <iconv.h>
 extern
 #ifdef __cplusplus
 "C"
 #endif
-#if defined(__STDC__) || defined(__cplusplus)
 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
-#else
-size_t iconv();
-#endif
-], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
-      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
-    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
-    AC_MSG_RESULT([$]{ac_t:-
-         }[$]am_cv_proto_iconv)
-    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
-      [Define as const if the declaration of iconv() needs const.])
+            ]],
+            [[]])],
+         [gl_cv_iconv_nonconst=yes],
+         [gl_cv_iconv_nonconst=no])
+      ])
+  else
+    dnl When compiling GNU libiconv on a system that does not have iconv yet,
+    dnl pick the POSIX compliant declaration without 'const'.
+    gl_cv_iconv_nonconst=yes
+  fi
+  if test $gl_cv_iconv_nonconst = yes; then
+    iconv_arg1=""
+  else
+    iconv_arg1="const"
+  fi
+  AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1],
+    [Define as const if the declaration of iconv() needs const.])
+  dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
+  m4_ifdef([gl_ICONV_H_DEFAULTS],
+    [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
+     if test $gl_cv_iconv_nonconst != yes; then
+       ICONV_CONST="const"
+     fi
+    ])
+
+  dnl A summary result, for those packages which want to print a summary at the
+  dnl end of the configuration.
+  if test "$am_func_iconv" = yes; then
+    if test -n "$LIBICONV"; then
+      am_cv_func_iconv_summary='yes, in libiconv'
+    else
+      am_cv_func_iconv_summary='yes, in libc'
+    fi
+  else
+    if test "$am_cv_func_iconv" = yes; then
+      am_cv_func_iconv_summary='not working, consider installing GNU libiconv'
+    else
+      am_cv_func_iconv_summary='no, consider installing GNU libiconv'
+    fi
   fi
 ])
diff --git a/config/intlmacosx.m4 b/config/intlmacosx.m4
new file mode 100644
index 00000000000..81eefd750b5
--- /dev/null
+++ b/config/intlmacosx.m4
@@ -0,0 +1,65 @@ 
+# intlmacosx.m4 serial 8 (gettext-0.20.2)
+dnl Copyright (C) 2004-2014, 2016, 2019-2023 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Lesser General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Lesser General Public License, and the rest of the GNU
+dnl gettext package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Checks for special options needed on Mac OS X.
+dnl Defines INTL_MACOSX_LIBS.
+AC_DEFUN([gt_INTL_MACOSX],
+[
+  dnl Check for API introduced in Mac OS X 10.4.
+  AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
+    [gt_cv_func_CFPreferencesCopyAppValue],
+    [gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <CoreFoundation/CFPreferences.h>]],
+          [[CFPreferencesCopyAppValue(NULL, NULL)]])],
+       [gt_cv_func_CFPreferencesCopyAppValue=yes],
+       [gt_cv_func_CFPreferencesCopyAppValue=no])
+     LIBS="$gt_save_LIBS"])
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
+    AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
+      [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
+  fi
+  dnl Don't check for the API introduced in Mac OS X 10.5, CFLocaleCopyCurrent,
+  dnl because in macOS 10.13.4 it has the following behaviour:
+  dnl When two or more languages are specified in the
+  dnl "System Preferences > Language & Region > Preferred Languages" panel,
+  dnl it returns en_CC where CC is the territory (even when English is not among
+  dnl the preferred languages!).  What we want instead is what
+  dnl CFLocaleCopyCurrent returned in earlier macOS releases and what
+  dnl CFPreferencesCopyAppValue still returns, namely ll_CC where ll is the
+  dnl first among the preferred languages and CC is the territory.
+  AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages],
+    [gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <CoreFoundation/CFLocale.h>]],
+          [[CFLocaleCopyPreferredLanguages();]])],
+       [gt_cv_func_CFLocaleCopyPreferredLanguages=yes],
+       [gt_cv_func_CFLocaleCopyPreferredLanguages=no])
+     LIBS="$gt_save_LIBS"])
+  if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
+    AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1],
+      [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.])
+  fi
+  INTL_MACOSX_LIBS=
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes \
+     || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
+    INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
+  fi
+  AC_SUBST([INTL_MACOSX_LIBS])
+])
diff --git a/configure.ac b/configure.ac
index 01cfd017273..76d36e7b358 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,7 +133,7 @@  build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libcody libdecnumber gmp mpfr mpc isl libiconv libctf libsframe"
+host_libs="gettext libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libcody libdecnumber gmp mpfr mpc isl libiconv libctf libsframe"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
@@ -3231,7 +3231,8 @@  AC_SUBST_FILE(serialization_dependencies)
 # files altogether, and which should be passed on to subconfigures.
 # Also strip program-prefix, program-suffix, and program-transform-name,
 # so that we can pass down a consistent program-transform-name.
-baseargs=
+hbaseargs=
+bbaseargs=
 tbaseargs=
 keep_next=no
 skip_next=no
@@ -3247,7 +3248,8 @@  do
       *\'*)
 	ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
-    baseargs="$baseargs '$ac_arg'"
+    hbaseargs="$hbaseargs '$ac_arg'"
+    bbaseargs="$bbaseargs '$ac_arg'"
     tbaseargs="$tbaseargs '$ac_arg'"
     keep_next=no
     continue
@@ -3271,6 +3273,7 @@  do
   esac
 
   skip_targ=no
+  skip_barg=no
   case $ac_arg in
 changequote(,)
   --with-* | --without-*)
@@ -3283,6 +3286,12 @@  changequote(,)
     *[-_]lib)
       lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
       ;;
+    *[-_]prefix)
+      lib=`echo "$libopt" | sed 's,[-_]prefix$,,'`
+      ;;
+    *[-_]type)
+      lib=`echo "$libopt" | sed 's,[-_]type$,,'`
+      ;;
     *)
       lib=$libopt
       ;;
@@ -3299,6 +3308,11 @@  changequote([,])
         skip_targ=yes
       fi
       ;;
+    libintl | libiconv)
+      # We don't want libintl (and co.) in anything but the host arguments.
+      skip_targ=yes
+      skip_barg=yes
+      ;;
     esac
     ;;
   esac
@@ -3307,7 +3321,8 @@  changequote([,])
     --cache-file=/dev/null | \
     -cache-file=/dev/null )
       # Handled here to avoid the test to skip args below.
-      baseargs="$baseargs '$ac_arg'"
+      hbaseargs="$hbaseargs '$ac_arg'"
+      bbaseargs="$bbaseargs '$ac_arg'"
       tbaseargs="$tbaseargs '$ac_arg'"
       # Assert: $separate_arg should always be no.
       keep_next=$separate_arg
@@ -3338,7 +3353,10 @@  changequote([,])
 	*\'*)
 	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
       esac
-      baseargs="$baseargs '$ac_arg'"
+      hbaseargs="$hbaseargs '$ac_arg'"
+      if test X"$skip_barg" = Xno; then
+	bbaseargs="$bbaseargs '$ac_arg'"
+      fi
       if test X"$skip_targ" = Xno; then
         tbaseargs="$tbaseargs '$ac_arg'"
       fi
@@ -3353,7 +3371,8 @@  changequote([,])
 done
 # Remove the initial space we just introduced and, as these will be
 # expanded by make, quote '$'.
-baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
+hbaseargs=`echo "x$hbaseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
+bbaseargs=`echo "x$bbaseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
 
 # Add in --program-transform-name, after --program-prefix and
 # --program-suffix have been applied to it.  Autoconf has already
@@ -3367,14 +3386,17 @@  ${program_transform_name}
 EOF_SED
 gcc_transform_name=`cat conftestsed.out`
 rm -f conftestsed.out
-baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
+hbaseargs="$hbaseargs --program-transform-name='${gcc_transform_name}'"
+bbaseargs="$bbaseargs --program-transform-name='${gcc_transform_name}'"
 tbaseargs="$tbaseargs --program-transform-name='${gcc_transform_name}'"
 if test "$silent" = yes; then
-  baseargs="$baseargs --silent"
+  bbaseargs="$bbaseargs --silent"
+  hbaseargs="$hbaseargs --silent"
   tbaseargs="$tbaseargs --silent"
 fi
 
-baseargs="$baseargs --disable-option-checking"
+bbaseargs="$bbaseargs --disable-option-checking"
+hbaseargs="$hbaseargs --disable-option-checking"
 tbaseargs="$tbaseargs --disable-option-checking"
 
 if test "$enable_year2038" = no; then
@@ -3395,7 +3417,7 @@  AC_ARG_VAR([target_configargs],
 # desired.  We can't even use the same cache file for all build-side
 # libraries, as they're compiled differently; some with C, some with
 # C++ or with different feature-enabling options.
-build_configargs="$build_configargs --cache-file=./config.cache ${baseargs}"
+build_configargs="$build_configargs --cache-file=./config.cache ${bbaseargs}"
 
 # For host modules, accept cache file option, or specification as blank.
 case "${cache_file}" in
@@ -3409,7 +3431,7 @@  esac
 
 # Host dirs don't like to share a cache file either, horribly enough.
 # This seems to be due to autoconf 2.5x stupidity.
-host_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${baseargs}"
+host_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${hbaseargs}"
 
 target_configargs="$target_configargs ${tbaseargs}"
 
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 173e40b440a..d505fbbb267 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -235,7 +235,8 @@  AC_DEFUN([GDB_AC_CHECK_BFD], [
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
-  intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
+  # LTLIBINTL because we use libtool as CC below.
+  intl="$(echo "$LTLIBINTL" | sed 's,\$[[{(]top_builddir[)}]]/,,')"
   LIBS="-lbfd -liberty $intl $LIBS"
   CC="./libtool --quiet --mode=link $CC"
   AC_CACHE_CHECK(
diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
index 00524e9a566..f1a641308fe 100644
--- a/gdbsupport/Makefile.am
+++ b/gdbsupport/Makefile.am
@@ -20,6 +20,11 @@ 
 AUTOMAKE_OPTIONS = no-dist foreign
 ACLOCAL_AMFLAGS = -I . -I ../config
 
+# Suppress 'configure.ac: error: AM_GNU_GETTEXT used but SUBDIRS not defined'
+# from Automake, as gdbsupport uses AM_GNU_GETTEXT through
+# ZW_GNU_GETTEXT_SISTER_DIR, but doesn't have any translations (currently).
+SUBDIRS =
+
 AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../gdb \
     -I../gnulib/import -I$(srcdir)/../gnulib/import \
     -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd \
diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index b1dbc2f6ba4..0835b203692 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -21,6 +21,11 @@  ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
 
 AUTOMAKE_OPTIONS = dejagnu foreign info-in-builddir no-texinfo.tex
 
+# Suppress 'configure.ac: error: AM_GNU_GETTEXT used but SUBDIRS not defined'
+# from Automake, as libctf uses AM_GNU_GETTEXT (through
+# ZW_GNU_GETTEXT_SISTER_DIR) but has no po/ subdir (currently).
+SUBDIRS =
+
 # Variables that we might accumulate conditionally or in subdirs.
 info_TEXINFOS =
 DISTCLEANFILES =
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 6a5eade1855..5264cca8868 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -220,7 +220,7 @@  changequote([,])dnl
   fi
 fi
 
-CTF_LIBADD="$CTF_LIBADD $LIBINTL"
+CTF_LIBADD="$CTF_LIBADD $LTLIBINTL"
 
 if test "$enable_shared" = "yes"; then
   case "${host}" in
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index cae2a67ff10..1734b82a355 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -190,7 +190,7 @@  changequote([,])dnl
   fi
 fi
 
-SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
+SHARED_LIBADD="$SHARED_LIBADD $LTLIBINTL"
 
 if test "$enable_shared" = "yes"; then
   case "${host}" in