]> Savannah Git Hosting - gnulib.git/commitdiff
build-to-host.m4: Add some convenience macros.
authorBruno Haible <bruno@clisp.org>
Wed, 25 Sep 2024 23:33:45 +0000 (01:33 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 26 Sep 2024 00:02:17 +0000 (02:02 +0200)
Reported by Michele Locati <michele@locati.it> in
<https://lists.gnu.org/archive/html/bug-gettext/2024-09/msg00033.html>.

* m4/build-to-host.m4 (gl_BUILD_TO_HOST_BINDIR, gl_BUILD_TO_HOST_LIBDIR,
gl_BUILD_TO_HOST_LIBEXECDIR, gl_BUILD_TO_HOST_LOCALEDIR,
gl_BUILD_TO_HOST_PKGDATADIR, gl_BUILD_TO_HOST_PKGLIBDIR): New macros.
* m4/gettext.m4 (AM_GNU_GETTEXT): Invoke gl_BUILD_TO_HOST_LOCALEDIR.
* doc/relocatable-maint.texi (Supporting Relocation): Suggest to use the
*dir_c_make variables and explain how to get them.

ChangeLog
doc/relocatable-maint.texi
m4/build-to-host.m4
m4/gettext.m4

index 61367d2e45df1d85cd6796b4cfd288df2e099a38..eb64686dbbf6e0a4f6006c51b6d928b1cfec774f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-09-25  Bruno Haible  <bruno@clisp.org>
+
+       build-to-host.m4: Add some convenience macros.
+       Reported by Michele Locati <michele@locati.it> in
+       <https://lists.gnu.org/archive/html/bug-gettext/2024-09/msg00033.html>.
+       * m4/build-to-host.m4 (gl_BUILD_TO_HOST_BINDIR, gl_BUILD_TO_HOST_LIBDIR,
+       gl_BUILD_TO_HOST_LIBEXECDIR, gl_BUILD_TO_HOST_LOCALEDIR,
+       gl_BUILD_TO_HOST_PKGDATADIR, gl_BUILD_TO_HOST_PKGLIBDIR): New macros.
+       * m4/gettext.m4 (AM_GNU_GETTEXT): Invoke gl_BUILD_TO_HOST_LOCALEDIR.
+       * doc/relocatable-maint.texi (Supporting Relocation): Suggest to use the
+       *dir_c_make variables and explain how to get them.
+
 2024-09-25  Bruno Haible  <bruno@clisp.org>
 
        xstring-buffer: New module.
index d39159810899dc3871964f7ebcdd2b169869e4b6..fe4f7812fd997f05bc7e0bd2b3b00f06260ba983 100644 (file)
@@ -200,12 +200,37 @@ In your @file{Makefile.am}, for every program @command{foo} that gets
 installed in, say, @file{$(bindir)}, you add:
 
 @example
-foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\"
+foo_CPPFLAGS = -DINSTALLDIR=$(bindir_c_make)
 if RELOCATABLE_VIA_LD
 foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)`
 endif
 @end example
 
+Similarly, if a program @command{foo} gets installed in @file{$(pkglibdir)},
+you add:
+
+@example
+foo_CPPFLAGS = -DINSTALLDIR=$(pkglibdir_c_make)
+if RELOCATABLE_VIA_LD
+foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(pkglibdir)`
+endif
+@end example
+
+The Makefile variables @code{bindir_c_make} or @code{pkglibdir_c_make}
+get defined by the Autoconf macros
+@code{gl_BUILD_TO_HOST_BINDIR} or @code{gl_BUILD_TO_HOST_PKGLIBDIR},
+respectively.
+These Autoconf macros are defined in the file @code{m4/build-to-host.m4}.
+You need to
+@itemize @bullet
+@item
+Import this file @code{m4/build-to-host.m4} into your package, for example
+by using of a command like @samp{gnulib-tool --copy m4/build-to-host.m4}.
+@item
+Invoke the corresponding macro(s) from your package's @file{configure.ac}.
+@end itemize
+
+@item
 When building gnulib to use with a relocatable library, you need to
 define the preprocessor symbol @code{IN_LIBRARY}.
 You may also want to build with @code{ENABLE_COSTLY_RELOCATABLE}, in which case
@@ -217,9 +242,9 @@ to build gnulib (@pxref{Modified build rules}).
 AM_CPPFLAGS += -DIN_LIBRARY -DENABLE_COSTLY_RELOCATABLE
 
 if SHLIBS_IN_BINDIR
-AM_CPPFLAGS += -DINSTALLDIR=\"$(bindir)\"
+AM_CPPFLAGS += -DINSTALLDIR=$(bindir_c_make)
 else
-AM_CPPFLAGS += -DINSTALLDIR=\"$(libdir)\"
+AM_CPPFLAGS += -DINSTALLDIR=$(libdir_c_make)
 endif
 @end example
 
index f466bdbd84abdf60e8305fa7adc12c74d7f05a8a..1e9a8161b52b608c604433aa573361203b4c9843 100644 (file)
@@ -1,5 +1,5 @@
 # build-to-host.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 2023-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -78,3 +78,148 @@ changequote([,])dnl
     *)  gl_tr_cr='\r' ;;
   esac
 ])
+
+
+dnl The following macros are convenience invocations of gl_BUILD_TO_HOST
+dnl for some of the variables that are defined by Autoconf.
+dnl To do so for _all_ the possible variables, use the module 'configmake'.
+
+dnl Defines bindir_c and bindir_c_make.
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_BINDIR],
+[
+  dnl Find the final value of bindir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_exec_prefix="${exec_prefix}"
+  gl_saved_bindir="${bindir}"
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    prefix="$ac_default_prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    exec_prefix='${prefix}'
+  fi
+  eval exec_prefix="$exec_prefix"
+  eval bindir="$bindir"
+  gl_BUILD_TO_HOST([bindir])
+  bindir="${gl_saved_bindir}"
+  exec_prefix="${gl_saved_exec_prefix}"
+  prefix="${gl_saved_prefix}"
+])
+
+dnl Defines libdir_c and libdir_c_make.
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LIBDIR],
+[
+  dnl Find the final value of libdir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_exec_prefix="${exec_prefix}"
+  gl_saved_libdir="${libdir}"
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    prefix="$ac_default_prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    exec_prefix='${prefix}'
+  fi
+  eval exec_prefix="$exec_prefix"
+  eval libdir="$libdir"
+  gl_BUILD_TO_HOST([libdir])
+  libdir="${gl_saved_libdir}"
+  exec_prefix="${gl_saved_exec_prefix}"
+  prefix="${gl_saved_prefix}"
+])
+
+dnl Defines libexecdir_c and libexecdir_c_make.
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LIBEXECDIR],
+[
+  dnl Find the final value of libexecdir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_exec_prefix="${exec_prefix}"
+  gl_saved_libexecdir="${libexecdir}"
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    prefix="$ac_default_prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    exec_prefix='${prefix}'
+  fi
+  eval exec_prefix="$exec_prefix"
+  eval libexecdir="$libexecdir"
+  gl_BUILD_TO_HOST([libexecdir])
+  libexecdir="${gl_saved_libexecdir}"
+  exec_prefix="${gl_saved_exec_prefix}"
+  prefix="${gl_saved_prefix}"
+])
+
+dnl Defines localedir_c and localedir_c_make.
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LOCALEDIR],
+[
+  dnl Find the final value of localedir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_datarootdir="${datarootdir}"
+  gl_saved_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"
+  gl_BUILD_TO_HOST([localedir])
+  localedir="${gl_saved_localedir}"
+  datarootdir="${gl_saved_datarootdir}"
+  prefix="${gl_saved_prefix}"
+])
+
+dnl Defines pkgdatadir_c and pkgdatadir_c_make,
+dnl where pkgdatadir = $(datadir)/$(PACKAGE)
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_PKGDATADIR],
+[
+  dnl Find the final value of pkgdatadir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_datarootdir="${datarootdir}"
+  gl_saved_datadir="${datadir}"
+  gl_saved_pkgdatadir="${pkgdatadir}"
+  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 datadir="$datadir"
+  eval pkgdatadir="$pkgdatadir"
+  gl_BUILD_TO_HOST([pkgdatadir])
+  pkgdatadir="${gl_saved_pkgdatadir}"
+  datadir="${gl_saved_datadir}"
+  datarootdir="${gl_saved_datarootdir}"
+  prefix="${gl_saved_prefix}"
+])
+
+dnl Defines pkglibdir_c and pkglibdir_c_make,
+dnl where pkglibdir = $(libdir)/$(PACKAGE)
+AC_DEFUN_ONCE([gl_BUILD_TO_HOST_PKGLIBDIR],
+[
+  dnl Find the final value of pkglibdir.
+  gl_saved_prefix="${prefix}"
+  gl_saved_exec_prefix="${exec_prefix}"
+  gl_saved_libdir="${libdir}"
+  gl_saved_pkglibdir="${pkglibdir}"
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    prefix="$ac_default_prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    exec_prefix='${prefix}'
+  fi
+  eval exec_prefix="$exec_prefix"
+  eval libdir="$libdir"
+  eval pkglibdir="$pkglibdir"
+  gl_BUILD_TO_HOST([pkglibdir])
+  pkglibdir="${gl_saved_pkglibdir}"
+  libdir="${gl_saved_libdir}"
+  exec_prefix="${gl_saved_exec_prefix}"
+  prefix="${gl_saved_prefix}"
+])
index 8cd3890b2c8b9078075a2437af86f13ecfd2c076..c8580c95fa7c5b81a5cb4bd8929eac0cebb7b3c7 100644 (file)
@@ -1,5 +1,5 @@
 # gettext.m4
-# serial 79 (gettext-0.23)
+# serial 80 (gettext-0.23)
 dnl Copyright (C) 1995-2014, 2016, 2018-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -365,21 +365,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
   AC_SUBST([POSUB])
 
   dnl Define localedir_c and localedir_c_make.
-  dnl Find the final value of localedir.
-  gt_saved_prefix="${prefix}"
-  gt_saved_datarootdir="${datarootdir}"
-  gt_saved_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"
-  gl_BUILD_TO_HOST([localedir])
-  localedir="${gt_saved_localedir}"
-  datarootdir="${gt_saved_datarootdir}"
-  prefix="${gt_saved_prefix}"
+  gl_BUILD_TO_HOST_LOCALEDIR
 ])