/[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.109
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2013 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.109 2013/12/31 16:53:05 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 # Ideally we'd want 'stat -c %a', but stat is highly non portable and we are
59 # guaranted to have GNU find, so use that instead.
60 local perms="$(find ${file} -maxdepth 0 -printf '%m')"
36 # We only support patchlevel of 0 - why worry if its static patches? 61 # We only support patchlevel of 0 - why worry if its static patches?
37 if patch -p0 --dry-run "${file}" "${patch}" &>> "${T}/elibtool.log" ; then 62 if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
38 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." 63 einfo " Applying ${disp} ..."
39 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \ 64 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
40 &>> "${T}/elibtool.log"
41 ret=$? 65 ret=$?
42 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 66 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
43 else 67 else
44 ret=1 68 ret=1
45 fi 69 fi
70 chmod "${perms}" "${file}"
46 71
47 return "${ret}" 72 return "${ret}"
48} 73}
49 74
50# 75#
61# 86#
62# Run through the patches in $2 and see if any 87# Run through the patches in $2 and see if any
63# apply to $1 ... 88# apply to $1 ...
64# 89#
65ELT_walk_patches() { 90ELT_walk_patches() {
66 local patch 91 local patch tmp
67 local ret=1 92 local ret=1
68 local file=$1 93 local file=$1
69 local patch_set=$2 94 local patch_set=$2
70 local patch_dir="${ELT_PATCH_DIR}/${patch_set}" 95 local patch_dir="$(elt_patch_dir)/${patch_set}"
71 local rem_int_dep=$3 96 local rem_int_dep=$3
72 97
73 [[ -z ${patch_set} ]] && return 1 98 [[ -z ${patch_set} ]] && return 1
74 [[ ! -d ${patch_dir} ]] && return 1 99 [[ ! -d ${patch_dir} ]] && return 1
75 100
76 pushd "${ELT_PATCH_DIR}" >/dev/null 101 # Allow patches to use @GENTOO_LIBDIR@ replacements
102 local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" )
103 if [[ -n ${rem_int_dep} ]] ; then
104 # replace @REM_INT_DEP@ with what was passed
105 # to --remove-internal-dep
106 sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" )
107 fi
108
109 pushd "$(elt_patch_dir)" >/dev/null || die
77 110
78 # Go through the patches in reverse order (newer version to older) 111 # 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 112 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do
80 # For --remove-internal-dep ... 113 tmp="${T}/libtool-elt.patch"
81 if [[ -n ${rem_int_dep} ]] ; then 114 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 115 if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
90 # Break to unwind w/popd rather than return directly 116 # Break to unwind w/popd rather than return directly
91 ret=0 117 ret=0
92 break 118 break
93 fi 119 fi
94 done 120 done
107# If the --shallow option is used, then only ${S}/ltmain.sh will be patched. 133# If the --shallow option is used, then only ${S}/ltmain.sh will be patched.
108# 134#
109# The other options should be avoided in general unless you know what's going on. 135# The other options should be avoided in general unless you know what's going on.
110elibtoolize() { 136elibtoolize() {
111 local x 137 local x
138 local dirs=()
112 local do_portage="no" 139 local do_portage="no"
113 local do_reversedeps="no" 140 local do_reversedeps="no"
114 local do_only_patches="no" 141 local do_only_patches="no"
115 local do_uclibc="yes" 142 local do_uclibc="yes"
116 local deptoremove= 143 local deptoremove=
117 local do_shallow="no" 144 local do_shallow="no"
145 local force="false"
118 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" 146 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm"
119 147
120 for x in "$@" ; do 148 for x in "$@" ; do
121 case ${x} in 149 case ${x} in
122 --portage) 150 --portage)
123 # Only apply portage patch, and don't 151 # Only apply portage patch, and don't
147 do_shallow="yes" 175 do_shallow="yes"
148 ;; 176 ;;
149 --no-uclibc) 177 --no-uclibc)
150 do_uclibc="no" 178 do_uclibc="no"
151 ;; 179 ;;
180 --force)
181 force="true"
182 ;;
152 *) 183 -*)
153 eerror "Invalid elibtoolize option: ${x}" 184 eerror "Invalid elibtoolize option: ${x}"
154 die "elibtoolize called with ${x} ??" 185 die "elibtoolize called with ${x} ??"
186 ;;
187 *) dirs+=( "${x}" )
155 esac 188 esac
156 done 189 done
157 190
158 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" 191 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf"
159 192
160 case ${CHOST} in 193 case ${CHOST} in
161 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277 194 *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277
162 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; 195 *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;;
196 *-solaris*) elt_patches+=" sol2-conf sol2-ltmain" ;;
163 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; 197 *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;;
164 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; 198 *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;;
165 *-irix*) elt_patches+=" irix-ltmain" ;; 199 *-irix*) elt_patches+=" irix-ltmain" ;;
166 *-mint*) elt_patches+=" mint-conf" ;; 200 *-mint*) elt_patches+=" mint-conf" ;;
167 esac 201 esac
168 202
169 if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then 203 if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then
170 elt_patches+=" gold-conf" 204 elt_patches+=" gold-conf"
171 fi 205 fi
172 206
173 # Reuse "$@" for dirs to patch 207 # Find out what dirs to scan.
174 set --
175 if [[ ${do_shallow} == "yes" ]] ; then 208 if [[ ${do_shallow} == "yes" ]] ; then
176 [[ -f ${S}/ltmain.sh ]] && set -- "${S}" 209 [[ ${#dirs[@]} -ne 0 ]] && die "Using --shallow with explicit dirs doesn't make sense"
210 [[ -f ${S}/ltmain.sh || -f ${S}/configure ]] && dirs+=( "${S}" )
177 else 211 else
178 set -- $(find "${S}" -name ltmain.sh -printf '%h ') 212 [[ ${#dirs[@]} -eq 0 ]] && dirs+=( "${S}" )
213 dirs=( $(find "${dirs[@]}" '(' -name ltmain.sh -o -name configure ')' -printf '%h\n' | sort -u) )
179 fi 214 fi
180 215
181 local d p 216 local d p ret
182 for d in "$@" ; do 217 for d in "${dirs[@]}" ; do
183 export ELT_APPLIED_PATCHES= 218 export ELT_APPLIED_PATCHES=
184 219
220 if [[ -f ${d}/.elibtoolized ]] ; then
221 ${force} || continue
222 fi
223
224 local outfunc="einfo"
185 [[ -f ${d}/.elibtoolized ]] && continue 225 [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn"
186
187 einfo "Running elibtoolize in: ${d#${WORKDIR}/}/" 226 ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/"
227 if [[ ${outfunc} == "ewarn" ]] ; then
228 ewarn " We've already been run in this tree; you should"
229 ewarn " avoid this if possible (perhaps by filing a bug)"
230 fi
188 231
232 # patching ltmain.sh
233 [[ -f ${d}/ltmain.sh ]] &&
189 for p in ${elt_patches} ; do 234 for p in ${elt_patches} ; do
190 local ret=0 235 ret=0
191 236
192 case ${p} in 237 case ${p} in
193 portage) 238 portage)
194 # Stupid test to see if its already applied ... 239 # Stupid test to see if its already applied ...
195 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then 240 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
217 ;; 262 ;;
218 as-needed) 263 as-needed)
219 ELT_walk_patches "${d}/ltmain.sh" "${p}" 264 ELT_walk_patches "${d}/ltmain.sh" "${p}"
220 ret=$? 265 ret=$?
221 ;; 266 ;;
222 uclibc-conf)
223 if grep -qs 'Transform linux' "${d}/configure" ; then
224 ELT_walk_patches "${d}/configure" "${p}"
225 ret=$?
226 # ltmain.sh and co might be in a subdirectory ...
227 elif [[ ! -e ${d}/configure ]] && \
228 grep -qs 'Transform linux' "${d}/../configure" ; then
229 ELT_walk_patches "${d}/../configure" "${p}"
230 ret=$?
231 fi
232 ;;
233 uclibc-ltconf) 267 uclibc-ltconf)
234 # Newer libtoolize clears ltconfig, as not used anymore 268 # Newer libtoolize clears ltconfig, as not used anymore
235 if [[ -s ${d}/ltconfig ]] ; then 269 if [[ -s ${d}/ltconfig ]] ; then
236 ELT_walk_patches "${d}/ltconfig" "${p}" 270 ELT_walk_patches "${d}/ltconfig" "${p}"
237 ret=$? 271 ret=$?
238 fi 272 fi
239 ;; 273 ;;
240 fbsd-conf)
241 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
242 ELT_walk_patches "${d}/configure" "${p}"
243 ret=$?
244 # ltmain.sh and co might be in a subdirectory ...
245 elif [[ ! -e ${d}/configure ]] && \
246 grep -qs 'version_type=freebsd-' "${d}/../configure" ; then
247 ELT_walk_patches "${d}/../configure" "${p}"
248 ret=$?
249 fi
250 ;;
251 fbsd-ltconf) 274 fbsd-ltconf)
252 if [[ -s ${d}/ltconfig ]] ; then 275 if [[ -s ${d}/ltconfig ]] ; then
253 ELT_walk_patches "${d}/ltconfig" "${p}" 276 ELT_walk_patches "${d}/ltconfig" "${p}"
254 ret=$?
255 fi
256 ;;
257 darwin-conf)
258 if grep -qs '&& echo \.so ||' "${d}/configure" ; then
259 ELT_walk_patches "${d}/configure" "${p}"
260 ret=$?
261 # ltmain.sh and co might be in a subdirectory ...
262 elif [[ ! -e ${d}/configure ]] && \
263 grep -qs '&& echo \.so ||' "${d}/../configure" ; then
264 ELT_walk_patches "${d}/../configure" "${p}"
265 ret=$? 277 ret=$?
266 fi 278 fi
267 ;; 279 ;;
268 darwin-ltconf) 280 darwin-ltconf)
269 # Newer libtoolize clears ltconfig, as not used anymore 281 # Newer libtoolize clears ltconfig, as not used anymore
278 # built in, so not much to patch around then 290 # built in, so not much to patch around then
279 if [[ -e ${d}/ltmain.sh ]] && \ 291 if [[ -e ${d}/ltmain.sh ]] && \
280 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then 292 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then
281 ELT_walk_patches "${d}/ltmain.sh" "${p}" 293 ELT_walk_patches "${d}/ltmain.sh" "${p}"
282 ret=$? 294 ret=$?
283 fi
284 ;;
285 aixrtl|hpux-conf)
286 ret=1
287 local subret=0
288 # apply multiple patches as often as they match
289 while [[ $subret -eq 0 ]]; do
290 subret=1
291 if [[ -e ${d}/configure ]]; then
292 ELT_walk_patches "${d}/configure" "${p}"
293 subret=$?
294 # ltmain.sh and co might be in a subdirectory ...
295 elif [[ ! -e ${d}/configure && -e ${d}/../configure ]] ; then
296 ELT_walk_patches "${d}/../configure" "${p}"
297 subret=$?
298 fi
299 if [[ $subret -eq 0 ]]; then
300 # have at least one patch succeeded.
301 ret=0
302 fi
303 done
304 ;;
305 mint-conf|gold-conf)
306 ret=1
307 local subret=1
308 if [[ -e ${d}/configure ]]; then
309 ELT_walk_patches "${d}/configure" "${p}"
310 subret=$?
311 # ltmain.sh and co might be in a subdirectory ...
312 elif [[ -e ${d}/../configure ]] ; then
313 ELT_walk_patches "${d}/../configure" "${p}"
314 subret=$?
315 elif [[ -e ${d}/../../configure ]] ; then
316 ELT_walk_patches "${d}/../../configure" "${p}"
317 subret=$?
318 fi
319 if [[ $subret -eq 0 ]]; then
320 # have at least one patch succeeded.
321 ret=0
322 fi 295 fi
323 ;; 296 ;;
324 install-sh) 297 install-sh)
325 ELT_walk_patches "${d}/install-sh" "${p}" 298 ELT_walk_patches "${d}/install-sh" "${p}"
326 ret=$? 299 ret=$?
373 fi 346 fi
374 # We do not want to run libtoolize ... 347 # We do not want to run libtoolize ...
375 ELT_APPLIED_PATCHES="portage" 348 ELT_APPLIED_PATCHES="portage"
376 fi 349 fi
377 ;; 350 ;;
351 darwin-*)
352 [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!"
353 ;;
354 esac
355 fi
356 done
357
358 # makes sense for ltmain.sh patches only
359 [[ -f ${d}/ltmain.sh ]] &&
360 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
361 if [[ ${do_portage} == "no" && \
362 ${do_reversedeps} == "no" && \
363 ${do_only_patches} == "no" && \
364 ${deptoremove} == "" ]]
365 then
366 ewarn "Cannot apply any patches, please file a bug about this"
367 die
368 fi
369 fi
370
371 # patching configure
372 [[ -f ${d}/configure ]] &&
373 for p in ${elt_patches} ; do
374 ret=0
375
376 case ${p} in
377 uclibc-conf)
378 if grep -qs 'Transform linux' "${d}/configure" ; then
379 ELT_walk_patches "${d}/configure" "${p}"
380 ret=$?
381 fi
382 ;;
383 fbsd-conf)
384 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
385 ELT_walk_patches "${d}/configure" "${p}"
386 ret=$?
387 fi
388 ;;
389 darwin-conf)
390 if grep -qs '&& echo \.so ||' "${d}/configure" ; then
391 ELT_walk_patches "${d}/configure" "${p}"
392 ret=$?
393 fi
394 ;;
395 aixrtl|hpux-conf)
396 ret=1
397 local subret=0
398 # apply multiple patches as often as they match
399 while [[ $subret -eq 0 ]]; do
400 subret=1
401 if [[ -e ${d}/configure ]]; then
402 ELT_walk_patches "${d}/configure" "${p}"
403 subret=$?
404 fi
405 if [[ $subret -eq 0 ]]; then
406 # have at least one patch succeeded.
407 ret=0
408 fi
409 done
410 ;;
411 mint-conf|gold-conf|sol2-conf)
412 ELT_walk_patches "${d}/configure" "${p}"
413 ret=$?
414 ;;
415 target-nm)
416 ELT_walk_patches "${d}/configure" "${p}"
417 ret=$?
418 ;;
419 *)
420 # ltmain.sh patches are applied above
421 ;;
422 esac
423
424 if [[ ${ret} -ne 0 ]] ; then
425 case ${p} in
378 uclibc-*) 426 uclibc-*)
379 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!" 427 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
380 ;; 428 ;;
381 fbsd-*) 429 fbsd-*)
382 if [[ ${CHOST} == *-freebsd* ]] ; then 430 if [[ ${CHOST} == *-freebsd* ]] ; then
383 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \ 431 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
384 "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then 432 "${d}/configure" 2>/dev/null) ]]; then
385 eerror " FreeBSD patch set '${p}' failed to apply!" 433 eerror " FreeBSD patch set '${p}' failed to apply!"
386 die "FreeBSD patch set '${p}' failed to apply!" 434 die "FreeBSD patch set '${p}' failed to apply!"
387 fi 435 fi
388 fi 436 fi
389 ;; 437 ;;
392 ;; 440 ;;
393 esac 441 esac
394 fi 442 fi
395 done 443 done
396 444
397 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
398 if [[ ${do_portage} == "no" && \
399 ${do_reversedeps} == "no" && \
400 ${do_only_patches} == "no" && \
401 ${deptoremove} == "" ]]
402 then
403 ewarn "Cannot apply any patches, please file a bug about this"
404 die
405 fi
406 fi
407
408 rm -f "${d}/libtool" 445 rm -f "${d}/libtool"
409 446
410 > "${d}/.elibtoolized" 447 > "${d}/.elibtoolized"
411 done 448 done
412} 449}
470 fi 507 fi
471 508
472 echo 1 509 echo 1
473 return 1 510 return 1
474} 511}
512
513fi

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

  ViewVC Help
Powered by ViewVC 1.1.20