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