Use "gcc -shared" instead of "ld -Bshareable" for building shared

libraries.  Remove the now-unneeded CPLUSPLUSLIB hack.  I will also
remove the CPLUSPLUSLIB definitions from the Makefiles that use it,
after the dust settles.

Use gcc's LIBRARY_PATH environment variable to handle DESTDIR,
instead of -L flags in LDDESTDIR.  LIBRARY_PATH is documented in
the gcc info pages.  It is better than using -L flags, because it
modifies the search for start-up files as well as for libraries.
A new variable LDDESTDIRENV is used to contain the normally-empty
LIBRARY_PATH environment setting.

LDDESTDIR is no longer set in <bsd.lib.mk>.  It is still honored for
the time being, because a couple of userland Makefiles still (wrongly)
set it.  These should be fixed, and LDDESTDIR should vanish.

Removed the commented-out "LDDESTDIR+=-nostdlib", because "gcc -shared"
doesn't link in any standard libraries anyway.

Removed the ".if defined(LDADD)" around the _EXTRADEPEND target for
shared libraries.  This target is always necessary now, because
c++rt0.o is linked into every shared library.

Don't merge this into -2.2 without first merging the support for
"gcc -shared".
This commit is contained in:
John Polstra 1997-05-04 21:30:40 +00:00
parent d301a38d89
commit ef431e2e9e

View File

@ -1,5 +1,5 @@
# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
# $Id: bsd.lib.mk,v 1.53 1997/04/13 06:44:23 jkh Exp $
# $Id: bsd.lib.mk,v 1.54 1997/04/23 10:26:18 bde Exp $
#
.if exists(${.CURDIR}/../Makefile.inc)
@ -145,20 +145,15 @@ lib${LIB}_p.a:: ${POBJS}
.endif
.if defined(DESTDIR)
LDDESTDIR?= -L${DESTDIR}${SHLIBDIR} -L${DESTDIR}/usr/lib
# LDDESTDIR+= -nostdlib
LDDESTDIRENV?= LIBRARY_PATH=${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib
.endif
.if !defined(NOPIC)
.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir)
SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o
.endif
SOBJS+= ${OBJS:.o=.so}
lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS}
@${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
@rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
@${LD} -Bshareable -x \
@${LDDESTDIRENV} ${CC} -shared -Wl,-x \
-o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
`lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD}
@ -191,11 +186,10 @@ _EXTRADEPEND::
> $$TMP; \
mv $$TMP ${DEPENDFILE}
.endif
.if defined(LDADD)
_EXTRADEPEND::
echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \
`ld -Bshareable -x -f ${LDDESTDIR} ${LDADD}` >> ${DEPENDFILE}
.endif
`${LDDESTDIRENV} ${CC} -shared -Wl,-f ${LDDESTDIR} ${LDADD}` \
>> ${DEPENDFILE}
.if !target(install)
.if !target(beforeinstall)