Subject: Re: buildlink2 problems with new libogg and libvorbis packages
To: NetBSD Packages Technical Discussion List <tech-pkg@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 10/04/2002 23:39:52
[ On , October 5, 2002 at 13:09:04 (+1000), Rene Hexel wrote: ]
> Subject: Re: buildlink2 problems with new libogg and libvorbis packages
>
> On Sat, 2002-10-05 at 12:37, Greg A. Woods wrote:
> 
> > The problem really is that -Wl,-R${PREFIX}/lib isn't passed in LDFLAGS
> 
>   This sounds like something is wrong in your setup.  From bsd.pkg.mk:
> 
> 
> .if ${_USE_RPATH} == "yes"
> LDFLAGS+=               -Wl,-R${LOCALBASE}/lib

Ah yes...  That was the hint I needed.  I had stared at that line for
many minutes, and I thought it should be having some effect, but I
didn't know for sure that's where buillink2 was supposed to get this
setting from.  Thank you very much for pointing it out directly!

It turns out that on the last merge with my local LDSTATIC changes an
extra ".else" had crept in and that section was never seen.

I should test this myself, but is it true our 'make' ignores unclosed
'.else' statements?  I thought I should have got a warning or error if
there was an unbalanced .else/.endif.


>   And _USE_RPATH is set to "yes" in defs.NetBSD.mk.  What does
> 
>   make show-var VARNAME=LDFLAGS
> 
>   produce in audio/libvorbis on your system?

It now correctly shows:

	$ make show-var VARNAME=LDFLAGS     
	-L/usr/pkg/lib   -Wl,-R/usr/pkg/lib

Note I got rid of the redundant identical '-L' with this hack:
(hand edited a bit, ignore the line numbers)

***************
*** 408,418 ****
  .endif
  
! .if !defined(USE_BUILDLINK_ONLY)
  LDFLAGS+=		-L${LOCALBASE}/lib
  .endif
--- 496,517 ----
  .endif
  
! .if !defined(USE_BUILDLINK_ONLY) && !defined(USE_BUILDLINK2)
  LDFLAGS+=		-L${LOCALBASE}/lib
  .endif


The correct fix would be for the LDFLAGS munging in
buildlink2/bsd.buildlink2.mk to check if a value is in the
variable before it adds it blindly again, something like this:

	.if empty(LDFLAGS:M*${NEW_VALUE}*)
	LDFLAGS+=		${NEW_VALUE}
	.endif

but then there are lots of similar sins still spread throughout pkgsrc.  :-)

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>