From owner-freebsd-arch@FreeBSD.ORG Sun May 5 21:58:42 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 757A4541; Sun, 5 May 2013 21:58:42 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 3579AEEC; Sun, 5 May 2013 21:58:42 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 3DB8C359306; Sun, 5 May 2013 23:58:40 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 228CF28493; Sun, 5 May 2013 23:58:40 +0200 (CEST) Date: Sun, 5 May 2013 23:58:40 +0200 From: Jilles Tjoelker To: Pawel Jakub Dawidek Subject: Re: Building library that depends on another library. Message-ID: <20130505215839.GA85274@stack.nl> References: <20130505201436.GJ1374@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130505201436.GJ1374@garage.freebsd.pl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 May 2013 21:58:42 -0000 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 /lib/libnv/, > but of course not in /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