Date: Sun, 5 May 2013 23:58:40 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Pawel Jakub Dawidek <pjd@FreeBSD.org> Cc: freebsd-arch@FreeBSD.org Subject: Re: Building library that depends on another library. Message-ID: <20130505215839.GA85274@stack.nl> In-Reply-To: <20130505201436.GJ1374@garage.freebsd.pl> References: <20130505201436.GJ1374@garage.freebsd.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, May 05, 2013 at 10:14:36PM +0200, Pawel Jakub Dawidek wrote:
> I'm trying to connect two libraries to the build without hacks and it
> doesn't work...
> My two libraries are libcapsicum and libnv. libcapsicum depends on libnv.
> I want to specify this dependency explicitely in libcapsicum's Makefile:
> DPADD= ${LIBNV}
> LDADD= -lnv
> (LIBNV was added to bsd.libnames.mk, in case you wonder.)
> From conversation with kan@ (Alexander Kabaev) declaring dependency
> directly in library's Makefile is required for symbol versioning to
> work. It just sounds right, too.
> If this is done, libcapsicum doesn't compile:
> ===> lib/libcapsicum (all)
> cc [...]
> cc [...]
> building static capsicum library
> ranlib libcapsicum.a
> cc [...]
> cc [...]
> make: don't know how to make
> /usr/home/pjd/obj/usr/home/pjd/p4/capsicum/tmp/usr/lib/libnv.a. Stop
> *** [all] Error code 2
>
> Stop in /usr/home/pjd/p4/capsicum/lib.
> *** [lib__L] Error code 1
> Note that when build fails libnv.{a,so} exist in <OBJDIR>/lib/libnv/,
> but of course not in <OBJDIR>/tmp/usr/lib/.
> It looks like to make such dependency work one HAS TO add libnv to
> _prebuild_libs in src/Makefile.inc1, which seems wrong.
[removing incorrect sentence about LD_LIBRARY_PATH here]
> My understanding was that all I need to do is to add my two libraries in
> proper order to SUBDIR_ORDERED variable in src/lib/Makefile.
> This means that currently SUBDIR_ORDERED is totally useless.
> No matter how libraries are ordered there, to compile, they need
> libraries they depend on in Makefile.inc1's _prebuild_libs.
This analysis seems correct. The order in SUBDIR_ORDERED in
src/lib/Makefile is useless because it first makes obj in all
directories, then depend, then all, then install; therefore, libraries
are not installed to ${WORLDTMP}/usr/lib to be picked up in time by
libraries depending on them.
Instead, the directories in _prebuild_libs first get
obj/depend/all/install for the first directory so that libraries are
installed in time. As noted in the comment in src/Makefile.inc1, the
script src/tools/make_libdeps.sh can be helpful in determining what to
put in _prebuild_libs.
> I can of course just add libnv to _prebuild_libs and make it compile
> twice for no reason, but maybe there is a better way or maybe I'm just
> missing something?
It just runs make through it twice. The second time, it does not compile
anything.
--
Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130505215839.GA85274>
