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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.43 - (show annotations) (download)
Sun Feb 27 20:29:04 2005 UTC (9 years, 1 month ago) by azarah
Branch: MAIN
Changes since 1.42: +42 -15 lines
Try to match patches more according to libtool version, bug #83486

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.42 2005/01/31 03:02:13 vapier Exp $
4 #
5 # Author: Martin Schlemmer <azarah@gentoo.org>
6 #
7 # This eclass patches ltmain.sh distributed with libtoolized packages with the
8 # relink and portage patch among others
9
10 ECLASS="libtool"
11 INHERITED="${INHERITED} ${ECLASS}"
12
13 # 2004.09.25 rac
14 # i have verified that at least one package can use this eclass and
15 # build properly even without libtool installed yet, probably using
16 # the files in the distribution. eliminating this dependency fixes
17 # bug 65209, which is a showstopper for people doing installs using
18 # stageballs <3. if anybody decides to revert this, please attempt
19 # to find an alternate way of resolving that bug at the same time.
20
21 DESCRIPTION="Based on the ${ECLASS} eclass"
22
23 ELIBTOOL_VERSION="2.0.1"
24
25 ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches"
26 ELT_APPLIED_PATCHES=
27
28 #
29 # Returns all the directories containing ltmain.sh
30 #
31 ELT_find_ltmain_sh() {
32 local x=
33 local dirlist=
34
35 for x in $(find "${S}" -name 'ltmain.sh') ; do
36 dirlist="${dirlist} ${x%/*}"
37 done
38
39 echo "${dirlist}"
40 }
41
42 #
43 # See if we can apply $2 on $1, and if so, do it
44 #
45 ELT_try_and_apply_patch() {
46 local ret=0
47 local patch="$2"
48
49 # We only support patchlevel of 0 - why worry if its static patches?
50 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then
51 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
52 patch -p0 $1 < ${patch} &>${T}/elibtool.log
53 ret=$?
54 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
55 else
56 ret=1
57 fi
58
59 return ${ret}
60 }
61
62 #
63 # Run through the patches in $2 and see if any
64 # apply to $1 ...
65 #
66 ELT_walk_patches() {
67 local x=
68 local y=
69 local ret=1
70 local patch_dir=
71 local version=$(eval $(grep -e '^[[:space:]]*VERSION=' $1); echo "${VERSION}")
72
73 if [[ -n $2 ]] ; then
74 if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then
75 patch_dir="${ELT_PATCH_DIR}/$2"
76 else
77 return ${ret}
78 fi
79
80 # First check a version specific patch, if not check major.minor*
81 for y in ${version} $(echo "${version}" | cut -d. -f1,2) ; do
82 [[ -z ${y} ]] && continue
83 for x in $(ls -d "${patch_dir}/${y}"* 2> /dev/null) ; do
84 if [[ -n ${x} && -f ${x} ]] ; then
85 # For --remove-internal-dep ...
86 if [[ -n $3 ]] ; then
87 # For replace @REM_INT_DEP@ with what was passed
88 # to --remove-internal-dep
89 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
90 ${T}/$$.rem_int_deps.patch
91
92 x="${T}/$$.rem_int_deps.patch"
93 fi
94
95 if ELT_try_and_apply_patch "$1" "${x}" ; then
96 ret=0
97 break
98 fi
99 fi
100 done
101 done
102
103 # If still nothing, try the rest.
104 if [[ ${ret} -eq 1 ]]; then
105 for x in $(ls -d "${patch_dir}"/* 2> /dev/null) ; do
106 if [[ -n ${x} && -f ${x} ]] ; then
107 # For --remove-internal-dep ...
108 if [[ -n $3 ]] ; then
109 # For replace @REM_INT_DEP@ with what was passed
110 # to --remove-internal-dep
111 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
112 ${T}/$$.rem_int_deps.patch
113
114 x="${T}/$$.rem_int_deps.patch"
115 fi
116
117 if ELT_try_and_apply_patch "$1" "${x}" ; then
118 ret=0
119 break
120 fi
121 fi
122 done
123 fi
124 fi
125
126 return ${ret}
127 }
128
129 elibtoolize() {
130 local x=
131 local y=
132 local do_portage="no"
133 local do_reversedeps="no"
134 local do_only_patches="no"
135 local deptoremove=
136 local my_dirlist=
137 local elt_patches="portage relink max_cmd_len sed test tmp"
138 local start_dir="${PWD}"
139
140 my_dirlist="$(ELT_find_ltmain_sh)"
141
142 for x in "$@" ; do
143 case "${x}" in
144 "--portage")
145 # Only apply portage patch, and don't
146 # 'libtoolize --copy --force' if all patches fail.
147 do_portage="yes"
148 ;;
149 "--reverse-deps")
150 # Apply the reverse-deps patch
151 # http://bugzilla.gnome.org/show_bug.cgi?id=75635
152 do_reversedeps="yes"
153 elt_patches="${elt_patches} fix-relink"
154 ;;
155 "--patch-only")
156 # Do not run libtoolize if none of the patches apply ..
157 do_only_patches="yes"
158 ;;
159 "^--remove-internal-dep="*)
160 # We will replace @REM_INT_DEP@ with what is needed
161 # in ELT_walk_patches() ...
162 deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
163
164 # Add the patch for this ...
165 [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
166 ;;
167 "--shallow")
168 # Only patch the ltmain.sh in ${S}
169 if [ -f "${S}/ltmain.sh" ]
170 then
171 my_dirlist="${S}"
172 else
173 my_dirlist=
174 fi
175 ;;
176 "--no-uclibc")
177 NO_UCLIBCTOOLIZE=1
178 ;;
179 *)
180 eerror "Invalid elibtoolize option: $x"
181 die "elibtoolize called with $x ??"
182 esac
183 done
184
185 if use ppc-macos ; then
186 glibtoolize --copy --force
187 darwintoolize
188 fi
189
190 for x in ${my_dirlist} ; do
191 local tmp=$(echo "${x}" | sed -e "s|${S}||")
192 export ELT_APPLIED_PATCHES=
193
194 cd ${x}
195 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
196
197 for y in ${elt_patches} ; do
198 local ret=0
199
200 case "${y}" in
201 "rem-int-dep")
202 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
203 ret=$?
204 ;;
205 "fix-relink")
206 # Do not apply if we do not have the relink patch applied ...
207 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
208 ELT_walk_patches "${x}/ltmain.sh" "${y}"
209 ret=$?
210 fi
211 ;;
212 "max_cmd_len")
213 # Do not apply if $max_cmd_len is not used ...
214 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
215 ELT_walk_patches "${x}/ltmain.sh" "${y}"
216 ret=$?
217 fi
218 ;;
219 *)
220 ELT_walk_patches "${x}/ltmain.sh" "${y}"
221 ret=$?
222 ;;
223 esac
224
225 if [[ ${ret} -ne 0 ]] ; then
226 case ${y} in
227 "relink")
228 # Critical patch, but could be applied ...
229 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
230 ewarn " Could not apply relink.patch!"
231 fi
232 ;;
233 "portage")
234 # Critical patch - for this one we abort, as it can really
235 # cause breakage without it applied!
236 if [[ ${do_portage} == "yes" ]] ; then
237 # Stupid test to see if its already applied ...
238 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
239 echo
240 eerror "Portage patch requested, but failed to apply!"
241 die "Portage patch requested, but failed to apply!"
242 fi
243 else
244 ewarn " Could not apply portage.patch!"
245 ewarn " Please verify that it is not needed."
246 fi
247 ;;
248 esac
249 fi
250
251 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
252 if [[ ${do_portage} == "no" && \
253 ${do_reversedeps} == "no" && \
254 ${do_only_patches} == "no" && \
255 ${deptoremove} == "" ]]
256 then
257 # Sometimes ltmain.sh is in a subdirectory ...
258 if [[ ! -f ${x}/configure.in && ! -f ${x}/configure.ac ]] ; then
259 if [[ -f ${x}/../configure.in || -f ${x}/../configure.ac ]] ; then
260 cd "${x}"/../
261 fi
262 fi
263
264 if type -p libtoolize &> /dev/null ; then
265 ewarn "Cannot apply any patch, running libtoolize..."
266 libtoolize --copy --force
267 fi
268 cd "${x}"
269 break
270 fi
271 fi
272 done
273 done
274
275 if [[ -f libtool ]] ; then
276 rm -f libtool
277 fi
278
279 cd "${start_dir}"
280
281 uclibctoolize
282 }
283
284 uclibctoolize() {
285 [[ -n ${NO_UCLIBCTOOLIZE} ]] && return 0
286
287 local errmsg=""
288 [[ ${CTARGET:-${CHOST}} == *-uclibc ]] \
289 && errmsg="PLEASE CHECK" \
290 || errmsg="Already patched"
291 local targets=""
292 local x
293
294 if [[ -z $* ]] ; then
295 targets=$(find ${S} -name configure -o -name ltconfig)
296 fi
297
298 einfo "Applying uClibc/libtool patches ..."
299 for x in ${targets} ; do
300 [[ ! -s ${x} ]] && continue
301 case ${x##*/} in
302 configure)
303 if grep 'Transform linux' "${x}" > /dev/null ; then
304 ebegin " Fixing \${S}${x/${S}}"
305 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
306 eend $? "${errmsg} ${x}"
307 fi
308 ;;
309
310 ltconfig)
311 local ver=$(grep '^VERSION=' ${x})
312 ver=${ver/VERSION=}
313 [[ ${ver:0:3} == "1.4" ]] && ver="1.3" # 1.4 and 1.3 are compat
314 ebegin " Fixing \${S}${x/${S}}"
315 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
316 eend $? "${errmsg} ${x}"
317 ;;
318 esac
319 done
320 }
321
322 darwintoolize() {
323 local targets=""
324 local x
325
326 if [[ -z $* ]] ; then
327 targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
328 fi
329
330 einfo "Applying Darwin/libtool patches ..."
331 for x in ${targets} ; do
332 [[ ! -s ${x} ]] && continue
333 case ${x##*/} in
334 ltmain.sh|ltconfig)
335 local ver=$(grep '^VERSION=' ${x})
336 ver=${ver/VERSION=}
337 if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
338 ver="1.3" # 1.4, 1.5 and 1.3 are compat
339 fi
340
341 ebegin " Fixing \${S}${x/${S}}"
342 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
343 eend $? "PLEASE CHECK ${x}"
344 ;;
345 esac
346 done
347 }

  ViewVC Help
Powered by ViewVC 1.1.20