/[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.109
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.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
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#
123# 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.
124# 134#
125# 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.
126elibtoolize() { 136elibtoolize() {
127 local x 137 local x
138 local dirs=()
128 local do_portage="no" 139 local do_portage="no"
129 local do_reversedeps="no" 140 local do_reversedeps="no"
130 local do_only_patches="no" 141 local do_only_patches="no"
131 local do_uclibc="yes" 142 local do_uclibc="yes"
132 local deptoremove= 143 local deptoremove=
133 local do_shallow="no" 144 local do_shallow="no"
134 local force="false" 145 local force="false"
135 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"
136 147
137 for x in "$@" ; do 148 for x in "$@" ; do
138 case ${x} in 149 case ${x} in
139 --portage) 150 --portage)
140 # Only apply portage patch, and don't 151 # Only apply portage patch, and don't
167 do_uclibc="no" 178 do_uclibc="no"
168 ;; 179 ;;
169 --force) 180 --force)
170 force="true" 181 force="true"
171 ;; 182 ;;
172 *) 183 -*)
173 eerror "Invalid elibtoolize option: ${x}" 184 eerror "Invalid elibtoolize option: ${x}"
174 die "elibtoolize called with ${x} ??" 185 die "elibtoolize called with ${x} ??"
186 ;;
187 *) dirs+=( "${x}" )
175 esac 188 esac
176 done 189 done
177 190
178 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" 191 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf"
179 192
189 202
190 if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then 203 if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then
191 elt_patches+=" gold-conf" 204 elt_patches+=" gold-conf"
192 fi 205 fi
193 206
194 # Reuse "$@" for dirs to patch 207 # Find out what dirs to scan.
195 set --
196 if [[ ${do_shallow} == "yes" ]] ; then 208 if [[ ${do_shallow} == "yes" ]] ; then
197 [[ -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}" )
198 else 211 else
199 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) )
200 fi 214 fi
201 215
202 local d p 216 local d p ret
203 for d in "$@" ; do 217 for d in "${dirs[@]}" ; do
204 export ELT_APPLIED_PATCHES= 218 export ELT_APPLIED_PATCHES=
205 219
206 if [[ -f ${d}/.elibtoolized ]] ; then 220 if [[ -f ${d}/.elibtoolized ]] ; then
207 ${force} || continue 221 ${force} || continue
208 fi 222 fi
213 if [[ ${outfunc} == "ewarn" ]] ; then 227 if [[ ${outfunc} == "ewarn" ]] ; then
214 ewarn " We've already been run in this tree; you should" 228 ewarn " We've already been run in this tree; you should"
215 ewarn " avoid this if possible (perhaps by filing a bug)" 229 ewarn " avoid this if possible (perhaps by filing a bug)"
216 fi 230 fi
217 231
232 # patching ltmain.sh
233 [[ -f ${d}/ltmain.sh ]] &&
218 for p in ${elt_patches} ; do 234 for p in ${elt_patches} ; do
219 local ret=0 235 ret=0
220 236
221 case ${p} in 237 case ${p} in
222 portage) 238 portage)
223 # Stupid test to see if its already applied ... 239 # Stupid test to see if its already applied ...
224 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
246 ;; 262 ;;
247 as-needed) 263 as-needed)
248 ELT_walk_patches "${d}/ltmain.sh" "${p}" 264 ELT_walk_patches "${d}/ltmain.sh" "${p}"
249 ret=$? 265 ret=$?
250 ;; 266 ;;
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) 267 uclibc-ltconf)
263 # Newer libtoolize clears ltconfig, as not used anymore 268 # Newer libtoolize clears ltconfig, as not used anymore
264 if [[ -s ${d}/ltconfig ]] ; then 269 if [[ -s ${d}/ltconfig ]] ; then
265 ELT_walk_patches "${d}/ltconfig" "${p}" 270 ELT_walk_patches "${d}/ltconfig" "${p}"
266 ret=$? 271 ret=$?
267 fi 272 fi
268 ;; 273 ;;
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) 274 fbsd-ltconf)
281 if [[ -s ${d}/ltconfig ]] ; then 275 if [[ -s ${d}/ltconfig ]] ; then
282 ELT_walk_patches "${d}/ltconfig" "${p}" 276 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=$? 277 ret=$?
295 fi 278 fi
296 ;; 279 ;;
297 darwin-ltconf) 280 darwin-ltconf)
298 # Newer libtoolize clears ltconfig, as not used anymore 281 # Newer libtoolize clears ltconfig, as not used anymore
307 # built in, so not much to patch around then 290 # built in, so not much to patch around then
308 if [[ -e ${d}/ltmain.sh ]] && \ 291 if [[ -e ${d}/ltmain.sh ]] && \
309 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then 292 ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then
310 ELT_walk_patches "${d}/ltmain.sh" "${p}" 293 ELT_walk_patches "${d}/ltmain.sh" "${p}"
311 ret=$? 294 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 295 fi
352 ;; 296 ;;
353 install-sh) 297 install-sh)
354 ELT_walk_patches "${d}/install-sh" "${p}" 298 ELT_walk_patches "${d}/install-sh" "${p}"
355 ret=$? 299 ret=$?
402 fi 346 fi
403 # We do not want to run libtoolize ... 347 # We do not want to run libtoolize ...
404 ELT_APPLIED_PATCHES="portage" 348 ELT_APPLIED_PATCHES="portage"
405 fi 349 fi
406 ;; 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
407 uclibc-*) 426 uclibc-*)
408 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!" 427 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
409 ;; 428 ;;
410 fbsd-*) 429 fbsd-*)
411 if [[ ${CHOST} == *-freebsd* ]] ; then 430 if [[ ${CHOST} == *-freebsd* ]] ; then
412 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \ 431 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
413 "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then 432 "${d}/configure" 2>/dev/null) ]]; then
414 eerror " FreeBSD patch set '${p}' failed to apply!" 433 eerror " FreeBSD patch set '${p}' failed to apply!"
415 die "FreeBSD patch set '${p}' failed to apply!" 434 die "FreeBSD patch set '${p}' failed to apply!"
416 fi 435 fi
417 fi 436 fi
418 ;; 437 ;;
421 ;; 440 ;;
422 esac 441 esac
423 fi 442 fi
424 done 443 done
425 444
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" 445 rm -f "${d}/libtool"
438 446
439 > "${d}/.elibtoolized" 447 > "${d}/.elibtoolized"
440 done 448 done
441} 449}

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

  ViewVC Help
Powered by ViewVC 1.1.20