1 |
commit: 029b4387d4d6201c1e83ad8a5d6a9c49ede5a389 |
2 |
Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 11 14:21:10 2020 +0000 |
4 |
Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 11 15:47:17 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=029b4387 |
7 |
|
8 |
prefix/winnt/profile.bashrc: ensure NAME.lib, libNAME.so |
9 |
|
10 |
Libtool for winnt does create NAME.lib (for windows'ish build tools) and |
11 |
libNAME.so (for libtool when .la was removed) import libs now, but |
12 |
Cygwin'ish or MinGW'ish build tools may create .dll.lib or .dll.a. |
13 |
Have the libNAME.so symlink point to them, to be found by libtool. |
14 |
|
15 |
Signed-off-by: Michael Haubenwallner <haubi <AT> gentoo.org> |
16 |
|
17 |
profiles/prefix/windows/winnt/profile.bashrc | 116 +++++++++++++++++++++------ |
18 |
1 file changed, 90 insertions(+), 26 deletions(-) |
19 |
|
20 |
diff --git a/profiles/prefix/windows/winnt/profile.bashrc b/profiles/prefix/windows/winnt/profile.bashrc |
21 |
index b8def6390de..b9496a65232 100644 |
22 |
--- a/profiles/prefix/windows/winnt/profile.bashrc |
23 |
+++ b/profiles/prefix/windows/winnt/profile.bashrc |
24 |
@@ -13,6 +13,34 @@ |
25 |
# Need to explicitly set PKG_CONFIG_PATH for cross EPREFIX. |
26 |
export PKG_CONFIG_PATH="${EPREFIX}/lib/pkgconfig:${EPREFIX}/usr/lib/pkgconfig" |
27 |
|
28 |
+####################################################################### |
29 |
+# |
30 |
+# Unix aware build tools may provide (e.g. pkg-config) and accept |
31 |
+# (e.g. gcc) the -lNAME linker option. While they create libNAME.so |
32 |
+# as the import library, they may be unaware of the additional dll. |
33 |
+# The dllhelper wrappers take care of copying the real dll when |
34 |
+# copying the libNAME.so. |
35 |
+# |
36 |
+# Cygwin and MinGW aware build tools may create the import library |
37 |
+# as libNAME.dll.a or libNAME.dll.lib, and are aware of the dll, |
38 |
+# while a subsequent linker step still receives the -lNAME option. |
39 |
+# |
40 |
+# MSVC aware build tools may provide (e.g. icu-config) and accept |
41 |
+# (e.g. cl.exe) the NAME.lib linker option, maybe with full path, |
42 |
+# and are aware of the dll. |
43 |
+# |
44 |
+# Libtool does accept both the Unix and MSVC variants now, but does |
45 |
+# search for the libNAME(.la|.dll|.so|.a) file upon -lNAME, in order. |
46 |
+# |
47 |
+# As Gentoo ebuilds may remove libNAME.la, we need the libNAME.so |
48 |
+# because we don't want to have libNAME.dll as an import library. |
49 |
+# |
50 |
+# Here, for whatever import library name we find, make sure there |
51 |
+# is both the NAME.lib and the libNAME.so for linkability via both |
52 |
+# the -lNAME and the NAME.lib linker option. |
53 |
+# |
54 |
+####################################################################### |
55 |
+ |
56 |
windows_setup_dllhelper() { |
57 |
case ${CATEGORY}/${PN} in |
58 |
sys-libs/zlib |\ |
59 |
@@ -30,46 +58,82 @@ windows_setup_dllhelper() { |
60 |
} |
61 |
|
62 |
post_src_install() { |
63 |
- cd "${ED}" |
64 |
- find . -name '*.exe' -o -name '*.dll.a' -o -name '*.so' | |
65 |
+ cd "${ED}" || return 0 |
66 |
+ # |
67 |
+ # File names being treated as import library: |
68 |
+ # libNAME.so |
69 |
+ # NAME.lib |
70 |
+ # libNAME.dll.lib |
71 |
+ # libNAME.dll.a |
72 |
+ # |
73 |
+ # File names being ignored as static library: |
74 |
+ # libNAME.lib |
75 |
+ # libNAME.a |
76 |
+ # |
77 |
+ # File names being warned about as suspect: |
78 |
+ # NAME.so |
79 |
+ # NAME.a |
80 |
+ # NAME.dll.lib |
81 |
+ # NAME.dll.a |
82 |
+ # |
83 |
+ find . -name '*.so' -o -name '*.lib' -o -name '*.a' | |
84 |
while read f |
85 |
do |
86 |
f=${f#./} |
87 |
- case ${f} in |
88 |
- *.exe) |
89 |
- if file "./${f}" | grep "GUI" > /dev/null 2>&1; then |
90 |
- if test ! -f "./${f%.exe}"; then |
91 |
- einfo "Windows GUI Executable $f will have no symlink." |
92 |
- fi |
93 |
- else |
94 |
- if test ! -f "./${f%.exe}"; then |
95 |
- ebegin "creating ${f%.exe} -> ${f} for console accessibility." |
96 |
- eend $(ln -sf "$(basename "${f}")" "./${f%.exe}" && echo 0 || echo 1) |
97 |
- fi |
98 |
- fi |
99 |
+ libdir=$(dirname "${f}") |
100 |
+ libfile=${f##*/} |
101 |
+ libname= |
102 |
+ case ${libfile} in |
103 |
+ lib.so) ;; # paranoia |
104 |
+ lib*.so) |
105 |
+ libname=${libfile%.so} |
106 |
+ libname=${libname#lib} |
107 |
;; |
108 |
- *.dll.a) |
109 |
- if test ! -f "./${f%.a}.lib"; then |
110 |
- ebegin "creating ${f%.a}.lib -> ${f##*/} for libtool linkability" |
111 |
- eend $(ln -sf "$(basename "${f}")" "./${f%.a}.lib" && echo 0 || echo 1) |
112 |
- fi |
113 |
+ lib.dll.lib) ;; # paranoia |
114 |
+ lib*.dll.lib) |
115 |
+ libname=${libfile%.dll.lib} |
116 |
+ libname=${libname#lib} |
117 |
;; |
118 |
- *.so) |
119 |
- if test ! -f "${f%.so}.dll.lib"; then |
120 |
- ebegin "creating ${f%.so}.dll.lib -> ${f##*/} for libtool linkability" |
121 |
- eend $(ln -sf "$(basename "${f}")" "./${f%.so}.dll.lib" && echo 0 || echo 1) |
122 |
- fi |
123 |
+ lib.lib) ;; # paranoia |
124 |
+ lib*.lib) continue ;; # ignore static library |
125 |
+ .lib) ;; # paranoia |
126 |
+ *.lib) |
127 |
+ libname=${libfile%.lib} |
128 |
;; |
129 |
+ lib.dll.a) ;; # paranoia |
130 |
+ lib*.dll.a) |
131 |
+ libname=${libfile%.dll.a} |
132 |
+ libname=${libname#lib} |
133 |
+ ;; |
134 |
+ lib.a) ;; # paranoia |
135 |
+ lib*.a) continue ;; # ignore static library |
136 |
esac |
137 |
+ if [[ -z ${libname} ]]; then |
138 |
+ ewarn "Ignoring suspect file with library extension: ${f}" |
139 |
+ continue |
140 |
+ fi |
141 |
+ |
142 |
+ NAMElib=${libname}.lib |
143 |
+ libNAMEso=lib${libname}.so |
144 |
+ if [[ ! -e ./${libdir}/${NAMElib} ]]; then |
145 |
+ ebegin "creating ${NAMElib} copied from ${f##*/} for MSVC linkability" |
146 |
+ cp -pf "./${libdir}/${libfile}" "./${libdir}/${NAMElib}" || die |
147 |
+ eend $? |
148 |
+ fi |
149 |
+ if [[ ! -e "./${libdir}/${libNAMEso}" ]]; then |
150 |
+ ebegin "creating ${libNAMEso} symlink to ${f##*/} for libtool linkability" |
151 |
+ ln -sf "${libfile}" "./${libdir}/${libNAMEso}" || die |
152 |
+ eend $? |
153 |
+ fi |
154 |
done |
155 |
[[ -d usr/$(get_libdir) ]] && |
156 |
find usr/$(get_libdir) -maxdepth 1 -type f -name '*.dll' | |
157 |
while read f |
158 |
do |
159 |
- if test ! -f usr/bin/${f##*/}; then |
160 |
+ if [[ ! -f usr/bin/${f##*/} ]]; then |
161 |
ebegin "moving ${f} to usr/bin for native loader" |
162 |
dodir usr/bin || die |
163 |
- mv -f "${f}" usr/bin || die |
164 |
+ mv -f "${f}" usr/bin/ || die |
165 |
ln -sf "../bin/${f##*/}" "${f}" || die |
166 |
eend $? |
167 |
fi |