/[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.70
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.70 2006/04/28 16:23:54 flameeyes 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"# kde-fastinstall
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
177 [[ ${do_uclibc} == "yes" ]] && \
178 elt_patches="${elt_patches} uclibc-conf uclibc-ltconf"
179
180 [[ ${CHOST} == *"-freebsd"* ]] && \
181 elt_patches="${elt_patches} fbsd-conf fbsd-ltconf"
182
175 if use ppc-macos ; then 183 if useq ppc-macos ; then
176 local opts 184 local opts
177 [[ -f Makefile.am ]] && opts="--automake" 185 [[ -f Makefile.am ]] && opts="--automake"
178 glibtoolize --copy --force ${opts} 186 glibtoolize --copy --force ${opts}
179 darwintoolize 187
188 elt_patches="${elt_patches} darwin-ltconf darwin-ltmain"
180 fi 189 fi
181 190
182 for x in ${my_dirlist} ; do 191 for x in ${my_dirlist} ; do
183 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||") 192 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||")
184 export ELT_APPLIED_PATCHES= 193 export ELT_APPLIED_PATCHES=
191 200
192 for y in ${elt_patches} ; do 201 for y in ${elt_patches} ; do
193 local ret=0 202 local ret=0
194 203
195 case "${y}" in 204 case "${y}" in
205 "portage")
206 # Stupid test to see if its already applied ...
207 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
208 ELT_walk_patches "${x}/ltmain.sh" "${y}"
209 ret=$?
210 fi
211 ;;
196 "rem-int-dep") 212 "rem-int-dep")
197 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}" 213 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
198 ret=$? 214 ret=$?
199 ;; 215 ;;
200 "fix-relink") 216 "fix-relink")
210 ELT_walk_patches "${x}/ltmain.sh" "${y}" 226 ELT_walk_patches "${x}/ltmain.sh" "${y}"
211 ret=$? 227 ret=$?
212 fi 228 fi
213 ;; 229 ;;
214 "uclibc-conf") 230 "uclibc-conf")
215 if [[ -e ${x}/configure ]] && \ 231 if [[ -e ${x}/configure && \
216 grep 'Transform linux' "${x}/configure" > /dev/null ; then 232 -n $(grep 'Transform linux' "${x}/configure") ]] ; then
217 ELT_walk_patches "${x}/configure" "${y}" 233 ELT_walk_patches "${x}/configure" "${y}"
218 ret=$? 234 ret=$?
219 # ltmain.sh and co might be in a subdirectory ... 235 # ltmain.sh and co might be in a subdirectory ...
220 elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] && \ 236 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
221 grep 'Transform linux' "${x}/../configure" > /dev/null ; then 237 -n $(grep 'Transform linux' "${x}/../configure") ]] ; then
222 ELT_walk_patches "${x}/../configure" "${y}" 238 ELT_walk_patches "${x}/../configure" "${y}"
223 ret=$? 239 ret=$?
224 fi 240 fi
225 ;; 241 ;;
226 "uclibc-ltconf") 242 "uclibc-ltconf")
243 # Newer libtoolize clears ltconfig, as not used anymore
227 if [[ -e ${x}/ltconfig ]] ; then 244 if [[ -s ${x}/ltconfig ]] ; then
245 ELT_walk_patches "${x}/ltconfig" "${y}"
246 ret=$?
247 fi
248 ;;
249 "fbsd-conf")
250 if [[ -e ${x}/configure && \
251 -n $(grep 'version_type=freebsd-' "${x}/configure") ]] ; then
252 ELT_walk_patches "${x}/configure" "${y}"
253 ret=$?
254 # ltmain.sh and co might be in a subdirectory ...
255 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
256 -n $(grep 'version_type=freebsd-' "${x}/../configure") ]] ; then
257 ELT_walk_patches "${x}/../configure" "${y}"
258 ret=$?
259 fi
260 ;;
261 "fbsd-ltconf")
262 if [[ -s ${x}/ltconfig ]] ; then
263 ELT_walk_patches "${x}/ltconfig" "${y}"
264 ret=$?
265 fi
266 ;;
267 "darwin-ltconf")
268 # Newer libtoolize clears ltconfig, as not used anymore
269 if [[ -s ${x}/ltconfig ]] ; then
228 ELT_walk_patches "${x}/ltconfig" "${y}" 270 ELT_walk_patches "${x}/ltconfig" "${y}"
229 ret=$? 271 ret=$?
230 fi 272 fi
231 ;; 273 ;;
232 *) 274 *)
236 esac 278 esac
237 279
238 if [[ ${ret} -ne 0 ]] ; then 280 if [[ ${ret} -ne 0 ]] ; then
239 case ${y} in 281 case ${y} in
240 "relink") 282 "relink")
283 local version=$(ELT_libtool_version "${x}/ltmain.sh")
241 # Critical patch, but could be applied ... 284 # Critical patch, but could be applied ...
285 # FIXME: Still need a patch for ltmain.sh > 1.4.0
242 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]] ; then 286 if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") && \
287 $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]] ; then
243 ewarn " Could not apply relink.patch!" 288 ewarn " Could not apply relink.patch!"
244 fi 289 fi
245 ;; 290 ;;
246 "portage") 291 "portage")
247 # Critical patch - for this one we abort, as it can really 292 # Critical patch - for this one we abort, as it can really
249 if [[ ${do_portage} == "yes" ]] ; then 294 if [[ ${do_portage} == "yes" ]] ; then
250 # Stupid test to see if its already applied ... 295 # Stupid test to see if its already applied ...
251 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then 296 if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
252 echo 297 echo
253 eerror "Portage patch requested, but failed to apply!" 298 eerror "Portage patch requested, but failed to apply!"
299 eerror "Please bug azarah or vapier to add proper patch."
254 die "Portage patch requested, but failed to apply!" 300 die "Portage patch requested, but failed to apply!"
255 fi 301 fi
256 else 302 else
257 if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then 303 if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]] ; then
258 # ewarn " Portage patch seems to be already applied." 304 # ewarn " Portage patch seems to be already applied."
263 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \ 309 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
264 echo "${VERSION}") 310 echo "${VERSION}")
265 311
266 echo 312 echo
267 eerror "Portage patch failed to apply (ltmain.sh version ${version})!" 313 eerror "Portage patch failed to apply (ltmain.sh version ${version})!"
314 eerror "Please bug azarah or vapier to add proper patch."
268 die "Portage patch failed to apply!" 315 die "Portage patch failed to apply!"
269 fi 316 fi
270 # We do not want to run libtoolize ... 317 # We do not want to run libtoolize ...
271 ELT_APPLIED_PATCHES="portage" 318 ELT_APPLIED_PATCHES="portage"
272 fi 319 fi
273 ;; 320 ;;
274 "uclibc-"*) 321 "uclibc-"*)
275 [[ ${CHOST} == *"-uclibc" ]] && \ 322 [[ ${CHOST} == *"-uclibc" ]] && \
276 ewarn " uClibc patch set '${y}' failed to apply!" 323 ewarn " uClibc patch set '${y}' failed to apply!"
324 ;;
325 "fbsd-"*)
326 if [[ ${CHOST} == *"-freebsd"* ]] ; then
327 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \
328 "${x}/configure" "${x}/../configure" 2>/dev/null) ]]; then
329 eerror " FreeBSD patch set '${y}' failed to apply!"
330 die "FreeBSD patch set '${y}' failed to apply!"
331 fi
332 fi
333 ;;
334 "darwin-"*)
335 useq ppc-macos && \
336 ewarn " Darwin patch set '${y}' failed to apply!"
337 ;;
338 "kde-fastinstall")
339 if [[ -n $(grep 'test "$mode" != relink && test "$fast_install" = no' ${x}/ltmain.sh) ]]; then
340 ewarn "Patch ${y} failed to apply. If you experience build failures, please report this."
341 fi
277 ;; 342 ;;
278 esac 343 esac
279 fi 344 fi
280 done 345 done
281 346
311 376
312 cd "${start_dir}" 377 cd "${start_dir}"
313} 378}
314 379
315uclibctoolize() { 380uclibctoolize() {
316 ewarn "uclibctoolize() is depreciated, please just use libtoolize()!" 381 ewarn "uclibctoolize() is depreciated, please just use elibtoolize()!"
317 elibtoolize 382 elibtoolize
318} 383}
319 384
320darwintoolize() { 385darwintoolize() {
321 local targets="" 386 ewarn "darwintoolize() is depreciated, please just use elibtoolize()!"
322 local x 387 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} 388}
346 389
347# char *VER_major(string) 390# char *VER_major(string)
348# 391#
349# Return the Major (X of X.Y.Z) version 392# Return the Major (X of X.Y.Z) version
350# 393#
351VER_major() { 394VER_major() {
352 [[ -z $1 ]] && return 1 395 [[ -z $1 ]] && return 1
353 396
354 local VER=$@ 397 local VER=$@
355 echo ${VER%%[^[:digit:]]*} 398 echo "${VER%%[^[:digit:]]*}"
356} 399}
357 400
358# char *VER_minor(string) 401# char *VER_minor(string)
359# 402#
360# Return the Minor (Y of X.Y.Z) version 403# Return the Minor (Y of X.Y.Z) version
362VER_minor() { 405VER_minor() {
363 [[ -z $1 ]] && return 1 406 [[ -z $1 ]] && return 1
364 407
365 local VER=$@ 408 local VER=$@
366 VER=${VER#*.} 409 VER=${VER#*.}
367 echo ${VER%%[^[:digit:]]*} 410 echo "${VER%%[^[:digit:]]*}"
368} 411}
369 412
370# char *VER_micro(string) 413# char *VER_micro(string)
371# 414#
372# Return the Micro (Z of X.Y.Z) version. 415# Return the Micro (Z of X.Y.Z) version.
374VER_micro() { 417VER_micro() {
375 [[ -z $1 ]] && return 1 418 [[ -z $1 ]] && return 1
376 419
377 local VER=$@ 420 local VER=$@
378 VER=${VER#*.*.} 421 VER=${VER#*.*.}
379 echo ${VER%%[^[:digit:]]*} 422 echo "${VER%%[^[:digit:]]*}"
380} 423}
381 424
382# int VER_to_int(string) 425# int VER_to_int(string)
383# 426#
384# Convert a string type version (2.4.0) to an int (132096) 427# Convert a string type version (2.4.0) to an int (132096)

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

  ViewVC Help
Powered by ViewVC 1.1.20