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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.31 - (hide annotations) (download)
Wed Sep 22 20:04:27 2004 UTC (9 years, 6 months ago) by vapier
Branch: MAIN
Changes since 1.30: +16 -4 lines
also patch ltconfig files

1 vapier 1.28 # Copyright 1999-2004 Gentoo Foundation
2 vapier 1.15 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.31 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.30 2004/09/22 18:33:47 vapier Exp $
4 vapier 1.20 #
5 azarah 1.1 # Author: Martin Schlemmer <azarah@gentoo.org>
6 vapier 1.20 #
7 azarah 1.1 # This eclass patches ltmain.sh distributed with libtoolized packages with the
8 azarah 1.24 # relink and portage patch among others
9 vapier 1.15
10 azarah 1.24 ECLASS="libtool"
11     INHERITED="${INHERITED} ${ECLASS}"
12 danarmak 1.12
13 mr_bones_ 1.26 DEPEND="!bootstrap? ( sys-devel/libtool )"
14 azarah 1.1
15 vapier 1.22 DESCRIPTION="Based on the ${ECLASS} eclass"
16 azarah 1.1
17 azarah 1.24 ELIBTOOL_VERSION="2.0.1"
18 azarah 1.1
19    
20 azarah 1.24 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 mr_bones_ 1.27 for x in $(find "${S}" -name 'ltmain.sh')
31     do
32     dirlist="${dirlist} ${x%/*}"
33     done
34 azarah 1.24
35 mr_bones_ 1.27 echo "${dirlist}"
36 azarah 1.24 }
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 azarah 1.2
69 azarah 1.24 if [ -n "$2" ]
70     then
71     if [ -d "${ELT_PATCH_DIR}/$2" ]
72 azarah 1.4 then
73 azarah 1.24 patch_dir="${ELT_PATCH_DIR}/$2"
74     else
75     return ${ret}
76 azarah 1.4 fi
77 mr_bones_ 1.27
78 azarah 1.24 for x in $(ls -d "${patch_dir}"/* 2>/dev/null)
79     do
80     if [ -n "${x}" -a -f "${x}" ]
81 azarah 1.4 then
82 azarah 1.24 # 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 mr_bones_ 1.27
90 azarah 1.24 x="${T}/$$.rem_int_deps.patch"
91     fi
92 mr_bones_ 1.27
93 azarah 1.24 if ELT_try_and_apply_patch "$1" "${x}"
94     then
95     ret=0
96     break
97     fi
98 azarah 1.4 fi
99 azarah 1.24 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 azarah 1.25 local elt_patches="portage relink max_cmd_len sed test tmp"
114 vapier 1.29 local start_dir="${PWD}"
115 azarah 1.24
116     my_dirlist="$(ELT_find_ltmain_sh)"
117 mr_bones_ 1.27
118 vapier 1.30 for x in "$@"
119 azarah 1.24 do
120     case "${x}" in
121     "--portage")
122     # Only apply portage patch, and don't
123     # 'libtoolize --copy --force' if all patches fail.
124     do_portage="yes"
125     ;;
126     "--reverse-deps")
127     # Apply the reverse-deps patch
128     # http://bugzilla.gnome.org/show_bug.cgi?id=75635
129     do_reversedeps="yes"
130     elt_patches="${elt_patches} fix-relink"
131     ;;
132     "--patch-only")
133     # Do not run libtoolize if none of the patches apply ..
134     do_only_patches="yes"
135     ;;
136     "^--remove-internal-dep="*)
137     # We will replace @REM_INT_DEP@ with what is needed
138     # in ELT_walk_patches() ...
139     deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
140    
141     # Add the patch for this ...
142     [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
143     ;;
144     "--shallow")
145     # Only patch the ltmain.sh in ${S}
146     if [ -f "${S}/ltmain.sh" ]
147     then
148     my_dirlist="${S}"
149     else
150     my_dirlist=
151     fi
152     ;;
153     esac
154 azarah 1.4 done
155 azarah 1.1
156 azarah 1.24 for x in ${my_dirlist}
157 azarah 1.1 do
158 azarah 1.24 local tmp="$(echo "${x}" | sed -e "s|${S}||")"
159     export ELT_APPLIED_PATCHES=
160 mr_bones_ 1.27
161 azarah 1.1 cd ${x}
162 azarah 1.24 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g')..."
163 azarah 1.2
164 azarah 1.24 for y in ${elt_patches}
165 azarah 1.1 do
166 azarah 1.24 local ret=0
167    
168     case "${y}" in
169     "rem-int-dep")
170     ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
171     ret=$?
172     ;;
173     "fix-relink")
174     # Do not apply if we do not have the relink patch applied ...
175     if [ -n "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
176     then
177     ELT_walk_patches "${x}/ltmain.sh" "${y}"
178     ret=$?
179     fi
180     ;;
181 azarah 1.25 "max_cmd_len")
182     # Do not apply if $max_cmd_len is not used ...
183     if [ -n "$(grep 'max_cmd_len' "${x}/ltmain.sh")" ]
184     then
185     ELT_walk_patches "${x}/ltmain.sh" "${y}"
186     ret=$?
187     fi
188     ;;
189 azarah 1.24 *)
190     ELT_walk_patches "${x}/ltmain.sh" "${y}"
191     ret=$?
192     ;;
193     esac
194 mr_bones_ 1.27
195 azarah 1.24 if [ "${ret}" -ne 0 ]
196 azarah 1.1 then
197 azarah 1.3 case ${y} in
198 azarah 1.24 "relink")
199     # Critical patch, but could be applied ...
200     if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
201     then
202     ewarn " Could not apply relink.patch!"
203     fi
204     ;;
205     "portage")
206     # Critical patch - for this one we abort, as it can really
207     # cause breakage without it applied!
208     if [ "${do_portage}" = "yes" ]
209     then
210     # Stupid test to see if its already applied ...
211     if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
212     then
213     echo
214     eerror "Portage patch requested, but failed to apply!"
215     die "Portage patch requested, but failed to apply!"
216     fi
217     else
218     ewarn " Could not apply portage.patch!"
219     ewarn " Please verify that it is not needed."
220 azarah 1.3 fi
221     ;;
222     esac
223 azarah 1.1 fi
224 azarah 1.11
225 azarah 1.24 if [ -z "${ELT_APPLIED_PATCHES}" ]
226 azarah 1.1 then
227 azarah 1.24 if [ "${do_portage}" = "no" -a \
228     "${do_reversedeps}" = "no" -a \
229     "${do_only_patches}" = "no" -a \
230     "${deptoremove}" = "" ]
231     then
232     # Sometimes ltmain.sh is in a subdirectory ...
233     if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
234     then
235     if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
236 azarah 1.3 then
237 azarah 1.24 cd ${x}/../
238 azarah 1.3 fi
239 azarah 1.24 fi
240    
241     if which libtoolize &>/dev/null
242 azarah 1.19 then
243 azarah 1.24 ewarn "Cannot apply any patch, running libtoolize..."
244     libtoolize --copy --force
245 azarah 1.19 fi
246 azarah 1.24 cd ${x}
247     break
248 azarah 1.19 fi
249 azarah 1.1 fi
250     done
251     done
252 azarah 1.6
253 azarah 1.7 if [ -f libtool ]
254     then
255     rm -f libtool
256     fi
257    
258 vapier 1.29 cd "${start_dir}"
259 vapier 1.30
260     uclibctoolize
261     }
262    
263     uclibctoolize() {
264     local targets=""
265     local x
266    
267     if [ -z "$@" ] ; then
268     targets="$(find ${S} -name configure)"
269     fi
270    
271     einfo "Applying uClibc/libtool patches ..."
272     for x in ${targets} ; do
273 vapier 1.31 case $(basename "${x}") in
274     configure)
275     if grep 'Transform linux' "${x}" >/dev/null ; then
276     ebegin " Fixing \${S}${x/${S}}"
277     patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/configure.patch" > /dev/null
278     eend $? "PLEASE CHECK ${x}"
279     fi
280     ;;
281    
282     ltconfig)
283     local ver="$(grep '^VERSION=' ${x})"
284     ver="${ver/VERSION=}"
285 vapier 1.30 ebegin " Fixing \${S}${x/${S}}"
286 vapier 1.31 patch -p0 "${x}" "${ELT_PATCH_DIR}/uclibc/ltconfig-${ver:0:3}.patch" > /dev/null
287 vapier 1.30 eend $? "PLEASE CHECK ${x}"
288 vapier 1.31 ;;
289     esac
290 vapier 1.30 done
291 azarah 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20