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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (show 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 # 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.41 2004/11/22 14:55:57 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
72 if [[ -n $2 ]] ; then
73 if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then
74 patch_dir="${ELT_PATCH_DIR}/$2"
75 else
76 return ${ret}
77 fi
78
79 for x in $(ls -d "${patch_dir}"/* 2> /dev/null) ; do
80 if [[ -n ${x} && -f ${x} ]] ; then
81 # For --remove-internal-dep ...
82 if [[ -n $3 ]] ; then
83 # 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
88 x="${T}/$$.rem_int_deps.patch"
89 fi
90
91 if ELT_try_and_apply_patch "$1" "${x}" ; then
92 ret=0
93 break
94 fi
95 fi
96 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 local elt_patches="portage relink max_cmd_len sed test tmp"
111 local start_dir="${PWD}"
112
113 my_dirlist="$(ELT_find_ltmain_sh)"
114
115 for x in "$@" ; do
116 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 "--no-uclibc")
150 NO_UCLIBCTOOLIZE=1
151 ;;
152 *)
153 eerror "Invalid elibtoolize option: $x"
154 die "elibtoolize called with $x ??"
155 esac
156 done
157
158 if use ppc-macos ; then
159 glibtoolize --copy --force
160 darwintoolize
161 fi
162
163 for x in ${my_dirlist} ; do
164 local tmp=$(echo "${x}" | sed -e "s|${S}||")
165 export ELT_APPLIED_PATCHES=
166
167 cd ${x}
168 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
169
170 for y in ${elt_patches} ; do
171 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 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
181 ELT_walk_patches "${x}/ltmain.sh" "${y}"
182 ret=$?
183 fi
184 ;;
185 "max_cmd_len")
186 # Do not apply if $max_cmd_len is not used ...
187 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
188 ELT_walk_patches "${x}/ltmain.sh" "${y}"
189 ret=$?
190 fi
191 ;;
192 *)
193 ELT_walk_patches "${x}/ltmain.sh" "${y}"
194 ret=$?
195 ;;
196 esac
197
198 if [[ ${ret} -ne 0 ]] ; then
199 case ${y} in
200 "relink")
201 # Critical patch, but could be applied ...
202 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
203 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 if [[ ${do_portage} == "yes" ]] ; then
210 # Stupid test to see if its already applied ...
211 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
212 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 fi
220 ;;
221 esac
222 fi
223
224 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
225 if [[ ${do_portage} == "no" && \
226 ${do_reversedeps} == "no" && \
227 ${do_only_patches} == "no" && \
228 ${deptoremove} == "" ]]
229 then
230 # Sometimes ltmain.sh is in a subdirectory ...
231 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 fi
235 fi
236
237 if type -p libtoolize &> /dev/null ; then
238 ewarn "Cannot apply any patch, running libtoolize..."
239 libtoolize --copy --force
240 fi
241 cd "${x}"
242 break
243 fi
244 fi
245 done
246 done
247
248 if [[ -f libtool ]] ; then
249 rm -f libtool
250 fi
251
252 cd "${start_dir}"
253
254 uclibctoolize
255 }
256
257 uclibctoolize() {
258 [[ -n ${NO_UCLIBCTOOLIZE} ]] && return 0
259
260 local errmsg=""
261 [[ ${CTARGET:-${CHOST}} == *-uclibc ]] \
262 && errmsg="PLEASE CHECK" \
263 || errmsg="Already patched"
264 local targets=""
265 local x
266
267 if [[ -z $* ]] ; then
268 targets=$(find ${S} -name configure -o -name ltconfig)
269 fi
270
271 einfo "Applying uClibc/libtool patches ..."
272 for x in ${targets} ; do
273 [[ ! -s ${x} ]] && continue
274 case ${x##*/} in
275 configure)
276 if grep 'Transform linux' "${x}" > /dev/null ; then
277 ebegin " Fixing \${S}${x/${S}}"
278 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
279 eend $? "${errmsg} ${x}"
280 fi
281 ;;
282
283 ltconfig)
284 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 ebegin " Fixing \${S}${x/${S}}"
288 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
289 eend $? "${errmsg} ${x}"
290 ;;
291 esac
292 done
293 }
294
295 darwintoolize() {
296 local targets=""
297 local x
298
299 if [[ -z $* ]] ; then
300 targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
301 fi
302
303 einfo "Applying Darwin/libtool patches ..."
304 for x in ${targets} ; do
305 [[ ! -s ${x} ]] && continue
306 case ${x##*/} in
307 ltmain.sh|ltconfig)
308 local ver=$(grep '^VERSION=' ${x})
309 ver=${ver/VERSION=}
310 if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
311 ver="1.3" # 1.4, 1.5 and 1.3 are compat
312 fi
313
314 ebegin " Fixing \${S}${x/${S}}"
315 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
316 eend $? "PLEASE CHECK ${x}"
317 ;;
318 esac
319 done
320 }

  ViewVC Help
Powered by ViewVC 1.1.20