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

Diff of /eclass/libtool.eclass

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

Revision 1.102 Revision 1.108
1# Copyright 1999-2012 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.102 2012/09/15 16:16:53 zmedico Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.108 2013/12/05 16:52:35 blueness 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
47 __ELT_NOTED_TMP=true 47 __ELT_NOTED_TMP=true
48 printf 'temp patch: %s\n' "${patch}" > "${log}" 48 printf 'temp patch: %s\n' "${patch}" > "${log}"
49 fi 49 fi
50 printf '\nTrying %s\n' "${disp}" >> "${log}" 50 printf '\nTrying %s\n' "${disp}" >> "${log}"
51 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')"
52 # 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?
53 if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then 62 if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
54 einfo " Applying ${disp} ..." 63 einfo " Applying ${disp} ..."
55 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1 64 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
56 ret=$? 65 ret=$?
57 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}" 66 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
58 else 67 else
59 ret=1 68 ret=1
60 fi 69 fi
70 chmod "${perms}" "${file}"
61 71
62 return "${ret}" 72 return "${ret}"
63} 73}
64 74
65# 75#
130 local do_only_patches="no" 140 local do_only_patches="no"
131 local do_uclibc="yes" 141 local do_uclibc="yes"
132 local deptoremove= 142 local deptoremove=
133 local do_shallow="no" 143 local do_shallow="no"
134 local force="false" 144 local force="false"
135 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" 145 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm"
136 146
137 for x in "$@" ; do 147 for x in "$@" ; do
138 case ${x} in 148 case ${x} in
139 --portage) 149 --portage)
140 # Only apply portage patch, and don't 150 # Only apply portage patch, and don't
192 fi 202 fi
193 203
194 # Reuse "$@" for dirs to patch 204 # Reuse "$@" for dirs to patch
195 set -- 205 set --
196 if [[ ${do_shallow} == "yes" ]] ; then 206 if [[ ${do_shallow} == "yes" ]] ; then
197 [[ -f ${S}/ltmain.sh ]] && set -- "${S}" 207 [[ -f ${S}/ltmain.sh || -f ${S}/configure ]] && set -- "${S}"
198 else 208 else
199 set -- $(find "${S}" -name ltmain.sh -printf '%h ') 209 set -- $(find "${S}" '(' -name ltmain.sh -o -name configure ')' -printf '%h\n' | sort -u)
200 fi 210 fi
201 211
202 local d p 212 local d p
203 for d in "$@" ; do 213 for d in "$@" ; do
204 export ELT_APPLIED_PATCHES= 214 export ELT_APPLIED_PATCHES=
213 if [[ ${outfunc} == "ewarn" ]] ; then 223 if [[ ${outfunc} == "ewarn" ]] ; then
214 ewarn " We've already been run in this tree; you should" 224 ewarn " We've already been run in this tree; you should"
215 ewarn " avoid this if possible (perhaps by filing a bug)" 225 ewarn " avoid this if possible (perhaps by filing a bug)"
216 fi 226 fi
217 227
228 local ret
229
230 # patching ltmain.sh
231 [[ -f ${d}/ltmain.sh ]] &&
218 for p in ${elt_patches} ; do 232 for p in ${elt_patches} ; do
219 local ret=0 233 ret=0
220 234
221 case ${p} in 235 case ${p} in
222 portage) 236 portage)
223 # Stupid test to see if its already applied ... 237 # Stupid test to see if its already applied ...
224 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then 238 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then
246 ;; 260 ;;
247 as-needed) 261 as-needed)
248 ELT_walk_patches "${d}/ltmain.sh" "${p}" 262 ELT_walk_patches "${d}/ltmain.sh" "${p}"
249 ret=$? 263 ret=$?
250 ;; 264 ;;
251 uclibc-conf)
252 if grep -qs 'Transform linux' "${d}/configure" ; then
253 ELT_walk_patches "${d}/configure" "${p}"
254 ret=$?
255 # ltmain.sh and co might be in a subdirectory ...
256 elif [[ ! -e ${d}/configure ]] && \
257 grep -qs 'Transform linux' "${d}/../configure" ; then
258 ELT_walk_patches "${d}/../configure" "${p}"
259 ret=$?
260 fi
261 ;;
262 uclibc-ltconf) 265 uclibc-ltconf)
263 # Newer libtoolize clears ltconfig, as not used anymore 266 # Newer libtoolize clears ltconfig, as not used anymore
264 if [[ -s ${d}/ltconfig ]] ; then 267 if [[ -s ${d}/ltconfig ]] ; then
265 ELT_walk_patches "${d}/ltconfig" "${p}" 268 ELT_walk_patches "${d}/ltconfig" "${p}"
266 ret=$? 269 ret=$?
267 fi 270 fi
268 ;; 271 ;;
269 fbsd-conf)
270 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
271 ELT_walk_patches "${d}/configure" "${p}"
272 ret=$?
273 # ltmain.sh and co might be in a subdirectory ...
274 elif [[ ! -e ${d}/configure ]] && \
275 grep -qs 'version_type=freebsd-' "${d}/../configure" ; then
276 ELT_walk_patches "${d}/../configure" "${p}"
277 ret=$?
278 fi
279 ;;
280 fbsd-ltconf) 272 fbsd-ltconf)
281 if [[ -s ${d}/ltconfig ]] ; then 273 if [[ -s ${d}/ltconfig ]] ; then
282 ELT_walk_patches "${d}/ltconfig" "${p}" 274 ELT_walk_patches "${d}/ltconfig" "${p}"
283 ret=$?
284 fi
285 ;;
286 darwin-conf)
287 if grep -qs '&& echo \.so ||' "${d}/configure" ; then
288 ELT_walk_patches "${d}/configure" "${p}"
289 ret=$?
290 # ltmain.sh and co might be in a subdirectory ...
291 elif [[ ! -e ${d}/configure ]] && \
292 grep -qs '&& echo \.so ||' "${d}/../configure" ; then
293 ELT_walk_patches "${d}/../configure" "${p}"
294 ret=$? 275 ret=$?
295 fi 276 fi
296 ;; 277 ;;
297 darwin-ltconf) 278 darwin-ltconf)
298 # Newer libtoolize clears ltconfig, as not used anymore 279 # Newer libtoolize clears ltconfig, as not used anymore
307 # built in, so not much to patch around then 288 # built in, so not much to patch around then
308 if [[ -e ${d}/ltmain.sh ]] && \ 289 if [[ -e ${d}/ltmain.sh ]] && \
309 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then 290 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then
310 ELT_walk_patches "${d}/ltmain.sh" "${p}" 291 ELT_walk_patches "${d}/ltmain.sh" "${p}"
311 ret=$? 292 ret=$?
312 fi
313 ;;
314 aixrtl|hpux-conf)
315 ret=1
316 local subret=0
317 # apply multiple patches as often as they match
318 while [[ $subret -eq 0 ]]; do
319 subret=1
320 if [[ -e ${d}/configure ]]; then
321 ELT_walk_patches "${d}/configure" "${p}"
322 subret=$?
323 # ltmain.sh and co might be in a subdirectory ...
324 elif [[ ! -e ${d}/configure && -e ${d}/../configure ]] ; then
325 ELT_walk_patches "${d}/../configure" "${p}"
326 subret=$?
327 fi
328 if [[ $subret -eq 0 ]]; then
329 # have at least one patch succeeded.
330 ret=0
331 fi
332 done
333 ;;
334 mint-conf|gold-conf|sol2-conf)
335 ret=1
336 local subret=1
337 if [[ -e ${d}/configure ]]; then
338 ELT_walk_patches "${d}/configure" "${p}"
339 subret=$?
340 # ltmain.sh and co might be in a subdirectory ...
341 elif [[ -e ${d}/../configure ]] ; then
342 ELT_walk_patches "${d}/../configure" "${p}"
343 subret=$?
344 elif [[ -e ${d}/../../configure ]] ; then
345 ELT_walk_patches "${d}/../../configure" "${p}"
346 subret=$?
347 fi
348 if [[ $subret -eq 0 ]]; then
349 # have at least one patch succeeded.
350 ret=0
351 fi 293 fi
352 ;; 294 ;;
353 install-sh) 295 install-sh)
354 ELT_walk_patches "${d}/install-sh" "${p}" 296 ELT_walk_patches "${d}/install-sh" "${p}"
355 ret=$? 297 ret=$?
402 fi 344 fi
403 # We do not want to run libtoolize ... 345 # We do not want to run libtoolize ...
404 ELT_APPLIED_PATCHES="portage" 346 ELT_APPLIED_PATCHES="portage"
405 fi 347 fi
406 ;; 348 ;;
349 darwin-*)
350 [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!"
351 ;;
352 esac
353 fi
354 done
355
356 # makes sense for ltmain.sh patches only
357 [[ -f ${d}/ltmain.sh ]] &&
358 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
359 if [[ ${do_portage} == "no" && \
360 ${do_reversedeps} == "no" && \
361 ${do_only_patches} == "no" && \
362 ${deptoremove} == "" ]]
363 then
364 ewarn "Cannot apply any patches, please file a bug about this"
365 die
366 fi
367 fi
368
369 # patching configure
370 [[ -f ${d}/configure ]] &&
371 for p in ${elt_patches} ; do
372 ret=0
373
374 case ${p} in
375 uclibc-conf)
376 if grep -qs 'Transform linux' "${d}/configure" ; then
377 ELT_walk_patches "${d}/configure" "${p}"
378 ret=$?
379 fi
380 ;;
381 fbsd-conf)
382 if grep -qs 'version_type=freebsd-' "${d}/configure" ; then
383 ELT_walk_patches "${d}/configure" "${p}"
384 ret=$?
385 fi
386 ;;
387 darwin-conf)
388 if grep -qs '&& echo \.so ||' "${d}/configure" ; then
389 ELT_walk_patches "${d}/configure" "${p}"
390 ret=$?
391 fi
392 ;;
393 aixrtl|hpux-conf)
394 ret=1
395 local subret=0
396 # apply multiple patches as often as they match
397 while [[ $subret -eq 0 ]]; do
398 subret=1
399 if [[ -e ${d}/configure ]]; then
400 ELT_walk_patches "${d}/configure" "${p}"
401 subret=$?
402 fi
403 if [[ $subret -eq 0 ]]; then
404 # have at least one patch succeeded.
405 ret=0
406 fi
407 done
408 ;;
409 mint-conf|gold-conf|sol2-conf)
410 ELT_walk_patches "${d}/configure" "${p}"
411 ret=$?
412 ;;
413 target-nm)
414 ELT_walk_patches "${d}/configure" "${p}"
415 ret=$?
416 ;;
417 *)
418 # ltmain.sh patches are applied above
419 ;;
420 esac
421
422 if [[ ${ret} -ne 0 ]] ; then
423 case ${p} in
407 uclibc-*) 424 uclibc-*)
408 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!" 425 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
409 ;; 426 ;;
410 fbsd-*) 427 fbsd-*)
411 if [[ ${CHOST} == *-freebsd* ]] ; then 428 if [[ ${CHOST} == *-freebsd* ]] ; then
412 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \ 429 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
413 "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then 430 "${d}/configure" 2>/dev/null) ]]; then
414 eerror " FreeBSD patch set '${p}' failed to apply!" 431 eerror " FreeBSD patch set '${p}' failed to apply!"
415 die "FreeBSD patch set '${p}' failed to apply!" 432 die "FreeBSD patch set '${p}' failed to apply!"
416 fi 433 fi
417 fi 434 fi
418 ;; 435 ;;
421 ;; 438 ;;
422 esac 439 esac
423 fi 440 fi
424 done 441 done
425 442
426 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
427 if [[ ${do_portage} == "no" && \
428 ${do_reversedeps} == "no" && \
429 ${do_only_patches} == "no" && \
430 ${deptoremove} == "" ]]
431 then
432 ewarn "Cannot apply any patches, please file a bug about this"
433 die
434 fi
435 fi
436
437 rm -f "${d}/libtool" 443 rm -f "${d}/libtool"
438 444
439 > "${d}/.elibtoolized" 445 > "${d}/.elibtoolized"
440 done 446 done
441} 447}

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

  ViewVC Help
Powered by ViewVC 1.1.20