| 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.92 2011/06/10 10:14:21 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.101 2012/07/26 16:14:47 grobian 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 | |
|
|
17 | if [[ ${___ECLASS_ONCE_LIBTOOL} != "recur -_+^+_- spank" ]] ; then |
|
|
18 | ___ECLASS_ONCE_LIBTOOL="recur -_+^+_- spank" |
|
|
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. |
|
|
24 | ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*} |
|
|
25 | elt_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 | |
| 17 | DESCRIPTION="Based on the ${ECLASS} eclass" |
33 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 18 | |
34 | |
| 19 | inherit toolchain-funcs |
35 | inherit multilib toolchain-funcs |
| 20 | |
|
|
| 21 | ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches" |
|
|
| 22 | |
36 | |
| 23 | # |
37 | # |
| 24 | # See if we can apply $2 on $1, and if so, do it |
38 | # See if we can apply $2 on $1, and if so, do it |
| 25 | # |
39 | # |
| 26 | ELT_try_and_apply_patch() { |
40 | ELT_try_and_apply_patch() { |
| 27 | local ret=0 |
41 | local ret=0 |
| 28 | local file=$1 |
42 | local file=$1 |
| 29 | local patch=$2 |
43 | local patch=$2 |
|
|
44 | local src=$3 |
|
|
45 | local disp="${src} patch" |
|
|
46 | local log="${T}/elibtool.log" |
| 30 | |
47 | |
| 31 | echo -e "\nTrying $(basename "$(dirname "${patch}")")-${patch##*/}.patch on ${file}" \ |
48 | if [[ -z ${__ELT_NOTED_TMP} ]] ; then |
| 32 | &>> "${T}/elibtool.log" |
49 | __ELT_NOTED_TMP=true |
|
|
50 | printf 'temp patch: %s\n' "${patch}" > "${log}" |
|
|
51 | fi |
|
|
52 | printf '\nTrying %s\n' "${disp}" >> "${log}" |
| 33 | |
53 | |
| 34 | # We only support patchlevel of 0 - why worry if its static patches? |
54 | # We only support patchlevel of 0 - why worry if its static patches? |
| 35 | if patch -p0 --dry-run "${file}" "${patch}" &>> "${T}/elibtool.log" ; then |
55 | if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then |
| 36 | einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." |
56 | einfo " Applying ${disp} ..." |
| 37 | patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \ |
57 | patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1 |
| 38 | &>> "${T}/elibtool.log" |
|
|
| 39 | ret=$? |
58 | ret=$? |
| 40 | export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" |
59 | export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}" |
| 41 | else |
60 | else |
| 42 | ret=1 |
61 | ret=1 |
| 43 | fi |
62 | fi |
| 44 | |
63 | |
| 45 | return "${ret}" |
64 | return "${ret}" |
| … | |
… | |
| 59 | # |
78 | # |
| 60 | # Run through the patches in $2 and see if any |
79 | # Run through the patches in $2 and see if any |
| 61 | # apply to $1 ... |
80 | # apply to $1 ... |
| 62 | # |
81 | # |
| 63 | ELT_walk_patches() { |
82 | ELT_walk_patches() { |
| 64 | local patch |
83 | local patch tmp |
| 65 | local ret=1 |
84 | local ret=1 |
| 66 | local file=$1 |
85 | local file=$1 |
| 67 | local patch_set=$2 |
86 | local patch_set=$2 |
| 68 | local patch_dir="${ELT_PATCH_DIR}/${patch_set}" |
87 | local patch_dir="$(elt_patch_dir)/${patch_set}" |
| 69 | local rem_int_dep=$3 |
88 | local rem_int_dep=$3 |
| 70 | |
89 | |
| 71 | [[ -z ${patch_set} ]] && return 1 |
90 | [[ -z ${patch_set} ]] && return 1 |
| 72 | [[ ! -d ${patch_dir} ]] && return 1 |
91 | [[ ! -d ${patch_dir} ]] && return 1 |
| 73 | |
92 | |
| 74 | pushd "${ELT_PATCH_DIR}" >/dev/null |
93 | # Allow patches to use @GENTOO_LIBDIR@ replacements |
|
|
94 | local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" ) |
|
|
95 | if [[ -n ${rem_int_dep} ]] ; then |
|
|
96 | # replace @REM_INT_DEP@ with what was passed |
|
|
97 | # to --remove-internal-dep |
|
|
98 | sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ) |
|
|
99 | fi |
|
|
100 | |
|
|
101 | pushd "$(elt_patch_dir)" >/dev/null || die |
| 75 | |
102 | |
| 76 | # Go through the patches in reverse order (newer version to older) |
103 | # Go through the patches in reverse order (newer version to older) |
| 77 | for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do |
104 | for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do |
| 78 | # For --remove-internal-dep ... |
105 | tmp="${T}/libtool-elt.patch" |
| 79 | if [[ -n ${rem_int_dep} ]] ; then |
106 | sed "${sed_args[@]}" "${patch}" > "${tmp}" || die |
| 80 | # For replace @REM_INT_DEP@ with what was passed |
|
|
| 81 | # to --remove-internal-dep |
|
|
| 82 | local tmp="${T}/$$.rem_int_deps.patch" |
|
|
| 83 | sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}" |
|
|
| 84 | patch=${tmp} |
|
|
| 85 | fi |
|
|
| 86 | |
|
|
| 87 | if ELT_try_and_apply_patch "${file}" "${patch}" ; then |
107 | if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then |
| 88 | # Break to unwind w/popd rather than return directly |
108 | # Break to unwind w/popd rather than return directly |
| 89 | ret=0 |
109 | ret=0 |
| 90 | break |
110 | break |
| 91 | fi |
111 | fi |
| 92 | done |
112 | done |
| … | |
… | |
| 111 | local do_reversedeps="no" |
131 | local do_reversedeps="no" |
| 112 | local do_only_patches="no" |
132 | local do_only_patches="no" |
| 113 | local do_uclibc="yes" |
133 | local do_uclibc="yes" |
| 114 | local deptoremove= |
134 | local deptoremove= |
| 115 | local do_shallow="no" |
135 | local do_shallow="no" |
|
|
136 | local force="false" |
| 116 | local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" |
137 | local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed" |
| 117 | |
138 | |
| 118 | for x in "$@" ; do |
139 | for x in "$@" ; do |
| 119 | case ${x} in |
140 | case ${x} in |
| 120 | --portage) |
141 | --portage) |
| … | |
… | |
| 145 | do_shallow="yes" |
166 | do_shallow="yes" |
| 146 | ;; |
167 | ;; |
| 147 | --no-uclibc) |
168 | --no-uclibc) |
| 148 | do_uclibc="no" |
169 | do_uclibc="no" |
| 149 | ;; |
170 | ;; |
|
|
171 | --force) |
|
|
172 | force="true" |
|
|
173 | ;; |
| 150 | *) |
174 | *) |
| 151 | eerror "Invalid elibtoolize option: ${x}" |
175 | eerror "Invalid elibtoolize option: ${x}" |
| 152 | die "elibtoolize called with ${x} ??" |
176 | die "elibtoolize called with ${x} ??" |
| 153 | esac |
177 | esac |
| 154 | done |
178 | done |
| … | |
… | |
| 156 | [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" |
180 | [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" |
| 157 | |
181 | |
| 158 | case ${CHOST} in |
182 | case ${CHOST} in |
| 159 | *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277 |
183 | *-aix*) elt_patches+=" hardcode aixrtl aix-noundef" ;; #213277 |
| 160 | *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; |
184 | *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; |
|
|
185 | *-solaris*) elt_patches+=" sol2-conf sol2-ltmain" ;; |
| 161 | *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; |
186 | *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; |
| 162 | *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; |
187 | *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; |
| 163 | *-irix*) elt_patches+=" irix-ltmain" ;; |
188 | *-irix*) elt_patches+=" irix-ltmain" ;; |
| 164 | *-mint*) elt_patches+=" mint-conf" ;; |
189 | *-mint*) elt_patches+=" mint-conf" ;; |
| 165 | esac |
190 | esac |
| … | |
… | |
| 178 | |
203 | |
| 179 | local d p |
204 | local d p |
| 180 | for d in "$@" ; do |
205 | for d in "$@" ; do |
| 181 | export ELT_APPLIED_PATCHES= |
206 | export ELT_APPLIED_PATCHES= |
| 182 | |
207 | |
|
|
208 | if [[ -f ${d}/.elibtoolized ]] ; then |
|
|
209 | ${force} || continue |
|
|
210 | fi |
|
|
211 | |
|
|
212 | local outfunc="einfo" |
| 183 | [[ -f ${d}/.elibtoolized ]] && continue |
213 | [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn" |
| 184 | |
|
|
| 185 | einfo "Running elibtoolize in: ${d#${WORKDIR}/}/" |
214 | ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/" |
|
|
215 | if [[ ${outfunc} == "ewarn" ]] ; then |
|
|
216 | ewarn " We've already been run in this tree; you should" |
|
|
217 | ewarn " avoid this if possible (perhaps by filing a bug)" |
|
|
218 | fi |
| 186 | |
219 | |
| 187 | for p in ${elt_patches} ; do |
220 | for p in ${elt_patches} ; do |
| 188 | local ret=0 |
221 | local ret=0 |
| 189 | |
222 | |
| 190 | case ${p} in |
223 | case ${p} in |
| … | |
… | |
| 298 | # have at least one patch succeeded. |
331 | # have at least one patch succeeded. |
| 299 | ret=0 |
332 | ret=0 |
| 300 | fi |
333 | fi |
| 301 | done |
334 | done |
| 302 | ;; |
335 | ;; |
| 303 | mint-conf|gold-conf) |
336 | mint-conf|gold-conf|sol2-conf) |
| 304 | ret=1 |
337 | ret=1 |
| 305 | local subret=1 |
338 | local subret=1 |
| 306 | if [[ -e ${d}/configure ]]; then |
339 | if [[ -e ${d}/configure ]]; then |
| 307 | ELT_walk_patches "${d}/configure" "${p}" |
340 | ELT_walk_patches "${d}/configure" "${p}" |
| 308 | subret=$? |
341 | subret=$? |
| … | |
… | |
| 468 | fi |
501 | fi |
| 469 | |
502 | |
| 470 | echo 1 |
503 | echo 1 |
| 471 | return 1 |
504 | return 1 |
| 472 | } |
505 | } |
|
|
506 | |
|
|
507 | fi |