Just wondering, we have get_libname, get_modname, shouldn't we just
introduce get_linklibname or something instead of trying to overload
get_libname?

The implementation of get_linklibname could be to just call get_libname
for anything but mingw of course.

Fabian

On 03-08-2018 00:09:41 -0500, Marty E. Plummer wrote:
> Signed-off-by: Marty E. Plummer <hanet...@startmail.com>
> ---
> 
> On mingw-w64 (and perhaps cygwin and mingw.org), there are two forms of
> non-static libraries. Standard *.dll libraries are for runtime and are
> loaded from %PATH% on windows systems, and are typically stored in
> either /bin or /usr/bin on mingw-w64 cross-toolchain filesystems. Import
> libraries, *.dll.a, are used when linking and live in the ''normal''
> libdirs, eg, /lib, /usr/lib and so on.
> 
> A number of ebuilds which otherwise work on mingw-w64 crossdev
> toolchains exhibit failure due to usage of get_libname not being able to
> specify which of the two types are required.
> 
> For example, sys-libs/ncurses, uses the following snippet of code:
> ln -sf libncurses$(get_libname) 
> "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
> in order to create a 'libcurses.so -> libncurses.so' symlink.
> 
> However, on a crossdev-built mingw-w64 toolchain, one will end up with a
> broken 'libcurses.dll -> libncurses.dll' symlink, which should properly
> be a 'libcurses.dll.a -> libncurses.dll.a' symlink, as the symlink here
> is provided to allow linking with -lcurses instead of -lncurses.
> 
>  eclass/multilib.eclass | 52 ++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 48 insertions(+), 4 deletions(-)
> 
> diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
> index 350b6f949d1..6a99f5977ec 100644
> --- a/eclass/multilib.eclass
> +++ b/eclass/multilib.eclass
> @@ -239,26 +239,70 @@ get_exeext() {
>  }
>  
>  # @FUNCTION: get_libname
> -# @USAGE: [version]
> +# @USAGE: --link|--run [version]
>  # @DESCRIPTION:
>  # Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
>  # supplied version for the current platform identified by CHOST.
>  #
> +# If '--link' argument is passed, the linktime library's suffix is returned,
> +# as in the file that must exist to let `gcc -lfoo foo.c -o foo` to work.
> +# If '--run' argument is passed, the runtime library's suffix is returned.
> +#
> +# In most unix-like platforms the two are identical, however on mingw-w64 the
> +# linktime library has the suffix of '.dll.a' and the runtime library '.dll'.
> +#
>  # Example:
>  #     get_libname ${PV}
>  #     Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
> +#     get_libname --link
> +#     Returns: .so (ELF) || .dylib (MACH) || .dll.a (PE32) || ...
>  get_libname() {
> -     local libname
> -     local ver=$1
> +     local libtype="undefined"
> +     local libname opt ver
> +     for opt; do
> +             case "${opt}" in
> +                     --link)
> +                             libtype="link"
> +                             shift
> +                             ;;
> +                     --run)
> +                             libtype="run"
> +                             shift
> +                             ;;
> +                     *)
> +                             ;;
> +             esac
> +     done
> +     ver="$1"
> +     # general unixy types
>       case ${CHOST} in
>               *-cygwin*)       libname="dll.a";; # import lib
> -             mingw*|*-mingw*) libname="dll";;
>               *-darwin*)       libname="dylib";;
>               *-mint*)         libname="irrelevant";;
>               hppa*-hpux*)     libname="sl";;
>               *)               libname="so";;
>       esac
>  
> +     # wierd mingw-w64 stuff, maybe even cygwin
> +     case ${CHOST} in
> +             mingw*|*-mingw*)
> +                     case ${libtype} in
> +                             link)
> +                                     libname="dll.a" # import library
> +                                     ;;
> +                             run)
> +                                     libname="dll" # runtime library
> +                                     ;;
> +                             undefined)
> +                                     eerror "please specify either --link or 
> --run to get_libname"
> +                                     eerror "for mingw builds, as there are 
> two types of libraries"
> +                                     eerror "on this platform"
> +                                     die
> +                                     ;;
> +                     esac
> +                     ;;
> +     esac
> +
>       if [[ -z $* ]] ; then
>               echo ".${libname}"
>       else
> -- 
> 2.18.0
> 
> 

-- 
Fabian Groffen
Gentoo on a different level

Attachment: signature.asc
Description: PGP signature

Reply via email to