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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.48 - (hide annotations) (download)
Wed Jul 6 20:20:03 2005 UTC (8 years, 9 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 vapier 1.42 # Copyright 1999-2005 Gentoo Foundation
2 vapier 1.15 # Distributed under the terms of the GNU General Public License v2
3 agriffis 1.48 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.47 2005/05/27 23:46:13 vapier Exp $
4 vapier 1.20 #
5 azarah 1.1 # Author: Martin Schlemmer <azarah@gentoo.org>
6 vapier 1.20 #
7 azarah 1.1 # This eclass patches ltmain.sh distributed with libtoolized packages with the
8 azarah 1.24 # relink and portage patch among others
9 vapier 1.15
10 azarah 1.24 INHERITED="${INHERITED} ${ECLASS}"
11 danarmak 1.12
12 rac 1.34 # 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 vapier 1.22 DESCRIPTION="Based on the ${ECLASS} eclass"
21 azarah 1.1
22 azarah 1.44 ELIBTOOL_VERSION="2.0.2"
23 azarah 1.1
24 azarah 1.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 vapier 1.42 for x in $(find "${S}" -name 'ltmain.sh') ; do
35 mr_bones_ 1.27 dirlist="${dirlist} ${x%/*}"
36     done
37 azarah 1.24
38 mr_bones_ 1.27 echo "${dirlist}"
39 azarah 1.24 }
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 vapier 1.42 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then
50 vapier 1.37 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
51 azarah 1.24 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 azarah 1.44 local version=$(eval $(grep -e '^[[:space:]]*VERSION=' $1); \
71     echo "${VERSION}")
72 azarah 1.2
73 vapier 1.42 if [[ -n $2 ]] ; then
74     if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then
75 azarah 1.24 patch_dir="${ELT_PATCH_DIR}/$2"
76     else
77     return ${ret}
78 azarah 1.4 fi
79 mr_bones_ 1.27
80 azarah 1.44 if [[ -z ${version} ]] ; then
81     eerror "Could not get VERSION for ${1##*/}!"
82     die "Could not get VERSION for ${1##*/}!"
83     fi
84 mr_bones_ 1.27
85 azarah 1.44 # 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 azarah 1.43
100 azarah 1.44 x="${T}/$$.rem_int_deps.patch"
101 azarah 1.24 fi
102 azarah 1.43
103 azarah 1.44 if ELT_try_and_apply_patch "$1" "${x}" ; then
104     ret=0
105     break
106 azarah 1.24 fi
107 azarah 1.44 fi
108     done
109 azarah 1.24 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 azarah 1.25 local elt_patches="portage relink max_cmd_len sed test tmp"
123 vapier 1.29 local start_dir="${PWD}"
124 azarah 1.24
125     my_dirlist="$(ELT_find_ltmain_sh)"
126 mr_bones_ 1.27
127 vapier 1.42 for x in "$@" ; do
128 azarah 1.24 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 vapier 1.40 "--no-uclibc")
162     NO_UCLIBCTOOLIZE=1
163     ;;
164 vapier 1.42 *)
165     eerror "Invalid elibtoolize option: $x"
166     die "elibtoolize called with $x ??"
167 azarah 1.24 esac
168 azarah 1.4 done
169 azarah 1.1
170 usata 1.36 if use ppc-macos ; then
171     glibtoolize --copy --force
172     darwintoolize
173     fi
174    
175 vapier 1.42 for x in ${my_dirlist} ; do
176     local tmp=$(echo "${x}" | sed -e "s|${S}||")
177 azarah 1.24 export ELT_APPLIED_PATCHES=
178 mr_bones_ 1.27
179 azarah 1.1 cd ${x}
180 vapier 1.37 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
181 azarah 1.2
182 vapier 1.42 for y in ${elt_patches} ; do
183 azarah 1.24 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 vapier 1.42 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
193 azarah 1.24 ELT_walk_patches "${x}/ltmain.sh" "${y}"
194     ret=$?
195     fi
196     ;;
197 azarah 1.25 "max_cmd_len")
198     # Do not apply if $max_cmd_len is not used ...
199 vapier 1.42 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
200 azarah 1.25 ELT_walk_patches "${x}/ltmain.sh" "${y}"
201     ret=$?
202     fi
203     ;;
204 azarah 1.24 *)
205     ELT_walk_patches "${x}/ltmain.sh" "${y}"
206     ret=$?
207     ;;
208     esac
209 mr_bones_ 1.27
210 vapier 1.42 if [[ ${ret} -ne 0 ]] ; then
211 azarah 1.3 case ${y} in
212 azarah 1.24 "relink")
213     # Critical patch, but could be applied ...
214 vapier 1.42 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
215 azarah 1.24 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 vapier 1.42 if [[ ${do_portage} == "yes" ]] ; then
222 azarah 1.24 # Stupid test to see if its already applied ...
223 vapier 1.42 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
224 azarah 1.24 echo
225     eerror "Portage patch requested, but failed to apply!"
226     die "Portage patch requested, but failed to apply!"
227     fi
228     else
229 azarah 1.45 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 azarah 1.46 local version=$( \
234     eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
235     echo "${VERSION}")
236    
237 azarah 1.45 echo
238 azarah 1.46 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
239 azarah 1.45 die "Portage patch failed to apply!"
240     fi
241     # We do not want to run libtoolize ...
242     ELT_APPLIED_PATCHES="portage"
243 azarah 1.3 fi
244     ;;
245     esac
246 azarah 1.1 fi
247 azarah 1.11
248 vapier 1.42 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
249     if [[ ${do_portage} == "no" && \
250     ${do_reversedeps} == "no" && \
251     ${do_only_patches} == "no" && \
252     ${deptoremove} == "" ]]
253 azarah 1.24 then
254 vapier 1.47 ewarn "Cannot apply any patches, please file a bug about this"
255     break
256    
257 azarah 1.24 # Sometimes ltmain.sh is in a subdirectory ...
258 vapier 1.42 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 azarah 1.3 fi
262 azarah 1.24 fi
263    
264 vapier 1.42 if type -p libtoolize &> /dev/null ; then
265 vapier 1.47 ewarn "Cannot apply any patches, running libtoolize..."
266 azarah 1.24 libtoolize --copy --force
267 azarah 1.19 fi
268 vapier 1.42 cd "${x}"
269 azarah 1.24 break
270 azarah 1.19 fi
271 azarah 1.1 fi
272     done
273     done
274 azarah 1.6
275 vapier 1.42 if [[ -f libtool ]] ; then
276 azarah 1.7 rm -f libtool
277     fi
278    
279 vapier 1.29 cd "${start_dir}"
280 vapier 1.30
281     uclibctoolize
282     }
283    
284     uclibctoolize() {
285 vapier 1.42 [[ -n ${NO_UCLIBCTOOLIZE} ]] && return 0
286 vapier 1.38
287 vapier 1.41 local errmsg=""
288 vapier 1.42 [[ ${CTARGET:-${CHOST}} == *-uclibc ]] \
289 vapier 1.41 && errmsg="PLEASE CHECK" \
290     || errmsg="Already patched"
291 vapier 1.30 local targets=""
292     local x
293    
294 vapier 1.42 if [[ -z $* ]] ; then
295     targets=$(find ${S} -name configure -o -name ltconfig)
296 vapier 1.30 fi
297    
298     einfo "Applying uClibc/libtool patches ..."
299     for x in ${targets} ; do
300 vapier 1.42 [[ ! -s ${x} ]] && continue
301     case ${x##*/} in
302 vapier 1.31 configure)
303 vapier 1.42 if grep 'Transform linux' "${x}" > /dev/null ; then
304 vapier 1.31 ebegin " Fixing \${S}${x/${S}}"
305     patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
306 vapier 1.41 eend $? "${errmsg} ${x}"
307 vapier 1.31 fi
308     ;;
309    
310     ltconfig)
311 vapier 1.42 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 vapier 1.30 ebegin " Fixing \${S}${x/${S}}"
315 vapier 1.31 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
316 vapier 1.41 eend $? "${errmsg} ${x}"
317 vapier 1.31 ;;
318     esac
319 vapier 1.30 done
320 azarah 1.1 }
321 usata 1.36
322     darwintoolize() {
323     local targets=""
324     local x
325    
326 vapier 1.42 if [[ -z $* ]] ; then
327     targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
328 usata 1.36 fi
329    
330     einfo "Applying Darwin/libtool patches ..."
331     for x in ${targets} ; do
332 vapier 1.42 [[ ! -s ${x} ]] && continue
333     case ${x##*/} in
334 usata 1.36 ltmain.sh|ltconfig)
335 vapier 1.42 local ver=$(grep '^VERSION=' ${x})
336     ver=${ver/VERSION=}
337     if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
338 usata 1.36 ver="1.3" # 1.4, 1.5 and 1.3 are compat
339     fi
340    
341     ebegin " Fixing \${S}${x/${S}}"
342 vapier 1.42 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
343 usata 1.36 eend $? "PLEASE CHECK ${x}"
344     ;;
345     esac
346     done
347     }
348 azarah 1.44
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