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

Diff of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.25 Revision 1.43
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.25 2004/02/11 19:33:14 azarah Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.43 2005/02/27 20:29:04 azarah Exp $
4# 4#
5# Author: Martin Schlemmer <azarah@gentoo.org> 5# Author: Martin Schlemmer <azarah@gentoo.org>
6# 6#
7# This eclass patches ltmain.sh distributed with libtoolized packages with the 7# This eclass patches ltmain.sh distributed with libtoolized packages with the
8# relink and portage patch among others 8# relink and portage patch among others
9 9
10ECLASS="libtool" 10ECLASS="libtool"
11INHERITED="${INHERITED} ${ECLASS}" 11INHERITED="${INHERITED} ${ECLASS}"
12 12
13newdepend "!bootstrap? ( sys-devel/libtool )" 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.
14 20
15DESCRIPTION="Based on the ${ECLASS} eclass" 21DESCRIPTION="Based on the ${ECLASS} eclass"
16 22
17ELIBTOOL_VERSION="2.0.1" 23ELIBTOOL_VERSION="2.0.1"
18
19 24
20ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches" 25ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches"
21ELT_APPLIED_PATCHES= 26ELT_APPLIED_PATCHES=
22 27
23# 28#
25# 30#
26ELT_find_ltmain_sh() { 31ELT_find_ltmain_sh() {
27 local x= 32 local x=
28 local dirlist= 33 local dirlist=
29 34
30 for x in $(find "${S}" -name 'ltmain.sh') 35 for x in $(find "${S}" -name 'ltmain.sh') ; do
31 do
32 dirlist="${dirlist} ${x%/*}" 36 dirlist="${dirlist} ${x%/*}"
33 done 37 done
34 38
35 echo "${dirlist}" 39 echo "${dirlist}"
36} 40}
37 41
38# 42#
39# See if we can apply $2 on $1, and if so, do it 43# See if we can apply $2 on $1, and if so, do it
40# 44#
41ELT_try_and_apply_patch() { 45ELT_try_and_apply_patch() {
42 local ret=0 46 local ret=0
43 local patch="$2" 47 local patch="$2"
44 48
45 # We only support patchlevel of 0 - why worry if its static patches? 49 # We only support patchlevel of 0 - why worry if its static patches?
46 if patch -p0 --dry-run $1 < ${patch} &>${T}/elibtool.log 50 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then
47 then
48 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch..." 51 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
49 patch -p0 $1 < ${patch} &>${T}/elibtool.log 52 patch -p0 $1 < ${patch} &>${T}/elibtool.log
50 ret=$? 53 ret=$?
51 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 54 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
52 else 55 else
53 ret=1 56 ret=1
63ELT_walk_patches() { 66ELT_walk_patches() {
64 local x= 67 local x=
65 local y= 68 local y=
66 local ret=1 69 local ret=1
67 local patch_dir= 70 local patch_dir=
71 local version=$(eval $(grep -e '^[[:space:]]*VERSION=' $1); echo "${VERSION}")
68 72
69 if [ -n "$2" ] 73 if [[ -n $2 ]] ; then
70 then
71 if [ -d "${ELT_PATCH_DIR}/$2" ] 74 if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then
72 then
73 patch_dir="${ELT_PATCH_DIR}/$2" 75 patch_dir="${ELT_PATCH_DIR}/$2"
74 else 76 else
75 return ${ret} 77 return ${ret}
76 fi 78 fi
77 79
80 # First check a version specific patch, if not check major.minor*
81 for y in ${version} $(echo "${version}" | cut -d. -f1,2) ; do
82 [[ -z ${y} ]] && continue
78 for x in $(ls -d "${patch_dir}"/* 2>/dev/null) 83 for x in $(ls -d "${patch_dir}/${y}"* 2> /dev/null) ; do
79 do 84 if [[ -n ${x} && -f ${x} ]] ; then
80 if [ -n "${x}" -a -f "${x}" ]
81 then
82 # For --remove-internal-dep ... 85 # For --remove-internal-dep ...
83 if [ -n "$3" ] 86 if [[ -n $3 ]] ; then
84 then
85 # For replace @REM_INT_DEP@ with what was passed 87 # For replace @REM_INT_DEP@ with what was passed
86 # to --remove-internal-dep 88 # to --remove-internal-dep
87 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \ 89 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
88 ${T}/$$.rem_int_deps.patch 90 ${T}/$$.rem_int_deps.patch
89 91
90 x="${T}/$$.rem_int_deps.patch" 92 x="${T}/$$.rem_int_deps.patch"
93 fi
94
95 if ELT_try_and_apply_patch "$1" "${x}" ; then
96 ret=0
97 break
98 fi
91 fi 99 fi
92 100 done
101 done
102
103 # If still nothing, try the rest.
104 if [[ ${ret} -eq 1 ]]; then
105 for x in $(ls -d "${patch_dir}"/* 2> /dev/null) ; do
106 if [[ -n ${x} && -f ${x} ]] ; then
107 # For --remove-internal-dep ...
108 if [[ -n $3 ]] ; then
109 # For replace @REM_INT_DEP@ with what was passed
110 # to --remove-internal-dep
111 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \
112 ${T}/$$.rem_int_deps.patch
113
114 x="${T}/$$.rem_int_deps.patch"
115 fi
116
93 if ELT_try_and_apply_patch "$1" "${x}" 117 if ELT_try_and_apply_patch "$1" "${x}" ; then
94 then
95 ret=0 118 ret=0
96 break 119 break
120 fi
97 fi 121 fi
98 fi
99 done 122 done
123 fi
100 fi 124 fi
101 125
102 return ${ret} 126 return ${ret}
103} 127}
104 128
109 local do_reversedeps="no" 133 local do_reversedeps="no"
110 local do_only_patches="no" 134 local do_only_patches="no"
111 local deptoremove= 135 local deptoremove=
112 local my_dirlist= 136 local my_dirlist=
113 local elt_patches="portage relink max_cmd_len sed test tmp" 137 local elt_patches="portage relink max_cmd_len sed test tmp"
138 local start_dir="${PWD}"
114 139
115 my_dirlist="$(ELT_find_ltmain_sh)" 140 my_dirlist="$(ELT_find_ltmain_sh)"
116 141
117 for x in $* 142 for x in "$@" ; do
118 do
119 case "${x}" in 143 case "${x}" in
120 "--portage") 144 "--portage")
121 # Only apply portage patch, and don't 145 # Only apply portage patch, and don't
122 # 'libtoolize --copy --force' if all patches fail. 146 # 'libtoolize --copy --force' if all patches fail.
123 do_portage="yes" 147 do_portage="yes"
147 my_dirlist="${S}" 171 my_dirlist="${S}"
148 else 172 else
149 my_dirlist= 173 my_dirlist=
150 fi 174 fi
151 ;; 175 ;;
176 "--no-uclibc")
177 NO_UCLIBCTOOLIZE=1
178 ;;
179 *)
180 eerror "Invalid elibtoolize option: $x"
181 die "elibtoolize called with $x ??"
152 esac 182 esac
153 done 183 done
154 184
185 if use ppc-macos ; then
186 glibtoolize --copy --force
187 darwintoolize
188 fi
189
155 for x in ${my_dirlist} 190 for x in ${my_dirlist} ; do
156 do
157 local tmp="$(echo "${x}" | sed -e "s|${S}||")" 191 local tmp=$(echo "${x}" | sed -e "s|${S}||")
158 export ELT_APPLIED_PATCHES= 192 export ELT_APPLIED_PATCHES=
159 193
160 cd ${x} 194 cd ${x}
161 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g')..." 195 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g') ..."
162 196
163 for y in ${elt_patches} 197 for y in ${elt_patches} ; do
164 do
165 local ret=0 198 local ret=0
166 199
167 case "${y}" in 200 case "${y}" in
168 "rem-int-dep") 201 "rem-int-dep")
169 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}" 202 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
170 ret=$? 203 ret=$?
171 ;; 204 ;;
172 "fix-relink") 205 "fix-relink")
173 # Do not apply if we do not have the relink patch applied ... 206 # Do not apply if we do not have the relink patch applied ...
174 if [ -n "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ] 207 if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
175 then
176 ELT_walk_patches "${x}/ltmain.sh" "${y}" 208 ELT_walk_patches "${x}/ltmain.sh" "${y}"
177 ret=$? 209 ret=$?
178 fi 210 fi
179 ;; 211 ;;
180 "max_cmd_len") 212 "max_cmd_len")
181 # Do not apply if $max_cmd_len is not used ... 213 # Do not apply if $max_cmd_len is not used ...
182 if [ -n "$(grep 'max_cmd_len' "${x}/ltmain.sh")" ] 214 if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]] ; then
183 then
184 ELT_walk_patches "${x}/ltmain.sh" "${y}" 215 ELT_walk_patches "${x}/ltmain.sh" "${y}"
185 ret=$? 216 ret=$?
186 fi 217 fi
187 ;; 218 ;;
188 *) 219 *)
189 ELT_walk_patches "${x}/ltmain.sh" "${y}" 220 ELT_walk_patches "${x}/ltmain.sh" "${y}"
190 ret=$? 221 ret=$?
191 ;; 222 ;;
192 esac 223 esac
193 224
194 if [ "${ret}" -ne 0 ] 225 if [[ ${ret} -ne 0 ]] ; then
195 then
196 case ${y} in 226 case ${y} in
197 "relink") 227 "relink")
198 # Critical patch, but could be applied ... 228 # Critical patch, but could be applied ...
199 if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ] 229 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then
200 then
201 ewarn " Could not apply relink.patch!" 230 ewarn " Could not apply relink.patch!"
202 fi 231 fi
203 ;; 232 ;;
204 "portage") 233 "portage")
205 # Critical patch - for this one we abort, as it can really 234 # Critical patch - for this one we abort, as it can really
206 # cause breakage without it applied! 235 # cause breakage without it applied!
207 if [ "${do_portage}" = "yes" ] 236 if [[ ${do_portage} == "yes" ]] ; then
208 then
209 # Stupid test to see if its already applied ... 237 # Stupid test to see if its already applied ...
210 if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ] 238 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
211 then
212 echo 239 echo
213 eerror "Portage patch requested, but failed to apply!" 240 eerror "Portage patch requested, but failed to apply!"
214 die "Portage patch requested, but failed to apply!" 241 die "Portage patch requested, but failed to apply!"
215 fi 242 fi
216 else 243 else
219 fi 246 fi
220 ;; 247 ;;
221 esac 248 esac
222 fi 249 fi
223 250
224 if [ -z "${ELT_APPLIED_PATCHES}" ] 251 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
225 then
226 if [ "${do_portage}" = "no" -a \ 252 if [[ ${do_portage} == "no" && \
227 "${do_reversedeps}" = "no" -a \ 253 ${do_reversedeps} == "no" && \
228 "${do_only_patches}" = "no" -a \ 254 ${do_only_patches} == "no" && \
229 "${deptoremove}" = "" ] 255 ${deptoremove} == "" ]]
230 then 256 then
231 # Sometimes ltmain.sh is in a subdirectory ... 257 # Sometimes ltmain.sh is in a subdirectory ...
232 if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ] 258 if [[ ! -f ${x}/configure.in && ! -f ${x}/configure.ac ]] ; then
233 then
234 if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ] 259 if [[ -f ${x}/../configure.in || -f ${x}/../configure.ac ]] ; then
235 then
236 cd ${x}/../ 260 cd "${x}"/../
237 fi 261 fi
238 fi 262 fi
239 263
240 if which libtoolize &>/dev/null 264 if type -p libtoolize &> /dev/null ; then
241 then
242 ewarn "Cannot apply any patch, running libtoolize..." 265 ewarn "Cannot apply any patch, running libtoolize..."
243 libtoolize --copy --force 266 libtoolize --copy --force
244 fi 267 fi
245 cd ${x} 268 cd "${x}"
246 break 269 break
247 fi 270 fi
248 fi 271 fi
249 done 272 done
250 done 273 done
251 274
252 if [ -f libtool ] 275 if [[ -f libtool ]] ; then
253 then
254 rm -f libtool 276 rm -f libtool
255 fi 277 fi
256 278
257 # We need to change the pwd back to $S, as we may be called in 279 cd "${start_dir}"
258 # src_compile()
259 cd ${S}
260}
261 280
281 uclibctoolize
282}
283
284uclibctoolize() {
285 [[ -n ${NO_UCLIBCTOOLIZE} ]] && return 0
286
287 local errmsg=""
288 [[ ${CTARGET:-${CHOST}} == *-uclibc ]] \
289 && errmsg="PLEASE CHECK" \
290 || errmsg="Already patched"
291 local targets=""
292 local x
293
294 if [[ -z $* ]] ; then
295 targets=$(find ${S} -name configure -o -name ltconfig)
296 fi
297
298 einfo "Applying uClibc/libtool patches ..."
299 for x in ${targets} ; do
300 [[ ! -s ${x} ]] && continue
301 case ${x##*/} in
302 configure)
303 if grep 'Transform linux' "${x}" > /dev/null ; then
304 ebegin " Fixing \${S}${x/${S}}"
305 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
306 eend $? "${errmsg} ${x}"
307 fi
308 ;;
309
310 ltconfig)
311 local ver=$(grep '^VERSION=' ${x})
312 ver=${ver/VERSION=}
313 [[ ${ver:0:3} == "1.4" ]] && ver="1.3" # 1.4 and 1.3 are compat
314 ebegin " Fixing \${S}${x/${S}}"
315 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
316 eend $? "${errmsg} ${x}"
317 ;;
318 esac
319 done
320}
321
322darwintoolize() {
323 local targets=""
324 local x
325
326 if [[ -z $* ]] ; then
327 targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
328 fi
329
330 einfo "Applying Darwin/libtool patches ..."
331 for x in ${targets} ; do
332 [[ ! -s ${x} ]] && continue
333 case ${x##*/} in
334 ltmain.sh|ltconfig)
335 local ver=$(grep '^VERSION=' ${x})
336 ver=${ver/VERSION=}
337 if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
338 ver="1.3" # 1.4, 1.5 and 1.3 are compat
339 fi
340
341 ebegin " Fixing \${S}${x/${S}}"
342 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
343 eend $? "PLEASE CHECK ${x}"
344 ;;
345 esac
346 done
347}

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20