Sat Jan 17 12:07:59 2009 UTC ()
Move _LIBLDOPTS and LDFLAGS to a spot behind LDADD when making a
shared library.  This is done so that -L options pointing into
DESTDIR will come after -L options pointing into our object tree
for shared libraries this shared library depends on.

This makes a difference when shared library major numbers are bumped
(as was recently done in our tree), and you build into an already-
populated DESTDIR, because otherwise the old major version shared
libraries will be picked up, because the new ones have not yet been
installed at this stage. This will in all probability lead to
conflicts later on when linking programs, where one would try to
mix new and old major versions for the same shared library.

I *hope* this will not have any negatively impact by moving other
order-dependent options around; local tests with rebuilds did not
uncover any problems I could see.

OK'ed by lukem@


(he)
diff -r1.293 -r1.294 src/share/mk/bsd.lib.mk

cvs diff -r1.293 -r1.294 src/share/mk/bsd.lib.mk (expand / switch to unified diff)

--- src/share/mk/bsd.lib.mk 2009/01/08 20:03:59 1.293
+++ src/share/mk/bsd.lib.mk 2009/01/17 12:07:59 1.294
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.lib.mk,v 1.293 2009/01/08 20:03:59 pooka Exp $ 1# $NetBSD: bsd.lib.mk,v 1.294 2009/01/17 12:07:59 he Exp $
2# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 2# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
3 3
4.include <bsd.init.mk> 4.include <bsd.init.mk>
5.include <bsd.shlib.mk> 5.include <bsd.shlib.mk>
6.include <bsd.gcc.mk> 6.include <bsd.gcc.mk>
7# Pull in <bsd.sys.mk> here so we can override its .c.o rule 7# Pull in <bsd.sys.mk> here so we can override its .c.o rule
8.include <bsd.sys.mk> 8.include <bsd.sys.mk>
9 9
10LIBISMODULE?= no 10LIBISMODULE?= no
11LIBISPRIVATE?= no 11LIBISPRIVATE?= no
12LIBISCXX?= no 12LIBISCXX?= no
13 13
14_LIB_PREFIX= lib 14_LIB_PREFIX= lib
@@ -501,30 +501,30 @@ LDADD+= -lgcc_pic @@ -501,30 +501,30 @@ LDADD+= -lgcc_pic
501 501
502.if ${LIBISCXX} != "no" 502.if ${LIBISCXX} != "no"
503LIBCC:= ${CXX} 503LIBCC:= ${CXX}
504.else 504.else
505LIBCC:= ${CC} 505LIBCC:= ${CC}
506.endif 506.endif
507 507
508lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \ 508lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
509 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} 509 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
510 ${_MKTARGET_BUILD} 510 ${_MKTARGET_BUILD}
511 rm -f lib${LIB}.so.${SHLIB_FULLVERSION} 511 rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
512.if defined(DESTDIR) 512.if defined(DESTDIR)
513 ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \ 513 ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
514 ${_LIBLDOPTS} \ 514 -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
515 -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \ 
516 -Wl,--whole-archive ${SOLIB} \ 515 -Wl,--whole-archive ${SOLIB} \
517 -Wl,--no-whole-archive ${LDADD} \ 516 -Wl,--no-whole-archive ${LDADD} \
 517 ${_LIBLDOPTS} ${LDFLAGS} \
518 -L${_GCC_LIBGCCDIR} 518 -L${_GCC_LIBGCCDIR}
519.else 519.else
520 ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \ 520 ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
521 -o ${.TARGET} ${_LIBLDOPTS} \ 521 -o ${.TARGET} ${_LIBLDOPTS} \
522 -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD} 522 -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
523.endif 523.endif
524.if ${OBJECT_FMT} == "ELF" 524.if ${OBJECT_FMT} == "ELF"
525# We don't use INSTALL_SYMLINK here because this is just 525# We don't use INSTALL_SYMLINK here because this is just
526# happening inside the build directory/objdir. XXX Why does 526# happening inside the build directory/objdir. XXX Why does
527# this spend so much effort on libraries that aren't live??? XXX 527# this spend so much effort on libraries that aren't live??? XXX
528.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \ 528.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
529 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" 529 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
530 ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp 530 ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp