Next: , Up: Autoconf macros for use in configure.ac   [Contents][Index]


13.5.1 AM_GNU_GETTEXT in gettext.m4

The AM_GNU_GETTEXT macro tests for the presence of the GNU gettext function family in either the C library or a separate libintl library (shared or static libraries are both supported). It also invokes AM_PO_SUBDIRS, thus preparing the po/ directories of the package for building.

AM_GNU_GETTEXT accepts up to two optional arguments. The general syntax is

AM_GNU_GETTEXT([intlsymbol], [needsymbol])

intlsymbol should always be ‘external’.

If needsymbol is specified and is ‘need-ngettext’, then GNU gettext implementations (in libc or libintl) without the ngettext() function will be ignored. If needsymbol is specified and is ‘need-formatstring-macros’, then GNU gettext implementations that don’t support the ISO C 99 <inttypes.h> formatstring macros will be ignored. Only one needsymbol can be specified. These requirements can also be specified by using the macro AM_GNU_GETTEXT_NEED elsewhere. To specify more than one requirement, just specify the strongest one among them, or invoke the AM_GNU_GETTEXT_NEED macro several times. The hierarchy among the various alternatives is as follows: ‘need-formatstring-macros’ implies ‘need-ngettext’.

The AM_GNU_GETTEXT macro determines whether GNU gettext is available and should be used. If so, it sets the USE_NLS variable to ‘yes’; it defines ENABLE_NLS to 1 in the autoconf generated configuration file (usually called config.h); it sets the variables LIBINTL and LTLIBINTL to the linker options for use in a Makefile (LIBINTL for use without libtool, LTLIBINTL for use with libtool); it adds an ‘-I’ option to CPPFLAGS if necessary. In the negative case, it sets USE_NLS to ‘no’; it sets LIBINTL and LTLIBINTL to empty and doesn’t change CPPFLAGS.

The complexities that AM_GNU_GETTEXT deals with are the following:

Additionally, the AM_GNU_GETTEXT macro sets two variables, for convenience. Both are derived from the --localedir configure option. They are correct even on native Windows, where directories frequently contain backslashes.

localedir_c

This is the value of localedir, in C syntax. This variable is meant to be substituted into C or C++ code through AC_CONFIG_FILES.

localedir_c_make

This is the value of localedir, in C syntax, escaped for use in a Makefile. This variable is meant to be used in Makefiles, for example for defining a C macro named LOCALEDIR:

AM_CPPFLAGS = ... -DLOCALEDIR=$(localedir_c_make) ...

Next: AM_GNU_GETTEXT_VERSION in gettext.m4, Up: Autoconf macros for use in configure.ac   [Contents][Index]