/[gentoo-x86]/eclass/libtool.eclass
Gentoo

Diff of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.91 Revision 1.105
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.91 2011/06/09 15:53:04 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.105 2013/05/07 14:23:33 vapier Exp $
4 4
5# @ECLASS: libtool.eclass 5# @ECLASS: libtool.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: quickly update bundled libtool code 8# @BLURB: quickly update bundled libtool code
12# 12#
13# Note, this eclass does not require libtool as it only applies patches to 13# Note, this eclass does not require libtool as it only applies patches to
14# generated libtool files. We do not run the libtoolize program because that 14# generated libtool files. We do not run the libtoolize program because that
15# requires a regeneration of the main autotool files in order to work properly. 15# requires a regeneration of the main autotool files in order to work properly.
16 16
17DESCRIPTION="Based on the ${ECLASS} eclass" 17if [[ ${___ECLASS_ONCE_LIBTOOL} != "recur -_+^+_- spank" ]] ; then
18___ECLASS_ONCE_LIBTOOL="recur -_+^+_- spank"
18 19
20# If an overlay has eclass overrides, but doesn't actually override the
21# libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
22# eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
23# add a check to locate the ELT-patches/ regardless of what's going on.
24ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
25elt_patch_dir() {
26 local d="${ECLASSDIR}/ELT-patches"
27 if [[ ! -d ${d} ]] ; then
28 d="${ECLASSDIR_LOCAL}/ELT-patches"
29 fi
30 echo "${d}"
31}
32
19inherit toolchain-funcs 33inherit multilib toolchain-funcs
20
21ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches"
22 34
23# 35#
24# See if we can apply $2 on $1, and if so, do it 36# See if we can apply $2 on $1, and if so, do it
25# 37#
26ELT_try_and_apply_patch() { 38ELT_try_and_apply_patch() {
27 local ret=0 39 local ret=0
28 local file=$1 40 local file=$1
29 local patch=$2 41 local patch=$2
42 local src=$3
43 local disp="${src} patch"
44 local log="${T}/elibtool.log"
30 45
31 ( 46 if [[ -z ${__ELT_NOTED_TMP} ]] ; then
32 echo "" 47 __ELT_NOTED_TMP=true
33 echo "Trying $(basename "$(dirname "${patch}")")-${patch##*/}.patch on ${file}" 48 printf 'temp patch: %s\n' "${patch}" > "${log}"
34 ) &>> "${T}/elibtool.log" 49 fi
50 printf '\nTrying %s\n' "${disp}" >> "${log}"
35 51
52 if [[ ! -e ${file} ]] ; then
53 echo "File not found: ${file}" >> "${log}"
54 return 1
55 fi
56
57 # Save file for permission restoration. `patch` sometimes resets things.
58 cp -p "${file}" "${file}.gentoo.elt"
36 # We only support patchlevel of 0 - why worry if its static patches? 59 # We only support patchlevel of 0 - why worry if its static patches?
37 if patch -p0 --dry-run "${file}" "${patch}" &>> "${T}/elibtool.log" ; then 60 if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
38 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." 61 einfo " Applying ${disp} ..."
39 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \ 62 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
40 &>> "${T}/elibtool.log"
41 ret=$? 63 ret=$?
42 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 64 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
43 else 65 else
44 ret=1 66 ret=1
45 fi 67 fi
68 chmod --reference="${file}.gentoo.elt" "${file}"
69 rm -f "${file}.gentoo.elt"
46 70
47 return "${ret}" 71 return "${ret}"
48} 72}
49 73
50# 74#
61# 85#
62# Run through the patches in $2 and see if any 86# Run through the patches in $2 and see if any
63# apply to $1 ... 87# apply to $1 ...
64# 88#
65ELT_walk_patches() { 89ELT_walk_patches() {
66 local patch 90 local patch tmp
67 local ret=1 91 local ret=1
68 local file=$1 92 local file=$1
69 local patch_set=$2 93 local patch_set=$2
70 local patch_dir="${ELT_PATCH_DIR}/${patch_set}" 94 local patch_dir="$(elt_patch_dir)/${patch_set}"
71 local rem_int_dep=$3 95 local rem_int_dep=$3
72 96
73 [[ -z ${patch_set} ]] && return 1 97 [[ -z ${patch_set} ]] && return 1
74 [[ ! -d ${patch_dir} ]] && return 1 98 [[ ! -d ${patch_dir} ]] && return 1
75 99
76 pushd "${ELT_PATCH_DIR}" >/dev/null 100 # Allow patches to use @GENTOO_LIBDIR@ replacements
101 local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" )
102 if [[ -n ${rem_int_dep} ]] ; then
103 # replace @REM_INT_DEP@ with what was passed
104 # to --remove-internal-dep
105 sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" )
106 fi
107
108 pushd "$(elt_patch_dir)" >/dev/null || die
77 109
78 # Go through the patches in reverse order (newer version to older) 110 # Go through the patches in reverse order (newer version to older)
79 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do 111 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do
80 # For --remove-internal-dep ... 112 tmp="${T}/libtool-elt.patch"
81 if [[ -n ${rem_int_dep} ]] ; then 113 sed "${sed_args[@]}" "${patch}" > "${tmp}" || die
82 # For replace @REM_INT_DEP@ with what was passed
83 # to --remove-internal-dep
84 local tmp="${T}/$$.rem_int_deps.patch"
85 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}"
86 patch=${tmp}
87 fi
88
89 if ELT_try_and_apply_patch "${file}" "${patch}" ; then 114 if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
90 # Break to unwind w/popd rather than return directly 115 # Break to unwind w/popd rather than return directly
91 ret=0 116 ret=0
92 break 117 break
93 fi 118 fi
94 done 119 done
113 local do_reversedeps="no" 138 local do_reversedeps="no"
114 local do_only_patches="no" 139 local do_only_patches="no"
115 local do_uclibc="yes" 140 local do_uclibc="yes"
116 local deptoremove= 141 local deptoremove=
117 local do_shallow="no" 142 local do_shallow="no"
143 local force="false"
118 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" 144 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm"
119 145
120 for x in "$@" ; do 146 for x in "$@" ; do
121 case ${x} in 147 case ${x} in
122 --portage) 148 --portage)
123 # Only apply portage patch, and don't 149 # Only apply portage patch, and don't
147 do_shallow="yes" 173 do_shallow="yes"
148 ;; 174 ;;
149 --no-uclibc) 175 --no-uclibc)
150 do_uclibc="no" 176 do_uclibc="no"
151 ;; 177 ;;
178 --force)
179 force="true"
180 ;;
152 *) 181 *)
153 eerror "Invalid elibtoolize option: ${x}" 182 eerror "Invalid elibtoolize option: ${x}"
154 die "elibtoolize called with ${x} ??" 183 die "elibtoolize called with ${x} ??"
155 esac 184 esac
156 done 185 done
158 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" 187 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf"
159 188
160 case ${CHOST} in 189 case ${CHOST} in
161 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277 190 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277
162 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; 191 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;;
192 *-solaris*) elt_patches+=" sol2-conf sol2-ltmain" ;;
163 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; 193 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;;
164 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; 194 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;;
165 *-irix*) elt_patches+=" irix-ltmain" ;; 195 *-irix*) elt_patches+=" irix-ltmain" ;;
166 *-mint*) elt_patches+=" mint-conf" ;; 196 *-mint*) elt_patches+=" mint-conf" ;;
167 esac 197 esac
180 210
181 local d p 211 local d p
182 for d in "$@" ; do 212 for d in "$@" ; do
183 export ELT_APPLIED_PATCHES= 213 export ELT_APPLIED_PATCHES=
184 214
215 if [[ -f ${d}/.elibtoolized ]] ; then
216 ${force} || continue
217 fi
218
219 local outfunc="einfo"
185 [[ -f ${d}/.elibtoolized ]] && continue 220 [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn"
186
187 einfo "Running elibtoolize in: ${d#${WORKDIR}/}/" 221 ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/"
222 if [[ ${outfunc} == "ewarn" ]] ; then
223 ewarn " We've already been run in this tree; you should"
224 ewarn " avoid this if possible (perhaps by filing a bug)"
225 fi
188 226
189 for p in ${elt_patches} ; do 227 for p in ${elt_patches} ; do
190 local ret=0 228 local ret=0
191 229
192 case ${p} in 230 case ${p} in
300 # have at least one patch succeeded. 338 # have at least one patch succeeded.
301 ret=0 339 ret=0
302 fi 340 fi
303 done 341 done
304 ;; 342 ;;
305 mint-conf|gold-conf) 343 mint-conf|gold-conf|sol2-conf)
306 ret=1 344 ret=1
307 local subret=1 345 local subret=1
308 if [[ -e ${d}/configure ]]; then 346 if [[ -e ${d}/configure ]]; then
309 ELT_walk_patches "${d}/configure" "${p}" 347 ELT_walk_patches "${d}/configure" "${p}"
310 subret=$? 348 subret=$?
318 fi 356 fi
319 if [[ $subret -eq 0 ]]; then 357 if [[ $subret -eq 0 ]]; then
320 # have at least one patch succeeded. 358 # have at least one patch succeeded.
321 ret=0 359 ret=0
322 fi 360 fi
361 ;;
362 target-nm)
363 ELT_walk_patches "${d}/configure" "${p}"
364 ret=$?
323 ;; 365 ;;
324 install-sh) 366 install-sh)
325 ELT_walk_patches "${d}/install-sh" "${p}" 367 ELT_walk_patches "${d}/install-sh" "${p}"
326 ret=$? 368 ret=$?
327 ;; 369 ;;
470 fi 512 fi
471 513
472 echo 1 514 echo 1
473 return 1 515 return 1
474} 516}
517
518fi

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.105

  ViewVC Help
Powered by ViewVC 1.1.20