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

Diff of /eclass/libtool.eclass

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

Revision 1.54 Revision 1.74
1# Copyright 1999-2005 Gentoo Foundation 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.54 2005/09/04 15:15:37 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.74 2007/03/01 18:48:02 grobian 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
18 18
19DESCRIPTION="Based on the ${ECLASS} eclass" 19DESCRIPTION="Based on the ${ECLASS} eclass"
20 20
21ELIBTOOL_VERSION="2.0.2" 21ELIBTOOL_VERSION="2.0.2"
22 22
23ELT_PATCH_DIR="${PORTDIR}/eclass/ELT-patches" 23ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches"
24ELT_APPLIED_PATCHES= 24ELT_APPLIED_PATCHES=
25ELT_LTMAIN_SH= 25ELT_LTMAIN_SH=
26 26
27# 27#
28# Returns all the directories containing ltmain.sh 28# Returns all the directories containing ltmain.sh
41# 41#
42# See if we can apply $2 on $1, and if so, do it 42# See if we can apply $2 on $1, and if so, do it
43# 43#
44ELT_try_and_apply_patch() { 44ELT_try_and_apply_patch() {
45 local ret=0 45 local ret=0
46 local file=$1
46 local patch="$2" 47 local patch=$2
47 48
48 # 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?
49 if patch -p0 --dry-run $1 < ${patch} &> ${T}/elibtool.log ; then 50 if patch -p0 --dry-run "${file}" "${patch}" &> "${T}/elibtool.log" ; then
50 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." 51 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
51 patch -p0 $1 < ${patch} &>${T}/elibtool.log 52 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \
53 &> "${T}/elibtool.log"
52 ret=$? 54 ret=$?
53 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 55 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
54 else 56 else
55 ret=1 57 ret=1
56 fi 58 fi
57 59
58 return ${ret} 60 return "${ret}"
61}
62
63#
64# Get string version of ltmain.sh or ltconfig (passed as $1)
65#
66ELT_libtool_version() {
67 local ltmain_sh=$1
68 local version=
69
70 version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}"); \
71 echo "${VERSION}")
72 [[ -z ${version} ]] && version="0"
73
74 echo "${version}"
59} 75}
60 76
61# 77#
62# Run through the patches in $2 and see if any 78# Run through the patches in $2 and see if any
63# apply to $1 ... 79# apply to $1 ...
64# 80#
65ELT_walk_patches() { 81ELT_walk_patches() {
66 local x= 82 local x=
67 local y= 83 local y=
68 local ret=1 84 local ret=1
85 local file=$1
86 local patch_set=$2
69 local patch_dir= 87 local patch_dir=
70 local version= 88 local rem_int_dep=$3
71 local ltmain_sh=$1
72 89
73 [[ $1 == *"/configure" ]] && ltmain_sh=${ELT_LTMAIN_SH}
74 version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}"); \
75 echo "${VERSION}")
76
77 if [[ -n $2 ]] ; then 90 if [[ -n ${patch_set} ]] ; then
78 if [[ -d ${ELT_PATCH_DIR}/$2 ]] ; then 91 if [[ -d ${ELT_PATCH_DIR}/${patch_set} ]] ; then
79 patch_dir="${ELT_PATCH_DIR}/$2" 92 patch_dir="${ELT_PATCH_DIR}/${patch_set}"
80 else 93 else
81 return ${ret} 94 return "${ret}"
82 fi 95 fi
83 96
84 if [[ -z ${version} ]] ; then
85 eerror "Could not get VERSION for ${1##*/}!"
86 die "Could not get VERSION for ${1##*/}!"
87 fi
88
89 # Go through the patches in reverse order (large to small) 97 # Go through the patches in reverse order (large to small)
90 for x in $(ls -d "${patch_dir}"/* 2> /dev/null | sort -r) ; do 98 for x in $(ls -d "${patch_dir}"/* 2> /dev/null | grep -v 'CVS' | sort -r) ; do
91 if [[ -n ${x} && -f ${x} ]] ; then 99 if [[ -n ${x} && -f ${x} ]] ; then
92 local ltver=$(VER_to_int "${version}")
93 local ptver=$(VER_to_int "${x##*/}")
94
95 # If libtool version smaller than patch version, skip patch.
96 [[ ${ltver} -lt ${ptver} ]] && continue
97 # For --remove-internal-dep ... 100 # For --remove-internal-dep ...
98 if [[ -n $3 ]] ; then 101 if [[ -n ${rem_int_dep} ]] ; then
99 # For replace @REM_INT_DEP@ with what was passed 102 # For replace @REM_INT_DEP@ with what was passed
100 # to --remove-internal-dep 103 # to --remove-internal-dep
101 sed -e "s|@REM_INT_DEP@|$3|g" ${x} > \ 104 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ${x} > \
102 ${T}/$$.rem_int_deps.patch 105 "${T}/$$.rem_int_deps.patch"
103 106
104 x="${T}/$$.rem_int_deps.patch" 107 x="${T}/$$.rem_int_deps.patch"
105 fi 108 fi
106 109
107 if ELT_try_and_apply_patch "$1" "${x}" ; then 110 if ELT_try_and_apply_patch "${file}" "${x}" ; then
108 ret=0 111 ret=0
109 break 112 break
110 fi 113 fi
111 fi 114 fi
112 done 115 done
113 fi 116 fi
114 117
115 return ${ret} 118 return "${ret}"
116} 119}
117 120
118elibtoolize() { 121elibtoolize() {
119 local x= 122 local x=
120 local y= 123 local y=
121 local do_portage="no" 124 local do_portage="no"
122 local do_reversedeps="no" 125 local do_reversedeps="no"
123 local do_only_patches="no" 126 local do_only_patches="no"
127 local do_uclibc="yes"
124 local deptoremove= 128 local deptoremove=
125 local my_dirlist= 129 local my_dirlist=
126 local elt_patches="portage relink max_cmd_len sed test tmp \ 130 local elt_patches="portage relink max_cmd_len sed test tmp"
127 uclibc-conf uclibc-ltconf"
128 local start_dir="${PWD}" 131 local start_dir=${PWD}
129 132
130 my_dirlist="$(ELT_find_ltmain_sh)" 133 my_dirlist=$(ELT_find_ltmain_sh)
131 134
132 for x in "$@" ; do 135 for x in "$@" ; do
133 case "${x}" in 136 case "${x}" in
134 "--portage") 137 "--portage")
135 # Only apply portage patch, and don't 138 # Only apply portage patch, and don't
147 do_only_patches="yes" 150 do_only_patches="yes"
148 ;; 151 ;;
149 "^--remove-internal-dep="*) 152 "^--remove-internal-dep="*)
150 # We will replace @REM_INT_DEP@ with what is needed 153 # We will replace @REM_INT_DEP@ with what is needed
151 # in ELT_walk_patches() ... 154 # in ELT_walk_patches() ...
152 deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')" 155 deptoremove=$(echo "${x}" | sed -e 's|--remove-internal-dep=||')
153 156
154 # Add the patch for this ... 157 # Add the patch for this ...
155 [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep" 158 [[ -n ${deptoremove} ]] && elt_patches="${elt_patches} rem-int-dep"
156 ;; 159 ;;
157 "--shallow") 160 "--shallow")
158 # Only patch the ltmain.sh in ${S} 161 # Only patch the ltmain.sh in ${S}
159 if [ -f "${S}/ltmain.sh" ] 162 if [[ -f ${S}/ltmain.sh ]] ; then
160 then
161 my_dirlist="${S}" 163 my_dirlist=${S}
162 else 164 else
163 my_dirlist= 165 my_dirlist=
164 fi 166 fi
165 ;; 167 ;;
166 "--no-uclibc") 168 "--no-uclibc")
167 NO_UCLIBCTOOLIZE=1 169 do_uclibc="no"
168 ;; 170 ;;
169 *) 171 *)
170 eerror "Invalid elibtoolize option: $x" 172 eerror "Invalid elibtoolize option: ${x}"
171 die "elibtoolize called with $x ??" 173 die "elibtoolize called with ${x} ??"
172 esac 174 esac
173 done 175 done
174 176
175 if use ppc-macos ; then 177 [[ ${do_uclibc} == "yes" ]] && \
176 local opts 178 elt_patches="${elt_patches} uclibc-conf uclibc-ltconf"
177 [[ -f Makefile.am ]] && opts="--automake" 179
178 glibtoolize --copy --force ${opts} 180 [[ ${CHOST} == *"-freebsd"* ]] && \
179 darwintoolize 181 elt_patches="${elt_patches} fbsd-conf fbsd-ltconf"
180 fi 182
183 [[ ${CHOST} == *"-darwin"* ]] && \
184 elt_patches="${elt_patches} darwin-ltconf darwin-ltmain"
181 185
182 for x in ${my_dirlist} ; do 186 for x in ${my_dirlist} ; do
183 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||") 187 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||")
184 export ELT_APPLIED_PATCHES= 188 export ELT_APPLIED_PATCHES=
185 export ELT_LTMAIN_SH="${x}/ltmain.sh" 189 export ELT_LTMAIN_SH="${x}/ltmain.sh"
191 195
192 for y in ${elt_patches} ; do 196 for y in ${elt_patches} ; do
193 local ret=0 197 local ret=0
194 198
195 case "${y}" in 199 case "${y}" in
200 "portage")
201 # Stupid test to see if its already applied ...
202 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
203 ELT_walk_patches "${x}/ltmain.sh" "${y}"
204 ret=$?
205 fi
206 ;;
196 "rem-int-dep") 207 "rem-int-dep")
197 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}" 208 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
198 ret=$? 209 ret=$?
199 ;; 210 ;;
200 "fix-relink") 211 "fix-relink")
210 ELT_walk_patches "${x}/ltmain.sh" "${y}" 221 ELT_walk_patches "${x}/ltmain.sh" "${y}"
211 ret=$? 222 ret=$?
212 fi 223 fi
213 ;; 224 ;;
214 "uclibc-conf") 225 "uclibc-conf")
215 if [[ -e ${x}/configure ]] && \ 226 if [[ -e ${x}/configure && \
216 grep 'Transform linux' "${x}/configure" > /dev/null ; then 227 -n $(grep 'Transform linux' "${x}/configure") ]] ; then
217 ELT_walk_patches "${x}/configure" "${y}" 228 ELT_walk_patches "${x}/configure" "${y}"
218 ret=$? 229 ret=$?
219 # ltmain.sh and co might be in a subdirectory ... 230 # ltmain.sh and co might be in a subdirectory ...
220 elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] && \ 231 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
221 grep 'Transform linux' "${x}/../configure" > /dev/null ; then 232 -n $(grep 'Transform linux' "${x}/../configure") ]] ; then
222 ELT_walk_patches "${x}/../configure" "${y}" 233 ELT_walk_patches "${x}/../configure" "${y}"
223 ret=$? 234 ret=$?
224 fi 235 fi
225 ;; 236 ;;
226 "uclibc-ltconf") 237 "uclibc-ltconf")
238 # Newer libtoolize clears ltconfig, as not used anymore
227 if [[ -e ${x}/ltconfig ]] ; then 239 if [[ -s ${x}/ltconfig ]] ; then
240 ELT_walk_patches "${x}/ltconfig" "${y}"
241 ret=$?
242 fi
243 ;;
244 "fbsd-conf")
245 if [[ -e ${x}/configure && \
246 -n $(grep 'version_type=freebsd-' "${x}/configure") ]] ; then
247 ELT_walk_patches "${x}/configure" "${y}"
248 ret=$?
249 # ltmain.sh and co might be in a subdirectory ...
250 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
251 -n $(grep 'version_type=freebsd-' "${x}/../configure") ]] ; then
252 ELT_walk_patches "${x}/../configure" "${y}"
253 ret=$?
254 fi
255 ;;
256 "fbsd-ltconf")
257 if [[ -s ${x}/ltconfig ]] ; then
258 ELT_walk_patches "${x}/ltconfig" "${y}"
259 ret=$?
260 fi
261 ;;
262 "darwin-ltconf")
263 # Newer libtoolize clears ltconfig, as not used anymore
264 if [[ -s ${x}/ltconfig ]] ; then
228 ELT_walk_patches "${x}/ltconfig" "${y}" 265 ELT_walk_patches "${x}/ltconfig" "${y}"
229 ret=$? 266 ret=$?
230 fi 267 fi
231 ;; 268 ;;
232 *) 269 *)
236 esac 273 esac
237 274
238 if [[ ${ret} -ne 0 ]] ; then 275 if [[ ${ret} -ne 0 ]] ; then
239 case ${y} in 276 case ${y} in
240 "relink") 277 "relink")
278 local version=$(ELT_libtool_version "${x}/ltmain.sh")
241 # Critical patch, but could be applied ... 279 # Critical patch, but could be applied ...
280 # FIXME: Still need a patch for ltmain.sh > 1.4.0
242 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then 281 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") && \
282 $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]] ; then
243 ewarn " Could not apply relink.patch!" 283 ewarn " Could not apply relink.patch!"
244 fi 284 fi
245 ;; 285 ;;
246 "portage") 286 "portage")
247 # Critical patch - for this one we abort, as it can really 287 # Critical patch - for this one we abort, as it can really
249 if [[ ${do_portage} == "yes" ]] ; then 289 if [[ ${do_portage} == "yes" ]] ; then
250 # Stupid test to see if its already applied ... 290 # Stupid test to see if its already applied ...
251 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then 291 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
252 echo 292 echo
253 eerror "Portage patch requested, but failed to apply!" 293 eerror "Portage patch requested, but failed to apply!"
294 eerror "Please bug azarah or vapier to add proper patch."
254 die "Portage patch requested, but failed to apply!" 295 die "Portage patch requested, but failed to apply!"
255 fi 296 fi
256 else 297 else
257 if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then 298 if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
258 # ewarn " Portage patch seems to be already applied." 299 # ewarn " Portage patch seems to be already applied."
263 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \ 304 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
264 echo "${VERSION}") 305 echo "${VERSION}")
265 306
266 echo 307 echo
267 eerror "Portage patch failed to apply (ltmain.sh version ${version})!" 308 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
309 eerror "Please bug azarah or vapier to add proper patch."
268 die "Portage patch failed to apply!" 310 die "Portage patch failed to apply!"
269 fi 311 fi
270 # We do not want to run libtoolize ... 312 # We do not want to run libtoolize ...
271 ELT_APPLIED_PATCHES="portage" 313 ELT_APPLIED_PATCHES="portage"
272 fi 314 fi
273 ;; 315 ;;
274 "uclibc-"*) 316 "uclibc-"*)
275 [[ ${CHOST} == *"-uclibc" ]] && \ 317 [[ ${CHOST} == *"-uclibc" ]] && \
276 ewarn " uClibc patch set '${y}' failed to apply!" 318 ewarn " uClibc patch set '${y}' failed to apply!"
277 ;; 319 ;;
320 "fbsd-"*)
321 if [[ ${CHOST} == *"-freebsd"* ]] ; then
322 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
323 "${x}/configure" "${x}/../configure" 2>/dev/null) ]]; then
324 eerror " FreeBSD patch set '${y}' failed to apply!"
325 die "FreeBSD patch set '${y}' failed to apply!"
326 fi
327 fi
328 ;;
329 "darwin-"*)
330 [[ ${CHOST} == *"-darwin"* ]] && \
331 ewarn " Darwin patch set '${y}' failed to apply!"
332 ;;
278 esac 333 esac
279 fi 334 fi
280 done 335 done
281 336
282 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then 337 if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then
311 366
312 cd "${start_dir}" 367 cd "${start_dir}"
313} 368}
314 369
315uclibctoolize() { 370uclibctoolize() {
316 ewarn "uclibctoolize() is depreciated, please just use libtoolize()!" 371 ewarn "uclibctoolize() is depreciated, please just use elibtoolize()!"
317 elibtoolize 372 elibtoolize
318} 373}
319 374
320darwintoolize() { 375darwintoolize() {
321 local targets="" 376 ewarn "darwintoolize() is depreciated, please just use elibtoolize()!"
322 local x 377 elibtoolize
323
324 if [[ -z $* ]] ; then
325 targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
326 fi
327
328 einfo "Applying Darwin/libtool patches ..."
329 for x in ${targets} ; do
330 [[ ! -s ${x} ]] && continue
331 case ${x##*/} in
332 ltmain.sh|ltconfig)
333 local ver=$(grep '^VERSION=' ${x})
334 ver=${ver/VERSION=}
335 if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
336 ver="1.3" # 1.4, 1.5 and 1.3 are compat
337 fi
338
339 ebegin " Fixing \${S}${x/${S}}"
340 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
341 eend $? "PLEASE CHECK ${x}"
342 ;;
343 esac
344 done
345} 378}
346 379
347# char *VER_major(string) 380# char *VER_major(string)
348# 381#
349# Return the Major (X of X.Y.Z) version 382# Return the Major (X of X.Y.Z) version
350# 383#
351VER_major() { 384VER_major() {
352 [[ -z $1 ]] && return 1 385 [[ -z $1 ]] && return 1
353 386
354 local VER=$@ 387 local VER=$@
355 echo ${VER%%[^[:digit:]]*} 388 echo "${VER%%[^[:digit:]]*}"
356} 389}
357 390
358# char *VER_minor(string) 391# char *VER_minor(string)
359# 392#
360# Return the Minor (Y of X.Y.Z) version 393# Return the Minor (Y of X.Y.Z) version
362VER_minor() { 395VER_minor() {
363 [[ -z $1 ]] && return 1 396 [[ -z $1 ]] && return 1
364 397
365 local VER=$@ 398 local VER=$@
366 VER=${VER#*.} 399 VER=${VER#*.}
367 echo ${VER%%[^[:digit:]]*} 400 echo "${VER%%[^[:digit:]]*}"
368} 401}
369 402
370# char *VER_micro(string) 403# char *VER_micro(string)
371# 404#
372# Return the Micro (Z of X.Y.Z) version. 405# Return the Micro (Z of X.Y.Z) version.
374VER_micro() { 407VER_micro() {
375 [[ -z $1 ]] && return 1 408 [[ -z $1 ]] && return 1
376 409
377 local VER=$@ 410 local VER=$@
378 VER=${VER#*.*.} 411 VER=${VER#*.*.}
379 echo ${VER%%[^[:digit:]]*} 412 echo "${VER%%[^[:digit:]]*}"
380} 413}
381 414
382# int VER_to_int(string) 415# int VER_to_int(string)
383# 416#
384# Convert a string type version (2.4.0) to an int (132096) 417# Convert a string type version (2.4.0) to an int (132096)

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.74

  ViewVC Help
Powered by ViewVC 1.1.20