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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

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 azarah 1.43 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.42 2005/01/31 03:02: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 ECLASS="libtool"
11     INHERITED="${INHERITED} ${ECLASS}"
12 danarmak 1.12
13 rac 1.34 # 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 vapier 1.22 DESCRIPTION="Based on the ${ECLASS} eclass"
22 azarah 1.1
23 azarah 1.24 ELIBTOOL_VERSION="2.0.1"
24 azarah 1.1
25 azarah 1.24 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 vapier 1.42 for x in $(find "${S}" -name 'ltmain.sh') ; do
36 mr_bones_ 1.27 dirlist="${dirlist} ${x%/*}"
37     done
38 azarah 1.24
39 mr_bones_ 1.27 echo "${dirlist}"
40 azarah 1.24 }
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 vapier 1.42 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then
51 vapier 1.37 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
52 azarah 1.24 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 azarah 1.43 local version=$(eval $(grep -e '^[[:space:]]*VERSION=' $1); 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.43 # 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 mr_bones_ 1.27
92 azarah 1.43 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 azarah 1.24 fi
100 azarah 1.43 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 mr_bones_ 1.27
117 azarah 1.43 if ELT_try_and_apply_patch "$1" "${x}" ; then
118     ret=0
119     break
120     fi
121 azarah 1.24 fi
122 azarah 1.43 done
123     fi
124 azarah 1.24 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 azarah 1.25 local elt_patches="portage relink max_cmd_len sed test tmp"
138 vapier 1.29 local start_dir="${PWD}"
139 azarah 1.24
140     my_dirlist="$(ELT_find_ltmain_sh)"
141 mr_bones_ 1.27
142 vapier 1.42 for x in "$@" ; do
143 azarah 1.24 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 vapier 1.40 "--no-uclibc")
177     NO_UCLIBCTOOLIZE=1
178     ;;
179 vapier 1.42 *)
180     eerror "Invalid elibtoolize option: $x"
181     die "elibtoolize called with $x ??"
182 azarah 1.24 esac
183 azarah 1.4 done
184 azarah 1.1
185 usata 1.36 if use ppc-macos ; then
186     glibtoolize --copy --force
187     darwintoolize
188     fi
189    
190 vapier 1.42 for x in ${my_dirlist} ; do
191     local tmp=$(echo "${x}" | sed -e "s|${S}||")
192 azarah 1.24 export ELT_APPLIED_PATCHES=
193 mr_bones_ 1.27
194 azarah 1.1 cd ${x}
195 vapier 1.37 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
196 azarah 1.2
197 vapier 1.42 for y in ${elt_patches} ; do
198 azarah 1.24 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 vapier 1.42 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
208 azarah 1.24 ELT_walk_patches "${x}/ltmain.sh" "${y}"
209     ret=$?
210     fi
211     ;;
212 azarah 1.25 "max_cmd_len")
213     # Do not apply if $max_cmd_len is not used ...
214 vapier 1.42 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
215 azarah 1.25 ELT_walk_patches "${x}/ltmain.sh" "${y}"
216     ret=$?
217     fi
218     ;;
219 azarah 1.24 *)
220     ELT_walk_patches "${x}/ltmain.sh" "${y}"
221     ret=$?
222     ;;
223     esac
224 mr_bones_ 1.27
225 vapier 1.42 if [[ ${ret} -ne 0 ]] ; then
226 azarah 1.3 case ${y} in
227 azarah 1.24 "relink")
228     # Critical patch, but could be applied ...
229 vapier 1.42 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
230 azarah 1.24 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 vapier 1.42 if [[ ${do_portage} == "yes" ]] ; then
237 azarah 1.24 # Stupid test to see if its already applied ...
238 vapier 1.42 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
239 azarah 1.24 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 azarah 1.3 fi
247     ;;
248     esac
249 azarah 1.1 fi
250 azarah 1.11
251 vapier 1.42 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
252     if [[ ${do_portage} == "no" && \
253     ${do_reversedeps} == "no" && \
254     ${do_only_patches} == "no" && \
255     ${deptoremove} == "" ]]
256 azarah 1.24 then
257     # 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 azarah 1.24 ewarn "Cannot apply any patch, running libtoolize..."
266     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     }

  ViewVC Help
Powered by ViewVC 1.1.20