localedef: Add --localedir and --archive-file options (Bug 19130)

Message ID 5627B868.2050402@redhat.com
State New, archived
Headers

Commit Message

Carlos O'Donell Oct. 21, 2015, 4:08 p.m. UTC
  On 10/20/2015 11:54 AM, Andreas Schwab wrote:
> "Carlos O'Donell" <carlos@redhat.com> writes:
> 
>> (2) Rename the uses of LOCALEDIR and $(localedir) within the glibc configury
>>     to avoid confusion. I suggest LOCARCHDIR and $(locarchdir).
> 
> What is a locarch?

The binary locale archive and binary compiled locales are loaded from
$(libdir)/locale. What variable name can we use for this path? The selected
name should be distinguishable from `localedir` which is the name of the
GNU standard configure name for the location to search for locale-specific
message catalogs e.g. --localedir.

My present suggestions are:

(1) LOCARCHDIR / $(locarchdir)

(2) LOCALE_ARCHIVE_DIR / $(locale_archive_dir)

(3) LOCARDIR / $(locardir)

For example the following patch does (2).

---


Cheers,
Carlos.
  

Comments

Mike Frysinger Oct. 22, 2015, 3:27 a.m. UTC | #1
On 21 Oct 2015 12:08, Carlos O'Donell wrote:
> (1) LOCARCHDIR / $(locarchdir)

i'd lean towards this, or locarchivedir

> (2) LOCALE_ARCHIVE_DIR / $(locale_archive_dir)

i don't think it matters because of how the var is used, but in automake, the
standard is to omit the _ before "dir", and in fact using implicit vars to
install into it require the _ to be omitted (or by duplicating the _ suffix).
-mike
  
Carlos O'Donell Oct. 22, 2015, 3:56 a.m. UTC | #2
On 10/21/2015 11:27 PM, Mike Frysinger wrote:
> On 21 Oct 2015 12:08, Carlos O'Donell wrote:
>> (1) LOCARCHDIR / $(locarchdir)
> 
> i'd lean towards this, or locarchivedir

Thanks. We'll see what Andreas says.

c.
  
Andreas Schwab Oct. 22, 2015, 7:57 a.m. UTC | #3
"Carlos O'Donell" <carlos@redhat.com> writes:

> diff --git a/Makeconfig b/Makeconfig
> index 1dc522c..4e585ce 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -190,11 +190,11 @@ zonedir = $(datadir)/zoneinfo
>  endif
>  inst_zonedir = $(install_root)$(zonedir)
>  
> -# Where to install the locale files.
> -ifndef localedir
> -localedir = $(libdir)/locale
> +# Where to install the binary locale archive and binary locale files.
> +ifndef locale_archive_dir

Why "archive"?  It doesn't store only the archive.

Andreas.
  
Carlos O'Donell Oct. 22, 2015, 1:57 p.m. UTC | #4
On 10/22/2015 03:57 AM, Andreas Schwab wrote:
> "Carlos O'Donell" <carlos@redhat.com> writes:
> 
>> diff --git a/Makeconfig b/Makeconfig
>> index 1dc522c..4e585ce 100644
>> --- a/Makeconfig
>> +++ b/Makeconfig
>> @@ -190,11 +190,11 @@ zonedir = $(datadir)/zoneinfo
>>  endif
>>  inst_zonedir = $(install_root)$(zonedir)
>>  
>> -# Where to install the locale files.
>> -ifndef localedir
>> -localedir = $(libdir)/locale
>> +# Where to install the binary locale archive and binary locale files.
>> +ifndef locale_archive_dir
> 
> Why "archive"?  It doesn't store only the archive.

How about:

$(locbindir)

and

LOCBINDIR

Since it contains the "binary locale" archive and the
compiled "binary locales."

Cheers,
Carlos.
  
Andreas Schwab Oct. 22, 2015, 2:13 p.m. UTC | #5
"Carlos O'Donell" <carlos@redhat.com> writes:

