]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
AM_GNU_GETTEXT: Define localedir_c and localedir_c_make.
authorBruno Haible <bruno@clisp.org>
Sat, 11 Feb 2023 16:17:05 +0000 (17:17 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 12 Feb 2023 21:22:14 +0000 (22:22 +0100)
* 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.

NEWS
gettext-runtime/intl/Makefile.am
gettext-runtime/m4/gettext.m4
gettext-runtime/src/Makefile.am
gettext-tools/doc/gettext.texi
gettext-tools/src/Makefile.am
gettext-tools/tests/Makefile.am

diff --git a/NEWS b/NEWS
index ea7ff0c76542a86a2a738a86774cea17254cd66a..01fc5498d4eb368568110dbd489f900ead553eb6 100644 (file)
--- 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
index 2eba70f8cef5f05b5ffeb7372efb702a8ea1d2b7..1f7f1efd9fb194d14be9813bbdba5a5502f7757d 100644 (file)
@@ -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
index 2ea12f0d08201f37a8c279764d288deb3ebaae18..d9f4cfcb341d6f7107d41c14517f7e654c80b6b7 100644 (file)
@@ -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])
 ])
 
 
index e86003468a8c8c6d923b70e1684281fc7ab3d3ae..1fa850745f0e497d79621eee7808b94be5920587 100644 (file)
@@ -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
index c08243a7b6f65f2b3486215ac2490d070d5439ff..ed9c885fbd52d595f7bc5dbbb6dbeece7edbea5e 100644 (file)
@@ -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}
 
index f5e52ea8ee52a21a0cf23740943a8f789790c626..59af8aaa7746c280d11c209d880ed6fe1a38a1c1 100644 (file)
@@ -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\" \
index 335e77648369fdb83a9e8ed6fc682930075f8cd7..92d28c479bf590a6c952a8044e8e39e504d82898 100644 (file)
@@ -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@