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

Diff of /eclass/libtool.eclass

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

Revision 1.57 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.57 2005/09/04 20:35:42 azarah 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
45 local ret=0 45 local ret=0
46 local file=$1 46 local file=$1
47 local patch=$2 47 local patch=$2
48 48
49 # 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?
50 if patch -p0 --dry-run "${file}" < "${patch}" &> "${T}/elibtool.log" ; then 50 if patch -p0 --dry-run "${file}" "${patch}" &> "${T}/elibtool.log" ; then
51 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." 51 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
52 patch -p0 "${file}" < "${patch}" &> "${T}/elibtool.log" 52 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \
53 &> "${T}/elibtool.log"
53 ret=$? 54 ret=$?
54 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" 55 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
55 else 56 else
56 ret=1 57 ret=1
57 fi 58 fi
58 59
59 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}"
60} 75}
61 76
62# 77#
63# Run through the patches in $2 and see if any 78# Run through the patches in $2 and see if any
64# apply to $1 ... 79# apply to $1 ...
69 local ret=1 84 local ret=1
70 local file=$1 85 local file=$1
71 local patch_set=$2 86 local patch_set=$2
72 local patch_dir= 87 local patch_dir=
73 local rem_int_dep=$3 88 local rem_int_dep=$3
74 local version=
75 local ltmain_sh=$1
76
77 [[ ${file} == *"/configure" ]] && ltmain_sh=${ELT_LTMAIN_SH}
78 version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}"); \
79 echo "${VERSION}")
80 89
81 if [[ -n ${patch_set} ]] ; then 90 if [[ -n ${patch_set} ]] ; then
82 if [[ -d ${ELT_PATCH_DIR}/${patch_set} ]] ; then 91 if [[ -d ${ELT_PATCH_DIR}/${patch_set} ]] ; then
83 patch_dir="${ELT_PATCH_DIR}/${patch_set}" 92 patch_dir="${ELT_PATCH_DIR}/${patch_set}"
84 else 93 else
85 return "${ret}" 94 return "${ret}"
86 fi 95 fi
87 96
88 if [[ -z ${version} ]] ; then
89 eerror "Could not get VERSION for ${file##*/}!"
90 die "Could not get VERSION for ${file##*/}!"
91 fi
92
93 # Go through the patches in reverse order (large to small) 97 # Go through the patches in reverse order (large to small)
94 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
95 if [[ -n ${x} && -f ${x} ]] ; then 99 if [[ -n ${x} && -f ${x} ]] ; then
96 local ltver=$(VER_to_int "${version}")
97 local ptver=$(VER_to_int "${x##*/}")
98
99 # If libtool version smaller than patch version, skip patch.
100 [[ ${ltver} -lt ${ptver} ]] && continue
101 # For --remove-internal-dep ... 100 # For --remove-internal-dep ...
102 if [[ -n ${rem_int_dep} ]] ; then 101 if [[ -n ${rem_int_dep} ]] ; then
103 # For replace @REM_INT_DEP@ with what was passed 102 # For replace @REM_INT_DEP@ with what was passed
104 # to --remove-internal-dep 103 # to --remove-internal-dep
105 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ${x} > \ 104 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ${x} > \
126 local do_reversedeps="no" 125 local do_reversedeps="no"
127 local do_only_patches="no" 126 local do_only_patches="no"
128 local do_uclibc="yes" 127 local do_uclibc="yes"
129 local deptoremove= 128 local deptoremove=
130 local my_dirlist= 129 local my_dirlist=
131 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
132 local start_dir=${PWD} 131 local start_dir=${PWD}
133 132
134 my_dirlist=$(ELT_find_ltmain_sh) 133 my_dirlist=$(ELT_find_ltmain_sh)
135 134
136 for x in "$@" ; do 135 for x in "$@" ; do
177 176
178 [[ ${do_uclibc} == "yes" ]] && \ 177 [[ ${do_uclibc} == "yes" ]] && \
179 elt_patches="${elt_patches} uclibc-conf uclibc-ltconf" 178 elt_patches="${elt_patches} uclibc-conf uclibc-ltconf"
180 179
181 [[ ${CHOST} == *"-freebsd"* ]] && \ 180 [[ ${CHOST} == *"-freebsd"* ]] && \
182 elt_patches="${elt_patches} fbsd-conf" 181 elt_patches="${elt_patches} fbsd-conf fbsd-ltconf"
183 182
184 if use ppc-macos ; then 183 if useq ppc-macos ; then
185 local opts 184 local opts
186 [[ -f Makefile.am ]] && opts="--automake" 185 [[ -f Makefile.am ]] && opts="--automake"
187 glibtoolize --copy --force ${opts} 186 glibtoolize --copy --force ${opts}
188 darwintoolize 187
188 elt_patches="${elt_patches} darwin-ltconf darwin-ltmain"
189 fi 189 fi
190 190
191 for x in ${my_dirlist} ; do 191 for x in ${my_dirlist} ; do
192 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||") 192 local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||")
193 export ELT_APPLIED_PATCHES= 193 export ELT_APPLIED_PATCHES=
200 200
201 for y in ${elt_patches} ; do 201 for y in ${elt_patches} ; do
202 local ret=0 202 local ret=0
203 203
204 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 ;;
205 "rem-int-dep") 212 "rem-int-dep")
206 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}" 213 ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
207 ret=$? 214 ret=$?
208 ;; 215 ;;
209 "fix-relink") 216 "fix-relink")
219 ELT_walk_patches "${x}/ltmain.sh" "${y}" 226 ELT_walk_patches "${x}/ltmain.sh" "${y}"
220 ret=$? 227 ret=$?
221 fi 228 fi
222 ;; 229 ;;
223 "uclibc-conf") 230 "uclibc-conf")
224 if [[ -e ${x}/configure ]] && \ 231 if [[ -e ${x}/configure && \
225 grep 'Transform linux' "${x}/configure" > /dev/null ; then 232 -n $(grep 'Transform linux' "${x}/configure") ]] ; then
226 ELT_walk_patches "${x}/configure" "${y}" 233 ELT_walk_patches "${x}/configure" "${y}"
227 ret=$? 234 ret=$?
228 # ltmain.sh and co might be in a subdirectory ... 235 # ltmain.sh and co might be in a subdirectory ...
229 elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] && \ 236 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
230 grep 'Transform linux' "${x}/../configure" > /dev/null ; then 237 -n $(grep 'Transform linux' "${x}/../configure") ]] ; then
231 ELT_walk_patches "${x}/../configure" "${y}" 238 ELT_walk_patches "${x}/../configure" "${y}"
232 ret=$? 239 ret=$?
233 fi 240 fi
234 ;; 241 ;;
235 "uclibc-ltconf") 242 "uclibc-ltconf")
243 # Newer libtoolize clears ltconfig, as not used anymore
236 if [[ -e ${x}/ltconfig ]] ; then 244 if [[ -s ${x}/ltconfig ]] ; then
237 ELT_walk_patches "${x}/ltconfig" "${y}" 245 ELT_walk_patches "${x}/ltconfig" "${y}"
238 ret=$? 246 ret=$?
239 fi 247 fi
240 ;; 248 ;;
241 "fbsd-conf") 249 "fbsd-conf")
242 if [[ -e ${x}/configure ]] && \ 250 if [[ -e ${x}/configure && \
243 grep 'version_type=freebsd-' "${x}/configure" > /dev/null ; then 251 -n $(grep 'version_type=freebsd-' "${x}/configure") ]] ; then
244 ELT_walk_patches "${x}/configure" "${y}" 252 ELT_walk_patches "${x}/configure" "${y}"
245 ret=$? 253 ret=$?
246 # ltmain.sh and co might be in a subdirectory ... 254 # ltmain.sh and co might be in a subdirectory ...
247 elif [[ ! -e ${x}/configure && -e ${x}/../configure ]] && \ 255 elif [[ ! -e ${x}/configure && -e ${x}/../configure && \
248 grep 'version_type=freebsd-' "${x}/../configure" > /dev/null ; then 256 -n $(grep 'version_type=freebsd-' "${x}/../configure") ]] ; then
249 ELT_walk_patches "${x}/../configure" "${y}" 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
270 ELT_walk_patches "${x}/ltconfig" "${y}"
250 ret=$? 271 ret=$?
251 fi 272 fi
252 ;; 273 ;;
253 *) 274 *)
254 ELT_walk_patches "${x}/ltmain.sh" "${y}" 275 ELT_walk_patches "${x}/ltmain.sh" "${y}"
257 esac 278 esac
258 279
259 if [[ ${ret} -ne 0 ]] ; then 280 if [[ ${ret} -ne 0 ]] ; then
260 case ${y} in 281 case ${y} in
261 "relink") 282 "relink")
283 local version=$(ELT_libtool_version "${x}/ltmain.sh")
262 # 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
263 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
264 ewarn " Could not apply relink.patch!" 288 ewarn " Could not apply relink.patch!"
265 fi 289 fi
266 ;; 290 ;;
267 "portage") 291 "portage")
268 # Critical patch - for this one we abort, as it can really 292 # Critical patch - for this one we abort, as it can really
270 if [[ ${do_portage} == "yes" ]] ; then 294 if [[ ${do_portage} == "yes" ]] ; then
271 # Stupid test to see if its already applied ... 295 # Stupid test to see if its already applied ...
272 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
273 echo 297 echo
274 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."
275 die "Portage patch requested, but failed to apply!" 300 die "Portage patch requested, but failed to apply!"
276 fi 301 fi
277 else 302 else
278 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
279 # ewarn " Portage patch seems to be already applied." 304 # ewarn " Portage patch seems to be already applied."
284 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \ 309 eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); \
285 echo "${VERSION}") 310 echo "${VERSION}")
286 311
287 echo 312 echo
288 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."
289 die "Portage patch failed to apply!" 315 die "Portage patch failed to apply!"
290 fi 316 fi
291 # We do not want to run libtoolize ... 317 # We do not want to run libtoolize ...
292 ELT_APPLIED_PATCHES="portage" 318 ELT_APPLIED_PATCHES="portage"
293 fi 319 fi
295 "uclibc-"*) 321 "uclibc-"*)
296 [[ ${CHOST} == *"-uclibc" ]] && \ 322 [[ ${CHOST} == *"-uclibc" ]] && \
297 ewarn " uClibc patch set '${y}' failed to apply!" 323 ewarn " uClibc patch set '${y}' failed to apply!"
298 ;; 324 ;;
299 "fbsd-"*) 325 "fbsd-"*)
300 [[ ${CHOST} == *"-freebsd"* ]] && \ 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
301 eerror " FreeBSD patch set '${y}' failed to apply!" 329 eerror " FreeBSD patch set '${y}' failed to apply!"
302 die "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
303 ;; 342 ;;
304 esac 343 esac
305 fi 344 fi
306 done 345 done
307 346
337 376
338 cd "${start_dir}" 377 cd "${start_dir}"
339} 378}
340 379
341uclibctoolize() { 380uclibctoolize() {
342 ewarn "uclibctoolize() is depreciated, please just use libtoolize()!" 381 ewarn "uclibctoolize() is depreciated, please just use elibtoolize()!"
343 elibtoolize 382 elibtoolize
344} 383}
345 384
346darwintoolize() { 385darwintoolize() {
347 local targets="" 386 ewarn "darwintoolize() is depreciated, please just use elibtoolize()!"
348 local x 387 elibtoolize
349
350 if [[ -z $* ]] ; then
351 targets=$(find ${S} -name ltmain.sh -o -name ltconfig)
352 fi
353
354 einfo "Applying Darwin/libtool patches ..."
355 for x in ${targets} ; do
356 [[ ! -s ${x} ]] && continue
357 case ${x##*/} in
358 ltmain.sh|ltconfig)
359 local ver=$(grep '^VERSION=' ${x})
360 ver=${ver/VERSION=}
361 if [[ ${ver:0:3} == "1.4" || ${ver:0:3} == "1.5" ]] ; then
362 ver="1.3" # 1.4, 1.5 and 1.3 are compat
363 fi
364
365 ebegin " Fixing \${S}${x/${S}}"
366 patch -p0 "${x}" "${ELT_PATCH_DIR}/darwin/${x##*/}-${ver:0:3}.patch" > /dev/null
367 eend $? "PLEASE CHECK ${x}"
368 ;;
369 esac
370 done
371} 388}
372 389
373# char *VER_major(string) 390# char *VER_major(string)
374# 391#
375# Return the Major (X of X.Y.Z) version 392# Return the Major (X of X.Y.Z) version

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

  ViewVC Help
Powered by ViewVC 1.1.20