1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-03 06:04:53 +00:00
freebsd-ports/Mk/Uses/libtool.mk

88 lines
3.1 KiB
Makefile
Raw Normal View History

# $FreeBSD$
#
# Bring libtool scripts up to date.
#
# Feature: libtool
# Usage: USES=libtool or USES=libtool:args
# Valid args: keepla Normally libtool libraries (*.la) are not installed.
# With this option they are. This is needed as long
# as there are dependent ports with .la libraries that
# refer to .la libraries in this port. As soon as all
# those dependent ports have some form of USES=libtool
# keepla can be removed.
# build Add a build dependency on devel/libtool. This can
# be used when a port does not generate its own libtool
# script and relies on the system to provide one.
#
# MAINTAINER: autotools@FreeBSD.org
.if !defined(_INCLUDE_USES_LIBTOOL_MK)
_INCLUDE_USES_LIBTOOL_MK= yes
_USES_POST+= libtool
libtool_ARGS:= ${libtool_ARGS:C/,/ /}
.if ${libtool_ARGS:Mbuild}
BUILD_DEPENDS+= libtool:${PORTSDIR}/devel/libtool
.endif
.endif
.if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_LIBTOOL_POST_MK)
_INCLUDE_USES_LIBTOOL_POST_MK= yes
patch-libtool:
@${FIND} ${WRKDIR} \( -name configure -or -name ltconfig \) \
-type f | while read i; do ${SED} -i.bak \
-e '/dragonfly\*/!s/^ *freebsd\*[ )]/dragonfly* | &/' \
-e '/gcc_dir=\\`/s/gcc /$$CC /' \
-e '/gcc_ver=\\`/s/gcc /$$CC /' \
-e '/link_all_deplibs[0-9A-Z_]*=/s/=unknown/=no/' \
-e '/objformat=/s/echo aout/echo elf/' \
-e "/freebsd-elf\\*)/,/;;/ { \
/deplibs_check_method=/s/=.*/=pass_all/; }" \
$${i} && ${TOUCH} -mr $${i}.bak $${i}; done
@${FIND} ${WRKDIR} -type f -name ltmain.sh | \
${XARGS} ${REINPLACE_CMD} \
Add 4 new sed commands to USES=libtool. The first two apply some of the changes that Debian made to their libtool. The first command applies to libtool versions 1.4 and up. The second command is somewhat more elaborate but essentially it uses the sed hold space to move an "elif...fi" block down. It applies to 2.x. Together these reduce overlinking to unpatched .la files (from ports that don't have USES=libtool yet but also .la files in the work directory). The third and fourth command fix relinking. During staging libtool may relink libA when it links to another library in the work directory libB. The reason is that libA created during build phase has its runpath set to the location of libB in the work directory. This allows running an executable that links to libA from within the work directory. The relink removes this extra runpath. When libtool relinks libA it replaces "libB.la" on the linker command line with "-L${STAGEDIR}${PREFIX}/lib -lB" with the intention to link to libB in the stage directory but this -L flag isn't necessarily the first so another libB may be linked instead. The two sed commands make relink the same as a normal link. This means libtool will relink with libraries from the work directory using a path similar to "../srcB/.libs/libB.so" without -L flags. This applies to libtool 1.4 and up. Earlier versions don't seem to relink libraries. (This fixes ports like devel/apr1 so they link with freshly built libraries instead of installed libraries.) Fix all ports with missing libraries. Additionally: archivers/rpm4: USES=patchfix. databases/gdbm: INSTALL_TARGET=install-strip. devel/gnome-vfs: remove patch that doesn't change anything. devel/ois: INSTALL_TARGET=install-strip and use standard USE_AUTOTOOLS. devel/zziplib: INSTALL_TARGET=install-strip, MAKE_CMD. multimedia/mjpegtools: remove USE_AUTOTOOLS, use modern compiler on i386 instead of disabling optimisations. net/libnetdude: disable static plugins. PR: 190941 Exp-run: antoine Approved by: portmgr (antoine)
2014-06-22 10:44:29 +00:00
-e '/if.*linkmode.*prog.*mode.*!= relink/s/if.*;/if :;/'\
-e '/if.*linkmode.*prog.*mode.* = relink/s/||.*;/;/' \
-e 's/|-p|-pg|/|-B*|-p|-pg|/'
2014-01-28 21:31:50 +00:00
.if ! ${libtool_ARGS:Moldver}
@${FIND} ${WRKDIR} \( -name configure -or -name ltconfig \) \
-type f | while read i; do ${SED} -i.bak \
-e "/freebsd-elf\\*)/,/;;/ { \
/library_names_spec=.*\\.so/ \
s/=.*/='\$$libname\$$release.so\$$versuffix \
\$$libname\$$release.so\$$major \$$libname.so' \
soname_spec='\$$libname\$$release.so\$$major'/; \
/library_names_spec=.*shared_ext/ \
s/=.*/='\$$libname\$$release\$$shared_ext\$$versuffix \
\$$libname\$$release\$$shared_ext\$$major \
\$$libname\$$shared_ext' \
soname_spec='\$$libname\$$release\$$shared_ext\$$major'/; \
}" $${i} && ${TOUCH} -mr $${i}.bak $${i}; done
@${FIND} ${WRKDIR} -type f -name ltmain.sh | \
${XARGS} ${REINPLACE_CMD} \
-e '/case $$version_type in/,+2 \
s/darwin|linux|/darwin|freebsd-elf|linux|/' \
-e '/freebsd-elf)/,+2 { \
/major=/s/=.*/=.$$(($$current - $$age))/; \
/versuffix=/s/=.*/="$$major.$$age.$$revision"/; }'
.endif
patch-lafiles:
.if ${libtool_ARGS:Mkeepla} || ${libtool_ARGS:Moldver}
@${FIND} ${STAGEDIR} -type f -name '*.la' | \
${XARGS} ${SED} -i '' -e "/dependency_libs=/s/=.*/=''/"
.else
@${FIND} ${STAGEDIR} -type l -exec ${SH} -c \
'case `${REALPATH} "{}"` in \
*.la) ${ECHO_CMD} "{}" ;; esac' \; | \
${XARGS} ${GREP} -l 'libtool library' | ${XARGS} ${RM}
@${FIND} ${STAGEDIR} -type f -name '*.la' | \
${XARGS} ${GREP} -l 'libtool library' | ${XARGS} ${RM}
.endif
.endif