> On 10/22/2015 03:57 AM, Andreas Schwab wrote:
>> "Carlos O'Donell" <carlos@redhat.com> writes:
>> 
>>> diff --git a/Makeconfig b/Makeconfig
>>> index 1dc522c..4e585ce 100644
>>> --- a/Makeconfig
>>> +++ b/Makeconfig
>>> @@ -190,11 +190,11 @@ zonedir = $(datadir)/zoneinfo
>>>  endif
>>>  inst_zonedir = $(install_root)$(zonedir)
>>>  
>>> -# Where to install the locale files.
>>> -ifndef localedir
>>> -localedir = $(libdir)/locale
>>> +# Where to install the binary locale archive and binary locale files.
>>> +ifndef locale_archive_dir
>> 
>> Why "archive"?  It doesn't store only the archive.
>
> How about:
>
> $(locbindir)

Please don't abbreviate locale.  Otherwise ok with me.

Andreas.
  
Carlos O'Donell Oct. 22, 2015, 2:29 p.m. UTC | #6
On 10/22/2015 10:13 AM, Andreas Schwab wrote:
> "Carlos O'Donell" <carlos@redhat.com> writes:
> 
>> On 10/22/2015 03:57 AM, Andreas Schwab wrote:
>>> "Carlos O'Donell" <carlos@redhat.com> writes:
>>>
>>>> diff --git a/Makeconfig b/Makeconfig
>>>> index 1dc522c..4e585ce 100644
>>>> --- a/Makeconfig
>>>> +++ b/Makeconfig
>>>> @@ -190,11 +190,11 @@ zonedir = $(datadir)/zoneinfo
>>>>  endif
>>>>  inst_zonedir = $(install_root)$(zonedir)
>>>>  
>>>> -# Where to install the locale files.
>>>> -ifndef localedir
>>>> -localedir = $(libdir)/locale
>>>> +# Where to install the binary locale archive and binary locale files.
>>>> +ifndef locale_archive_dir
>>>
>>> Why "archive"?  It doesn't store only the archive.
>>
>> How about:
>>
>> $(locbindir)
> 
> Please don't abbreviate locale.  Otherwise ok with me.

OK. Final form is:

$(localebindir)

LOCALEBINDIR

I'll post the patch after testing.

c.
  
Roland McGrath Oct. 22, 2015, 6:33 p.m. UTC | #7
Not that I really care, but anything with "bin" in it seems like a poor
choice.  People expect that to mean some .../bin directory, a place where
executables are stored.  I don't really have a better suggestion, though.
  
Carlos O'Donell Oct. 22, 2015, 6:42 p.m. UTC | #8
On 10/22/2015 02:33 PM, Roland McGrath wrote:
> Not that I really care, but anything with "bin" in it seems like a poor
> choice.  People expect that to mean some .../bin directory, a place where
> executables are stored.  I don't really have a better suggestion, though.

What about compiled? Since this is the directory where glibc will look for
the compiled locales and the compiled locale archive?

Makefile variable: $(complocaledir)

Source macro: COMPLOCALEDIR

Configure option: --compiledlocaledir=/path

Cheers,
Carlos.
  
Roland McGrath Oct. 22, 2015, 8:25 p.m. UTC | #9
> What about compiled? Since this is the directory where glibc will look for
> the compiled locales and the compiled locale archive?

OK

> Makefile variable: $(complocaledir)
> 
> Source macro: COMPLOCALEDIR

These should match the configure option exactly (except for upcasing).
  
Carlos O'Donell Oct. 24, 2015, 3:34 a.m. UTC | #10
On 10/22/2015 04:25 PM, Roland McGrath wrote:
>> What about compiled? Since this is the directory where glibc will look for
>> the compiled locales and the compiled locale archive?
> 
> OK
> 
>> Makefile variable: $(complocaledir)
>>
>> Source macro: COMPLOCALEDIR
> 
> These should match the configure option exactly (except for upcasing).

OK.

c.
  

Patch

diff --git a/Makeconfig b/Makeconfig
index 1dc522c..4e585ce 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -190,11 +190,11 @@  zonedir = $(datadir)/zoneinfo
 endif
 inst_zonedir = $(install_root)$(zonedir)
 
