Gentoo Archives: gentoo-dev

From: "Marty E. Plummer" <hanetzer@×××××××××.com>
To: gentoo-dev@l.g.o
Cc: "Marty E. Plummer" <hanetzer@×××××××××.com>
Subject: [gentoo-dev] [PATCH] multilib: allow specifying the subtype of library in get_libname
Date: Fri, 03 Aug 2018 05:11:35
Message-Id: 20180803050941.14596-1-hanetzer@startmail.com
1 Signed-off-by: Marty E. Plummer <hanetzer@×××××××××.com>
2 ---
3
4 On mingw-w64 (and perhaps cygwin and mingw.org), there are two forms of
5 non-static libraries. Standard *.dll libraries are for runtime and are
6 loaded from %PATH% on windows systems, and are typically stored in
7 either /bin or /usr/bin on mingw-w64 cross-toolchain filesystems. Import
8 libraries, *.dll.a, are used when linking and live in the ''normal''
9 libdirs, eg, /lib, /usr/lib and so on.
10
11 A number of ebuilds which otherwise work on mingw-w64 crossdev
12 toolchains exhibit failure due to usage of get_libname not being able to
13 specify which of the two types are required.
14
15 For example, sys-libs/ncurses, uses the following snippet of code:
16 ln -sf libncurses$(get_libname) "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
17 in order to create a 'libcurses.so -> libncurses.so' symlink.
18
19 However, on a crossdev-built mingw-w64 toolchain, one will end up with a
20 broken 'libcurses.dll -> libncurses.dll' symlink, which should properly
21 be a 'libcurses.dll.a -> libncurses.dll.a' symlink, as the symlink here
22 is provided to allow linking with -lcurses instead of -lncurses.
23
24 eclass/multilib.eclass | 52 ++++++++++++++++++++++++++++++++++++++----
25 1 file changed, 48 insertions(+), 4 deletions(-)
26
27 diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
28 index 350b6f949d1..6a99f5977ec 100644
29 --- a/eclass/multilib.eclass
30 +++ b/eclass/multilib.eclass
31 @@ -239,26 +239,70 @@ get_exeext() {
32 }
33
34 # @FUNCTION: get_libname
35 -# @USAGE: [version]
36 +# @USAGE: --link|--run [version]
37 # @DESCRIPTION:
38 # Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
39 # supplied version for the current platform identified by CHOST.
40 #
41 +# If '--link' argument is passed, the linktime library's suffix is returned,
42 +# as in the file that must exist to let `gcc -lfoo foo.c -o foo` to work.
43 +# If '--run' argument is passed, the runtime library's suffix is returned.
44 +#
45 +# In most unix-like platforms the two are identical, however on mingw-w64 the
46 +# linktime library has the suffix of '.dll.a' and the runtime library '.dll'.
47 +#
48 # Example:
49 # get_libname ${PV}
50 # Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
51 +# get_libname --link
52 +# Returns: .so (ELF) || .dylib (MACH) || .dll.a (PE32) || ...
53 get_libname() {
54 - local libname
55 - local ver=$1
56 + local libtype="undefined"
57 + local libname opt ver
58 + for opt; do
59 + case "${opt}" in
60 + --link)
61 + libtype="link"
62 + shift
63 + ;;
64 + --run)
65 + libtype="run"
66 + shift
67 + ;;
68 + *)
69 + ;;
70 + esac
71 + done
72 + ver="$1"
73 + # general unixy types
74 case ${CHOST} in
75 *-cygwin*) libname="dll.a";; # import lib
76 - mingw*|*-mingw*) libname="dll";;
77 *-darwin*) libname="dylib";;
78 *-mint*) libname="irrelevant";;
79 hppa*-hpux*) libname="sl";;
80 *) libname="so";;
81 esac
82
83 + # wierd mingw-w64 stuff, maybe even cygwin
84 + case ${CHOST} in
85 + mingw*|*-mingw*)
86 + case ${libtype} in
87 + link)
88 + libname="dll.a" # import library
89 + ;;
90 + run)
91 + libname="dll" # runtime library
92 + ;;
93 + undefined)
94 + eerror "please specify either --link or --run to get_libname"
95 + eerror "for mingw builds, as there are two types of libraries"
96 + eerror "on this platform"
97 + die
98 + ;;
99 + esac
100 + ;;
101 + esac
102 +
103 if [[ -z $* ]] ; then
104 echo ".${libname}"
105 else
106 --
107 2.18.0

Replies