gnulib: define the path to gnulib's parent dir

Message ID 20210613052352.18771-1-vapier@gentoo.org
State New
Headers show
Series
  • gnulib: define the path to gnulib's parent dir
Related show

Commit Message

The current setting assumes that gnulib is only used by dirs
immediately under the source root.  Trying to build it two or
more levels deep fails.  Switch GNULIB_BUILDDIR to a relative
GNULIB_PARENT_DIR so that it can be used to construct both the
build & source paths.
---
 gdb/Makefile.in               |  4 ++--
 gdbserver/Makefile.in         |  4 ++--
 gnulib/Makefile.gnulib.inc.in | 10 ++++++----
 sim/common/Make-common.in     |  4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

-- 
2.31.1

Comments

Tom Tromey June 14, 2021, 3:23 p.m. | #1
>>>>> "Mike" == Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> writes:


Mike> The current setting assumes that gnulib is only used by dirs
Mike> immediately under the source root.  Trying to build it two or
Mike> more levels deep fails.  Switch GNULIB_BUILDDIR to a relative
Mike> GNULIB_PARENT_DIR so that it can be used to construct both the
Mike> build & source paths.

Looks good.  Thank you.

Tom

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index f664d964536d..b3d264f267cb 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -245,8 +245,8 @@  CODESIGN_CERT = @CODESIGN_CERT@
 GDBFLAGS =
 
 # Helper code from gnulib.
-GNULIB_BUILDDIR = ../gnulib
-include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc
+GNULIB_PARENT_DIR = ..
+include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc
 
 SUPPORT = ../gdbsupport
 LIBSUPPORT = $(SUPPORT)/libgdbsupport.a
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
index f7ade7d61d5c..12e9b2777aef 100644
--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -122,8 +122,8 @@  ustlibs = @ustlibs@
 ustinc = @ustinc@
 
 # gnulib
-GNULIB_BUILDDIR = ../gnulib
-include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc
+GNULIB_PARENT_DIR = ..
+include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc
 
 # Where is the INTL library?  Typically in ../intl.
 INTL = @LIBINTL@
diff --git a/gnulib/Makefile.gnulib.inc.in b/gnulib/Makefile.gnulib.inc.in
index 822f892a189a..cf69b835cfda 100644
--- a/gnulib/Makefile.gnulib.inc.in
+++ b/gnulib/Makefile.gnulib.inc.in
@@ -32,13 +32,15 @@ 
 # INCGNU: A list of -I.... include paths that should be passed to the
 #        compiler, these are where the gnulib headers can be found.
 
-ifndef GNULIB_BUILDDIR
-$(error missing GNULIB_BUILDDIR)
+# Packages must define the relative path to gnulib's parent dir.
+ifndef GNULIB_PARENT_DIR
+$(error missing GNULIB_PARENT_DIR)
 endif
 
-LIBGNU = $(GNULIB_BUILDDIR)/import/libgnu.a
+LIBGNU = $(GNULIB_PARENT_DIR)/gnulib/import/libgnu.a
 LIBGNU_EXTRA_LIBS = @FREXPL_LIBM@ @FREXP_LIBM@ @INET_NTOP_LIB@ \
                     @LIBTHREAD@ @LIB_GETLOGIN@ @LIB_GETRANDOM@ \
                     @LIB_HARD_LOCALE@ @LIB_MBRTOWC@ \
                     @LIB_SETLOCALE_NULL@ @LIBINTL@ @LIB_SELECT@ @LIBSOCKET@
-INCGNU = -I$(srcdir)/../gnulib/import -I$(GNULIB_BUILDDIR)/import
+INCGNU = -I$(srcdir)/$(GNULIB_PARENT_DIR)/gnulib/import \
+         -I$(GNULIB_PARENT_DIR)/gnulib/import
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 7a5bbc1a985c..3dab9ca1fd14 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -41,8 +41,8 @@  srcroot = $(srcdir)/../..
 srcsim = $(srcdir)/..
 
 # Helper code from gnulib.
-GNULIB_BUILDDIR = ../../gnulib
-include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc
+GNULIB_PARENT_DIR = ../..
+include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc
 
 prefix = @prefix@
 exec_prefix = @exec_prefix@