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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (hide annotations) (download)
Mon Jan 31 03:02:13 2005 UTC (9 years, 9 months ago) by vapier
Branch: MAIN
Changes since 1.41: +52 -75 lines
style updates

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 vapier 1.42 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.41 2004/11/22 14:55:57 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.2
72 vapier 1.42 if [[ -n $2 ]] ; then
73     if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then
74 azarah 1.24 patch_dir="${ELT_PATCH_DIR}/$2"
75     else
76     return ${ret}
77 azarah 1.4 fi
78 mr_bones_ 1.27
79 vapier 1.42 for x in $(ls -d "${patch_dir}"/* 2> /dev/null) ; do
80     if [[ -n ${x} && -f ${x} ]] ; then
81 azarah 1.24 # For --remove-internal-dep ...
82 vapier 1.42 if [[ -n $3 ]] ; then
83 azarah 1.24 # For replace @REM_INT_DEP@ with what was passed
84     # to --remove-internal-dep
85     sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
86     ${T}/$$.rem_int_deps.patch
87 mr_bones_ 1.27
88 azarah 1.24 x="${T}/$$.rem_int_deps.patch"
89     fi
90 mr_bones_ 1.27
91 vapier 1.42 if ELT_try_and_apply_patch "$1" "${x}" ; then
92 azarah 1.24 ret=0
93     break
94     fi
95 azarah 1.4 fi
96 azarah 1.24 done
97     fi
98    
99     return ${ret}
100     }
101    
102     elibtoolize() {
103     local x=
104     local y=
105     local do_portage="no"
106     local do_reversedeps="no"
107     local do_only_patches="no"
108     local deptoremove=
109     local my_dirlist=
110 azarah 1.25 local elt_patches="portage relink max_cmd_len sed test tmp"
111 vapier 1.29 local start_dir="${PWD}"
112 azarah 1.24
113     my_dirlist="$(ELT_find_ltmain_sh)"
114 mr_bones_ 1.27
115 vapier 1.42 for x in "$@" ; do
116 azarah 1.24 case "${x}" in
117     "--portage")
118     # Only apply portage patch, and don't
119     # 'libtoolize --copy --force' if all patches fail.
120     do_portage="yes"
121     ;;
122     "--reverse-deps")
123     # Apply the reverse-deps patch
124     # http://bugzilla.gnome.org/show_bug.cgi?id=75635
125     do_reversedeps="yes"
126     elt_patches="${elt_patches} fix-relink"
127     ;;
128     "--patch-only")
129     # Do not run libtoolize if none of the patches apply ..
130     do_only_patches="yes"
131     ;;
132     "^--remove-internal-dep="*)
133     # We will replace @REM_INT_DEP@ with what is needed
134     # in ELT_walk_patches() ...
135     deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
136    
137     # Add the patch for this ...
138     [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
139     ;;
140     "--shallow")
141     # Only patch the ltmain.sh in ${S}
142     if [ -f "${S}/ltmain.sh" ]
143     then
144     my_dirlist="${S}"
145     else
146     my_dirlist=
147     fi
148     ;;
149 vapier 1.40 "--no-uclibc")
150     NO_UCLIBCTOOLIZE=1
151     ;;
152 vapier 1.42 *)
153     eerror "Invalid elibtoolize option: $x"
154     die "elibtoolize called with $x ??"
155 azarah 1.24 esac
156 azarah 1.4 done
157 azarah 1.1
158 usata 1.36 if use ppc-macos ; then
159     glibtoolize --copy --force
160     darwintoolize
161     fi
162    
163 vapier 1.42 for x in ${my_dirlist} ; do
164     local tmp=$(echo "${x}" | sed -e "s|${S}||")
165 azarah 1.24 export ELT_APPLIED_PATCHES=
166 mr_bones_ 1.27
167 azarah 1.1 cd ${x}
168 vapier 1.37 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
169 azarah 1.2
170 vapier 1.42 for y in ${elt_patches} ; do
171 azarah 1.24 local ret=0
172    
173     case "${y}" in
174     "rem-int-dep")
175     ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
176     ret=$?
177     ;;
178     "fix-relink")
179     # Do not apply if we do not have the relink patch applied ...
180 vapier 1.42 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
181 azarah 1.24 ELT_walk_patches "${x}/ltmain.sh" "${y}"
182     ret=$?
183     fi
184     ;;
185 azarah 1.25 "max_cmd_len")
186     # Do not apply if $max_cmd_len is not used ...
187 vapier 1.42 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
188 azarah 1.25 ELT_walk_patches "${x}/ltmain.sh" "${y}"
189     ret=$?
190     fi
191     ;;
192 azarah 1.24 *)
193     ELT_walk_patches "${x}/ltmain.sh" "${y}"
194     ret=$?
195     ;;
196     esac
197 mr_bones_ 1.27
198 vapier 1.42 if [[ ${ret} -ne 0 ]] ; then
199 azarah 1.3 case ${y} in
200 azarah 1.24 "relink")
201     # Critical patch, but could be applied ...
202 vapier 1.42 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
203 azarah 1.24 ewarn " Could not apply relink.patch!"
204     fi
205     ;;
206     "portage")
207     # Critical patch - for this one we abort, as it can really
208     # cause breakage without it applied!
209 vapier 1.42 if [[ ${do_portage} == "yes" ]] ; then
210 azarah 1.24 # Stupid test to see if its already applied ...
211 vapier 1.42 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
212 azarah 1.24 echo
213     eerror "Portage patch requested, but failed to apply!"
214     die "Portage patch requested, but failed to apply!"
215     fi
216     else
217     ewarn " Could not apply portage.patch!"
218     ewarn " Please verify that it is not needed."
219 azarah 1.3 fi
220     ;;
221     esac
222 azarah 1.1 fi
223 azarah 1.11
224 vapier 1.42 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
225     if [[ ${do_portage} == "no" && \
226     ${do_reversedeps} == "no" && \
227     ${do_only_patches} == "no" && \
228     ${deptoremove} == "" ]]
229 azarah 1.24 then
230     # Sometimes ltmain.sh is in a subdirectory ...
231 vapier 1.42 if [[ ! -f ${x}/configure.in && ! -f ${x}/configure.ac ]] ; then
232     if [[ -f ${x}/../configure.in || -f ${x}/../configure.ac ]] ; then
233     cd "${x}"/../
234 azarah 1.3 fi
235 azarah 1.24 fi
236    
237 vapier 1.42 if type -p libtoolize &> /dev/null ; then
238 azarah 1.24 ewarn "Cannot apply any patch, running libtoolize..."
239     libtoolize --copy --force
240 azarah 1.19 fi
241 vapier 1.42 cd "${x}"
242 azarah 1.24 break
243 azarah 1.19 fi
244 azarah 1.1 fi
245     done
246     done
247 azarah 1.6
248 vapier 1.42 if [[ -f libtool ]] ; then
249 azarah 1.7 rm -f libtool
250     fi
251    
252 vapier 1.29 cd "${start_dir}"
253 vapier 1.30
254     uclibctoolize
255     }
256    
257     uclibctoolize() {
258 vapier 1.42 [[ -n ${NO_UCLIBCTOOLIZE} ]] && return 0
259 vapier 1.38
260 vapier 1.41 local errmsg=""
261 vapier 1.42 [[ ${CTARGET:-${CHOST}} == *-uclibc ]] \
262 vapier 1.41 && errmsg="PLEASE CHECK" \
263     || errmsg="Already patched"
264 vapier 1.30 local targets=""
265     local x
266    
267 vapier 1.42 if [[ -z $* ]] ; then
268     targets=$(find ${S} -name configure -o -name ltconfig)
269 vapier 1.30 fi
270    
271     einfo "Applying uClibc/libtool patches ..."
272     for x in ${targets} ; do
273 vapier 1.42 [[ ! -s ${x} ]] && continue
274     case ${x##*/} in
275 vapier 1.31 configure)
276 vapier 1.42 if grep 'Transform linux' "${x}" > /dev/null ; then
277 vapier 1.31 ebegin " Fixing \${S}${x/${S}}"
278     patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
279 vapier 1.41 eend $? "${errmsg} ${x}"
280 vapier 1.31 fi
281     ;;
282    
283     ltconfig)
284 vapier 1.42 local ver=$(grep '^VERSION=' ${x})
285     ver=${ver/VERSION=}
286     [[ ${ver:0:3} == "1.4" ]] && ver="1.3" # 1.4 and 1.3 are compat
287 vapier 1.30 ebegin " Fixing \${S}${x/${S}}"
288 vapier 1.31 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
289 vapier 1.41 eend $? "${errmsg} ${x}"
290 vapier 1.31 ;;
291     esac
292 vapier 1.30 done
293 azarah 1.1 }
294 usata 1.36
295     darwintoolize() {
296     local targets=""
297     local x
298    
299 vapier 1.42 if [[ -z $* ]] ; then
300     targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
301 usata 1.36 fi
302    
303     einfo "Applying Darwin/libtool patches ..."
304     for x in ${targets} ; do
305 vapier 1.42 [[ ! -s ${x} ]] && continue
306     case ${x##*/} in
307 usata 1.36 ltmain.sh|ltconfig)
308 vapier 1.42 local ver=$(grep '^VERSION=' ${x})
309     ver=${ver/VERSION=}
310     if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
311 usata 1.36 ver="1.3" # 1.4, 1.5 and 1.3 are compat
312     fi
313    
314     ebegin " Fixing \${S}${x/${S}}"
315 vapier 1.42 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
316 usata 1.36 eend $? "PLEASE CHECK ${x}"
317     ;;
318     esac
319     done
320     }

  ViewVC Help
Powered by ViewVC 1.1.20