Gentoo Archives: gentoo-commits

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