diff options
author | jlh <jlh@FreeBSD.org> | 2012-05-07 09:00:30 +0000 |
---|---|---|
committer | jlh <jlh@FreeBSD.org> | 2012-05-07 09:00:30 +0000 |
commit | 4b07a79925078e4a03c602b68c047474d719e2c4 (patch) | |
tree | dca9d905670795528979b5d46bacbc5635ee0d85 | |
parent | 74d5826dee4ed85c5c5c6a30263eb75ed253f4c7 (diff) | |
download | FreeBSD-src-4b07a79925078e4a03c602b68c047474d719e2c4.zip FreeBSD-src-4b07a79925078e4a03c602b68c047474d719e2c4.tar.gz |
Introduce the ${SHLIB_LDSCRIPT} variable to have an ld(1) script
instead of a symlink for .so files.
Reviewed by: kib, kan (previous version), dim
Approved by: kib (mentor)
Silence from: -hackers@
MFC after: 1 week
-rw-r--r-- | Makefile.inc1 | 6 | ||||
-rw-r--r-- | share/mk/bsd.README | 4 | ||||
-rw-r--r-- | share/mk/bsd.lib.mk | 27 |
3 files changed, 33 insertions, 4 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index cb18826..da669b4 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -265,6 +265,7 @@ XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ # world stage WMAKEENV= ${CROSSENV} \ _SHLIBDIRPREFIX=${WORLDTMP} \ + _LDSCRIPTROOT= \ VERSION="${VERSION}" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${TMPPATH} @@ -307,6 +308,7 @@ LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \ # Yes, the flags are redundant. LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ _SHLIBDIRPREFIX=${LIB32TMP} \ + _LDSCRIPTROOT=${LIB32TMP} \ VERSION="${VERSION}" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${TMPPATH} \ @@ -319,11 +321,11 @@ LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \ -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \ -DWITHOUT_HTML -DNO_CTF -DNO_LINT -ECC -ECXX -EAS -ELD \ DESTDIR=${LIB32TMP} -LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS +LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS .endif # install stage -IMAKEENV= ${CROSSENV} +IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*} IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 .if empty(.MAKEFLAGS:M-n) IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \ diff --git a/share/mk/bsd.README b/share/mk/bsd.README index 51cfb39..e91a231 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -352,6 +352,10 @@ SRCS List of source files to build the library. Suffix types to .c files of the same name. (This is not the default for versions of make.) +SHLIB_LDSCRIPT Template file to generate shared library linker script. + Unless used, a simple symlink is created to the real + shared object. + The include file <bsd.lib.mk> includes the file named "../Makefile.inc" if it exists, as well as the include file <bsd.man.mk>. diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index a4abe2f..f5fcd48 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -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) |