gnulib: allow control over srcdir

Message ID 20210608220639.1975-1-vapier@gentoo.org
State New
Headers show
Series
  • gnulib: allow control over srcdir
Related show

Commit Message

Simon Marchi via Gdb-patches June 8, 2021, 10:06 p.m.
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.  Add a variable so users can control.
---
 gnulib/Makefile.gnulib.inc.in | 6 +++++-
 sim/common/Make-common.in     | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.31.1

Comments

Tom Tromey June 9, 2021, 2:47 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.  Add a variable so users can control.

This is ok.

This file isn't actually used any more by gdb.

Tom
Simon Marchi via Gdb-patches June 9, 2021, 4:58 p.m. | #2
On 09 Jun 2021 08:47, Tom Tromey wrote:
> >>>>> "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.  Add a variable so users can control.

> 

> This is ok.


i noticed an issue.  upstream gnulib already uses GNULIB_SRCDIR in its bootstrap
so people can export it in their env to point to the upstream gnulib git tree.
if that's exported, then building gdb fails :/.

since we can't assume GNU make, i was going to rename it to GNULIB_LOCAL_SRCDIR
unless someone wants to bikeshed a diff name.

> This file isn't actually used any more by gdb.


seems to be ?  gdb/Makefile.in & gdbserver/Makefile.in have:

gdb/Makefile.in:GNULIB_BUILDDIR = ../gnulib
gdb/Makefile.in:include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc
gdb/Makefile.in:	$(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(ENABLE_CFLAGS) \
gdb/Makefile.in:	$(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \
gdb/Makefile.in:	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
gdbserver/Makefile.in:GNULIB_BUILDDIR = ../gnulib
gdbserver/Makefile.in:include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc
gdbserver/Makefile.in:	-I$(srcdir)/../gdb $(INCGNU) $(INCSUPPORT) \
gdbserver/Makefile.in:gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY) \
gdbserver/Makefile.in:		-o gdbserver$(EXEEXT) $(OBS) $(GDBSUPPORT) $(LIBGNU) \
gdbserver/Makefile.in:		$(LIBGNU_EXTRA_LIBS) $(LIBIBERTY) $(INTL) \
gdbserver/Makefile.in:gdbreplay$(EXEEXT): $(sort $(GDBREPLAY_OBS)) $(LIBGNU) $(LIBIBERTY) \
gdbserver/Makefile.in:		$(GDBSUPPORT) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) \
-mike
Tom Tromey June 10, 2021, 6:15 p.m. | #3
Mike> since we can't assume GNU make, i was going to rename it to GNULIB_LOCAL_SRCDIR
Mike> unless someone wants to bikeshed a diff name.

I think it's fine to assume GNU make, Makefile.gnulib.inc already seems
to with its use of $(error)


Anyway, one idea is to replace GNULIB_BUILDDIR with a variable that just
indicates how to reach top-of-entire-tree from the Makefile in question,
like:

# gdb or whatever sets:
top_of_tree = ../..

# gnulib does:
GNULIB_BUILDDIR = $(top_of_tree)/gnulib
INCGNU = -I$(srcdir)/$(top_of_tree)/gnulib/import


>> This file isn't actually used any more by gdb.


Mike> seems to be ?  gdb/Makefile.in & gdbserver/Makefile.in have:

Ugh, sorry.  grep fail by me.

Tom

Patch

diff --git a/gnulib/Makefile.gnulib.inc.in b/gnulib/Makefile.gnulib.inc.in
index 822f892a189a..fc3d63c39f18 100644
--- a/gnulib/Makefile.gnulib.inc.in
+++ b/gnulib/Makefile.gnulib.inc.in
@@ -36,9 +36,13 @@  ifndef GNULIB_BUILDDIR
 $(error missing GNULIB_BUILDDIR)
 endif
 
+ifndef GNULIB_SRCDIR
+GNULIB_SRCDIR = $(srcdir)/../gnulib
+endif
+
 LIBGNU = $(GNULIB_BUILDDIR)/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$(GNULIB_SRCDIR)/import -I$(GNULIB_BUILDDIR)/import
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 4b2587985379..3ea840d935e0 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -41,6 +41,7 @@  srcroot = $(srcdir)/../..
 srcsim = $(srcdir)/..
 
 # Helper code from gnulib.
+GNULIB_SRCDIR = $(srcroot)/gnulib
 GNULIB_BUILDDIR = ../../gnulib
 include $(GNULIB_BUILDDIR)/Makefile.gnulib.inc