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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.32 - (show annotations) (download)
Sat Sep 25 06:35:09 2004 UTC (10 years, 2 months ago) by vapier
Branch: MAIN
Changes since 1.31: +2 -2 lines
forgot to add the extra search param in uclibctoolize

1 # Copyright 1999-2004 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.31 2004/09/22 20:04:27 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 DEPEND="!bootstrap? ( sys-devel/libtool )"
14
15 DESCRIPTION="Based on the ${ECLASS} eclass"
16
17 ELIBTOOL_VERSION="2.0.1"
18
19
20 ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches"
21 ELT_APPLIED_PATCHES=
22
23 #
24 # Returns all the directories containing ltmain.sh
25 #
26 ELT_find_ltmain_sh() {
27 local x=
28 local dirlist=
29
30 for x in $(find "${S}" -name 'ltmain.sh')
31 do
32 dirlist="${dirlist} ${x%/*}"
33 done
34
35 echo "${dirlist}"
36 }
37
38 #
39 # See if we can apply $2 on $1, and if so, do it
40 #
41 ELT_try_and_apply_patch() {
42 local ret=0
43 local patch="$2"
44
45 # We only support patchlevel of 0 - why worry if its static patches?
46 if patch -p0 --dry-run $1 < ${patch} &>${T}/elibtool.log
47 then
48 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch..."
49 patch -p0 $1 < ${patch} &>${T}/elibtool.log
50 ret=$?
51 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
52 else
53 ret=1
54 fi
55
56 return ${ret}
57 }
58
59 #
60 # Run through the patches in $2 and see if any
61 # apply to $1 ...
62 #
63 ELT_walk_patches() {
64 local x=
65 local y=
66 local ret=1
67 local patch_dir=
68
69 if [ -n "$2" ]
70 then
71 if [ -d "${ELT_PATCH_DIR}/$2" ]
72 then
73 patch_dir="${ELT_PATCH_DIR}/$2"
74 else
75 return ${ret}
76 fi
77
78 for x in $(ls -d "${patch_dir}"/* 2>/dev/null)
79 do
80 if [ -n "${x}" -a -f "${x}" ]
81 then
82 # For --remove-internal-dep ...
83 if [ -n "$3" ]
84 then
85 # For replace @REM_INT_DEP@ with what was passed
86 # to --remove-internal-dep
87 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
88 ${T}/$$.rem_int_deps.patch
89
90 x="${T}/$$.rem_int_deps.patch"
91 fi
92
93 if ELT_try_and_apply_patch "$1" "${x}"
94 then
95 ret=0
96 break
97 fi
98 fi
99 done
100 fi
101
102 return ${ret}
103 }
104
105 elibtoolize() {
106 local x=
107 local y=
108 local do_portage="no"
109 local do_reversedeps="no"
110 local do_only_patches="no"
111 local deptoremove=
112 local my_dirlist=
113 local elt_patches="portage relink max_cmd_len sed test tmp"
114 local start_dir="${PWD}"
115
116 my_dirlist="$(ELT_find_ltmain_sh)"
117
118 for x in "$@"
119 do
120 case "${x}" in
121 "--portage")
122 # Only apply portage patch, and don't
123 # 'libtoolize --copy --force' if all patches fail.
124 do_portage="yes"
125 ;;
126 "--reverse-deps")
127 # Apply the reverse-deps patch
128 # http://bugzilla.gnome.org/show_bug.cgi?id=75635
129 do_reversedeps="yes"
130 elt_patches="${elt_patches} fix-relink"
131 ;;
132 "--patch-only")
133 # Do not run libtoolize if none of the patches apply ..
134 do_only_patches="yes"
135 ;;
136 "^--remove-internal-dep="*)
137 # We will replace @REM_INT_DEP@ with what is needed
138 # in ELT_walk_patches() ...
139 deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
140
141 # Add the patch for this ...
142 [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
143 ;;
144 "--shallow")
145 # Only patch the ltmain.sh in ${S}
146 if [ -f "${S}/ltmain.sh" ]
147 then
148 my_dirlist="${S}"
149 else
150 my_dirlist=
151 fi
152 ;;
153 esac
154 done
155
156 for x in ${my_dirlist}
157 do
158 local tmp="$(echo "${x}" | sed -e "s|${S}||")"
159 export ELT_APPLIED_PATCHES=
160
161 cd ${x}
162 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g')..."
163
164 for y in ${elt_patches}
165 do
166 local ret=0
167
168 case "${y}" in
169 "rem-int-dep")
170 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
171 ret=$?
172 ;;
173 "fix-relink")
174 # Do not apply if we do not have the relink patch applied ...
175 if [ -n "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
176 then
177 ELT_walk_patches "${x}/ltmain.sh" "${y}"
178 ret=$?
179 fi
180 ;;
181 "max_cmd_len")
182 # Do not apply if $max_cmd_len is not used ...
183 if [ -n "$(grep 'max_cmd_len' "${x}/ltmain.sh")" ]
184 then
185 ELT_walk_patches "${x}/ltmain.sh" "${y}"
186 ret=$?
187 fi
188 ;;
189 *)
190 ELT_walk_patches "${x}/ltmain.sh" "${y}"
191 ret=$?
192 ;;
193 esac
194
195 if [ "${ret}" -ne 0 ]
196 then
197 case ${y} in
198 "relink")
199 # Critical patch, but could be applied ...
200 if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
201 then
202 ewarn " Could not apply relink.patch!"
203 fi
204 ;;
205 "portage")
206 # Critical patch - for this one we abort, as it can really
207 # cause breakage without it applied!
208 if [ "${do_portage}" = "yes" ]
209 then
210 # Stupid test to see if its already applied ...
211 if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
212 then
213 echo
214 eerror "Portage patch requested, but failed to apply!"
215 die "Portage patch requested, but failed to apply!"
216 fi
217 else
218 ewarn " Could not apply portage.patch!"
219 ewarn " Please verify that it is not needed."
220 fi
221 ;;
222 esac
223 fi
224
225 if [ -z "${ELT_APPLIED_PATCHES}" ]
226 then
227 if [ "${do_portage}" = "no" -a \
228 "${do_reversedeps}" = "no" -a \
229 "${do_only_patches}" = "no" -a \
230 "${deptoremove}" = "" ]
231 then
232 # Sometimes ltmain.sh is in a subdirectory ...
233 if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
234 then
235 if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
236 then
237 cd ${x}/../
238 fi
239 fi
240
241 if which libtoolize &>/dev/null
242 then
243 ewarn "Cannot apply any patch, running libtoolize..."
244 libtoolize --copy --force
245 fi
246 cd ${x}
247 break
248 fi
249 fi
250 done
251 done
252
253 if [ -f libtool ]
254 then
255 rm -f libtool
256 fi
257
258 cd "${start_dir}"
259
260 uclibctoolize
261 }
262
263 uclibctoolize() {
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 case $(basename "${x}") in
274 configure)
275 if grep 'Transform linux' "${x}" >/dev/null ; then
276 ebegin " Fixing \${S}${x/${S}}"
277 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
278 eend $? "PLEASE CHECK ${x}"
279 fi
280 ;;
281
282 ltconfig)
283 local ver="$(grep '^VERSION=' ${x})"
284 ver="${ver/VERSION=}"
285 ebegin " Fixing \${S}${x/${S}}"
286 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
287 eend $? "PLEASE CHECK ${x}"
288 ;;
289 esac
290 done
291 }

  ViewVC Help
Powered by ViewVC 1.1.20