From: Bruno Haible Date: Sat, 11 Feb 2023 16:17:05 +0000 (+0100) Subject: AM_GNU_GETTEXT: Define localedir_c and localedir_c_make. X-Git-Tag: v0.22~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e24758e499363e02849e3274786df54fe80852a9;p=thirdparty%2Fgettext.git AM_GNU_GETTEXT: Define localedir_c and localedir_c_make. * gettext-runtime/m4/gettext.m4 (AM_GNU_GETTEXT): Define and substitute localedir_c and localedir_c_make. * gettext-runtime/src/Makefile.am (AM_CPPFLAGS): Use $(localedir_c_make) instead of $(localedir). This is useful in native Windows environments. * gettext-runtime/intl/Makefile.am (AM_CPPFLAGS): Likewise. * gettext-tools/src/Makefile.am (AM_CPPFLAGS): Likewise. * gettext-tools/tests/Makefile.am (AM_CPPFLAGS): Likewise. * gettext-tools/doc/gettext.texi (AM_GNU_GETTEXT): Small updates. Mention localedir_c and localedir_c_make. * NEWS: Mention the change. --- diff --git a/NEWS b/NEWS index ea7ff0c76..01fc5498d 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,16 @@ -Version 0.21.2 - January 2023 +Version 0.21.2 - February 2023 * PO file format: - When a #: line contains references to file names that contain spaces, these file names are surrounded by Unicode characters U+2068 and U+2069. This makes it possible to parse such references correctly. +* Improvements for maintainers: + - The AM_GNU_GETTEXT macro now defines two variables localedir_c and + localedir_c_make, that can be used in C code or in Makefiles, + respectively, for representing the value of the --localedir configure + option. + * Programming languages support: - C, C++: xgettext now supports gettext-like functions that take wide strings (of type 'const wchar_t *', 'const char16_t *', or 'const char32_t *') as diff --git a/gettext-runtime/intl/Makefile.am b/gettext-runtime/intl/Makefile.am index 2eba70f8c..1f7f1efd9 100644 --- a/gettext-runtime/intl/Makefile.am +++ b/gettext-runtime/intl/Makefile.am @@ -34,7 +34,7 @@ SUFFIXES = # -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro. AM_CPPFLAGS = \ -Ignulib-lib -I$(srcdir)/gnulib-lib \ - -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ + -DLOCALEDIR=$(localedir_c_make) -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ -DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL if WOE32 diff --git a/gettext-runtime/m4/gettext.m4 b/gettext-runtime/m4/gettext.m4 index 2ea12f0d0..d9f4cfcb3 100644 --- a/gettext-runtime/m4/gettext.m4 +++ b/gettext-runtime/m4/gettext.m4 @@ -1,5 +1,5 @@ -# gettext.m4 serial 75 (gettext-0.21.2) -dnl Copyright (C) 1995-2014, 2016, 2018-2022 Free Software Foundation, Inc. +# gettext.m4 serial 76 (gettext-0.21.2) +dnl Copyright (C) 1995-2014, 2016, 2018-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. @@ -355,6 +355,47 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) AC_SUBST([POSUB]) + + dnl Define localedir_c. + AC_REQUIRE([AC_CANONICAL_BUILD]) + dnl Find the final value of localedir. + gt_save_prefix="${prefix}" + gt_save_datarootdir="${datarootdir}" + gt_save_localedir="${localedir}" + dnl Unfortunately, prefix gets only finally determined at the end of + dnl configure. + if test "X$prefix" = "XNONE"; then + prefix="$ac_default_prefix" + fi + eval datarootdir="$datarootdir" + eval localedir="$localedir" + gt_final_localedir="$localedir" + localedir="${gt_save_localedir}" + datarootdir="${gt_save_datarootdir}" + prefix="${gt_save_prefix}" + dnl Translate it from build syntax to host syntax. + case "$build_os" in + cygwin*) gt_final_localedir=`cygpath -w "$gt_final_localedir"` ;; + esac + dnl Convert it to C string syntax. + gt_sed_double_backslashes='s/\\/\\\\/g' + gt_sed_escape_doublequotes='s/"/\\"/g' + localedir_c=`echo "$gt_final_localedir" | sed -e "$gt_sed_double_backslashes" -e "$gt_sed_escape_doublequotes"` + localedir_c='"'"$localedir_c"'"' + AC_SUBST([localedir_c]) + + dnl Define localedir_c_make. +changequote(,)dnl + gt_sed_escape_for_make_1="s,\\([ \"&'();<>\\\\\`|]\\),\\\\\\1,g" +changequote([,])dnl + gt_sed_escape_for_make_2='s,\$,\\$$,g' + localedir_c_make=`echo "$localedir_c" | sed -e "$gt_sed_escape_for_make_1" -e "$gt_sed_escape_for_make_2"` + dnl Use the substituted localedir variable, when possible, so that the user + dnl may adjust localedir a posteriori when there are no special characters. + if test "$localedir_c_make" = '\"'"${gt_final_localedir}"'\"'; then + localedir_c_make='\"$(localedir)\"' + fi + AC_SUBST([localedir_c_make]) ]) diff --git a/gettext-runtime/src/Makefile.am b/gettext-runtime/src/Makefile.am index e86003468..1fa850745 100644 --- a/gettext-runtime/src/Makefile.am +++ b/gettext-runtime/src/Makefile.am @@ -1,5 +1,5 @@ ## Makefile for the gettext-runtime/src subdirectory of GNU gettext -## Copyright (C) 1995-1998, 2000-2007, 2009, 2019 Free Software Foundation, Inc. +## Copyright (C) 1995-1998, 2000-2007, 2009, 2019, 2023 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ AM_CPPFLAGS = \ -I.. \ -I../intl -I$(srcdir)/../intl \ -I../gnulib-lib -I$(srcdir)/../gnulib-lib -DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ +DEFS = -DLOCALEDIR=$(localedir_c_make) @DEFS@ # Source dependencies. gettext_SOURCES = gettext.c escapes.h diff --git a/gettext-tools/doc/gettext.texi b/gettext-tools/doc/gettext.texi index c08243a7b..ed9c885fb 100644 --- a/gettext-tools/doc/gettext.texi +++ b/gettext-tools/doc/gettext.texi @@ -8879,7 +8879,7 @@ library (shared or static libraries are both supported). It also invokes @code{AM_PO_SUBDIRS}, thus preparing the @file{po/} directories of the package for building. -@code{AM_GNU_GETTEXT} accepts up to three optional arguments. The general +@code{AM_GNU_GETTEXT} accepts up to two optional arguments. The general syntax is @example @@ -8930,10 +8930,10 @@ path (@code{CPPFLAGS} for the include file search path, @code{LDFLAGS} for the library search path). @item -Except for glibc, the operating system's native @code{gettext} cannot -exploit the GNU mo files, doesn't have the necessary locale dependency -features, and cannot convert messages from the catalog's text encoding -to the user's locale encoding. +Except for glibc and the Solaris 11 libc, the operating system's native +@code{gettext} cannot exploit the GNU mo files, doesn't have the +necessary locale dependency features, and cannot convert messages from +the catalog's text encoding to the user's locale encoding. @item GNU @code{libintl}, if installed, is not necessarily already in the @@ -8949,6 +8949,25 @@ linker options needed to use iconv and appends them to the @code{LIBINTL} and @code{LTLIBINTL} variables. @end itemize +Additionally, the @code{AM_GNU_GETTEXT} macro sets two variables, for +convenience. Both are derived from the @code{--localedir} configure +option. They are correct even on native Windows, where directories +frequently contain backslashes. +@table @code +@item localedir_c +This is the value of @code{localedir}, in C syntax. This variable is +meant to be substituted into C or C++ code through +@code{AC_CONFIG_FILES}. + +@item localedir_c_make +This is the value of @code{localedir}, in C syntax, escaped for use in +a @code{Makefile}. This variable is meant to be used in Makefiles, +for example for defining a C macro named @code{LOCALEDIR}: +@smallexample +AM_CPPFLAGS = ... -DLOCALEDIR=$(localedir_c_make) ... +@end smallexample +@end table + @node AM_GNU_GETTEXT_VERSION @subsection AM_GNU_GETTEXT_VERSION in @file{gettext.m4} diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index f5e52ea8e..59af8aaa7 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -1,5 +1,5 @@ ## Makefile for the gettext-tools/src subdirectory of GNU gettext -## Copyright (C) 1995-1998, 2000-2021 Free Software Foundation, Inc. +## Copyright (C) 1995-1998, 2000-2023 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -97,7 +97,7 @@ AM_CPPFLAGS = \ -I../gnulib-lib -I$(top_srcdir)/gnulib-lib \ -I../../gettext-runtime/intl -I$(top_srcdir)/../gettext-runtime/intl DEFS = \ - -DLOCALEDIR=\"$(localedir)\" -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \ + -DLOCALEDIR=$(localedir_c_make) -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \ -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ -DUSEJAVA=$(USEJAVA) \ -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \ diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 335e77648..92d28c479 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -1,5 +1,5 @@ ## Makefile for the gettext-tools/tests subdirectory of GNU gettext -## Copyright (C) 1995-1997, 2001-2010, 2012-2016, 2018-2022 Free Software Foundation, Inc. +## Copyright (C) 1995-1997, 2001-2010, 2012-2016, 2018-2023 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -246,7 +246,7 @@ AM_CPPFLAGS = \ -I.. \ -I../gnulib-lib -I$(top_srcdir)/gnulib-lib \ -I../../gettext-runtime/intl -DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ +DEFS = -DLOCALEDIR=$(localedir_c_make) @DEFS@ # INTL_MACOSX_LIBS is needed because the programs depend on libintl.la # but libtool doesn't put -Wl,-framework options into .la files. LDADD = $(LDADD_@USE_INCLUDED_LIBINTL@) @INTL_MACOSX_LIBS@