Date: Tue, 7 May 2013 12:20:56 -0700 From: mdf@FreeBSD.org To: Pawel Jakub Dawidek <pjd@freebsd.org> Cc: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no>, FreeBSD Arch <freebsd-arch@freebsd.org> Subject: Re: Building library that depends on another library. Message-ID: <CAMBSHm_bsiCbUoabZ2YM7sq7HRQ7Lo2OXuOSuykbg_4ViOSO2g@mail.gmail.com> In-Reply-To: <20130507185005.GB1888@garage.freebsd.pl> References: <20130505201436.GJ1374@garage.freebsd.pl> <86r4hkgd04.fsf@nine.des.no> <20130507185005.GB1888@garage.freebsd.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 7, 2013 at 11:50 AM, Pawel Jakub Dawidek <pjd@freebsd.org>wrote= : > On Mon, May 06, 2013 at 08:49:15PM +0200, Dag-Erling Sm=F8rgrav wrote: > > Pawel Jakub Dawidek <pjd@FreeBSD.org> writes: > > > It looks like to make such dependency work one HAS TO add libnv to > > > _prebuild_libs in src/Makefile.inc1, which seems wrong. > > > > It may seem wrong, but it is correct, cf the following comment in > > Makefile.inc1: > > > > # The list of libraries with dependents (${_prebuild_libs}) and their > > # interdependencies (__L) are built automatically by the > > # ${.CURDIR}/tools/make_libdeps.sh script. > > Yes, this also means SUBDIR_ORDERED in lib/Makefile doesn't make sense. > > All in all I really don't like to add libraries to Makefile.inc1, it > doesn't sound right. I'd like this to be self-contained. For bsd.prog.mk > it is enough to specify DPADD/LDADD in program's Makefile instead of > hacking some central Makefile. > > I came up with something like the following. Instead of: > > DPADD=3D ${LIBNV} > LDADD=3D -lnv > (plus modifying src/Makefile.inc1) > > I only add: > > LDADD=3D -L${.OBJDIR}/../libnv -lnv > > What do people think? > I won't claim any knowledge of various Makefile variables, but at work we use this. (I think gcooper is changing this to have the -L in LDFLAGS so the LDADD stays pure; I suppose it is better but it's even more verbose). We also use rcorder on our makefiles so they're built in the right order, which AFAICT serves the same purpose as DPADD but perhaps less annoyingly (no need to define LIBNV somewhere). However, it still requires over-specification (and a mis-spelling will break it). So for our libraries, each Makefile should have a # PROIVIDE: line as well as potentially some # REQUIRE: lines. Using rcorder has the advantage that it will detect circular dependencies. It would be nice if the existence of an LDADD in the Makefile would automatically also mean the ordering of build was determined; DPADD/LDADD should be in parallel already. And for our use of rcorder, it's redundant to have both a REQUIRE line and an LDADD line. But I think quickly we're getting past what make(1) can do and into the realms of "build systems are hard". Cheers, matthew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm_bsiCbUoabZ2YM7sq7HRQ7Lo2OXuOSuykbg_4ViOSO2g>