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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (show annotations) (download)
Fri Jun 25 00:39:48 2004 UTC (9 years, 9 months ago) by vapier
Branch: MAIN
Changes since 1.27: +2 -2 lines
update the copyright info

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.27 2004/06/08 21:11:50 mr_bones_ 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
115 my_dirlist="$(ELT_find_ltmain_sh)"
116
117 for x in $*
118 do
119 case "${x}" in
120 "--portage")
121 # Only apply portage patch, and don't
122 # 'libtoolize --copy --force' if all patches fail.
123 do_portage="yes"
124 ;;
125 "--reverse-deps")
126 # Apply the reverse-deps patch
127 # http://bugzilla.gnome.org/show_bug.cgi?id=75635
128 do_reversedeps="yes"
129 elt_patches="${elt_patches} fix-relink"
130 ;;
131 "--patch-only")
132 # Do not run libtoolize if none of the patches apply ..
133 do_only_patches="yes"
134 ;;
135 "^--remove-internal-dep="*)
136 # We will replace @REM_INT_DEP@ with what is needed
137 # in ELT_walk_patches() ...
138 deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
139
140 # Add the patch for this ...
141 [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
142 ;;
143 "--shallow")
144 # Only patch the ltmain.sh in ${S}
145 if [ -f "${S}/ltmain.sh" ]
146 then
147 my_dirlist="${S}"
148 else
149 my_dirlist=
150 fi
151 ;;
152 esac
153 done
154
155 for x in ${my_dirlist}
156 do
157 local tmp="$(echo "${x}" | sed -e "s|${S}||")"
158 export ELT_APPLIED_PATCHES=
159
160 cd ${x}
161 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g')..."
162
163 for y in ${elt_patches}
164 do
165 local ret=0
166
167 case "${y}" in
168 "rem-int-dep")
169 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
170 ret=$?
171 ;;
172 "fix-relink")
173 # Do not apply if we do not have the relink patch applied ...
174 if [ -n "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
175 then
176 ELT_walk_patches "${x}/ltmain.sh" "${y}"
177 ret=$?
178 fi
179 ;;
180 "max_cmd_len")
181 # Do not apply if $max_cmd_len is not used ...
182 if [ -n "$(grep 'max_cmd_len' "${x}/ltmain.sh")" ]
183 then
184 ELT_walk_patches "${x}/ltmain.sh" "${y}"
185 ret=$?
186 fi
187 ;;
188 *)
189 ELT_walk_patches "${x}/ltmain.sh" "${y}"
190 ret=$?
191 ;;
192 esac
193
194 if [ "${ret}" -ne 0 ]
195 then
196 case ${y} in
197 "relink")
198 # Critical patch, but could be applied ...
199 if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
200 then
201 ewarn " Could not apply relink.patch!"
202 fi
203 ;;
204 "portage")
205 # Critical patch - for this one we abort, as it can really
206 # cause breakage without it applied!
207 if [ "${do_portage}" = "yes" ]
208 then
209 # Stupid test to see if its already applied ...
210 if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
211 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}" ]
225 then
226 if [ "${do_portage}" = "no" -a \
227 "${do_reversedeps}" = "no" -a \
228 "${do_only_patches}" = "no" -a \
229 "${deptoremove}" = "" ]
230 then
231 # Sometimes ltmain.sh is in a subdirectory ...
232 if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
233 then
234 if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
235 then
236 cd ${x}/../
237 fi
238 fi
239
240 if which libtoolize &>/dev/null
241 then
242 ewarn "Cannot apply any patch, running libtoolize..."
243 libtoolize --copy --force
244 fi
245 cd ${x}
246 break
247 fi
248 fi
249 done
250 done
251
252 if [ -f libtool ]
253 then
254 rm -f libtool
255 fi
256
257 # We need to change the pwd back to $S, as we may be called in
258 # src_compile()
259 cd ${S}
260 }

  ViewVC Help
Powered by ViewVC 1.1.20