Discussion:
relocatable-lib and "make distcheck"
(too old to reply)
Reuben Thomas
2017-03-27 19:27:57 UTC
Permalink
Raw Message
When I use relocatable-lib it adds a line like this to Makefile in src/:

include ../lib/$(DEPDIR)/relocatable.Plo

In my top-level Makefile.am, I have "lib" (containing gnulib) before "src",
which is necessary, because the programs in src link against libgnu.la.

When I run "make distcheck", "make distclean" is run first in lib/. Then
when it is run in src/ I get an error because reloctable.Plo no longer
exists.

I can't see anything in the gnulib docs about this, so at least there seems
to be a documentation problem, but I also can't work out how to fix it, so
would appreciate some help!
--
http://rrt.sc3d.org
Bruno Haible
2017-03-28 19:06:17 UTC
Permalink
Raw Message
Hi Reuben,
Post by Reuben Thomas
include ../lib/$(DEPDIR)/relocatable.Plo
In my top-level Makefile.am, I have "lib" (containing gnulib) before "src",
which is necessary, because the programs in src link against libgnu.la.
When I run "make distcheck", "make distclean" is run first in lib/. Then
when it is run in src/ I get an error because reloctable.Plo no longer
exists.
1)
When I use GNU hello, I cannot reproduce it, because it has only 1 Makefile.am.

When I use GNU gettext, the gettext-tools/gnulib-tests/ directory also refers
to a .la file in a sibling directory (../gnulib-lib/libgettextlib.la), but
the generated Makefile contains 'include' statements only for directories in
the current directory.

So, I cannot reproduce. => Next time, please tell how to reproduce it.

2) When I look at the generated Makefile, I see this snippet:

case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \

Have you tried to define the DIST_SUBDIRS variable in Makefile.am [1], listing the
subdirectories in reverse order?

Bruno

[1] https://www.gnu.org/software/automake/manual/html_node/SUBDIRS-vs-DIST_005fSUBDIRS.html
Reuben Thomas
2017-03-29 12:32:06 UTC
Permalink
Raw Message
Post by Bruno Haible
So, I cannot reproduce. => Next time, please tell how to reproduce it.
​Current master head of https://github.com/rrthomas/enchant/ :

./autogen.sh
make
make clean
make distclean​

​Do let me know if you'd prefer a M!WE​.
​ (So far I've been working on trying to understand what is going on, see
below.)​
Post by Bruno Haible
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
Have you tried to define the DIST_SUBDIRS variable in Makefile.am [1], listing the
subdirectories in reverse order?
​I tried this just now, and it merely shifts the problem to lib/, where I
get

make[1]: Entering directory '/home/rrt/.local/var/repo/enchant/lib'
Makefile:861: .deps/alloca.Plo: No such file or directory
Makefile:862: .deps/alloca.Plo: No such file or directory
Makefile:863: .deps/flock.Plo: No such file or directory
Makefile:864: .deps/malloc.Plo: No such file or directory
Makefile:865: .deps/msvc-inval.Plo: No such file or directory
Makefile:866: .deps/msvc-nothrow.Plo: No such file or directory
Makefile:867: .deps/relocatable.Plo: No such file or directory
Makefile:868: .deps/strdup.Plo: No such file or directory
Makefile:869: .deps/unistd.Plo: No such file or directory
make[1]: *** No rule to make target '.deps/unistd.Plo'. Stop.

This is because when running "make distclean" in src it does:

rm -rf ../lib/.deps ./.deps

Looking at automake's source, this is a result of removing DEPDIRS, which
is a pseudo-variable (defined specially in the automake script), which
expands to the list of directories from @deplist.

I cannot see how relocatable.c is treated specially (i.e. included
directly, as it needs to be, rather than just via libgnu.la).
m4/relocatable-lib.m4 doesn't seem to mention it, and
modules/relocatable-lib-lgpl doesn't seem to do anything special with the
relocatable.[ch] files, just mentions them as deps.
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-29 12:38:37 UTC
Permalink
Raw Message
Post by Reuben Thomas
I cannot see how relocatable.c is treated specially (i.e. included
directly, as it needs to be, rather than just via libgnu.la).
m4/relocatable-lib.m4 doesn't seem to mention it, and
modules/relocatable-lib-lgpl doesn't seem to do anything special with the
relocatable.[ch] files, just mentions them as deps.
​OK, this happens by means of AC_LIBOBJ([relocatable]) in configure.ac, as
mandated by the relocatable documentation.
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-29 15:29:18 UTC
Permalink
Raw Message
Post by Reuben Thomas
Post by Reuben Thomas
I cannot see how relocatable.c is treated specially (i.e. included
directly, as it needs to be, rather than just via libgnu.la).
m4/relocatable-lib.m4 doesn't seem to mention it, and
modules/relocatable-lib-lgpl doesn't seem to do anything special with the
relocatable.[ch] files, just mentions them as deps.
​OK, this happens by means of AC_LIBOBJ([relocatable]) in configure.ac,
as mandated by the relocatable documentation.
​(I know that relocatable-lib-lgpl doesn't mention AC_LIBOBJ, but
relocatable-lib does, and I believe it's also required for
relocatable-lib-lgpl; this will feature in my documentation update when I
get things working!)
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-29 15:59:38 UTC
Permalink
Raw Message
Post by Reuben Thomas
Post by Reuben Thomas
I cannot see how relocatable.c is treated specially (i.e. included
directly, as it needs to be, rather than just via libgnu.la).
m4/relocatable-lib.m4 doesn't seem to mention it, and
modules/relocatable-lib-lgpl doesn't seem to do anything special with the
relocatable.[ch] files, just mentions them as deps.
​OK, this happens by means of AC_LIBOBJ([relocatable]) in configure.ac,
as mandated by the relocatable documentation.
​Further, neither gettext nor hello calls AC_LIBOBJ in configure.ac.

