summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.lib.mk
diff options
context:
space:
mode:
Diffstat (limited to 'share/mk/bsd.lib.mk')
-rw-r--r--share/mk/bsd.lib.mk29
1 files changed, 26 insertions, 3 deletions
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index a4abe2f..efaf9dc 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -74,7 +74,7 @@ PO_FLAG=-pg
${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
-.cc.o:
+.cc.o .C.o .cpp.o .cxx.o:
${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.cc.po .C.po .cpp.po .cxx.po:
@@ -271,6 +271,25 @@ _libinstall:
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
.if defined(SHLIB_LINK)
+# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
+# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory
+# prefix where shared objects will be installed. ${_LDSCRIPTROOT} is the
+# directory prefix that will be used in generated ld(1) scripts. They cannot
+# be coalesced because of the way ld(1) handles the sysroot prefix (used in the
+# cross-toolchain):
+# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty.
+# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full
+# path. Note that ld(1) scripts are generated both during buildworld and
+# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty.
+# On the other hand, the use of ${_SHLIBDIRPREFIX} is more consistent since it
+# does not involve the logic of a tool we do not own.
+.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+ sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \
+ -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \
+ ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
+ ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+.else
.if ${SHLIBDIR} == ${LIBDIR}
ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
.else
@@ -281,8 +300,9 @@ _libinstall:
rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
.endif
.endif
-.endif
-.endif
+.endif # SHLIB_LDSCRIPT
+.endif # SHLIB_LINK
+.endif # SHIB_NAME
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
@@ -350,6 +370,9 @@ clean:
.endif
.if defined(SHLIB_NAME)
.if defined(SHLIB_LINK)
+.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+ rm -f lib${LIB}.ld
+.endif
rm -f ${SHLIB_LINK}
.endif
.if defined(LIB) && !empty(LIB)
OpenPOWER on IntegriCloud