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

Diff of /eclass/libtool.eclass

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

Revision 1.90 Revision 1.102
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.90 2010/08/22 22:44:45 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.102 2012/09/15 16:16:53 zmedico 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"
45
46 if [[ -z ${__ELT_NOTED_TMP} ]] ; then
47 __ELT_NOTED_TMP=true
48 printf 'temp patch: %s\n' "${patch}" > "${log}"
49 fi
50 printf '\nTrying %s\n' "${disp}" >> "${log}"
30 51
31 # We only support patchlevel of 0 - why worry if its static patches? 52 # We only support patchlevel of 0 - why worry if its static patches?
32 if patch -p0 --dry-run "${file}" "${patch}" &> "${T}/elibtool.log" ; then 53 if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
33 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." 54 einfo " Applying ${disp} ..."
34 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \ 55 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
35 &> "${T}/elibtool.log"
36 ret=$? 56 ret=$?
37 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 57 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
38 else 58 else
39 ret=1 59 ret=1
40 fi 60 fi
41 61
42 return "${ret}" 62 return "${ret}"
56# 76#
57# Run through the patches in $2 and see if any 77# Run through the patches in $2 and see if any
58# apply to $1 ... 78# apply to $1 ...
59# 79#
60ELT_walk_patches() { 80ELT_walk_patches() {
61 local patch 81 local patch tmp
62 local ret=1 82 local ret=1
63 local file=$1 83 local file=$1
64 local patch_set=$2 84 local patch_set=$2
65 local patch_dir="${ELT_PATCH_DIR}/${patch_set}" 85 local patch_dir="$(elt_patch_dir)/${patch_set}"
66 local rem_int_dep=$3 86 local rem_int_dep=$3
67 87
68 [[ -z ${patch_set} ]] && return 1 88 [[ -z ${patch_set} ]] && return 1
69 [[ ! -d ${patch_dir} ]] && return 1 89 [[ ! -d ${patch_dir} ]] && return 1
70 90
71 pushd "${ELT_PATCH_DIR}" >/dev/null 91 # Allow patches to use @GENTOO_LIBDIR@ replacements
92 local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" )
93 if [[ -n ${rem_int_dep} ]] ; then
94 # replace @REM_INT_DEP@ with what was passed
95 # to --remove-internal-dep
96 sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" )
97 fi
98
99 pushd "$(elt_patch_dir)" >/dev/null || die
72 100
73 # Go through the patches in reverse order (newer version to older) 101 # Go through the patches in reverse order (newer version to older)
74 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do 102 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do
75 # For --remove-internal-dep ... 103 tmp="${T}/libtool-elt.patch"
76 if [[ -n ${rem_int_dep} ]] ; then 104 sed "${sed_args[@]}" "${patch}" > "${tmp}" || die
77 # For replace @REM_INT_DEP@ with what was passed
78 # to --remove-internal-dep
79 local tmp="${T}/$$.rem_int_deps.patch"
80 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}"
81 patch=${tmp}
82 fi
83
84 if ELT_try_and_apply_patch "${file}" "${patch}" ; then 105 if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
85 # Break to unwind w/popd rather than return directly 106 # Break to unwind w/popd rather than return directly
86 ret=0 107 ret=0
87 break 108 break
88 fi 109 fi
89 done 110 done
108 local do_reversedeps="no" 129 local do_reversedeps="no"
109 local do_only_patches="no" 130 local do_only_patches="no"
110 local do_uclibc="yes" 131 local do_uclibc="yes"
111 local deptoremove= 132 local deptoremove=
112 local do_shallow="no" 133 local do_shallow="no"
134 local force="false"
113 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" 135 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed"
114 136
115 for x in "$@" ; do 137 for x in "$@" ; do
116 case ${x} in 138 case ${x} in
117 --portage) 139 --portage)
142 do_shallow="yes" 164 do_shallow="yes"
143 ;; 165 ;;
144 --no-uclibc) 166 --no-uclibc)
145 do_uclibc="no" 167 do_uclibc="no"
146 ;; 168 ;;
169 --force)
170 force="true"
171 ;;
147 *) 172 *)
148 eerror "Invalid elibtoolize option: ${x}" 173 eerror "Invalid elibtoolize option: ${x}"
149 die "elibtoolize called with ${x} ??" 174 die "elibtoolize called with ${x} ??"
150 esac 175 esac
151 done 176 done
153 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" 178 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf"
154 179
155 case ${CHOST} in 180 case ${CHOST} in
156 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277 181 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277
157 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; 182 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;;
183 *-solaris*) elt_patches+=" sol2-conf sol2-ltmain" ;;
158 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; 184 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;;
159 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; 185 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;;
160 *-irix*) elt_patches+=" irix-ltmain" ;; 186 *-irix*) elt_patches+=" irix-ltmain" ;;
161 *-mint*) elt_patches+=" mint-conf" ;; 187 *-mint*) elt_patches+=" mint-conf" ;;
162 esac 188 esac
189
190 if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then
191 elt_patches+=" gold-conf"
192 fi
163 193
164 # Reuse "$@" for dirs to patch 194 # Reuse "$@" for dirs to patch
165 set -- 195 set --
166 if [[ ${do_shallow} == "yes" ]] ; then 196 if [[ ${do_shallow} == "yes" ]] ; then
167 [[ -f ${S}/ltmain.sh ]] && set -- "${S}" 197 [[ -f ${S}/ltmain.sh ]] && set -- "${S}"
171 201
172 local d p 202 local d p
173 for d in "$@" ; do 203 for d in "$@" ; do
174 export ELT_APPLIED_PATCHES= 204 export ELT_APPLIED_PATCHES=
175 205
206 if [[ -f ${d}/.elibtoolized ]] ; then
207 ${force} || continue
208 fi
209
210 local outfunc="einfo"
176 [[ -f ${d}/.elibtoolized ]] && continue 211 [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn"
177
178 einfo "Running elibtoolize in: ${d#${WORKDIR}/}/" 212 ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/"
213 if [[ ${outfunc} == "ewarn" ]] ; then
214 ewarn " We've already been run in this tree; you should"
215 ewarn " avoid this if possible (perhaps by filing a bug)"
216 fi
179 217
180 for p in ${elt_patches} ; do 218 for p in ${elt_patches} ; do
181 local ret=0 219 local ret=0
182 220
183 case ${p} in 221 case ${p} in
214 if grep -qs 'Transform linux' "${d}/configure" ; then 252 if grep -qs 'Transform linux' "${d}/configure" ; then
215 ELT_walk_patches "${d}/configure" "${p}" 253 ELT_walk_patches "${d}/configure" "${p}"
216 ret=$? 254 ret=$?
217 # ltmain.sh and co might be in a subdirectory ... 255 # ltmain.sh and co might be in a subdirectory ...
218 elif [[ ! -e ${d}/configure ]] && \ 256 elif [[ ! -e ${d}/configure ]] && \
219 grep -qs 'Transform linux' "${d}/../configure" ; then 257 grep -qs 'Transform linux' "${d}/../configure" ; then
220 ELT_walk_patches "${d}/../configure" "${p}" 258 ELT_walk_patches "${d}/../configure" "${p}"
221 ret=$? 259 ret=$?
222 fi 260 fi
223 ;; 261 ;;
224 uclibc-ltconf) 262 uclibc-ltconf)
232 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then 270 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
233 ELT_walk_patches "${d}/configure" "${p}" 271 ELT_walk_patches "${d}/configure" "${p}"
234 ret=$? 272 ret=$?
235 # ltmain.sh and co might be in a subdirectory ... 273 # ltmain.sh and co might be in a subdirectory ...
236 elif [[ ! -e ${d}/configure ]] && \ 274 elif [[ ! -e ${d}/configure ]] && \
237 grep -qs 'version_type=freebsd-' "${d}/../configure" ; then 275 grep -qs 'version_type=freebsd-' "${d}/../configure" ; then
238 ELT_walk_patches "${d}/../configure" "${p}" 276 ELT_walk_patches "${d}/../configure" "${p}"
239 ret=$? 277 ret=$?
240 fi 278 fi
241 ;; 279 ;;
242 fbsd-ltconf) 280 fbsd-ltconf)
249 if grep -qs '&& echo \.so ||' "${d}/configure" ; then 287 if grep -qs '&& echo \.so ||' "${d}/configure" ; then
250 ELT_walk_patches "${d}/configure" "${p}" 288 ELT_walk_patches "${d}/configure" "${p}"
251 ret=$? 289 ret=$?
252 # ltmain.sh and co might be in a subdirectory ... 290 # ltmain.sh and co might be in a subdirectory ...
253 elif [[ ! -e ${d}/configure ]] && \ 291 elif [[ ! -e ${d}/configure ]] && \
254 grep -qs '&& echo \.so ||' "${d}/../configure" ; then 292 grep -qs '&& echo \.so ||' "${d}/../configure" ; then
255 ELT_walk_patches "${d}/../configure" "${p}" 293 ELT_walk_patches "${d}/../configure" "${p}"
256 ret=$? 294 ret=$?
257 fi 295 fi
258 ;; 296 ;;
259 darwin-ltconf) 297 darwin-ltconf)
291 # have at least one patch succeeded. 329 # have at least one patch succeeded.
292 ret=0 330 ret=0
293 fi 331 fi
294 done 332 done
295 ;; 333 ;;
296 mint-conf) 334 mint-conf|gold-conf|sol2-conf)
297 ret=1 335 ret=1
298 local subret=1 336 local subret=1
299 if [[ -e ${d}/configure ]]; then 337 if [[ -e ${d}/configure ]]; then
300 ELT_walk_patches "${d}/configure" "${p}" 338 ELT_walk_patches "${d}/configure" "${p}"
301 subret=$? 339 subret=$?
302 # ltmain.sh and co might be in a subdirectory ... 340 # ltmain.sh and co might be in a subdirectory ...
303 elif [[ ! -e ${d}/configure && -e ${d}/../configure ]] ; then 341 elif [[ -e ${d}/../configure ]] ; then
304 ELT_walk_patches "${d}/../configure" "${p}" 342 ELT_walk_patches "${d}/../configure" "${p}"
343 subret=$?
344 elif [[ -e ${d}/../../configure ]] ; then
345 ELT_walk_patches "${d}/../../configure" "${p}"
305 subret=$? 346 subret=$?
306 fi 347 fi
307 if [[ $subret -eq 0 ]]; then 348 if [[ $subret -eq 0 ]]; then
308 # have at least one patch succeeded. 349 # have at least one patch succeeded.
309 ret=0 350 ret=0
351 if grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then 392 if grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
352 # ewarn " Portage patch seems to be already applied." 393 # ewarn " Portage patch seems to be already applied."
353 # ewarn " Please verify that it is not needed." 394 # ewarn " Please verify that it is not needed."
354 : 395 :
355 else 396 else
356 local version=$(ELT_libtool_version "${d}"/ltmain.sh) 397 local version=$(ELT_libtool_version "${d}"/ltmain.sh)
357 echo 398 echo
358 eerror "Portage patch failed to apply (ltmain.sh version ${version})!" 399 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
359 eerror "Please file a bug report to add a proper patch." 400 eerror "Please file a bug report to add a proper patch."
360 die "Portage patch failed to apply!" 401 die "Portage patch failed to apply!"
361 fi 402 fi
458 fi 499 fi
459 500
460 echo 1 501 echo 1
461 return 1 502 return 1
462} 503}
504
505fi

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.102

  ViewVC Help
Powered by ViewVC 1.1.20