I can find some code that parses the Makefile include lines in
/usr/share/aclocal-1.15/depend.m4, but I can't find where they are
generated (looking in automake, aclocal and autoconf).

I'm now just floundering around in the sources without a very clear idea, a
long way from any documentation, so I shall back up and try to create a
minimal failing example.
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-29 16:51:36 UTC
Permalink
Raw Message
Post by Reuben Thomas
I'm now just floundering around in the sources without a very clear idea,
a long way from any documentation, so I shall back up and try to create a
minimal failing example.
​See https://github.com/rrthomas/enchant.git branch
relocatable-build-problem

./autogen.sh
make
make distclean

shows the error. Let me know if you need it cut down more.
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-30 11:53:14 UTC
Permalink
Raw Message
Post by Reuben Thomas
Post by Reuben Thomas
I'm now just floundering around in the sources without a very clear idea,
a long way from any documentation, so I shall back up and try to create a
minimal failing example.
​See https://github.com/rrthomas/enchant.git branch
relocatable-build-problem
./autogen.sh
make
make distclean
shows the error. Let me know if you need it cut down more.
​I've cut down the build system and code to pretty much trivial levels.
Hopefully that's enough for you to see what the problem is (either mine or
relocatable's). As before, do let me know if I should remove something else.
--
http://rrt.sc3d.org
Bruno Haible
2017-04-02 19:59:41 UTC
Permalink
Raw Message
Hi Reuben,
​See https://github.com/rrthomas/enchant.git branch
relocatable-build-problem
./autogen.sh
make
make distclean
shows the error. Let me know if you need it cut down more.
​I've cut down the build system and code to pretty much trivial levels.
Hopefully that's enough for you to see what the problem is (either mine or
relocatable's).
Yes, this time I can analyze it.

In configure.ac you use
AC_LIBOBJ([relocatable])

Don't use AC_LIBOBJ. Especially, don't use AC_LIBOBJ with gnulib.

Rationale: AC_LIBOBJ has some design limitations. Some of the gnulib logic
is devoted to overcoming these limitations.

$ grep 'relocate (' */*.c
lib/relocatable.c:relocate (const char *pathname)
src/lib.c:enchant_relocate (const char *path)
src/lib.c: char *newpath = (char *) relocate (path);
src/lib.c: conf_dirs = g_slist_append (conf_dirs, enchant_relocate (PKGDATADIR));
src/lib.c: char *sysconfdir = enchant_relocate (SYSCONFDIR);
src/lib.c: char *module_dir = enchant_relocate (PKGLIBDIR);
src/lib.c: return enchant_relocate (INSTALLPREFIX);

So, you need the relocate() function only in lib.c, which is part of
libenchant_la_SOURCES. libenchant_la_LIBADD already contains libgnu.la,
so there is no point in the extra AC_LIBOBJ.

When you do so, you get a link error
./.libs/libenchant.so: undefined reference to `relocate'
./.libs/libenchant.so: undefined reference to `set_relocation_prefix'

The reason is, when I look at the difference between modules/relocatable-lib
and modules/relocatable-lib-lgpl, the missing AC_LIBOBJ invocation there.
This is a mistake in my commit from 2011-05-21
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=357d319ff8af64cc9dcce17868a4c40260f6cccc
Fixing it as follows:


2017-04-02 Bruno Haible <***@clisp.org>

relocatable-lib-lgpl: Fix link error (regression from 2011-06-16).
* modules/relocatable-lib-lgpl (configure.ac): Add AC_LIBOBJ invocation,
like it was done in modules/relocatable-lib on 2011-05-21 and in
modules/relocatable-prog on 2011-08-15.
Reported by Reuben Thomas <***@sc3d.org>.

diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl
index 26abd40..11b1400 100644
--- a/modules/relocatable-lib-lgpl
+++ b/modules/relocatable-lib-lgpl
@@ -13,6 +13,9 @@ strdup

configure.ac:
gl_RELOCATABLE_LIBRARY
+if test $RELOCATABLE = yes; then
+ AC_LIBOBJ([relocatable])
+fi

Makefile.am:
DEFS += -DNO_XMALLOC
Reuben Thomas
2017-04-03 12:31:23 UTC
Permalink
Raw Message
Post by Bruno Haible
Yes, this time I can analyze it.
​Thanks very much for your help, again!​

So, you need the relocate() function only in lib.c, which is part of
Post by Bruno Haible
libenchant_la_SOURCES. libenchant_la_LIBADD already contains libgnu.la,
so there is no point in the extra AC_LIBOBJ.
​OK, I got confused and I thought that the "configure.ac" etc. sections of
the modules/ file were things I had to add to configure.ac manually.​

​The fix is reassuring, because I suggested before that the AC_LIBOBJ call
was needed in relocatable-lib-lgpl (but I didn't understand, as I said
above above, ​that it is applied automatically, and is not something one
needs to add manually).

​Many thanks​, I'm back on track!

Loading...