-# Where to install the locale files.
-ifndef localedir
-localedir = $(libdir)/locale
+# Where to install the binary locale archive and binary locale files.
+ifndef locale_archive_dir
+locale_archive_dir = $(libdir)/locale
 endif
-inst_localedir = $(install_root)$(localedir)
+inst_locale_archive_dir = $(install_root)$(locale_archive_dir)
 
 # Where to install the message catalog data files (which are
 # machine-independent).
diff --git a/aclocal.m4 b/aclocal.m4
index abc34d2..86247bd 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -296,7 +296,7 @@  case "$prefix" in
   if test "$libdir" = '${exec_prefix}/lib'; then
     libdir='${exec_prefix}/$1';
     # Locale data can be shared between 32-bit and 64-bit libraries.
-    libc_cv_localedir='${exec_prefix}/lib/locale'
+    libc_cv_locale_archive_dir='${exec_prefix}/lib/locale'
   fi
   ;;
 esac])
diff --git a/config.make.in b/config.make.in
index 7f561eb..54377a7 100644
--- a/config.make.in
+++ b/config.make.in
@@ -12,7 +12,7 @@  datadir = @datadir@
 libdir = @libdir@
 slibdir = @libc_cv_slibdir@
 rtlddir = @libc_cv_rtlddir@
-localedir = @libc_cv_localedir@
+locale_archive_dir = @libc_cv_locale_archive_dir@
 sysconfdir = @libc_cv_sysconfdir@
 libexecdir = @libexecdir@
 rootsbindir = @libc_cv_rootsbindir@
diff --git a/configure.ac b/configure.ac
index eba7a15..a8df166 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1920,7 +1920,7 @@  AC_SUBST(old_glibc_headers)
 
 AC_SUBST(libc_cv_slibdir)
 AC_SUBST(libc_cv_rtlddir)
-AC_SUBST(libc_cv_localedir)
+AC_SUBST(libc_cv_locale_archive_dir)
 AC_SUBST(libc_cv_sysconfdir)
 AC_SUBST(libc_cv_localstatedir)
 AC_SUBST(libc_cv_rootsbindir)
diff --git a/locale/Makefile b/locale/Makefile
index f1b4343..f5e3e92 100644
--- a/locale/Makefile
+++ b/locale/Makefile
@@ -76,12 +76,15 @@  C-translit.h: C-translit.h.in gen-translit.pl
 	$(PERL) gen-translit.pl < $< > $@.tmp
 	mv -f $@.tmp $@
 
-localepath = "$(localedir):$(i18ndir)"
+# The path to the binary locale archive or compiled archvies,
+# along with the parent path to the source locales and source
+# charmaps.
+localepath = "$(locale_archive_dir):$(i18ndir)"
 
 # -Iprograms doesn't really belong here, but this gets it at the head
 # of the list instead of the tail, where CPPFLAGS-$(lib) gets added.
 # We need it before the standard -I's to see programs/config.h first.
-locale-CPPFLAGS = -DLOCALEDIR='"$(localedir)"' \
+locale-CPPFLAGS = -DLOCALE_ARCHIVE_DIR='"$(locale_archvie_dir)"' \
 		  -DLOCALE_ALIAS_PATH='"$(msgcatdir)"' \
 		  -Iprograms
 
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 9e7df12..b1341a8 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -56,7 +56,7 @@  struct __locale_data *const _nl_C[] attribute_hidden =
    which are somehow addressed.  */
 struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST];
 
-const char _nl_default_locale_path[] attribute_hidden = LOCALEDIR;
+const char _nl_default_locale_path[] attribute_hidden = LOCALE_ARCHIVE_DIR;
 
 /* Checks if the name is actually present, that is, not NULL and not
    empty.  */
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index 3e18cf0..2da1ebf 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -42,7 +42,7 @@ 
 
 
 /* Name of the locale archive file.  */
-static const char archfname[] = LOCALEDIR "/locale-archive";
+static const char archfname[] = LOCALE_ARCHIVE_DIR "/locale-archive";
 
 /* Size of initial mapping window, optimal if large enough to
    cover the header plus the initial locale.  */
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index b1de17f..f277c68 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -45,7 +45,7 @@ 
 #include "../locarchive.h"
 #include <programs/xmalloc.h>
 
