diff options
author | Michael Haubenwallner <haubi@gentoo.org> | 2020-03-11 15:21:10 +0100 |
---|---|---|
committer | Michael Haubenwallner <haubi@gentoo.org> | 2020-03-11 16:47:17 +0100 |
commit | 029b4387d4d6201c1e83ad8a5d6a9c49ede5a389 (patch) | |
tree | 89479f526b1bf31a4d70196518a22b050dfce141 /profiles/prefix | |
parent | profiles/prefix/winnt/x86/make.defaults: fix copyright year typo (diff) | |
download | gentoo-029b4387d4d6201c1e83ad8a5d6a9c49ede5a389.tar.gz gentoo-029b4387d4d6201c1e83ad8a5d6a9c49ede5a389.tar.bz2 gentoo-029b4387d4d6201c1e83ad8a5d6a9c49ede5a389.zip |
prefix/winnt/profile.bashrc: ensure NAME.lib, libNAME.so
Libtool for winnt does create NAME.lib (for windows'ish build tools) and
libNAME.so (for libtool when .la was removed) import libs now, but
Cygwin'ish or MinGW'ish build tools may create .dll.lib or .dll.a.
Have the libNAME.so symlink point to them, to be found by libtool.
Signed-off-by: Michael Haubenwallner <haubi@gentoo.org>
Diffstat (limited to 'profiles/prefix')
-rw-r--r-- | profiles/prefix/windows/winnt/profile.bashrc | 116 |
1 files changed, 90 insertions, 26 deletions
diff --git a/profiles/prefix/windows/winnt/profile.bashrc b/profiles/prefix/windows/winnt/profile.bashrc index b8def6390deb..b9496a65232d 100644 --- a/profiles/prefix/windows/winnt/profile.bashrc +++ b/profiles/prefix/windows/winnt/profile.bashrc @@ -13,6 +13,34 @@ # 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 |\ @@ -30,46 +58,82 @@ windows_setup_dllhelper() { } 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 |