diff options
Diffstat (limited to 'share/mk/bsd.lib.mk')
-rw-r--r-- | share/mk/bsd.lib.mk | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index d22e78ce7f9d..f70cc95d2553 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -126,8 +126,10 @@ PO_FLAG=-pg ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} +.if !defined(_SKIP_BUILD) all: beforebuild .WAIT beforebuild: objwarn +.endif _LIBDIR:=${LIBDIR} _SHLIBDIR:=${SHLIBDIR} @@ -210,10 +212,40 @@ SOLINKOPTS+= -Wl,--warn-shared-textrel beforelinking: ${SOBJS} ${SHLIB_NAME_FULL}: beforelinking .endif + +.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 by the install target. +# +# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating +# ld(1) scripts. The crosstools' ld is configured to lookup libraries in an +# alternative directory which is called "sysroot", so during buildworld binaries +# won't be linked against the running system libraries but against the ones of +# the current source tree. ${_LDSCRIPTROOT} behavior is twisted because of +# the location where we store them: +# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty +# because ld(1) will manage to find them from sysroot; +# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full +# path, outside of sysroot. +# Note that ld(1) scripts are generated both during buildworld and +# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty +# because on the target system, libraries are meant to be looked up from /. +.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) +${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT} + sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \ + -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \ + -e 's,/[^ ]*/,,g' \ + ${.ALLSRC} > ${.TARGET} + +${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld +.endif +.endif + ${SHLIB_NAME_FULL}: ${SOBJS} @${ECHO} building shared library ${SHLIB_NAME} @rm -f ${SHLIB_NAME} ${SHLIB_LINK} -.if defined(SHLIB_LINK) +.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK} .endif ${_LD} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ @@ -258,11 +290,15 @@ ${LINTLIB}: ${LINTOBJS} .endif # !defined(INTERNALLIB) +.if defined(_SKIP_BUILD) +all: +.else all: ${_LIBS} .if ${MK_MAN} != "no" all: _manpages .endif +.endif _EXTRADEPEND: @TMP=_depend$$$$; \ @@ -318,32 +354,10 @@ _libinstall: ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR} .endif .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 by the install target. -# -# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating -# ld(1) scripts. The crosstools' ld is configured to lookup libraries in an -# alternative directory which is called "sysroot", so during buildworld binaries -# won't be linked against the running system libraries but against the ones of -# the current source tree. ${_LDSCRIPTROOT} behavior is twisted because of -# the location where we store them: -# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty -# because ld(1) will manage to find them from sysroot; -# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full -# path, outside of sysroot. -# Note that ld(1) scripts are generated both during buildworld and -# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty -# because on the target system, libraries are meant to be looked up from /. -.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} > ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld +.if commands(${SHLIB_LINK:R}.ld) ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld \ + ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} - rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld - .else .if ${_SHLIBDIR} == ${_LIBDIR} ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} |