Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] libtool.eclass cleanup
Date: Sun, 22 Aug 2010 22:34:10
Message-Id: 201008221836.26887.vapier@gentoo.org
1 due to the nature of this eclass, people generally dont touch it. so a bit of
2 cruft has built up over the years. ive given it a good wringing and added
3 some documentation. if elibtoolize starts breaking on people, this is the
4 change to look into.
5 -mike
6
7 http://sources.gentoo.org/eclass/libtool.eclass?r1=1.89&r2=1.90
8
9 libtool.eclass | 316 ++++++++++++++++++++++++---------------------------------
10 1 file changed, 138 insertions(+), 178 deletions(-)
11
12 --- libtool.eclass 20 May 2010 08:22:15 -0000 1.89
13 +++ libtool.eclass 22 Aug 2010 22:27:57 -0000
14 @@ -1,9 +1,12 @@
15 -# Copyright 1999-2007 Gentoo Foundation
16 +# Copyright 1999-2010 Gentoo Foundation
17 # Distributed under the terms of the GNU General Public License v2
18 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.89 2010/05/20 08:22:15 haubi Exp $
19 -#
20 -# Maintainer: base-system@g.o
21 -#
22 +
23 +# @ECLASS: libtool.eclass
24 +# @MAINTAINER:
25 +# base-system@g.o
26 +# @BLURB: quickly update bundled libtool code
27 +# @DESCRIPTION:
28 # This eclass patches ltmain.sh distributed with libtoolized packages with the
29 # relink and portage patch among others
30 #
31 @@ -13,27 +16,9 @@
32
33 DESCRIPTION="Based on the ${ECLASS} eclass"
34
35 -ELIBTOOL_VERSION="2.0.2"
36 -
37 inherit toolchain-funcs
38
39 ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches"
40 -ELT_APPLIED_PATCHES=
41 -ELT_LTMAIN_SH=
42 -
43 -#
44 -# Returns all the directories containing ltmain.sh
45 -#
46 -ELT_find_ltmain_sh() {
47 - local x=
48 - local dirlist=
49 -
50 - for x in $(find "${S}" -name 'ltmain.sh') ; do
51 - dirlist="${dirlist} ${x%/*}"
52 - done
53 -
54 - echo "${dirlist}"
55 -}
56
57 #
58 # See if we can apply $2 on $1, and if so, do it
59 @@ -61,14 +46,11 @@ ELT_try_and_apply_patch() {
60 # Get string version of ltmain.sh or ltconfig (passed as $1)
61 #
62 ELT_libtool_version() {
63 - local ltmain_sh=$1
64 - local version=
65 -
66 - version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}"); \
67 - echo "${VERSION}")
68 - [[ -z ${version} ]] && version="0"
69 -
70 - echo "${version}"
71 + (
72 + unset VERSION
73 + eval $(grep -e '^[[:space:]]*VERSION=' "$1")
74 + echo "${VERSION:-0}"
75 + )
76 }
77
78 #
79 @@ -110,54 +92,56 @@ ELT_walk_patches() {
80 return ${ret}
81 }
82
83 +# @FUNCTION: elibtoolize
84 +# @USAGE: [dirs] [--portage] [--reverse-deps] [--patch-only] [--remove-internal-dep=xxx] [--shallow] [--no-
85 uclibc]
86 +# @DESCRIPTION:
87 +# Apply a smorgasbord of patches to bundled libtool files. This function
88 +# should always be safe to run. If no directories are specified, then
89 +# ${S} will be searched for appropriate files.
90 +#
91 +# If the --shallow option is used, then only ${S}/ltmain.sh will be patched.
92 +#
93 +# The other options should be avoided in general unless you know what's going on.
94 elibtoolize() {
95 - local x=
96 - local y=
97 + local x
98 local do_portage="no"
99 local do_reversedeps="no"
100 local do_only_patches="no"
101 local do_uclibc="yes"
102 local deptoremove=
103 - local my_dirlist=
104 + local do_shallow="no"
105 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed"
106 - local start_dir=${PWD}
107 -
108 - my_dirlist=$(ELT_find_ltmain_sh)
109
110 for x in "$@" ; do
111 - case "${x}" in
112 - "--portage")
113 + case ${x} in
114 + --portage)
115 # Only apply portage patch, and don't
116 # 'libtoolize --copy --force' if all patches fail.
117 do_portage="yes"
118 ;;
119 - "--reverse-deps")
120 + --reverse-deps)
121 # Apply the reverse-deps patch
122 # http://bugzilla.gnome.org/show_bug.cgi?id=75635
123 do_reversedeps="yes"
124 - elt_patches="${elt_patches} fix-relink"
125 + elt_patches+=" fix-relink"
126 ;;
127 - "--patch-only")
128 + --patch-only)
129 # Do not run libtoolize if none of the patches apply ..
130 do_only_patches="yes"
131 ;;
132 - "^--remove-internal-dep="*)
133 + --remove-internal-dep=*)
134 # We will replace @REM_INT_DEP@ with what is needed
135 # in ELT_walk_patches() ...
136 - deptoremove=$(echo "${x}" | sed -e 's|--remove-internal-dep=||')
137 + deptoremove=${x#--remove-internal-dep=}
138
139 # Add the patch for this ...
140 - [[ -n ${deptoremove} ]] && elt_patches="${elt_patches} rem-int-dep"
141 + [[ -n ${deptoremove} ]] && elt_patches+=" rem-int-dep"
142 ;;
143 - "--shallow")
144 + --shallow)
145 # Only patch the ltmain.sh in ${S}
146 - if [[ -f ${S}/ltmain.sh ]] ; then
147 - my_dirlist=${S}
148 - else
149 - my_dirlist=
150 - fi
151 + do_shallow="yes"
152 ;;
153 - "--no-uclibc")
154 + --no-uclibc)
155 do_uclibc="no"
156 ;;
157 *)
158 @@ -166,151 +150,141 @@ elibtoolize() {
159 esac
160 done
161
162 - [[ ${do_uclibc} == "yes" ]] && \
163 - elt_patches="${elt_patches} uclibc-conf uclibc-ltconf"
164 + [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf"
165
166 - case "${CHOST}" in
167 - *-aix*) # see bug #213277
168 - elt_patches="${elt_patches} hardcode aixrtl aix-noundef"
169 - ;;
170 - *-darwin*)
171 - elt_patches="${elt_patches} darwin-ltconf darwin-ltmain darwin-conf"
172 - ;;
173 - *-freebsd*)
174 - elt_patches="${elt_patches} fbsd-conf fbsd-ltconf"
175 - ;;
176 - *-hpux*)
177 - elt_patches="${elt_patches} hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-
178 prog no-lc"
179 - ;;
180 - *-irix*)
181 - elt_patches="${elt_patches} irix-ltmain"
182 - ;;
183 - *-mint*)
184 - elt_patches="${elt_patches} mint-conf"
185 - ;;
186 + case ${CHOST} in
187 + *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277
188 + *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;;
189 + *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;;
190 + *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc"
191 ;;
192 + *-irix*) elt_patches+=" irix-ltmain" ;;
193 + *-mint*) elt_patches+=" mint-conf" ;;
194 esac
195
196 - for x in ${my_dirlist} ; do
197 - local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||")
198 + # Reuse "$@" for dirs to patch
199 + set --
200 + if [[ ${do_shallow} == "yes" ]] ; then
201 + [[ -f ${S}/ltmain.sh ]] && set -- "${S}"
202 + else
203 + set -- $(find "${S}" -name ltmain.sh -printf '%h ')
204 + fi
205 +
206 + local d p
207 + for d in "$@" ; do
208 export ELT_APPLIED_PATCHES=
209 - export ELT_LTMAIN_SH="${x}/ltmain.sh"
210
211 - [[ -f ${x}/.elibtoolized ]] && continue
212 + [[ -f ${d}/.elibtoolized ]] && continue
213
214 - cd ${x}
215 - einfo "Running elibtoolize in: $(echo "/${tmp}" | sed -e 's|//|/|g; s|^/||')"
216 + einfo "Running elibtoolize in: ${d#${WORKDIR}/}/"
217
218 - for y in ${elt_patches} ; do
219 + for p in ${elt_patches} ; do
220 local ret=0
221
222 - case "${y}" in
223 - "portage")
224 + case ${p} in
225 + portage)
226 # Stupid test to see if its already applied ...
227 - if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
228 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
229 + if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
230 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
231 ret=$?
232 fi
233 ;;
234 - "rem-int-dep")
235 - ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
236 + rem-int-dep)
237 + ELT_walk_patches "${d}/ltmain.sh" "${p}" "${deptoremove}"
238 ret=$?
239 ;;
240 - "fix-relink")
241 + fix-relink)
242 # Do not apply if we do not have the relink patch applied ...
243 - if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
244 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
245 + if grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" ; then
246 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
247 ret=$?
248 fi
249 ;;
250 - "max_cmd_len")
251 + max_cmd_len)
252 # Do not apply if $max_cmd_len is not used ...
253 - if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
254 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
255 + if grep -qs 'max_cmd_len' "${d}/ltmain.sh" ; then
256 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
257 ret=$?
258 fi
259 ;;
260 - "as-needed")
261 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
262 + as-needed)
263 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
264 ret=$?
265 ;;
266 - "uclibc-conf")
267 - if [[ -e ${x}/configure && \
268 - -n $(grep 'Transform linux' "${x}/configure") ]] ; then
269 - ELT_walk_patches "${x}/configure" "${y}"
270 + uclibc-conf)
271 + if grep -qs 'Transform linux' "${d}/configure" ; then
272 + ELT_walk_patches "${d}/configure" "${p}"
273 ret=$?
274 # ltmain.sh and co might be in a subdirectory ...
275 - elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
276 - -n $(grep 'Transform linux' "${x}/../configure") ]] ; then
277 - ELT_walk_patches "${x}/../configure" "${y}"
278 + elif [[ ! -e ${d}/configure ]] && \
279 + grep -qs 'Transform linux' "${d}/../configure" ; then
280 + ELT_walk_patches "${d}/../configure" "${p}"
281 ret=$?
282 fi
283 ;;
284 - "uclibc-ltconf")
285 + uclibc-ltconf)
286 # Newer libtoolize clears ltconfig, as not used anymore
287 - if [[ -s ${x}/ltconfig ]] ; then
288 - ELT_walk_patches "${x}/ltconfig" "${y}"
289 + if [[ -s ${d}/ltconfig ]] ; then
290 + ELT_walk_patches "${d}/ltconfig" "${p}"
291 ret=$?
292 fi
293 ;;
294 - "fbsd-conf")
295 - if [[ -e ${x}/configure && \
296 - -n $(grep 'version_type=freebsd-' "${x}/configure") ]] ; then
297 - ELT_walk_patches "${x}/configure" "${y}"
298 + fbsd-conf)
299 + if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
300 + ELT_walk_patches "${d}/configure" "${p}"
301 ret=$?
302 # ltmain.sh and co might be in a subdirectory ...
303 - elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
304 - -n $(grep 'version_type=freebsd-' "${x}/../configure") ]] ; then
305 - ELT_walk_patches "${x}/../configure" "${y}"
306 + elif [[ ! -e ${d}/configure ]] && \
307 + grep -qs 'version_type=freebsd-' "${d}/../configure" ; then
308 + ELT_walk_patches "${d}/../configure" "${p}"
309 ret=$?
310 fi
311 ;;
312 - "fbsd-ltconf")
313 - if [[ -s ${x}/ltconfig ]] ; then
314 - ELT_walk_patches "${x}/ltconfig" "${y}"
315 + fbsd-ltconf)
316 + if [[ -s ${d}/ltconfig ]] ; then
317 + ELT_walk_patches "${d}/ltconfig" "${p}"
318 ret=$?
319 fi
320 ;;
321 - "darwin-conf")
322 - if [[ -e ${x}/configure && \
323 - -n $(grep '&& echo \.so ||' "${x}/configure") ]] ; then
324 - ELT_walk_patches "${x}/configure" "${y}"
325 + darwin-conf)
326 + if grep -qs '&& echo \.so ||' "${d}/configure" ; then
327 + ELT_walk_patches "${d}/configure" "${p}"
328 ret=$?
329 # ltmain.sh and co might be in a subdirectory ...
330 - elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
331 - -n $(grep '&& echo \.so ||' "${x}/../configure") ]] ; then
332 - ELT_walk_patches "${x}/../configure" "${y}"
333 + elif [[ ! -e ${d}/configure ]] && \
334 + grep -qs '&& echo \.so ||' "${d}/../configure" ; then
335 + ELT_walk_patches "${d}/../configure" "${p}"
336 ret=$?
337 fi
338 ;;
339 - "darwin-ltconf")
340 + darwin-ltconf)
341 # Newer libtoolize clears ltconfig, as not used anymore
342 - if [[ -s ${x}/ltconfig ]] ; then
343 - ELT_walk_patches "${x}/ltconfig" "${y}"
344 + if [[ -s ${d}/ltconfig ]] ; then
345 + ELT_walk_patches "${d}/ltconfig" "${p}"
346 ret=$?
347 fi
348 ;;
349 - "darwin-ltmain")
350 + darwin-ltmain)
351 # special case to avoid false positives (failing to apply
352 # ltmain.sh path message), newer libtools have this patch
353 # built in, so not much to patch around then
354 - if [[ -e ${x}/ltmain.sh && \
355 - -z $(grep 'verstring="-compatibility_version' "${x}/ltmain.sh") ]] ; then
356 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
357 + if [[ -e ${d}/ltmain.sh ]] && \
358 + ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then
359 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
360 ret=$?
361 fi
362 ;;
363 - "aixrtl" | "hpux-conf")
364 + aixrtl|hpux-conf)
365 ret=1
366 local subret=0
367 # apply multiple patches as often as they match
368 while [[ $subret -eq 0 ]]; do
369 subret=1
370 - if [[ -e ${x}/configure ]]; then
371 - ELT_walk_patches "${x}/configure" "${y}"
372 + if [[ -e ${d}/configure ]]; then
373 + ELT_walk_patches "${d}/configure" "${p}"
374 subret=$?
375 # ltmain.sh and co might be in a subdirectory ...
376 - elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] ; then
377 - ELT_walk_patches "${x}/../configure" "${y}"
378 + elif [[ ! -e ${d}/configure && -e ${d}/../configure ]] ; then
379 + ELT_walk_patches "${d}/../configure" "${p}"
380 subret=$?
381 fi
382 if [[ $subret -eq 0 ]]; then
383 @@ -319,15 +293,15 @@ elibtoolize() {
384 fi
385 done
386 ;;
387 - "mint-conf")
388 + mint-conf)
389 ret=1
390 local subret=1
391 - if [[ -e ${x}/configure ]]; then
392 - ELT_walk_patches "${x}/configure" "${y}"
393 + if [[ -e ${d}/configure ]]; then
394 + ELT_walk_patches "${d}/configure" "${p}"
395 subret=$?
396 # ltmain.sh and co might be in a subdirectory ...
397 - elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] ; then
398 - ELT_walk_patches "${x}/../configure" "${y}"
399 + elif [[ ! -e ${d}/configure && -e ${d}/../configure ]] ; then
400 + ELT_walk_patches "${d}/../configure" "${p}"
401 subret=$?
402 fi
403 if [[ $subret -eq 0 ]]; then
404 @@ -335,54 +309,51 @@ elibtoolize() {
405 ret=0
406 fi
407 ;;
408 - "install-sh")
409 - ELT_walk_patches "${x}/install-sh" "${y}"
410 + install-sh)
411 + ELT_walk_patches "${d}/install-sh" "${p}"
412 ret=$?
413 ;;
414 - "cross")
415 + cross)
416 if tc-is-cross-compiler ; then
417 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
418 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
419 ret=$?
420 fi
421 ;;
422 *)
423 - ELT_walk_patches "${x}/ltmain.sh" "${y}"
424 + ELT_walk_patches "${d}/ltmain.sh" "${p}"
425 ret=$?
426 ;;
427 esac
428
429 if [[ ${ret} -ne 0 ]] ; then
430 - case ${y} in
431 - "relink")
432 - local version=$(ELT_libtool_version "${x}/ltmain.sh")
433 + case ${p} in
434 + relink)
435 + local version=$(ELT_libtool_version "${d}/ltmain.sh")
436 # Critical patch, but could be applied ...
437 # FIXME: Still need a patch for ltmain.sh > 1.4.0
438 - if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") && \
439 - $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]] ; then
440 + if ! grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" && \
441 + [[ $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]] ; then
442 ewarn " Could not apply relink.patch!"
443 fi
444 ;;
445 - "portage")
446 + portage)
447 # Critical patch - for this one we abort, as it can really
448 # cause breakage without it applied!
449 if [[ ${do_portage} == "yes" ]] ; then
450 # Stupid test to see if its already applied ...
451 - if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
452 + if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
453 echo
454 eerror "Portage patch requested, but failed to apply!"
455 eerror "Please file a bug report to add a proper patch."
456 die "Portage patch requested, but failed to apply!"
457 fi
458 else
459 - if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
460 + if grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
461 # ewarn " Portage patch seems to be already applied."
462 # ewarn " Please verify that it is not needed."
463 :
464 else
465 - local version=$( \
466 - eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
467 - echo "${VERSION}")
468 -
469 + local version=$(ELT_libtool_version "${d}"/ltmain.sh)
470 echo
471 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
472 eerror "Please file a bug report to add a proper patch."
473 @@ -392,22 +363,20 @@ elibtoolize() {
474 ELT_APPLIED_PATCHES="portage"
475 fi
476 ;;
477 - "uclibc-"*)
478 - [[ ${CHOST} == *"-uclibc" ]] && \
479 - ewarn " uClibc patch set '${y}' failed to apply!"
480 + uclibc-*)
481 + [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
482 ;;
483 - "fbsd-"*)
484 - if [[ ${CHOST} == *"-freebsd"* ]] ; then
485 + fbsd-*)
486 + if [[ ${CHOST} == *-freebsd* ]] ; then
487 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
488 - "${x}/configure" "${x}/../configure" 2>/dev/null) ]]; then
489 - eerror " FreeBSD patch set '${y}' failed to apply!"
490 - die "FreeBSD patch set '${y}' failed to apply!"
491 + "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then
492 + eerror " FreeBSD patch set '${p}' failed to apply!"
493 + die "FreeBSD patch set '${p}' failed to apply!"
494 fi
495 fi
496 ;;
497 - "darwin-"*)
498 - [[ ${CHOST} == *"-darwin"* ]] && \
499 - ewarn " Darwin patch set '${y}' failed to apply!"
500 + darwin-*)
501 + [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to
502 apply!"
503 ;;
504 esac
505 fi
506 @@ -424,23 +393,14 @@ elibtoolize() {
507 fi
508 fi
509
510 - [[ -f ${x}/libtool ]] && rm -f "${x}/libtool"
511 + rm -f "${d}/libtool"
512
513 - >> "${x}/.elibtoolized"
514 + > "${d}/.elibtoolized"
515 done
516 -
517 - cd "${start_dir}"
518 }
519
520 -uclibctoolize() {
521 - ewarn "uclibctoolize() is deprecated, please just use elibtoolize()!"
522 - elibtoolize
523 -}
524 -
525 -darwintoolize() {
526 - ewarn "darwintoolize() is deprecated, please just use elibtoolize()!"
527 - elibtoolize
528 -}
529 +uclibctoolize() { die "Use elibtoolize"; }
530 +darwintoolize() { die "Use elibtoolize"; }
531
532 # char *VER_major(string)
533 #

Attachments

File name MIME type
signature.asc application/pgp-signature