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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations) (download)
Fri Jan 2 21:54:28 2004 UTC (10 years, 3 months ago) by azarah
Branch: MAIN
Changes since 1.23: +202 -817 lines
Mostly complete rewrite in effort to make it easier to maintain.
Add all the patches temporary in ELT-patches, until I can get a
better place that do not need a tarball or such to download.

1 # Copyright 1999-2004 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.23 2003/04/08 11:34:57 azarah 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 newdepend "!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 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 *)
181 ELT_walk_patches "${x}/ltmain.sh" "${y}"
182 ret=$?
183 ;;
184 esac
185
186 if [ "${ret}" -ne 0 ]
187 then
188 case ${y} in
189 "relink")
190 # Critical patch, but could be applied ...
191 if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
192 then
193 ewarn " Could not apply relink.patch!"
194 fi
195 ;;
196 "portage")
197 # Critical patch - for this one we abort, as it can really
198 # cause breakage without it applied!
199 if [ "${do_portage}" = "yes" ]
200 then
201 # Stupid test to see if its already applied ...
202 if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
203 then
204 echo
205 eerror "Portage patch requested, but failed to apply!"
206 die "Portage patch requested, but failed to apply!"
207 fi
208 else
209 ewarn " Could not apply portage.patch!"
210 ewarn " Please verify that it is not needed."
211 fi
212 ;;
213 esac
214 fi
215
216 if [ -z "${ELT_APPLIED_PATCHES}" ]
217 then
218 if [ "${do_portage}" = "no" -a \
219 "${do_reversedeps}" = "no" -a \
220 "${do_only_patches}" = "no" -a \
221 "${deptoremove}" = "" ]
222 then
223 # Sometimes ltmain.sh is in a subdirectory ...
224 if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
225 then
226 if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
227 then
228 cd ${x}/../
229 fi
230 fi
231
232 if which libtoolize &>/dev/null
233 then
234 ewarn "Cannot apply any patch, running libtoolize..."
235 libtoolize --copy --force
236 fi
237 cd ${x}
238 break
239 fi
240 fi
241 done
242 done
243
244 if [ -f libtool ]
245 then
246 rm -f libtool
247 fi
248
249 # We need to change the pwd back to $S, as we may be called in
250 # src_compile()
251 cd ${S}
252 }

  ViewVC Help
Powered by ViewVC 1.1.20