# Need to explicitly set PKG_CONFIG_PATH for cross EPREFIX.
export PKG_CONFIG_PATH="${EPREFIX}/lib/pkgconfig:${EPREFIX}/usr/lib/pkgconfig"
+#######################################################################
+#
+# Unix aware build tools may provide (e.g. pkg-config) and accept
+# (e.g. gcc) the -lNAME linker option. While they create libNAME.so
+# as the import library, they may be unaware of the additional dll.
+# The dllhelper wrappers take care of copying the real dll when
+# copying the libNAME.so.
+#
+# Cygwin and MinGW aware build tools may create the import library
+# as libNAME.dll.a or libNAME.dll.lib, and are aware of the dll,
+# while a subsequent linker step still receives the -lNAME option.
+#
+# MSVC aware build tools may provide (e.g. icu-config) and accept
+# (e.g. cl.exe) the NAME.lib linker option, maybe with full path,
+# and are aware of the dll.
+#
+# Libtool does accept both the Unix and MSVC variants now, but does
+# search for the libNAME(.la|.dll|.so|.a) file upon -lNAME, in order.
+#
+# As Gentoo ebuilds may remove libNAME.la, we need the libNAME.so
+# because we don't want to have libNAME.dll as an import library.
+#
+# Here, for whatever import library name we find, make sure there
+# is both the NAME.lib and the libNAME.so for linkability via both
+# the -lNAME and the NAME.lib linker option.
+#
+#######################################################################
+
windows_setup_dllhelper() {
case ${CATEGORY}/${PN} in
sys-libs/zlib |\
}
post_src_install() {
- cd "${ED}"
- find . -name '*.exe' -o -name '*.dll.a' -o -name '*.so' |
+ cd "${ED}" || return 0
+ #
+ # File names being treated as import library:
+ # libNAME.so
+ # NAME.lib
+ # libNAME.dll.lib
+ # libNAME.dll.a
+ #
+ # File names being ignored as static library:
+ # libNAME.lib
+ # libNAME.a
+ #
+ # File names being warned about as suspect:
+ # NAME.so
+ # NAME.a
+ # NAME.dll.lib
+ # NAME.dll.a
+ #
+ find . -name '*.so' -o -name '*.lib' -o -name '*.a' |
while read f
do
f=${f#./}
- case ${f} in
- *.exe)
- if file "./${f}" | grep "GUI" > /dev/null 2>&1; then
- if test ! -f "./${f%.exe}"; then
- einfo "Windows GUI Executable $f will have no symlink."
- fi
- else
- if test ! -f "./${f%.exe}"; then
- ebegin "creating ${f%.exe} -> ${f} for console accessibility."
- eend $(ln -sf "$(basename "${f}")" "./${f%.exe}" && echo 0 || echo 1)
- fi
- fi
+ libdir=$(dirname "${f}")
+ libfile=${f##*/}
+ libname=
+ case ${libfile} in
+ lib.so) ;; # paranoia
+ lib*.so)
+ libname=${libfile%.so}
+ libname=${libname#lib}
;;
- *.dll.a)
- if test ! -f "./${f%.a}.lib"; then
- ebegin "creating ${f%.a}.lib -> ${f##*/} for libtool linkability"
- eend $(ln -sf "$(basename "${f}")" "./${f%.a}.lib" && echo 0 || echo 1)
- fi
+ lib.dll.lib) ;; # paranoia
+ lib*.dll.lib)
+ libname=${libfile%.dll.lib}
+ libname=${libname#lib}
;;
- *.so)
- if test ! -f "${f%.so}.dll.lib"; then
- ebegin "creating ${f%.so}.dll.lib -> ${f##*/} for libtool linkability"
- eend $(ln -sf "$(basename "${f}")" "./${f%.so}.dll.lib" && echo 0 || echo 1)
- fi
+ lib.lib) ;; # paranoia
+ lib*.lib) continue ;; # ignore static library
+ .lib) ;; # paranoia
+ *.lib)
+ libname=${libfile%.lib}
;;
+ lib.dll.a) ;; # paranoia
+ lib*.dll.a)
+ libname=${libfile%.dll.a}
+ libname=${libname#lib}
+ ;;
+ lib.a) ;; # paranoia
+ lib*.a) continue ;; # ignore static library
esac
+ if [[ -z ${libname} ]]; then
+ ewarn "Ignoring suspect file with library extension: ${f}"
+ continue
+ fi
+
+ NAMElib=${libname}.lib
+ libNAMEso=lib${libname}.so
+ if [[ ! -e ./${libdir}/${NAMElib} ]]; then
+ ebegin "creating ${NAMElib} copied from ${f##*/} for MSVC linkability"
+ cp -pf "./${libdir}/${libfile}" "./${libdir}/${NAMElib}" || die
+ eend $?
+ fi
+ if [[ ! -e "./${libdir}/${libNAMEso}" ]]; then
+ ebegin "creating ${libNAMEso} symlink to ${f##*/} for libtool linkability"
+ ln -sf "${libfile}" "./${libdir}/${libNAMEso}" || die
+ eend $?
+ fi
done
[[ -d usr/$(get_libdir) ]] &&
find usr/$(get_libdir) -maxdepth 1 -type f -name '*.dll' |
while read f
do
- if test ! -f usr/bin/${f##*/}; then
+ if [[ ! -f usr/bin/${f##*/} ]]; then
ebegin "moving ${f} to usr/bin for native loader"
dodir usr/bin || die
- mv -f "${f}" usr/bin || die
+ mv -f "${f}" usr/bin/ || die
ln -sf "../bin/${f##*/}" "${f}" || die
eend $?
fi