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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.48 - (show annotations) (download)
Wed Jul 6 20:20:03 2005 UTC (9 years, 2 months ago) by agriffis
Branch: MAIN
Changes since 1.47: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

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.47 2005/05/27 23:46: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 INHERITED="${INHERITED} ${ECLASS}"
11
12 # 2004.09.25 rac
13 # i have verified that at least one package can use this eclass and
14 # build properly even without libtool installed yet, probably using
15 # the files in the distribution. eliminating this dependency fixes
16 # bug 65209, which is a showstopper for people doing installs using
17 # stageballs <3. if anybody decides to revert this, please attempt
18 # to find an alternate way of resolving that bug at the same time.
19
20 DESCRIPTION="Based on the ${ECLASS} eclass"
21
22 ELIBTOOL_VERSION="2.0.2"
23
24 ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches"
25 ELT_APPLIED_PATCHES=
26
27 #
28 # Returns all the directories containing ltmain.sh
29 #
30 ELT_find_ltmain_sh() {
31 local x=
32 local dirlist=
33
34 for x in $(find "${S}" -name 'ltmain.sh') ; do
35 dirlist="${dirlist} ${x%/*}"
36 done
37
38 echo "${dirlist}"
39 }
40
41 #
42 # See if we can apply $2 on $1, and if so, do it
43 #
44 ELT_try_and_apply_patch() {
45 local ret=0
46 local patch="$2"
47
48 # We only support patchlevel of 0 - why worry if its static patches?
49 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then
50 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
51 patch -p0 $1 < ${patch} &>${T}/elibtool.log
52 ret=$?
53 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
54 else
55 ret=1
56 fi
57
58 return ${ret}
59 }
60
61 #
62 # Run through the patches in $2 and see if any
63 # apply to $1 ...
64 #
65 ELT_walk_patches() {
66 local x=
67 local y=
68 local ret=1
69 local patch_dir=
70 local version=$(eval $(grep -e '^[[:space:]]*VERSION=' $1); \
71 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 if [[ -z ${version} ]] ; then
81 eerror "Could not get VERSION for ${1##*/}!"
82 die "Could not get VERSION for ${1##*/}!"
83 fi
84
85 # Go through the patches in reverse order (large to small)
86 for x in $(ls -d "${patch_dir}"/* 2> /dev/null | sort -r) ; do
87 if [[ -n ${x} && -f ${x} ]] ; then
88 local ltver=$(VER_to_int "${version}")
89 local ptver=$(VER_to_int "${x##*/}")
90
91 # If libtool version smaller than patch version, skip patch.
92 [[ ${ltver} -lt ${ptver} ]] && continue
93 # For --remove-internal-dep ...
94 if [[ -n $3 ]] ; then
95 # For replace @REM_INT_DEP@ with what was passed
96 # to --remove-internal-dep
97 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
98 ${T}/$$.rem_int_deps.patch
99
100 x="${T}/$$.rem_int_deps.patch"
101 fi
102
103 if ELT_try_and_apply_patch "$1" "${x}" ; then
104 ret=0
105 break
106 fi
107 fi
108 done
109 fi
110
111 return ${ret}
112 }
113
114 elibtoolize() {
115 local x=
116 local y=
117 local do_portage="no"
118 local do_reversedeps="no"
119 local do_only_patches="no"
120 local deptoremove=
121 local my_dirlist=
122 local elt_patches="portage relink max_cmd_len sed test tmp"
123 local start_dir="${PWD}"
124
125 my_dirlist="$(ELT_find_ltmain_sh)"
126
127 for x in "$@" ; do
128 case "${x}" in
129 "--portage")
130 # Only apply portage patch, and don't
131 # 'libtoolize --copy --force' if all patches fail.
132 do_portage="yes"
133 ;;
134 "--reverse-deps")
135 # Apply the reverse-deps patch
136 # http://bugzilla.gnome.org/show_bug.cgi?id=75635
137 do_reversedeps="yes"
138 elt_patches="${elt_patches} fix-relink"
139 ;;
140 "--patch-only")
141 # Do not run libtoolize if none of the patches apply ..
142 do_only_patches="yes"
143 ;;
144 "^--remove-internal-dep="*)
145 # We will replace @REM_INT_DEP@ with what is needed
146 # in ELT_walk_patches() ...
147 deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
148
149 # Add the patch for this ...
150 [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
151 ;;
152 "--shallow")
153 # Only patch the ltmain.sh in ${S}
154 if [ -f "${S}/ltmain.sh" ]
155 then
156 my_dirlist="${S}"
157 else
158 my_dirlist=
159 fi
160 ;;
161 "--no-uclibc")
162 NO_UCLIBCTOOLIZE=1
163 ;;
164 *)
165 eerror "Invalid elibtoolize option: $x"
166 die "elibtoolize called with $x ??"
167 esac
168 done
169
170 if use ppc-macos ; then
171 glibtoolize --copy --force
172 darwintoolize
173 fi
174
175 for x in ${my_dirlist} ; do
176 local tmp=$(echo "${x}" | sed -e "s|${S}||")
177 export ELT_APPLIED_PATCHES=
178
179 cd ${x}
180 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
181
182 for y in ${elt_patches} ; do
183 local ret=0
184
185 case "${y}" in
186 "rem-int-dep")
187 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
188 ret=$?
189 ;;
190 "fix-relink")
191 # Do not apply if we do not have the relink patch applied ...
192 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
193 ELT_walk_patches "${x}/ltmain.sh" "${y}"
194 ret=$?
195 fi
196 ;;
197 "max_cmd_len")
198 # Do not apply if $max_cmd_len is not used ...
199 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
200 ELT_walk_patches "${x}/ltmain.sh" "${y}"
201 ret=$?
202 fi
203 ;;
204 *)
205 ELT_walk_patches "${x}/ltmain.sh" "${y}"
206 ret=$?
207 ;;
208 esac
209
210 if [[ ${ret} -ne 0 ]] ; then
211 case ${y} in
212 "relink")
213 # Critical patch, but could be applied ...
214 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
215 ewarn " Could not apply relink.patch!"
216 fi
217 ;;
218 "portage")
219 # Critical patch - for this one we abort, as it can really
220 # cause breakage without it applied!
221 if [[ ${do_portage} == "yes" ]] ; then
222 # Stupid test to see if its already applied ...
223 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
224 echo
225 eerror "Portage patch requested, but failed to apply!"
226 die "Portage patch requested, but failed to apply!"
227 fi
228 else
229 if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
230 ewarn " Portage patch seems to be already applied."
231 ewarn " Please verify that it is not needed."
232 else
233 local version=$( \
234 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
235 echo "${VERSION}")
236
237 echo
238 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
239 die "Portage patch failed to apply!"
240 fi
241 # We do not want to run libtoolize ...
242 ELT_APPLIED_PATCHES="portage"
243 fi
244 ;;
245 esac
246 fi
247
248 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
249 if [[ ${do_portage} == "no" && \
250 ${do_reversedeps} == "no" && \
251 ${do_only_patches} == "no" && \
252 ${deptoremove} == "" ]]
253 then
254 ewarn "Cannot apply any patches, please file a bug about this"
255 break
256
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 patches, 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 }
348
349 # char *VER_major(string)
350 #
351 # Return the Major (X of X.Y.Z) version
352 #
353 VER_major() {
354 [[ -z $1 ]] && return 1
355
356 local VER=$@
357 echo ${VER%%[^[:digit:]]*}
358 }
359
360 # char *VER_minor(string)
361 #
362 # Return the Minor (Y of X.Y.Z) version
363 #
364 VER_minor() {
365 [[ -z $1 ]] && return 1
366
367 local VER=$@
368 VER=${VER#*.}
369 echo ${VER%%[^[:digit:]]*}
370 }
371
372 # char *VER_micro(string)
373 #
374 # Return the Micro (Z of X.Y.Z) version.
375 #
376 VER_micro() {
377 [[ -z $1 ]] && return 1
378
379 local VER=$@
380 VER=${VER#*.*.}
381 echo ${VER%%[^[:digit:]]*}
382 }
383
384 # int VER_to_int(string)
385 #
386 # Convert a string type version (2.4.0) to an int (132096)
387 # for easy compairing or versions ...
388 #
389 VER_to_int() {
390 [[ -z $1 ]] && return 1
391
392 local VER_MAJOR=$(VER_major "$1")
393 local VER_MINOR=$(VER_minor "$1")
394 local VER_MICRO=$(VER_micro "$1")
395 local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ))
396
397 # We make version 1.0.0 the minimum version we will handle as
398 # a sanity check ... if its less, we fail ...
399 if [[ ${VER_int} -ge 65536 ]] ; then
400 echo "${VER_int}"
401 return 0
402 fi
403
404 echo 1
405 return 1
406 }

  ViewVC Help
Powered by ViewVC 1.1.20