-#define ARCHIVE_NAME LOCALEDIR "/locale-archive"
+#define ARCHIVE_NAME LOCALE_ARCHIVE_DIR "/locale-archive"
 
 /* If set print the name of the category.  */
 static int show_category_name;
@@ -325,9 +325,11 @@  select_dirs (const struct dirent *dirent)
 #endif
 	{
 	  struct stat64 st;
-	  char buf[sizeof (LOCALEDIR) + strlen (dirent->d_name) + 1];
+	  char buf[sizeof (LOCALE_ARCHIVE_DIR)
+		   + strlen (dirent->d_name) + 1];
 
-	  stpcpy (stpcpy (stpcpy (buf, LOCALEDIR), "/"), dirent->d_name);
+	  stpcpy (stpcpy (stpcpy (buf, LOCALE_ARCHIVE_DIR), "/"),
+		  dirent->d_name);
 
 	  if (stat64 (buf, &st) == 0)
 	    mode = st.st_mode;
@@ -444,17 +446,21 @@  write_locales (void)
     first_locale = 0;
 
   /* Now we can look for all files in the directory.  */
-  ndirents = scandir (LOCALEDIR, &dirents, select_dirs, alphasort);
+  ndirents = scandir (LOCALE_ARCHIVE_DIR, &dirents, select_dirs,
+		      alphasort);
   for (cnt = 0; cnt < ndirents; ++cnt)
     {
       /* Test whether at least the LC_CTYPE data is there.  Some
 	 directories only contain translations.  */
-      char buf[sizeof (LOCALEDIR) + strlen (dirents[cnt]->d_name)
-	      + sizeof "/LC_IDENTIFICATION"];
+      char buf[sizeof (LOCALE_ARCHIVE_DIR)
+	       + strlen (dirents[cnt]->d_name)
+	       + sizeof "/LC_IDENTIFICATION"];
       char *enddir;
       struct stat64 st;
 
-      stpcpy (enddir = stpcpy (stpcpy (stpcpy (buf, LOCALEDIR), "/"),
+      stpcpy (enddir = stpcpy (stpcpy (stpcpy (buf,
+					       LOCALE_ARCHIVE_DIR),
+					       "/"),
 			       dirents[cnt]->d_name),
 	      "/LC_IDENTIFICATION");
 
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 06fca12..4ea6fe6 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -457,11 +457,11 @@  construct_output_path (char *path)
 	 '/'.  */
       ssize_t n;
       if (normal == NULL)
-	n = asprintf (&result, "%s%s/%s%c",
-		      output_prefix ?: "", LOCALEDIR, path, '\0');
+	n = asprintf (&result, "%s%s/%s%c", output_prefix ?: "",
+		      LOCALE_ARCHIVE_DIR, path, '\0');
       else
 	n = asprintf (&result, "%s%s/%.*s%s%s%c",
-		      output_prefix ?: "", LOCALEDIR,
+		      output_prefix ?: "", LOCALE_ARCHIVE_DIR,
 		      (int) (startp - path), path, normal, endp, '\0');
 
       if (n < 0)
diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
index 49f7f1b..54aba06 100644
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -57,7 +57,7 @@ 
 
 extern const char *output_prefix;
 
-#define ARCHIVE_NAME LOCALEDIR "/locale-archive"
+#define ARCHIVE_NAME LOCALE_ARCHIVE_DIR "/locale-archive"
 
 static const char *locnames[] =
   {
diff --git a/localedata/Makefile b/localedata/Makefile
index ebf6ac9..c1f43a1 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -199,7 +199,7 @@  $(rtld-prefix) $(common-objpfx)locale/localedef
 install-locales: $(INSTALL-SUPPORTED-LOCALES)
 
 install-locales-dir:
-	$(..)./scripts/mkinstalldirs $(inst_localedir)
+	$(..)./scripts/mkinstalldirs $(inst_locale_archive_dir)
 
 $(INSTALL-SUPPORTED-LOCALES): install-locales-dir
 	@locale=`echo $@ | sed -e 's/^install-//'`; \