Subject: bsd.lib.mk - little feature request
To: None <tech-userlevel@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-userlevel
Date: 04/07/2004 21:54:36
First, cut from 
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-release-2-0/src/share/mk/bsd.lib.mk

---cut---
lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} \
    ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
	${_MKTARGET_BUILD}
	rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
.if defined(DESTDIR)
	${CC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
	    ${_LIBLDOPTS} \
	    -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
	    -Wl,--whole-archive ${SOLIB} \
	    -Wl,--no-whole-archive ${LDADD} \
	    -L${_GCC_LIBGCCDIR}
.else
	${CC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
	    ${_LIBLDOPTS} \
	    -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
.endif
---cut---

...so as listed above, libs defined in LDADD are *always* linked as references 
to external libs. Same's true for 1.6.1 and 1.6.2.

The problem is that sometimes I need to link some libs as whole and some as 
references. Wouldn't it be good to add something like LDADD_STATIC and change 
ld's call like:

	${CC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
	    ${_LIBLDOPTS} \
	    -Wl,--whole-archive ${SOLIB} ${LDADD_STATIC} -Wl,--no-whole-archive 
${LDADD}

so i can do Makefile like:

LDADD+=  -lfoo1
LDADD_STATIC += lfoo2

...and foo2 will be linked as a whole archive.

It would be very usefull feature, at least for me :)

Any ideas ?

// wbr