]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext-runtime: Provide helper script to build against uninstalled binaries.
authorBruno Haible <bruno@clisp.org>
Tue, 21 Jun 2022 00:50:34 +0000 (02:50 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2022 07:30:42 +0000 (09:30 +0200)
Prompted by <https://gcc.gnu.org/pipermail/gcc/2022-June/238929.html>.

* gettext-runtime/uninstalled-config.sh.in: New file.
* gettext-runtime/configure.ac: New variable ENABLE_SHARED. Generate
uninstalled-config.sh at configure time.

.gitignore
gettext-runtime/configure.ac
gettext-runtime/uninstalled-config.sh.in [new file with mode: 0644]

index 0b269b341d8f953401f7f03e15336342478b6653..f7f4850a83db4d0a8a5a925d56178c2956b1a0f3 100644 (file)
@@ -565,6 +565,7 @@ autom4te.cache/
 /gettext-runtime/javacomp.sh
 /gettext-runtime/libtool
 /gettext-runtime/stamp-h1
+/gettext-runtime/uninstalled-config.sh
 /gettext-runtime/doc/Makefile
 /gettext-runtime/intl/Makefile
 /gettext-runtime/intl-csharp/Makefile
index aef12e9fd563a300034b0536e378e5146850dfe8..e0afe2e3062d6b651247cbe2f9fa4e5232d828de 100644 (file)
@@ -188,9 +188,14 @@ if test "$CXX" = "no"; then
 fi
 AM_CONDITIONAL([ENABLE_LIBASPRINTF], [test -n "$SUBDIR_libasprintf"])
 
+dnl Determine variables used by uninstalled-config.sh.
+ENABLE_SHARED="$enable_shared"
+AC_SUBST([ENABLE_SHARED])
+
 AC_CONFIG_SUBDIRS([libasprintf])
 
 AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([uninstalled-config.sh])
 
 AC_CONFIG_FILES([doc/Makefile])
 
diff --git a/gettext-runtime/uninstalled-config.sh.in b/gettext-runtime/uninstalled-config.sh.in
new file mode 100644 (file)
index 0000000..62bea4a
--- /dev/null
@@ -0,0 +1,113 @@
+#! /bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+# This script makes it possible to build this package in a sibling directory
+# of a package such as GCC, gdb, or binutils, and use the binaries in the
+# build tree without doing 'make install'.
+#
+# Use from within a Bourne-compatible shell:
+#     relative_builddir='${top_builddir}/../gettext-runtime'
+#     . ${top_builddir}/../gettext-runtime/uninstalled-config.sh
+
+# Note: Another option for the same use-case would be a Makefile target
+# 'install-lib', such that the sibling package could do
+#     cd ${top_builddir}/../gettext-runtime \
+#     && $(MAKE) all \
+#     && $(MAKE) install-lib libdir=... includedir=...
+# This is how it's done in GNU libiconv. However, the 'uninstalled-config.sh'
+# approach has two advantages:
+#   - it does not copy artifacts around,
+#   - it even allows for Makefile rules to depend on the uninstalled binaries.
+# It has also a drawback:
+#   - On platforms with weird shared library mechanisms (e.g. AIX, HP-UX,
+#     native Windows) it works only with '--disable-shared'.
+
+# ================= Configuration variables for using libintl =================
+
+# INCINTL is a set of compiler options, to use when preprocessing or compiling,
+# that ensures that the uninstalled <libintl.h> gets found.
+# Attention! This variable needs to be used _after_ the -I options that ensure
+# access to config.h (because INCINTL may contain a -I option that would allow
+# access to libintl's private config.h, which you should not use).
+if test @USE_INCLUDED_LIBINTL@ = yes; then
+  # The intl/ subdirectory contains the <libintl.h> that "make install" would
+  # install.
+  INCINTL="-I ${relative_builddir}/intl"
+else
+  # No <libintl.h> file is needed, as it is provided by libc.
+  INCINTL=
+fi
+
+# LIBINTL is a set of compiler options, to use when linking without libtool,
+# that ensures that the library that contains the *gettext() family of functions
+# gets found.
+if test @USE_INCLUDED_LIBINTL@ = yes; then
+  if test '@ENABLE_SHARED@' = yes; then
+    # NB: This case is not supported on AIX and HP-UX.
+    LIBINTL="${relative_builddir}/intl/.libs/libintl.so -Wl,-rpath,${relative_builddir}/intl/.libs @LIBICONV@ @INTL_MACOSX_LIBS@"
+  else
+    LIBINTL="${relative_builddir}/intl/.libs/libintl.a @LIBICONV@ @INTL_MACOSX_LIBS@"
+  fi
+else
+  # The functionality is provided by libc.
+  LIBINTL=
+fi
+
+# LTLIBINTL is a set of compiler options, to use when linking with libtool,
+# that ensures that the library that contains the *gettext() family of functions
+# gets found.
+if test @USE_INCLUDED_LIBINTL@ = yes; then
+  LTLIBINTL="${relative_builddir}/intl/libintl.la @LTLIBICONV@ @INTL_MACOSX_LIBS@"
+else
+  # The functionality is provided by libc.
+  LTLIBINTL=
+fi
+
+# LIBINTL_DEP is a list of files, that can be used in Makefile dependency lists,
+# that indicate that binaries linked with LIBINTL or LTLIBINTL need to be
+# rebuilt.
+if test @USE_INCLUDED_LIBINTL@ = yes; then
+  LIBINTL_DEP="${relative_builddir}/intl/libintl.la"
+else
+  LIBINTL_DEP=
+fi
+
+# ============== Configuration variables for compiling PO files ==============
+
+# USE_NLS is 'yes' if the build is NLS enabled and therefore .po files should
+# be compiled and .mo files should be installed. It is 'no' otherwise.
+USE_NLS='@USE_NLS@'
+
+# POSUB is 'po' if the build is NLS enabled and therefore the build needs to
+# recurse into the 'po' directory. It is empty otherwise.
+POSUB='@POSUB@'
+
+# XGETTEXT is a GNU xgettext version ≥ 0.12, if found in $PATH, or ':' if
+# not found.
+XGETTEXT='@XGETTEXT@'
+
+# XGETTEXT_015 is a GNU xgettext version ≥ 0.15, if found in $PATH, or ':' if
+# not found.
+XGETTEXT_015='@XGETTEXT_015@'
+
+# GMSGFMT is a GNU msgfmt, if found in $PATH, or ':' if not found.
+GMSGFMT='@GMSGFMT@'
+
+# GMSGFMT_015 is a GNU msgfmt version ≥ 0.15, if found in $PATH, or ':' if
+# not found.
+GMSGFMT_015='@GMSGFMT_015@'