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

Contents of /eclass/libtool.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (hide annotations) (download)
Fri Jan 2 21:54:28 2004 UTC (10 years, 7 months ago) by azarah
Branch: MAIN
Changes since 1.23: +202 -817 lines
Mostly complete rewrite in effort to make it easier to maintain.
Add all the patches temporary in ELT-patches, until I can get a
better place that do not need a tarball or such to download.

1 azarah 1.24 # Copyright 1999-2004 Gentoo Technologies, Inc.
2 vapier 1.15 # Distributed under the terms of the GNU General Public License v2
3 azarah 1.24 # $Header: /home/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.23 2003/04/08 11:34:57 azarah 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 azarah 1.18 newdepend "!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     for x in $(find "${S}" -name 'ltmain.sh')
31     do
32     dirlist="${dirlist} ${x%/*}"
33     done
34    
35     echo "${dirlist}"
36     }
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 azarah 1.24
78     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    
90     x="${T}/$$.rem_int_deps.patch"
91     fi
92    
93     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     local elt_patches="portage relink sed test tmp"
114    
115     my_dirlist="$(ELT_find_ltmain_sh)"
116    
117     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    
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     *)
181     ELT_walk_patches "${x}/ltmain.sh" "${y}"
182     ret=$?
183     ;;
184     esac
185    
186     if [ "${ret}" -ne 0 ]
187 azarah 1.1 then
188 azarah 1.3 case ${y} in
189 azarah 1.24 "relink")
190     # Critical patch, but could be applied ...
191     if [ -z "$(grep 'inst_prefix_dir' "${x}/ltmain.sh")" ]
192     then
193     ewarn " Could not apply relink.patch!"
194     fi
195     ;;
196     "portage")
197     # Critical patch - for this one we abort, as it can really
198     # cause breakage without it applied!
199     if [ "${do_portage}" = "yes" ]
200     then
201     # Stupid test to see if its already applied ...
202     if [ -z "$(grep 'We do not want portage' "${x}/ltmain.sh")" ]
203     then
204     echo
205     eerror "Portage patch requested, but failed to apply!"
206     die "Portage patch requested, but failed to apply!"
207     fi
208     else
209     ewarn " Could not apply portage.patch!"
210     ewarn " Please verify that it is not needed."
211 azarah 1.3 fi
212     ;;
213     esac
214 azarah 1.1 fi
215 azarah 1.11
216 azarah 1.24 if [ -z "${ELT_APPLIED_PATCHES}" ]
217 azarah 1.1 then
218 azarah 1.24 if [ "${do_portage}" = "no" -a \
219     "${do_reversedeps}" = "no" -a \
220     "${do_only_patches}" = "no" -a \
221     "${deptoremove}" = "" ]
222     then
223     # Sometimes ltmain.sh is in a subdirectory ...
224     if [ ! -f ${x}/configure.in -a ! -f ${x}/configure.ac ]
225     then
226     if [ -f ${x}/../configure.in -o -f ${x}/../configure.ac ]
227 azarah 1.3 then
228 azarah 1.24 cd ${x}/../
229 azarah 1.3 fi
230 azarah 1.24 fi
231    
232     if which libtoolize &>/dev/null
233 azarah 1.19 then
234 azarah 1.24 ewarn "Cannot apply any patch, running libtoolize..."
235     libtoolize --copy --force
236 azarah 1.19 fi
237 azarah 1.24 cd ${x}
238     break
239 azarah 1.19 fi
240 azarah 1.1 fi
241     done
242     done
243 azarah 1.6
244 azarah 1.7 if [ -f libtool ]
245     then
246     rm -f libtool
247     fi
248    
249 azarah 1.6 # We need to change the pwd back to $S, as we may be called in
250     # src_compile()
251     cd ${S}
252 azarah 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20