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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (hide annotations) (download)
Fri Jun 25 00:39:48 2004 UTC (10 years, 2 months ago) by vapier
Branch: MAIN
Changes since 1.27: +2 -2 lines
update the copyright info

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.28 # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.27 2004/06/08 21:11:50 mr_bones_ 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 azarah 1.24
115     my_dirlist="$(ELT_find_ltmain_sh)"
116 mr_bones_ 1.27
117 azarah 1.24 for x in $*
118     do
119     case "${x}" in
120     "--portage")
121     # Only apply portage patch, and don't
122     # 'libtoolize --copy --force' if all patches fail.
123     do_portage="yes"
124     ;;
125     "--reverse-deps")
126     # Apply the reverse-deps patch
127     # http://bugzilla.gnome.org/show_bug.cgi?id=75635
128     do_reversedeps="yes"
129     elt_patches="${elt_patches} fix-relink"
130     ;;
131     "--patch-only")
132     # Do not run libtoolize if none of the patches apply ..
133     do_only_patches="yes"
134     ;;
135     "^--remove-internal-dep="*)
136     # We will replace @REM_INT_DEP@ with what is needed
137     # in ELT_walk_patches() ...
138     deptoremove="$(echo "${x}" | sed -e 's|--remove-internal-dep=||')"
139    
140     # Add the patch for this ...
141     [ -n "${deptoremove}" ] && elt_patches="${elt_patches} rem-int-dep"
142     ;;
143     "--shallow")
144     # Only patch the ltmain.sh in ${S}
145     if [ -f "${S}/ltmain.sh" ]
146     then
147     my_dirlist="${S}"
148     else
149     my_dirlist=
150     fi
151     ;;
152     esac
153 azarah 1.4 done
154 azarah 1.1
155 azarah 1.24 for x in ${my_dirlist}
156 azarah 1.1 do
157 azarah 1.24 local tmp="$(echo "${x}" | sed -e "s|${S}||")"
158     export ELT_APPLIED_PATCHES=
159 mr_bones_ 1.27
160 azarah 1.1 cd ${x}
161 azarah 1.24 einfo "Patching \${S}$(echo "/${tmp}/ltmain.sh" | sed -e 's|//|/|g')..."
162 azarah 1.2
163 azarah 1.24 for y in ${elt_patches}
164 azarah 1.1 do
165 azarah 1.24 local ret=0
166    
167     case "${y}" in
168     "rem-int-dep")
169     ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}"
170     ret=$?
171     ;;
172     "fix-relink")
173     # Do not apply if we do not have the relink patch applied ...
174     if [ -n "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
175     then
176     ELT_walk_patches "${x}/ltmain.sh" "${y}"
177     ret=$?
178     fi
179     ;;
180 azarah 1.25 "max_cmd_len")
181     # Do not apply if $max_cmd_len is not used ...
182     if [ -n "$(grep 'max_cmd_len' "${x}/ltmain.sh")" ]
183     then
184     ELT_walk_patches "${x}/ltmain.sh" "${y}"
185     ret=$?
186     fi
187     ;;
188 azarah 1.24 *)
189     ELT_walk_patches "${x}/ltmain.sh" "${y}"
190     ret=$?
191     ;;
192     esac
193 mr_bones_ 1.27
194 azarah 1.24 if [ "${ret}" -ne 0 ]
195 azarah 1.1 then
196 azarah 1.3 case ${y} in
197 azarah 1.24 "relink")
198     # Critical patch, but could be applied ...
199     if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
200     then
201     ewarn " Could not apply relink.patch!"
202     fi
203     ;;
204     "portage")
205     # Critical patch - for this one we abort, as it can really
206     # cause breakage without it applied!
207     if [ "${do_portage}" = "yes" ]
208     then
209     # Stupid test to see if its already applied ...
210     if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
211     then
212     echo
213     eerror "Portage patch requested, but failed to apply!"
214     die "Portage patch requested, but failed to apply!"
215     fi
216     else
217     ewarn " Could not apply portage.patch!"
218     ewarn " Please verify that it is not needed."
219 azarah 1.3 fi
220     ;;
221     esac
222 azarah 1.1 fi
223 azarah 1.11
224 azarah 1.24 if [ -z "${ELT_APPLIED_PATCHES}" ]
225 azarah 1.1 then
226 azarah 1.24 if [ "${do_portage}" = "no" -a \
227     "${do_reversedeps}" = "no" -a \
228     "${do_only_patches}" = "no" -a \
229     "${deptoremove}" = "" ]
230     then
231     # Sometimes ltmain.sh is in a subdirectory ...
232     if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
233     then
234     if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
235 azarah 1.3 then
236 azarah 1.24 cd ${x}/../
237 azarah 1.3 fi
238 azarah 1.24 fi
239    
240     if which libtoolize &>/dev/null
241 azarah 1.19 then
242 azarah 1.24 ewarn "Cannot apply any patch, running libtoolize..."
243     libtoolize --copy --force
244 azarah 1.19 fi
245 azarah 1.24 cd ${x}
246     break
247 azarah 1.19 fi
248 azarah 1.1 fi
249     done
250     done
251 azarah 1.6
252 azarah 1.7 if [ -f libtool ]
253     then
254     rm -f libtool
255     fi
256    
257 azarah 1.6 # We need to change the pwd back to $S, as we may be called in
258     # src_compile()
259     cd ${S}
260 azarah 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20