1 |
commit: 55da2019a0255dbc6b593516fe0846978bd58eed |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 12 01:47:21 2012 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 12 01:47:21 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=55da2019 |
7 |
|
8 |
overriding eclasses sucks |
9 |
|
10 |
--- |
11 |
eclass/kernel-2.eclass | 1229 ---------------------------- |
12 |
eclass/toolchain.eclass | 2035 ----------------------------------------------- |
13 |
2 files changed, 0 insertions(+), 3264 deletions(-) |
14 |
|
15 |
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass |
16 |
deleted file mode 100644 |
17 |
index 724a485..0000000 |
18 |
--- a/eclass/kernel-2.eclass |
19 |
+++ /dev/null |
20 |
@@ -1,1229 +0,0 @@ |
21 |
-# Copyright 1999-2011 Gentoo Foundation |
22 |
-# Distributed under the terms of the GNU General Public License v2 |
23 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.274 2011/12/28 13:38:05 psomas Exp $ |
24 |
- |
25 |
-# Description: kernel.eclass rewrite for a clean base regarding the 2.6 |
26 |
-# series of kernel with back-compatibility for 2.4 |
27 |
-# |
28 |
-# Original author: John Mylchreest <johnm@g.o> |
29 |
-# Maintainer: kernel-misc@g.o |
30 |
-# |
31 |
-# Please direct your bugs to the current eclass maintainer :) |
32 |
- |
33 |
-# added functionality: |
34 |
-# unipatch - a flexible, singular method to extract, add and remove patches. |
35 |
- |
36 |
-# A Couple of env vars are available to effect usage of this eclass |
37 |
-# These are as follows: |
38 |
-# |
39 |
-# K_USEPV - When setting the EXTRAVERSION variable, it should |
40 |
-# add PV to the end. |
41 |
-# this is useful for thigns like wolk. IE: |
42 |
-# EXTRAVERSION would be something like : -wolk-4.19-r1 |
43 |
-# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be |
44 |
-# automatically set within the kernel Makefile |
45 |
-# K_NOUSENAME - if this is set then EXTRAVERSION will not include the |
46 |
-# first part of ${PN} in EXTRAVERSION |
47 |
-# K_NOUSEPR - if this is set then EXTRAVERSION will not include the |
48 |
-# anything based on ${PR}. |
49 |
-# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, |
50 |
-# ck-sources, ac-sources) it will use PR (ie: -r5) as |
51 |
-# the patchset version for |
52 |
-# and not use it as a true package revision |
53 |
-# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in |
54 |
-# postinst and can be used to carry additional postinst |
55 |
-# messages |
56 |
-# K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo |
57 |
-# K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo |
58 |
-# K_SYMLINK - if this is set, then forcably create symlink anyway |
59 |
-# |
60 |
-# K_DEFCONFIG - Allow specifying a different defconfig target. |
61 |
-# If length zero, defaults to "defconfig". |
62 |
-# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any |
63 |
-# combination of "base" and "extras" |
64 |
-# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply. |
65 |
-# A value of "5" would apply genpatches-2.6.12-5 to |
66 |
-# my-sources-2.6.12.ebuild |
67 |
-# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security |
68 |
-# K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob |
69 |
-# code. If empty, will be set to "1" if deblobbing is |
70 |
-# possible. Test ONLY for "1". |
71 |
-# K_PREDEBLOBBED - This kernel was already deblobbed elsewhere. |
72 |
-# If false, either optional deblobbing will be available |
73 |
-# or the license will note the inclusion of freedist |
74 |
-# code. |
75 |
-# K_LONGTERM - If set, the eclass will search for the kernel source |
76 |
-# in the long term directories on the upstream servers |
77 |
-# as the location has been changed by upstream |
78 |
-# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which |
79 |
-# can be supported by the headers ebuild |
80 |
- |
81 |
-# UNIPATCH_LIST - space delimetered list of patches to be applied to the |
82 |
-# kernel |
83 |
-# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely |
84 |
-# on "<passedstring>*" and not "<passedno#>_*" |
85 |
-# - this should _NOT_ be used from the ebuild as this is |
86 |
-# reserved for end users passing excludes from the cli |
87 |
-# UNIPATCH_DOCS - space delimemeted list of docs to be installed to |
88 |
-# the doc dir |
89 |
-# UNIPATCH_STRICTORDER - if this is set places patches into directories of |
90 |
-# order, so they are applied in the order passed |
91 |
- |
92 |
-inherit eutils toolchain-funcs versionator multilib |
93 |
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm |
94 |
- |
95 |
-# Added by Daniel Ostrow <dostrow@g.o> |
96 |
-# This is an ugly hack to get around an issue with a 32-bit userland on ppc64. |
97 |
-# I will remove it when I come up with something more reasonable. |
98 |
-[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}" |
99 |
- |
100 |
-export CTARGET=${CTARGET:-${CHOST}} |
101 |
-if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then |
102 |
- export CTARGET=${CATEGORY/cross-} |
103 |
-fi |
104 |
- |
105 |
-HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" |
106 |
-: ${LICENSE:="GPL-2"} |
107 |
- |
108 |
-# This is the latest KV_PATCH of the deblob tool available from the |
109 |
-# libre-sources upstream. If you bump this, you MUST regenerate the Manifests |
110 |
-# for ALL kernel-2 consumer packages where deblob is available. |
111 |
-: ${DEBLOB_MAX_VERSION:=38} |
112 |
- |
113 |
-# No need to run scanelf/strip on kernel sources/headers (bug #134453). |
114 |
-RESTRICT="binchecks strip" |
115 |
- |
116 |
-# set LINUX_HOSTCFLAGS if not already set |
117 |
-: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"} |
118 |
- |
119 |
-# debugging functions |
120 |
-#============================================================== |
121 |
-# this function exists only to help debug kernel-2.eclass |
122 |
-# if you are adding new functionality in, put a call to it |
123 |
-# at the start of src_unpack, or during SRC_URI/dep generation. |
124 |
-debug-print-kernel2-variables() { |
125 |
- for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \ |
126 |
- RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \ |
127 |
- UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do |
128 |
- debug-print "${v}: ${!v}" |
129 |
- done |
130 |
-} |
131 |
- |
132 |
-#Eclass functions only from here onwards ... |
133 |
-#============================================================== |
134 |
-handle_genpatches() { |
135 |
- local tarball |
136 |
- [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1 |
137 |
- |
138 |
- debug-print "Inside handle_genpatches" |
139 |
- local OKV_ARRAY |
140 |
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}" |
141 |
- |
142 |
- # for > 3.0 kernels, handle genpatches tarball name |
143 |
- # genpatches for 3.0 and 3.0.1 might be named |
144 |
- # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2 |
145 |
- # respectively. Handle this. |
146 |
- |
147 |
- for i in ${K_WANT_GENPATCHES} ; do |
148 |
- if [[ ${KV_MAJOR} -ge 3 ]]; then |
149 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then |
150 |
- tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.bz2" |
151 |
- else |
152 |
- tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.bz2" |
153 |
- fi |
154 |
- else |
155 |
- tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2" |
156 |
- fi |
157 |
- debug-print "genpatches tarball: $tarball" |
158 |
- GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}" |
159 |
- UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}" |
160 |
- done |
161 |
-} |
162 |
- |
163 |
-detect_version() { |
164 |
- # this function will detect and set |
165 |
- # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) |
166 |
- # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) |
167 |
- # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) |
168 |
- |
169 |
- # We've already run, so nothing to do here. |
170 |
- [[ -n ${KV_FULL} ]] && return 0 |
171 |
- |
172 |
- # CKV is used as a comparison kernel version, which is used when |
173 |
- # PV doesnt reflect the genuine kernel version. |
174 |
- # this gets set to the portage style versioning. ie: |
175 |
- # CKV=2.6.11_rc4 |
176 |
- CKV=${CKV:-${PV}} |
177 |
- OKV=${OKV:-${CKV}} |
178 |
- OKV=${OKV/_beta/-test} |
179 |
- OKV=${OKV/_rc/-rc} |
180 |
- OKV=${OKV/-r*} |
181 |
- OKV=${OKV/_p*} |
182 |
- |
183 |
- KV_MAJOR=$(get_version_component_range 1 ${OKV}) |
184 |
- # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1) |
185 |
- local OKV_ARRAY |
186 |
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}" |
187 |
- |
188 |
- # if KV_MAJOR >= 3, then we have no more KV_MINOR |
189 |
- #if [[ ${KV_MAJOR} -lt 3 ]]; then |
190 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then |
191 |
- KV_MINOR=$(get_version_component_range 2 ${OKV}) |
192 |
- KV_PATCH=$(get_version_component_range 3 ${OKV}) |
193 |
- if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then |
194 |
- KV_EXTRA=$(get_version_component_range 4- ${OKV}) |
195 |
- KV_EXTRA=${KV_EXTRA/[-_]*} |
196 |
- else |
197 |
- KV_PATCH=$(get_version_component_range 3- ${OKV}) |
198 |
- fi |
199 |
- else |
200 |
- KV_PATCH=$(get_version_component_range 2 ${OKV}) |
201 |
- KV_EXTRA=$(get_version_component_range 3- ${OKV}) |
202 |
- KV_EXTRA=${KV_EXTRA/[-_]*} |
203 |
- fi |
204 |
- |
205 |
- debug-print "KV_EXTRA is ${KV_EXTRA}" |
206 |
- |
207 |
- KV_PATCH=${KV_PATCH/[-_]*} |
208 |
- |
209 |
- local v n=0 missing |
210 |
- #if [[ ${KV_MAJOR} -lt 3 ]]; then |
211 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then |
212 |
- for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do |
213 |
- [[ -z ${!v} ]] && n=1 && missing="${missing}${v} "; |
214 |
- done |
215 |
- else |
216 |
- for v in CKV OKV KV_{MAJOR,PATCH} ; do |
217 |
- [[ -z ${!v} ]] && n=1 && missing="${missing}${v} "; |
218 |
- done |
219 |
- fi |
220 |
- |
221 |
- [[ $n -eq 1 ]] && \ |
222 |
- eerror "Missing variables: ${missing}" && \ |
223 |
- die "Failed to extract kernel version (try explicit CKV in ebuild)!" |
224 |
- unset v n missing |
225 |
- |
226 |
-# if [[ ${KV_MAJOR} -ge 3 ]]; then |
227 |
- if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then |
228 |
- KV_PATCH_ARR=(${KV_PATCH//\./ }) |
229 |
- |
230 |
- # at this point 080811, Linus is putting 3.1 kernels in 3.0 directory |
231 |
- # revisit when 3.1 is released |
232 |
- if [[ ${KV_PATCH} -gt 0 ]]; then |
233 |
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))" |
234 |
- else |
235 |
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}" |
236 |
- fi |
237 |
- # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}" |
238 |
- [[ -n "${K_LONGTERM}" ]] && |
239 |
- KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}" |
240 |
- else |
241 |
- #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0" |
242 |
- #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}" |
243 |
- if [[ ${KV_MAJOR} -ge 3 ]]; then |
244 |
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x" |
245 |
- else |
246 |
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}" |
247 |
- fi |
248 |
- |
249 |
- [[ -n "${K_LONGTERM}" ]] && |
250 |
- #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm" |
251 |
- KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" |
252 |
- fi |
253 |
- |
254 |
- debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}" |
255 |
- |
256 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then |
257 |
- # handle non genpatch using sources correctly |
258 |
- if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then |
259 |
- KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.bz2" |
260 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2" |
261 |
- fi |
262 |
- KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2" |
263 |
- else |
264 |
- KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
265 |
- fi |
266 |
- |
267 |
- RELEASE=${CKV/${OKV}} |
268 |
- RELEASE=${RELEASE/_beta} |
269 |
- RELEASE=${RELEASE/_rc/-rc} |
270 |
- RELEASE=${RELEASE/_pre/-pre} |
271 |
- # We cannot trivally call kernel_is here, because it calls us to detect the |
272 |
- # version |
273 |
- #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git} |
274 |
- [ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git} |
275 |
- RELEASETYPE=${RELEASE//[0-9]} |
276 |
- |
277 |
- # Now we know that RELEASE is the -rc/-git |
278 |
- # and RELEASETYPE is the same but with its numerics stripped |
279 |
- # we can work on better sorting EXTRAVERSION. |
280 |
- # first of all, we add the release |
281 |
- EXTRAVERSION="${RELEASE}" |
282 |
- debug-print "0 EXTRAVERSION:${EXTRAVERSION}" |
283 |
- [[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}" |
284 |
- |
285 |
- debug-print "1 EXTRAVERSION:${EXTRAVERSION}" |
286 |
- if [[ -n "${K_NOUSEPR}" ]]; then |
287 |
- # Don't add anything based on PR to EXTRAVERSION |
288 |
- debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}" |
289 |
- elif [[ -n ${K_PREPATCHED} ]]; then |
290 |
- debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}" |
291 |
- EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}" |
292 |
- elif [[ "${ETYPE}" = "sources" ]]; then |
293 |
- debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}" |
294 |
- # For some sources we want to use the PV in the extra version |
295 |
- # This is because upstream releases with a completely different |
296 |
- # versioning scheme. |
297 |
- case ${PN/-*} in |
298 |
- wolk) K_USEPV=1;; |
299 |
- vserver) K_USEPV=1;; |
300 |
- esac |
301 |
- |
302 |
- [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}" |
303 |
- [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}" |
304 |
- [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}" |
305 |
- fi |
306 |
- debug-print "2 EXTRAVERSION:${EXTRAVERSION}" |
307 |
- |
308 |
- # The only messing around which should actually effect this is for KV_EXTRA |
309 |
- # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else |
310 |
- # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION |
311 |
- |
312 |
- if [[ -n ${KV_EXTRA} ]]; then |
313 |
- if [[ -n ${KV_MINOR} ]]; then |
314 |
- OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" |
315 |
- else |
316 |
- OKV="${KV_MAJOR}.${KV_PATCH}" |
317 |
- fi |
318 |
- KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.bz2 |
319 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
320 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2" |
321 |
- fi |
322 |
- |
323 |
- # We need to set this using OKV, but we need to set it before we do any |
324 |
- # messing around with OKV based on RELEASETYPE |
325 |
- KV_FULL=${OKV}${EXTRAVERSION} |
326 |
- |
327 |
- # we will set this for backwards compatibility. |
328 |
- S=${WORKDIR}/linux-${KV_FULL} |
329 |
- KV=${KV_FULL} |
330 |
- |
331 |
- # -rc-git pulls can be achieved by specifying CKV |
332 |
- # for example: |
333 |
- # CKV="2.6.11_rc3_pre2" |
334 |
- # will pull: |
335 |
- # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2 |
336 |
- |
337 |
- if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then |
338 |
- |
339 |
- if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then |
340 |
- OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" |
341 |
- KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2 |
342 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
343 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2" |
344 |
- fi |
345 |
- |
346 |
- if [[ ${RELEASETYPE} == -git ]]; then |
347 |
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2 |
348 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
349 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2" |
350 |
- fi |
351 |
- |
352 |
- if [[ ${RELEASETYPE} == -rc-git ]]; then |
353 |
- OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" |
354 |
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 |
355 |
- ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 |
356 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
357 |
- |
358 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2" |
359 |
- fi |
360 |
- else |
361 |
- if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then |
362 |
- if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then |
363 |
- OKV="2.6.39" |
364 |
- else |
365 |
- KV_PATCH_ARR=(${KV_PATCH//\./ }) |
366 |
- OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))" |
367 |
- fi |
368 |
- KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2 |
369 |
- ${KERNEL_BASE_URI}/testing/linux-${OKV}.tar.bz2" |
370 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2" |
371 |
- fi |
372 |
- |
373 |
- if [[ ${RELEASETYPE} == -git ]]; then |
374 |
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2 |
375 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
376 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2" |
377 |
- fi |
378 |
- |
379 |
- if [[ ${RELEASETYPE} == -rc-git ]]; then |
380 |
- if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then |
381 |
- OKV="2.6.39" |
382 |
- else |
383 |
- KV_PATCH_ARR=(${KV_PATCH//\./ }) |
384 |
- OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))" |
385 |
- fi |
386 |
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2 |
387 |
- ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2 |
388 |
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" |
389 |
- |
390 |
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2" |
391 |
- fi |
392 |
- |
393 |
- |
394 |
- fi |
395 |
- |
396 |
- |
397 |
- debug-print-kernel2-variables |
398 |
- |
399 |
- handle_genpatches |
400 |
-} |
401 |
- |
402 |
-# Note: duplicated in linux-info.eclass |
403 |
-kernel_is() { |
404 |
- # ALL of these should be set before we can safely continue this function. |
405 |
- # some of the sources have in the past had only one set. |
406 |
- local v n=0 |
407 |
- for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done |
408 |
- [[ $n -eq 1 ]] && detect_version |
409 |
- unset v n |
410 |
- |
411 |
- # Now we can continue |
412 |
- local operator test value |
413 |
- |
414 |
- case ${1#-} in |
415 |
- lt) operator="-lt"; shift;; |
416 |
- gt) operator="-gt"; shift;; |
417 |
- le) operator="-le"; shift;; |
418 |
- ge) operator="-ge"; shift;; |
419 |
- eq) operator="-eq"; shift;; |
420 |
- *) operator="-eq";; |
421 |
- esac |
422 |
- [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters" |
423 |
- |
424 |
- : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH )) |
425 |
- : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} )) |
426 |
- [ ${test} ${operator} ${value} ] |
427 |
-} |
428 |
- |
429 |
-kernel_is_2_4() { |
430 |
- kernel_is 2 4 |
431 |
-} |
432 |
- |
433 |
-kernel_is_2_6() { |
434 |
- kernel_is 2 6 || kernel_is 2 5 |
435 |
-} |
436 |
- |
437 |
-# Capture the sources type and set DEPENDs |
438 |
-if [[ ${ETYPE} == sources ]]; then |
439 |
- DEPEND="!build? ( sys-apps/sed |
440 |
- >=sys-devel/binutils-2.11.90.0.31 )" |
441 |
- RDEPEND="!build? ( >=sys-libs/ncurses-5.2 |
442 |
- sys-devel/make )" |
443 |
- |
444 |
- SLOT="${PVR}" |
445 |
- DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR:-$KV_PATCH} linux kernel" |
446 |
- IUSE="symlink build" |
447 |
- |
448 |
- # Bug #266157, deblob for libre support |
449 |
- if [[ -z ${K_PREDEBLOBBED} ]] ; then |
450 |
- # Bug #359865, force a call to detect_version if needed |
451 |
- kernel_is ge 2 6 27 && \ |
452 |
- [[ -z "${K_DEBLOB_AVAILABLE}" ]] && \ |
453 |
- kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \ |
454 |
- K_DEBLOB_AVAILABLE=1 |
455 |
- if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then |
456 |
- IUSE="${IUSE} deblob" |
457 |
- # Reflect that kernels contain firmware blobs unless otherwise |
458 |
- # stripped |
459 |
- LICENSE="${LICENSE} !deblob? ( freedist )" |
460 |
- |
461 |
- if [[ -n KV_MINOR ]]; then |
462 |
- DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" |
463 |
- else |
464 |
- DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}" |
465 |
- fi |
466 |
- |
467 |
- if [[ ${KV_MAJOR} -ge 3 ]]; then |
468 |
- DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}" |
469 |
- fi |
470 |
- |
471 |
- DEBLOB_A="deblob-${DEBLOB_PV}" |
472 |
- DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}" |
473 |
- DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/" |
474 |
- DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N" |
475 |
- if ! has "${EAPI:-0}" 0 1 ; then |
476 |
- DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}" |
477 |
- else |
478 |
- DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}" |
479 |
- fi |
480 |
- DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}" |
481 |
- HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}" |
482 |
- |
483 |
- KERNEL_URI="${KERNEL_URI} |
484 |
- deblob? ( |
485 |
- ${DEBLOB_URI} |
486 |
- ${DEBLOB_CHECK_URI} |
487 |
- )" |
488 |
- else |
489 |
- # We have no way to deblob older kernels, so just mark them as |
490 |
- # tainted with non-libre materials. |
491 |
- LICENSE="${LICENSE} freedist" |
492 |
- fi |
493 |
- fi |
494 |
- |
495 |
-elif [[ ${ETYPE} == headers ]]; then |
496 |
- DESCRIPTION="Linux system headers" |
497 |
- |
498 |
- # Since we should NOT honour KBUILD_OUTPUT in headers |
499 |
- # lets unset it here. |
500 |
- unset KBUILD_OUTPUT |
501 |
- |
502 |
- SLOT="0" |
503 |
-else |
504 |
- eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" |
505 |
- die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" |
506 |
-fi |
507 |
- |
508 |
-# Cross-compile support functions |
509 |
-#============================================================== |
510 |
-kernel_header_destdir() { |
511 |
- [[ ${CTARGET} == ${CHOST} ]] \ |
512 |
- && echo /usr/include \ |
513 |
- || echo /usr/${CTARGET}/usr/include |
514 |
-} |
515 |
- |
516 |
-cross_pre_c_headers() { |
517 |
- use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]] |
518 |
-} |
519 |
- |
520 |
-env_setup_xmakeopts() { |
521 |
- # Kernel ARCH != portage ARCH |
522 |
- export KARCH=$(tc-arch-kernel) |
523 |
- |
524 |
- # When cross-compiling, we need to set the ARCH/CROSS_COMPILE |
525 |
- # variables properly or bad things happen ! |
526 |
- xmakeopts="ARCH=${KARCH}" |
527 |
- if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then |
528 |
- xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-" |
529 |
- elif type -p ${CHOST}-ar > /dev/null ; then |
530 |
- xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-" |
531 |
- fi |
532 |
- export xmakeopts |
533 |
-} |
534 |
- |
535 |
-# Unpack functions |
536 |
-#============================================================== |
537 |
-unpack_2_4() { |
538 |
- # this file is required for other things to build properly, |
539 |
- # so we autogenerate it |
540 |
- make -s mrproper ${xmakeopts} || die "make mrproper failed" |
541 |
- make -s symlinks ${xmakeopts} || die "make symlinks failed" |
542 |
- make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" |
543 |
- echo ">>> version.h compiled successfully." |
544 |
-} |
545 |
- |
546 |
-unpack_2_6() { |
547 |
- # this file is required for other things to build properly, so we |
548 |
- # autogenerate it ... generate a .config to keep version.h build from |
549 |
- # spitting out an annoying warning |
550 |
- make -s mrproper ${xmakeopts} 2>/dev/null \ |
551 |
- || die "make mrproper failed" |
552 |
- |
553 |
- # quick fix for bug #132152 which triggers when it cannot include linux |
554 |
- # headers (ie, we have not installed it yet) |
555 |
- if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then |
556 |
- touch .config |
557 |
- eerror "make defconfig failed." |
558 |
- eerror "assuming you dont have any headers installed yet and continuing" |
559 |
- epause 5 |
560 |
- fi |
561 |
- |
562 |
- make -s include/linux/version.h ${xmakeopts} 2>/dev/null \ |
563 |
- || die "make include/linux/version.h failed" |
564 |
- rm -f .config >/dev/null |
565 |
-} |
566 |
- |
567 |
-universal_unpack() { |
568 |
- debug-print "Inside universal_unpack" |
569 |
- |
570 |
- local OKV_ARRAY |
571 |
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}" |
572 |
- |
573 |
- cd "${WORKDIR}" |
574 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then |
575 |
- unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2 |
576 |
- else |
577 |
- unpack linux-${OKV}.tar.bz2 |
578 |
- fi |
579 |
- |
580 |
- if [[ -d "linux" ]]; then |
581 |
- debug-print "Moving linux to linux-${KV_FULL}" |
582 |
- mv linux linux-${KV_FULL} \ |
583 |
- || die "Unable to move source tree to ${KV_FULL}." |
584 |
- elif [[ "${OKV}" != "${KV_FULL}" ]]; then |
585 |
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] && |
586 |
- [[ "${ETYPE}" = "sources" ]]; then |
587 |
- debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} " |
588 |
- mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \ |
589 |
- || die "Unable to move source tree to ${KV_FULL}." |
590 |
- else |
591 |
- debug-print "moving linux-${OKV} to linux-${KV_FULL} " |
592 |
- mv linux-${OKV} linux-${KV_FULL} \ |
593 |
- || die "Unable to move source tree to ${KV_FULL}." |
594 |
- fi |
595 |
- elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then |
596 |
- mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \ |
597 |
- || die "Unable to move source tree to ${KV_FULL}." |
598 |
- fi |
599 |
- cd "${S}" |
600 |
- |
601 |
- # remove all backup files |
602 |
- find . -iname "*~" -exec rm {} \; 2> /dev/null |
603 |
- |
604 |
- # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox |
605 |
- # only do this for kernel < 2.6.27 since this file does not exist in later |
606 |
- # kernels |
607 |
- if [[ -n ${KV_MINOR} && ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] |
608 |
- then |
609 |
- sed -i \ |
610 |
- -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \ |
611 |
- "${S}"/arch/ppc/Makefile |
612 |
- else |
613 |
- sed -i \ |
614 |
- -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \ |
615 |
- "${S}"/arch/powerpc/Makefile |
616 |
- fi |
617 |
-} |
618 |
- |
619 |
-unpack_set_extraversion() { |
620 |
- cd "${S}" |
621 |
- sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile |
622 |
- cd "${OLDPWD}" |
623 |
-} |
624 |
- |
625 |
-# Should be done after patches have been applied |
626 |
-# Otherwise patches that modify the same area of Makefile will fail |
627 |
-unpack_fix_install_path() { |
628 |
- cd "${S}" |
629 |
- sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile |
630 |
-} |
631 |
- |
632 |
-# Compile Functions |
633 |
-#============================================================== |
634 |
-compile_headers() { |
635 |
- env_setup_xmakeopts |
636 |
- |
637 |
- # if we couldnt obtain HOSTCFLAGS from the Makefile, |
638 |
- # then set it to something sane |
639 |
- local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile) |
640 |
- HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer} |
641 |
- |
642 |
- if kernel_is 2 4; then |
643 |
- yes "" | make oldconfig ${xmakeopts} |
644 |
- echo ">>> make oldconfig complete" |
645 |
- make dep ${xmakeopts} |
646 |
- elif kernel_is 2 6; then |
647 |
- # 2.6.18 introduces headers_install which means we dont need any |
648 |
- # of this crap anymore :D |
649 |
- kernel_is ge 2 6 18 && return 0 |
650 |
- |
651 |
- # autoconf.h isnt generated unless it already exists. plus, we have |
652 |
- # no guarantee that any headers are installed on the system... |
653 |
- [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \ |
654 |
- || touch include/linux/autoconf.h |
655 |
- |
656 |
- # if K_DEFCONFIG isn't set, force to "defconfig" |
657 |
- # needed by mips |
658 |
- if [[ -z ${K_DEFCONFIG} ]]; then |
659 |
- if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then |
660 |
- case ${CTARGET} in |
661 |
- powerpc64*) K_DEFCONFIG="ppc64_defconfig";; |
662 |
- powerpc*) K_DEFCONFIG="pmac32_defconfig";; |
663 |
- *) K_DEFCONFIG="defconfig";; |
664 |
- esac |
665 |
- else |
666 |
- K_DEFCONFIG="defconfig" |
667 |
- fi |
668 |
- fi |
669 |
- |
670 |
- # if there arent any installed headers, then there also isnt an asm |
671 |
- # symlink in /usr/include/, and make defconfig will fail, so we have |
672 |
- # to force an include path with $S. |
673 |
- HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/" |
674 |
- ln -sf asm-${KARCH} "${S}"/include/asm |
675 |
- cross_pre_c_headers && return 0 |
676 |
- |
677 |
- make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})" |
678 |
- if compile_headers_tweak_config ; then |
679 |
- yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed" |
680 |
- fi |
681 |
- make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" |
682 |
- make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" |
683 |
- fi |
684 |
-} |
685 |
- |
686 |
-compile_headers_tweak_config() { |
687 |
- # some targets can be very very picky, so let's finesse the |
688 |
- # .config based upon any info we may have |
689 |
- case ${CTARGET} in |
690 |
- sh*) |
691 |
- sed -i '/CONFIG_CPU_SH/d' .config |
692 |
- echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config |
693 |
- return 0;; |
694 |
- esac |
695 |
- |
696 |
- # no changes, so lets do nothing |
697 |
- return 1 |
698 |
-} |
699 |
- |
700 |
-# install functions |
701 |
-#============================================================== |
702 |
-install_universal() { |
703 |
- #fix silly permissions in tarball |
704 |
- cd "${WORKDIR}" |
705 |
- chown -R root:0 * >& /dev/null |
706 |
- chmod -R a+r-w+X,u+w * |
707 |
- cd ${OLDPWD} |
708 |
-} |
709 |
- |
710 |
-install_headers() { |
711 |
- local ddir=$(kernel_header_destdir) |
712 |
- |
713 |
- # 2.6.18 introduces headers_install which means we dont need any |
714 |
- # of this crap anymore :D |
715 |
- if kernel_is ge 2 6 18 ; then |
716 |
- env_setup_xmakeopts |
717 |
- emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die |
718 |
- |
719 |
- # let other packages install some of these headers |
720 |
- rm -rf "${D}"/${ddir}/sound #alsa-headers |
721 |
- rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc... |
722 |
- return 0 |
723 |
- fi |
724 |
- |
725 |
- # Do not use "linux/*" as that can cause problems with very long |
726 |
- # $S values where the cmdline to cp is too long |
727 |
- pushd "${S}" >/dev/null |
728 |
- dodir ${ddir}/linux |
729 |
- cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die |
730 |
- rm -rf "${D}"/${ddir}/linux/modules |
731 |
- |
732 |
- dodir ${ddir}/asm |
733 |
- cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm |
734 |
- |
735 |
- if kernel_is 2 6 ; then |
736 |
- dodir ${ddir}/asm-generic |
737 |
- cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic |
738 |
- fi |
739 |
- |
740 |
- # clean up |
741 |
- find "${D}" -name '*.orig' -exec rm -f {} \; |
742 |
- |
743 |
- popd >/dev/null |
744 |
-} |
745 |
- |
746 |
-install_sources() { |
747 |
- local file |
748 |
- |
749 |
- cd "${S}" |
750 |
- dodir /usr/src |
751 |
- echo ">>> Copying sources ..." |
752 |
- |
753 |
- file="$(find ${WORKDIR} -iname "docs" -type d)" |
754 |
- if [[ -n ${file} ]]; then |
755 |
- for file in $(find ${file} -type f); do |
756 |
- echo "${file//*docs\/}" >> "${S}"/patches.txt |
757 |
- echo "===================================================" >> "${S}"/patches.txt |
758 |
- cat ${file} >> "${S}"/patches.txt |
759 |
- echo "===================================================" >> "${S}"/patches.txt |
760 |
- echo "" >> "${S}"/patches.txt |
761 |
- done |
762 |
- fi |
763 |
- |
764 |
- if [[ ! -f ${S}/patches.txt ]]; then |
765 |
- # patches.txt is empty so lets use our ChangeLog |
766 |
- [[ -f ${FILESDIR}/../ChangeLog ]] && \ |
767 |
- echo "Please check the ebuild ChangeLog for more details." \ |
768 |
- > "${S}"/patches.txt |
769 |
- fi |
770 |
- |
771 |
- mv ${WORKDIR}/linux* "${D}"/usr/src |
772 |
-} |
773 |
- |
774 |
-# pkg_preinst functions |
775 |
-#============================================================== |
776 |
-preinst_headers() { |
777 |
- local ddir=$(kernel_header_destdir) |
778 |
- [[ -L ${ddir}/linux ]] && rm ${ddir}/linux |
779 |
- [[ -L ${ddir}/asm ]] && rm ${ddir}/asm |
780 |
-} |
781 |
- |
782 |
-# pkg_postinst functions |
783 |
-#============================================================== |
784 |
-postinst_sources() { |
785 |
- local MAKELINK=0 |
786 |
- |
787 |
- # if we have USE=symlink, then force K_SYMLINK=1 |
788 |
- use symlink && K_SYMLINK=1 |
789 |
- |
790 |
- # if we're using a deblobbed kernel, it's not supported |
791 |
- [[ $K_DEBLOB_AVAILABLE == 1 ]] && \ |
792 |
- use deblob && \ |
793 |
- K_SECURITY_UNSUPPORTED=deblob |
794 |
- |
795 |
- # if we are to forcably symlink, delete it if it already exists first. |
796 |
- if [[ ${K_SYMLINK} > 0 ]]; then |
797 |
- [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux |
798 |
- MAKELINK=1 |
799 |
- fi |
800 |
- |
801 |
- # if the link doesnt exist, lets create it |
802 |
- [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 |
803 |
- |
804 |
- if [[ ${MAKELINK} == 1 ]]; then |
805 |
- cd "${ROOT}"usr/src |
806 |
- ln -sf linux-${KV_FULL} linux |
807 |
- cd ${OLDPWD} |
808 |
- fi |
809 |
- |
810 |
- # Don't forget to make directory for sysfs |
811 |
- [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys |
812 |
- |
813 |
- echo |
814 |
- elog "If you are upgrading from a previous kernel, you may be interested" |
815 |
- elog "in the following document:" |
816 |
- elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml" |
817 |
- echo |
818 |
- |
819 |
- # if K_EXTRAEINFO is set then lets display it now |
820 |
- if [[ -n ${K_EXTRAEINFO} ]]; then |
821 |
- echo ${K_EXTRAEINFO} | fmt | |
822 |
- while read -s ELINE; do einfo "${ELINE}"; done |
823 |
- fi |
824 |
- |
825 |
- # if K_EXTRAELOG is set then lets display it now |
826 |
- if [[ -n ${K_EXTRAELOG} ]]; then |
827 |
- echo ${K_EXTRAELOG} | fmt | |
828 |
- while read -s ELINE; do elog "${ELINE}"; done |
829 |
- fi |
830 |
- |
831 |
- # if K_EXTRAEWARN is set then lets display it now |
832 |
- if [[ -n ${K_EXTRAEWARN} ]]; then |
833 |
- echo ${K_EXTRAEWARN} | fmt | |
834 |
- while read -s ELINE; do ewarn "${ELINE}"; done |
835 |
- fi |
836 |
- |
837 |
- # optionally display security unsupported message |
838 |
- # Start with why |
839 |
- if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then |
840 |
- ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security." |
841 |
- elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then |
842 |
- ewarn "${PN} is UNSUPPORTED by Gentoo Security." |
843 |
- fi |
844 |
- # And now the general message. |
845 |
- if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then |
846 |
- ewarn "This means that it is likely to be vulnerable to recent security issues." |
847 |
- ewarn "For specific information on why this kernel is unsupported, please read:" |
848 |
- ewarn "http://www.gentoo.org/proj/en/security/kernel.xml" |
849 |
- fi |
850 |
- |
851 |
- # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765) |
852 |
- KV_MAJOR=$(get_version_component_range 1 ${OKV}) |
853 |
- KV_MINOR=$(get_version_component_range 2 ${OKV}) |
854 |
- KV_PATCH=$(get_version_component_range 3 ${OKV}) |
855 |
- if [[ "$(tc-arch)" = "sparc" ]]; then |
856 |
- if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] |
857 |
- then |
858 |
- echo |
859 |
- elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that" |
860 |
- elog "you now need to do" |
861 |
- elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-" |
862 |
- elog "instead of just" |
863 |
- elog " make" |
864 |
- elog "to compile the kernel. For more information please browse to" |
865 |
- elog "https://bugs.gentoo.org/show_bug.cgi?id=214765" |
866 |
- echo |
867 |
- fi |
868 |
- fi |
869 |
-} |
870 |
- |
871 |
-# pkg_setup functions |
872 |
-#============================================================== |
873 |
-setup_headers() { |
874 |
- [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/} |
875 |
- for i in ${H_SUPPORTEDARCH}; do |
876 |
- [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes" |
877 |
- done |
878 |
- |
879 |
- if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then |
880 |
- echo |
881 |
- eerror "This version of ${PN} does not support $(tc-arch)." |
882 |
- eerror "Please merge the appropriate sources, in most cases" |
883 |
- eerror "(but not all) this will be called $(tc-arch)-headers." |
884 |
- die "Package unsupported for $(tc-arch)" |
885 |
- fi |
886 |
-} |
887 |
- |
888 |
-# unipatch |
889 |
-#============================================================== |
890 |
-unipatch() { |
891 |
- local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE |
892 |
- local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG |
893 |
- |
894 |
- # set to a standard locale to ensure sorts are ordered properly. |
895 |
- myLC_ALL="${LC_ALL}" |
896 |
- myLANG="${LANG}" |
897 |
- LC_ALL="C" |
898 |
- LANG="" |
899 |
- |
900 |
- [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" |
901 |
- [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} |
902 |
- |
903 |
- # We're gonna need it when doing patches with a predefined patchlevel |
904 |
- eshopts_push -s extglob |
905 |
- |
906 |
- # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers |
907 |
- # usage can be either via an env var or by params |
908 |
- # although due to the nature we pass this within this eclass |
909 |
- # it shall be by param only. |
910 |
- # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" |
911 |
- UNIPATCH_LIST="${@}" |
912 |
- |
913 |
- #unpack any passed tarballs |
914 |
- for i in ${UNIPATCH_LIST}; do |
915 |
- if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then |
916 |
- if [ -n "${UNIPATCH_STRICTORDER}" ]; then |
917 |
- unset z |
918 |
- STRICT_COUNT=$((10#${STRICT_COUNT} + 1)) |
919 |
- for((y=0; y<$((6 - ${#STRICT_COUNT})); y++)); |
920 |
- do z="${z}0"; |
921 |
- done |
922 |
- PATCH_ORDER="${z}${STRICT_COUNT}" |
923 |
- |
924 |
- mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}" |
925 |
- pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null |
926 |
- unpack ${i##*/} |
927 |
- popd >/dev/null |
928 |
- else |
929 |
- pushd "${KPATCH_DIR}" >/dev/null |
930 |
- unpack ${i##*/} |
931 |
- popd >/dev/null |
932 |
- fi |
933 |
- |
934 |
- [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets" |
935 |
- else |
936 |
- extention=${i/*./} |
937 |
- extention=${extention/:*/} |
938 |
- PIPE_CMD="" |
939 |
- case ${extention} in |
940 |
- xz) PIPE_CMD="xz -dc";; |
941 |
- lzma) PIPE_CMD="lzma -dc";; |
942 |
- bz2) PIPE_CMD="bzip2 -dc";; |
943 |
- patch) PIPE_CMD="cat";; |
944 |
- diff) PIPE_CMD="cat";; |
945 |
- gz|Z|z) PIPE_CMD="gzip -dc";; |
946 |
- ZIP|zip) PIPE_CMD="unzip -p";; |
947 |
- *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";; |
948 |
- esac |
949 |
- |
950 |
- PATCH_LEVEL=${i/*([^:])?(:)} |
951 |
- i=${i/:*/} |
952 |
- x=${i/*\//} |
953 |
- x=${x/\.${extention}/} |
954 |
- |
955 |
- if [ -n "${PIPE_CMD}" ]; then |
956 |
- if [ ! -r "${i}" ]; then |
957 |
- echo |
958 |
- eerror "FATAL: unable to locate:" |
959 |
- eerror "${i}" |
960 |
- eerror "for read-only. The file either has incorrect permissions" |
961 |
- eerror "or does not exist." |
962 |
- die Unable to locate ${i} |
963 |
- fi |
964 |
- |
965 |
- if [ -n "${UNIPATCH_STRICTORDER}" ]; then |
966 |
- unset z |
967 |
- STRICT_COUNT=$((10#${STRICT_COUNT} + 1)) |
968 |
- for((y=0; y<$((6 - ${#STRICT_COUNT})); y++)); |
969 |
- do z="${z}0"; |
970 |
- done |
971 |
- PATCH_ORDER="${z}${STRICT_COUNT}" |
972 |
- |
973 |
- mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/ |
974 |
- $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed" |
975 |
- else |
976 |
- $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed" |
977 |
- fi |
978 |
- fi |
979 |
- fi |
980 |
- done |
981 |
- |
982 |
- #populate KPATCH_DIRS so we know where to look to remove the excludes |
983 |
- x=${KPATCH_DIR} |
984 |
- KPATCH_DIR="" |
985 |
- for i in $(find ${x} -type d | sort -n); do |
986 |
- KPATCH_DIR="${KPATCH_DIR} ${i}" |
987 |
- done |
988 |
- |
989 |
- # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot |
990 |
- # bug #272676 |
991 |
- if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then |
992 |
- if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then |
993 |
- UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch" |
994 |
- echo |
995 |
- ewarn "fbcondecor currently prevents sparc/sparc64 from booting" |
996 |
- ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch." |
997 |
- ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details" |
998 |
- echo |
999 |
- fi |
1000 |
- fi |
1001 |
- |
1002 |
- #so now lets get rid of the patchno's we want to exclude |
1003 |
- UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}" |
1004 |
- for i in ${UNIPATCH_DROP}; do |
1005 |
- ebegin "Excluding Patch #${i}" |
1006 |
- for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done |
1007 |
- eend $? |
1008 |
- done |
1009 |
- |
1010 |
- # and now, finally, we patch it :) |
1011 |
- for x in ${KPATCH_DIR}; do |
1012 |
- for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do |
1013 |
- STDERR_T="${T}/${i/*\//}" |
1014 |
- STDERR_T="${STDERR_T/.patch*/.err}" |
1015 |
- |
1016 |
- [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/} |
1017 |
- #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/} |
1018 |
- |
1019 |
- if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi |
1020 |
- |
1021 |
- ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)" |
1022 |
- while [ ${PATCH_DEPTH} -lt 5 ]; do |
1023 |
- echo "Attempting Dry-run:" >> ${STDERR_T} |
1024 |
- echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T} |
1025 |
- echo "=======================================================" >> ${STDERR_T} |
1026 |
- if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then |
1027 |
- echo "Attempting patch:" > ${STDERR_T} |
1028 |
- echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T} |
1029 |
- echo "=======================================================" >> ${STDERR_T} |
1030 |
- if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then |
1031 |
- eend 0 |
1032 |
- rm ${STDERR_T} |
1033 |
- break |
1034 |
- else |
1035 |
- eend 1 |
1036 |
- eerror "Failed to apply patch ${i/*\//}" |
1037 |
- eerror "Please attach ${STDERR_T} to any bug you may post." |
1038 |
- eshopts_pop |
1039 |
- die "Failed to apply ${i/*\//}" |
1040 |
- fi |
1041 |
- else |
1042 |
- PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) |
1043 |
- fi |
1044 |
- done |
1045 |
- if [ ${PATCH_DEPTH} -eq 5 ]; then |
1046 |
- eend 1 |
1047 |
- eerror "Please attach ${STDERR_T} to any bug you may post." |
1048 |
- eshopts_pop |
1049 |
- die "Unable to dry-run patch." |
1050 |
- fi |
1051 |
- done |
1052 |
- done |
1053 |
- |
1054 |
- # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which |
1055 |
- # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite, |
1056 |
- # which is why I'm not taking too much time over this. |
1057 |
- local tmp |
1058 |
- for i in ${UNIPATCH_DOCS}; do |
1059 |
- tmp="${tmp} ${i//*\/}" |
1060 |
- cp -f ${i} "${T}"/ |
1061 |
- done |
1062 |
- UNIPATCH_DOCS="${tmp}" |
1063 |
- |
1064 |
- # clean up KPATCH_DIR's - fixes bug #53610 |
1065 |
- for x in ${KPATCH_DIR}; do rm -Rf ${x}; done |
1066 |
- |
1067 |
- LC_ALL="${myLC_ALL}" |
1068 |
- LANG="${myLANG}" |
1069 |
- eshopts_pop |
1070 |
-} |
1071 |
- |
1072 |
-# getfilevar accepts 2 vars as follows: |
1073 |
-# getfilevar <VARIABLE> <CONFIGFILE> |
1074 |
-# pulled from linux-info |
1075 |
- |
1076 |
-getfilevar() { |
1077 |
- local workingdir basefname basedname xarch=$(tc-arch-kernel) |
1078 |
- |
1079 |
- if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then |
1080 |
- echo -e "\n" |
1081 |
- eerror "getfilevar requires 2 variables, with the second a valid file." |
1082 |
- eerror " getfilevar <VARIABLE> <CONFIGFILE>" |
1083 |
- else |
1084 |
- workingdir=${PWD} |
1085 |
- basefname=$(basename ${2}) |
1086 |
- basedname=$(dirname ${2}) |
1087 |
- unset ARCH |
1088 |
- |
1089 |
- cd ${basedname} |
1090 |
- echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \ |
1091 |
- make ${BUILD_FIXES} -s -f - e 2>/dev/null |
1092 |
- cd ${workingdir} |
1093 |
- |
1094 |
- ARCH=${xarch} |
1095 |
- fi |
1096 |
-} |
1097 |
- |
1098 |
-detect_arch() { |
1099 |
- # This function sets ARCH_URI and ARCH_PATCH |
1100 |
- # with the neccessary info for the arch sepecific compatibility |
1101 |
- # patchsets. |
1102 |
- |
1103 |
- local ALL_ARCH LOOP_ARCH COMPAT_URI i |
1104 |
- |
1105 |
- # COMPAT_URI is the contents of ${ARCH}_URI |
1106 |
- # ARCH_URI is the URI for all the ${ARCH}_URI patches |
1107 |
- # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH |
1108 |
- |
1109 |
- ARCH_URI="" |
1110 |
- ARCH_PATCH="" |
1111 |
- ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86" |
1112 |
- |
1113 |
- for LOOP_ARCH in ${ALL_ARCH}; do |
1114 |
- COMPAT_URI="${LOOP_ARCH}_URI" |
1115 |
- COMPAT_URI="${!COMPAT_URI}" |
1116 |
- |
1117 |
- [[ -n ${COMPAT_URI} ]] && \ |
1118 |
- ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )" |
1119 |
- |
1120 |
- if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then |
1121 |
- for i in ${COMPAT_URI}; do |
1122 |
- ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}" |
1123 |
- done |
1124 |
- fi |
1125 |
- done |
1126 |
-} |
1127 |
- |
1128 |
-headers___fix() { |
1129 |
- # Voodoo to partially fix broken upstream headers. |
1130 |
- # note: do not put inline/asm/volatile together (breaks "inline asm volatile") |
1131 |
- sed -i \ |
1132 |
- -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \ |
1133 |
- -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \ |
1134 |
- -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \ |
1135 |
- -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \ |
1136 |
- -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \ |
1137 |
- "$@" |
1138 |
-} |
1139 |
- |
1140 |
-# common functions |
1141 |
-#============================================================== |
1142 |
-kernel-2_src_unpack() { |
1143 |
- universal_unpack |
1144 |
- debug-print "Doing unipatch" |
1145 |
- |
1146 |
- [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \ |
1147 |
- unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}" |
1148 |
- |
1149 |
- debug-print "Doing premake" |
1150 |
- |
1151 |
- # allow ebuilds to massage the source tree after patching but before |
1152 |
- # we run misc `make` functions below |
1153 |
- [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake |
1154 |
- |
1155 |
- debug-print "Doing epatch_user" |
1156 |
- epatch_user |
1157 |
- |
1158 |
- debug-print "Doing unpack_set_extraversion" |
1159 |
- |
1160 |
- [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion |
1161 |
- unpack_fix_install_path |
1162 |
- |
1163 |
- # Setup xmakeopts and cd into sourcetree. |
1164 |
- env_setup_xmakeopts |
1165 |
- cd "${S}" |
1166 |
- |
1167 |
- # We dont need a version.h for anything other than headers |
1168 |
- # at least, I should hope we dont. If this causes problems |
1169 |
- # take out the if/fi block and inform me please. |
1170 |
- # unpack_2_6 should now be 2.6.17 safe anyways |
1171 |
- if [[ ${ETYPE} == headers ]]; then |
1172 |
- kernel_is 2 4 && unpack_2_4 |
1173 |
- kernel_is 2 6 && unpack_2_6 |
1174 |
- fi |
1175 |
- |
1176 |
- if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then |
1177 |
- cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed" |
1178 |
- cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed" |
1179 |
- chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed" |
1180 |
- fi |
1181 |
-} |
1182 |
- |
1183 |
-kernel-2_src_compile() { |
1184 |
- cd "${S}" |
1185 |
- [[ ${ETYPE} == headers ]] && compile_headers |
1186 |
- |
1187 |
- if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then |
1188 |
- echo ">>> Running deblob script ..." |
1189 |
- sh "${T}/${DEBLOB_A}" --force || \ |
1190 |
- die "Deblob script failed to run!!!" |
1191 |
- fi |
1192 |
-} |
1193 |
- |
1194 |
-# if you leave it to the default src_test, it will run make to |
1195 |
-# find whether test/check targets are present; since "make test" |
1196 |
-# actually produces a few support files, they are installed even |
1197 |
-# though the package is binchecks-restricted. |
1198 |
-# |
1199 |
-# Avoid this altogether by making the function moot. |
1200 |
-kernel-2_src_test() { :; } |
1201 |
- |
1202 |
-kernel-2_pkg_preinst() { |
1203 |
- [[ ${ETYPE} == headers ]] && preinst_headers |
1204 |
-} |
1205 |
- |
1206 |
-kernel-2_src_install() { |
1207 |
- install_universal |
1208 |
- [[ ${ETYPE} == headers ]] && install_headers |
1209 |
- [[ ${ETYPE} == sources ]] && install_sources |
1210 |
-} |
1211 |
- |
1212 |
-kernel-2_pkg_postinst() { |
1213 |
- [[ ${ETYPE} == sources ]] && postinst_sources |
1214 |
-} |
1215 |
- |
1216 |
-kernel-2_pkg_setup() { |
1217 |
- if kernel_is 2 4; then |
1218 |
- if [[ $(gcc-major-version) -ge 4 ]] ; then |
1219 |
- echo |
1220 |
- ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!" |
1221 |
- ewarn "Either switch to another gcc-version (via gcc-config) or use a" |
1222 |
- ewarn "newer kernel that supports gcc-4." |
1223 |
- echo |
1224 |
- ewarn "Also be aware that bugreports about gcc-4 not working" |
1225 |
- ewarn "with linux-2.4 based ebuilds will be closed as INVALID!" |
1226 |
- echo |
1227 |
- epause 10 |
1228 |
- fi |
1229 |
- fi |
1230 |
- |
1231 |
- ABI="${KERNEL_ABI}" |
1232 |
- [[ ${ETYPE} == headers ]] && setup_headers |
1233 |
- [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." |
1234 |
-} |
1235 |
- |
1236 |
-kernel-2_pkg_postrm() { |
1237 |
- # This warning only makes sense for kernel sources. |
1238 |
- [[ ${ETYPE} == headers ]] && return 0 |
1239 |
- |
1240 |
- # If there isn't anything left behind, then don't complain. |
1241 |
- [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0 |
1242 |
- echo |
1243 |
- ewarn "Note: Even though you have successfully unmerged " |
1244 |
- ewarn "your kernel package, directories in kernel source location: " |
1245 |
- ewarn "${ROOT}usr/src/linux-${KV_FULL}" |
1246 |
- ewarn "with modified files will remain behind. By design, package managers" |
1247 |
- ewarn "will not remove these modified files and the directories they reside in." |
1248 |
- echo |
1249 |
-} |
1250 |
|
1251 |
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass |
1252 |
deleted file mode 100644 |
1253 |
index d4d8c3e..0000000 |
1254 |
--- a/eclass/toolchain.eclass |
1255 |
+++ /dev/null |
1256 |
@@ -1,2035 +0,0 @@ |
1257 |
-# Copyright 1999-2011 Gentoo Foundation |
1258 |
-# Distributed under the terms of the GNU General Public License v2 |
1259 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.514 2011/12/16 18:44:34 vapier Exp $ |
1260 |
-# |
1261 |
-# Maintainer: Toolchain Ninjas <toolchain@g.o> |
1262 |
- |
1263 |
-#---->> eclass stuff <<---- |
1264 |
-HOMEPAGE="http://gcc.gnu.org/" |
1265 |
-LICENSE="GPL-2 LGPL-2.1" |
1266 |
-RESTRICT="strip" # cross-compilers need controlled stripping |
1267 |
- |
1268 |
-inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails |
1269 |
- |
1270 |
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm |
1271 |
-DESCRIPTION="Based on the ${ECLASS} eclass" |
1272 |
- |
1273 |
-FEATURES=${FEATURES/multilib-strict/} |
1274 |
-#----<< eclass stuff >>---- |
1275 |
- |
1276 |
- |
1277 |
-#---->> globals <<---- |
1278 |
-export CTARGET=${CTARGET:-${CHOST}} |
1279 |
-if [[ ${CTARGET} = ${CHOST} ]] ; then |
1280 |
- if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then |
1281 |
- export CTARGET=${CATEGORY/cross-} |
1282 |
- fi |
1283 |
-fi |
1284 |
-is_crosscompile() { |
1285 |
- [[ ${CHOST} != ${CTARGET} ]] |
1286 |
-} |
1287 |
- |
1288 |
-tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" ; } |
1289 |
- |
1290 |
-GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}} |
1291 |
-GCC_PVR=${GCC_PV} |
1292 |
-[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR} |
1293 |
-GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV}) |
1294 |
-GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV}) |
1295 |
-GCCMAJOR=$(get_version_component_range 1 ${GCC_PV}) |
1296 |
-GCCMINOR=$(get_version_component_range 2 ${GCC_PV}) |
1297 |
-GCCMICRO=$(get_version_component_range 3 ${GCC_PV}) |
1298 |
-[[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV}) |
1299 |
- |
1300 |
-# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex. |
1301 |
-# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? |
1302 |
-GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})} |
1303 |
- |
1304 |
-# Pre-release support |
1305 |
-if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then |
1306 |
- PRERELEASE=${GCC_PV/_pre/-} |
1307 |
-fi |
1308 |
-# make _alpha and _beta ebuilds automatically use a snapshot |
1309 |
-if [[ ${GCC_PV} == *_alpha* ]] ; then |
1310 |
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha} |
1311 |
-elif [[ ${GCC_PV} == *_beta* ]] ; then |
1312 |
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta} |
1313 |
-elif [[ ${GCC_PV} == *_rc* ]] ; then |
1314 |
- SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc} |
1315 |
-fi |
1316 |
-export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}} |
1317 |
- |
1318 |
-PREFIX=${TOOLCHAIN_PREFIX:-/usr} |
1319 |
- |
1320 |
-if tc_version_is_at_least 3.4.0 ; then |
1321 |
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}} |
1322 |
-else |
1323 |
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}} |
1324 |
-fi |
1325 |
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include} |
1326 |
-if is_crosscompile ; then |
1327 |
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
1328 |
-else |
1329 |
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
1330 |
-fi |
1331 |
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}} |
1332 |
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory. |
1333 |
-# We will handle /usr/include/g++-v3/ with gcc-config ... |
1334 |
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}} |
1335 |
- |
1336 |
-#----<< globals >>---- |
1337 |
- |
1338 |
- |
1339 |
-#---->> SLOT+IUSE logic <<---- |
1340 |
-IUSE="build multislot nls nptl test vanilla" |
1341 |
- |
1342 |
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then |
1343 |
- IUSE+=" altivec cxx fortran nocxx" |
1344 |
- [[ -n ${PIE_VER} ]] && IUSE+=" nopie" |
1345 |
- [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking" |
1346 |
- [[ -n ${D_VER} ]] && IUSE+=" d" |
1347 |
- [[ -n ${SPECS_VER} ]] && IUSE+=" nossp" |
1348 |
- |
1349 |
- if tc_version_is_at_least 3 ; then |
1350 |
- IUSE+=" bootstrap doc gcj gtk hardened libffi multilib objc" |
1351 |
- |
1352 |
- tc_version_is_at_least "4.0" && IUSE+=" objc-gc mudflap" |
1353 |
- tc_version_is_at_least "4.1" && IUSE+=" libssp objc++" |
1354 |
- tc_version_is_at_least "4.2" && IUSE+=" openmp" |
1355 |
- tc_version_is_at_least "4.3" && IUSE+=" fixed-point" |
1356 |
- tc_version_is_at_least "4.4" && IUSE+=" graphite" |
1357 |
- [[ ${GCC_BRANCH_VER} == 4.5 ]] && IUSE+=" lto" |
1358 |
- tc_version_is_at_least "4.6" && IUSE+=" go" |
1359 |
- fi |
1360 |
-fi |
1361 |
- |
1362 |
-# Support upgrade paths here or people get pissed |
1363 |
-if use multislot ; then |
1364 |
- SLOT="${CTARGET}-${GCC_CONFIG_VER}" |
1365 |
-elif is_crosscompile; then |
1366 |
- SLOT="${CTARGET}-${GCC_BRANCH_VER}" |
1367 |
-else |
1368 |
- SLOT="${GCC_BRANCH_VER}" |
1369 |
-fi |
1370 |
-#----<< SLOT+IUSE logic >>---- |
1371 |
- |
1372 |
-#---->> DEPEND <<---- |
1373 |
- |
1374 |
-RDEPEND="sys-libs/zlib |
1375 |
- !build? ( |
1376 |
- nls? ( sys-devel/gettext ) |
1377 |
- )" |
1378 |
-if tc_version_is_at_least 3 ; then |
1379 |
- RDEPEND+=" virtual/libiconv" |
1380 |
-fi |
1381 |
-if tc_version_is_at_least 4 ; then |
1382 |
- GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2 >=dev-libs/mpfr-2.4.2" |
1383 |
- if tc_version_is_at_least 4.3 ; then |
1384 |
- RDEPEND+=" ${GMP_MPFR_DEPS}" |
1385 |
- elif in_iuse fortran ; then |
1386 |
- RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )" |
1387 |
- fi |
1388 |
- if tc_version_is_at_least 4.5 ; then |
1389 |
- RDEPEND+=" >=dev-libs/mpc-0.8.1" |
1390 |
- fi |
1391 |
- in_iuse lto && RDEPEND+=" lto? ( || ( >=dev-libs/elfutils-0.143 dev-libs/libelf ) )" |
1392 |
-fi |
1393 |
-if in_iuse graphite ; then |
1394 |
- RDEPEND+=" |
1395 |
- graphite? ( |
1396 |
- >=dev-libs/cloog-ppl-0.15.10 |
1397 |
- >=dev-libs/ppl-0.10 |
1398 |
- )" |
1399 |
-fi |
1400 |
- |
1401 |
-DEPEND="${RDEPEND} |
1402 |
- >=sys-apps/texinfo-4.8 |
1403 |
- >=sys-devel/bison-1.875 |
1404 |
- >=sys-devel/flex-2.5.4 |
1405 |
- test? ( |
1406 |
- >=dev-util/dejagnu-1.4.4 |
1407 |
- >=sys-devel/autogen-5.5.4 |
1408 |
- )" |
1409 |
-if in_iuse gcj ; then |
1410 |
- GCJ_GTK_DEPS=" |
1411 |
- x11-libs/libXt |
1412 |
- x11-libs/libX11 |
1413 |
- x11-libs/libXtst |
1414 |
- x11-proto/xproto |
1415 |
- x11-proto/xextproto |
1416 |
- =x11-libs/gtk+-2*" |
1417 |
- tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango" |
1418 |
- GCJ_DEPS=">=media-libs/libart_lgpl-2.1" |
1419 |
- tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip" |
1420 |
- DEPEND+=" gcj? ( gtk? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )" |
1421 |
-fi |
1422 |
- |
1423 |
-PDEPEND=">=sys-devel/gcc-config-1.4" |
1424 |
- |
1425 |
-#----<< DEPEND >>---- |
1426 |
- |
1427 |
-#---->> S + SRC_URI essentials <<---- |
1428 |
- |
1429 |
-# Set the source directory depending on whether we're using |
1430 |
-# a prerelease, snapshot, or release tarball. |
1431 |
-S=$( |
1432 |
- if [[ -n ${PRERELEASE} ]] ; then |
1433 |
- echo ${WORKDIR}/gcc-${PRERELEASE} |
1434 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
1435 |
- echo ${WORKDIR}/gcc-${SNAPSHOT} |
1436 |
- else |
1437 |
- echo ${WORKDIR}/gcc-${GCC_RELEASE_VER} |
1438 |
- fi |
1439 |
-) |
1440 |
- |
1441 |
-# This function handles the basics of setting the SRC_URI for a gcc ebuild. |
1442 |
-# To use, set SRC_URI with: |
1443 |
-# |
1444 |
-# SRC_URI="$(get_gcc_src_uri)" |
1445 |
-# |
1446 |
-# Other than the variables normally set by portage, this function's behavior |
1447 |
-# can be altered by setting the following: |
1448 |
-# |
1449 |
-# SNAPSHOT |
1450 |
-# If set, this variable signals that we should be using a snapshot |
1451 |
-# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is |
1452 |
-# expected to be in the format "YYYY-MM-DD". Note that if the ebuild |
1453 |
-# has a _pre suffix, this variable is ignored and the prerelease |
1454 |
-# tarball is used instead. |
1455 |
-# |
1456 |
-# BRANCH_UPDATE |
1457 |
-# If set, this variable signals that we should be using the main |
1458 |
-# release tarball (determined by ebuild version) and applying a |
1459 |
-# CVS branch update patch against it. The location of this branch |
1460 |
-# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}. |
1461 |
-# Just like with SNAPSHOT, this variable is ignored if the ebuild |
1462 |
-# has a _pre suffix. |
1463 |
-# |
1464 |
-# PATCH_VER |
1465 |
-# PATCH_GCC_VER |
1466 |
-# This should be set to the version of the gentoo patch tarball. |
1467 |
-# The resulting filename of this tarball will be: |
1468 |
-# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2 |
1469 |
-# |
1470 |
-# PIE_VER |
1471 |
-# PIE_GCC_VER |
1472 |
-# These variables control patching in various updates for the logic |
1473 |
-# controlling Position Independant Executables. PIE_VER is expected |
1474 |
-# to be the version of this patch, and PIE_GCC_VER the gcc version of |
1475 |
-# the patch: |
1476 |
-# An example: |
1477 |
-# PIE_VER="8.7.6.5" |
1478 |
-# PIE_GCC_VER="3.4.0" |
1479 |
-# The resulting filename of this tarball will be: |
1480 |
-# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2 |
1481 |
-# |
1482 |
-# SPECS_VER |
1483 |
-# SPECS_GCC_VER |
1484 |
-# This is for the minispecs files included in the hardened gcc-4.x |
1485 |
-# The specs files for hardenedno*, vanilla and for building the "specs" file. |
1486 |
-# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER |
1487 |
-# the gcc version of the patch. |
1488 |
-# An example: |
1489 |
-# SPECS_VER="8.7.6.5" |
1490 |
-# SPECS_GCC_VER="3.4.0" |
1491 |
-# The resulting filename of this tarball will be: |
1492 |
-# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2 |
1493 |
-# |
1494 |
-# HTB_VER |
1495 |
-# HTB_GCC_VER |
1496 |
-# These variables control whether or not an ebuild supports Herman |
1497 |
-# ten Brugge's bounds-checking patches. If you want to use a patch |
1498 |
-# for an older gcc version with a new gcc, make sure you set |
1499 |
-# HTB_GCC_VER to that version of gcc. |
1500 |
-# |
1501 |
-gentoo_urls() { |
1502 |
- local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI |
1503 |
- HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI" |
1504 |
- devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/} |
1505 |
- echo mirror://gentoo/$1 ${devspace//URI/$1} |
1506 |
-} |
1507 |
- |
1508 |
-get_gcc_src_uri() { |
1509 |
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
1510 |
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
1511 |
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
1512 |
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
1513 |
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
1514 |
- |
1515 |
- # Set where to download gcc itself depending on whether we're using a |
1516 |
- # prerelease, snapshot, or release tarball. |
1517 |
- if [[ -n ${PRERELEASE} ]] ; then |
1518 |
- GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2" |
1519 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
1520 |
- GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2" |
1521 |
- else |
1522 |
- GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2" |
1523 |
- # we want all branch updates to be against the main release |
1524 |
- [[ -n ${BRANCH_UPDATE} ]] && \ |
1525 |
- GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)" |
1526 |
- fi |
1527 |
- |
1528 |
- [[ -n ${UCLIBC_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)" |
1529 |
- [[ -n ${PATCH_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)" |
1530 |
- |
1531 |
- # strawberry pie, Cappuccino and a Gauloises (it's a good thing) |
1532 |
- [[ -n ${PIE_VER} ]] && \ |
1533 |
- PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \ |
1534 |
- GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})" |
1535 |
- |
1536 |
- # gcc minispec for the hardened gcc 4 compiler |
1537 |
- [[ -n ${SPECS_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)" |
1538 |
- |
1539 |
- # gcc bounds checking patch |
1540 |
- if [[ -n ${HTB_VER} ]] ; then |
1541 |
- local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
1542 |
- GCC_SRC_URI+=" |
1543 |
- boundschecking? ( |
1544 |
- mirror://sourceforge/boundschecking/${HTBFILE} |
1545 |
- $(gentoo_urls ${HTBFILE}) |
1546 |
- )" |
1547 |
- fi |
1548 |
- |
1549 |
- [[ -n ${D_VER} ]] && GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )" |
1550 |
- |
1551 |
- # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain |
1552 |
- # conditions |
1553 |
- if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then |
1554 |
- if tc_version_is_at_least "4.5" ; then |
1555 |
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )" |
1556 |
- elif tc_version_is_at_least "4.3" ; then |
1557 |
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )" |
1558 |
- fi |
1559 |
- fi |
1560 |
- |
1561 |
- echo "${GCC_SRC_URI}" |
1562 |
-} |
1563 |
-SRC_URI=$(get_gcc_src_uri) |
1564 |
-#---->> S + SRC_URI essentials >>---- |
1565 |
- |
1566 |
- |
1567 |
-#---->> support checks <<---- |
1568 |
- |
1569 |
-# Grab a variable from the build system (taken from linux-info.eclass) |
1570 |
-get_make_var() { |
1571 |
- local var=$1 makefile=${2:-${WORKDIR}/build/Makefile} |
1572 |
- echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \ |
1573 |
- r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null |
1574 |
-} |
1575 |
-XGCC() { get_make_var GCC_FOR_TARGET ; } |
1576 |
- |
1577 |
-# The gentoo piessp patches allow for 3 configurations: |
1578 |
-# 1) PIE+SSP by default |
1579 |
-# 2) PIE by default |
1580 |
-# 3) SSP by default |
1581 |
-hardened_gcc_works() { |
1582 |
- if [[ $1 == "pie" ]] ; then |
1583 |
- # $gcc_cv_ld_pie is unreliable as it simply take the output of |
1584 |
- # `ld --help | grep -- -pie`, that reports the option in all cases, also if |
1585 |
- # the loader doesn't actually load the resulting executables. |
1586 |
- # To avoid breakage, blacklist FreeBSD here at least |
1587 |
- [[ ${CTARGET} == *-freebsd* ]] && return 1 |
1588 |
- |
1589 |
- want_pie || return 1 |
1590 |
- use_if_iuse nopie && return 1 |
1591 |
- hardened_gcc_is_stable pie |
1592 |
- return $? |
1593 |
- elif [[ $1 == "ssp" ]] ; then |
1594 |
- [[ -n ${SPECS_VER} ]] || return 1 |
1595 |
- use_if_iuse nossp && return 1 |
1596 |
- hardened_gcc_is_stable ssp |
1597 |
- return $? |
1598 |
- else |
1599 |
- # laziness ;) |
1600 |
- hardened_gcc_works pie || return 1 |
1601 |
- hardened_gcc_works ssp || return 1 |
1602 |
- return 0 |
1603 |
- fi |
1604 |
-} |
1605 |
- |
1606 |
-hardened_gcc_is_stable() { |
1607 |
- local tocheck |
1608 |
- if [[ $1 == "pie" ]] ; then |
1609 |
- if [[ ${CTARGET} == *-uclibc* ]] ; then |
1610 |
- tocheck=${PIE_UCLIBC_STABLE} |
1611 |
- else |
1612 |
- tocheck=${PIE_GLIBC_STABLE} |
1613 |
- fi |
1614 |
- elif [[ $1 == "ssp" ]] ; then |
1615 |
- if [[ ${CTARGET} == *-uclibc* ]] ; then |
1616 |
- tocheck=${SSP_UCLIBC_STABLE} |
1617 |
- else |
1618 |
- tocheck=${SSP_STABLE} |
1619 |
- fi |
1620 |
- else |
1621 |
- die "hardened_gcc_stable needs to be called with pie or ssp" |
1622 |
- fi |
1623 |
- |
1624 |
- has $(tc-arch) ${tocheck} && return 0 |
1625 |
- return 1 |
1626 |
-} |
1627 |
- |
1628 |
-want_pie() { |
1629 |
- ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1 |
1630 |
- [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0 |
1631 |
- tc_version_is_at_least 4.3.2 && return 1 |
1632 |
- [[ -z ${PIE_VER} ]] && return 1 |
1633 |
- use !nopie && return 0 |
1634 |
- return 1 |
1635 |
-} |
1636 |
- |
1637 |
-want_minispecs() { |
1638 |
- if tc_version_is_at_least 4.3.2 && use hardened ; then |
1639 |
- if ! want_pie ; then |
1640 |
- ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild." |
1641 |
- elif use vanilla ; then |
1642 |
- ewarn "You will not get hardened features if you have the vanilla USE-flag." |
1643 |
- elif use nopie && use nossp ; then |
1644 |
- ewarn "You will not get hardened features if you have the nopie and nossp USE-flag." |
1645 |
- elif ! hardened_gcc_works ; then |
1646 |
- ewarn "Your $(tc-arch) arch is not supported." |
1647 |
- else |
1648 |
- return 0 |
1649 |
- fi |
1650 |
- ewarn "Hope you know what you are doing. Hardened will not work." |
1651 |
- return 0 |
1652 |
- fi |
1653 |
- return 1 |
1654 |
-} |
1655 |
- |
1656 |
-# This is to make sure we don't accidentally try to enable support for a |
1657 |
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc. |
1658 |
-# |
1659 |
-# Also add a hook so special ebuilds (kgcc64) can control which languages |
1660 |
-# exactly get enabled |
1661 |
-gcc-lang-supported() { |
1662 |
- grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1 |
1663 |
- [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0 |
1664 |
- has $1 ${TOOLCHAIN_ALLOWED_LANGS} |
1665 |
-} |
1666 |
- |
1667 |
-#----<< support checks >>---- |
1668 |
- |
1669 |
-#---->> specs + env.d logic <<---- |
1670 |
- |
1671 |
-# configure to build with the hardened GCC specs as the default |
1672 |
-make_gcc_hard() { |
1673 |
- # defaults to enable for all hardened toolchains |
1674 |
- local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW" |
1675 |
- |
1676 |
- if hardened_gcc_works ; then |
1677 |
- einfo "Updating gcc to use automatic PIE + SSP building ..." |
1678 |
- gcc_hard_flags+=" -DEFAULT_PIE_SSP" |
1679 |
- elif hardened_gcc_works pie ; then |
1680 |
- einfo "Updating gcc to use automatic PIE building ..." |
1681 |
- ewarn "SSP has not been enabled by default" |
1682 |
- gcc_hard_flags+=" -DEFAULT_PIE" |
1683 |
- elif hardened_gcc_works ssp ; then |
1684 |
- einfo "Updating gcc to use automatic SSP building ..." |
1685 |
- ewarn "PIE has not been enabled by default" |
1686 |
- gcc_hard_flags+=" -DEFAULT_SSP" |
1687 |
- else |
1688 |
- # do nothing if hardened isnt supported, but dont die either |
1689 |
- ewarn "hardened is not supported for this arch in this gcc version" |
1690 |
- ebeep |
1691 |
- return 0 |
1692 |
- fi |
1693 |
- |
1694 |
- sed -i \ |
1695 |
- -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \ |
1696 |
- "${S}"/gcc/Makefile.in || die |
1697 |
- |
1698 |
- # rebrand to make bug reports easier |
1699 |
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} |
1700 |
-} |
1701 |
- |
1702 |
-create_gcc_env_entry() { |
1703 |
- dodir /etc/env.d/gcc |
1704 |
- local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" |
1705 |
- |
1706 |
- if [[ -z $1 ]] ; then |
1707 |
- gcc_envd_file="${D}${gcc_envd_base}" |
1708 |
- # I'm leaving the following commented out to remind me that it |
1709 |
- # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset |
1710 |
- # on chroot or in non-toolchain.eclass gcc ebuilds! |
1711 |
- #gcc_specs_file="${LIBPATH}/specs" |
1712 |
- gcc_specs_file="" |
1713 |
- else |
1714 |
- gcc_envd_file="${D}${gcc_envd_base}-$1" |
1715 |
- gcc_specs_file="${LIBPATH}/$1.specs" |
1716 |
- fi |
1717 |
- |
1718 |
- # phase PATH/ROOTPATH out ... |
1719 |
- echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file} |
1720 |
- echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file} |
1721 |
- echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file} |
1722 |
- |
1723 |
- # We want to list the default ABI's LIBPATH first so libtool |
1724 |
- # searches that directory first. This is a temporary |
1725 |
- # workaround for libtool being stupid and using .la's from |
1726 |
- # conflicting ABIs by using the first one in the search path |
1727 |
- local abi=${DEFAULT_ABI} |
1728 |
- local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
1729 |
- local LDPATH=${LIBPATH} |
1730 |
- [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR} |
1731 |
- for abi in $(get_all_abis) ; do |
1732 |
- [[ ${abi} == ${DEFAULT_ABI} ]] && continue |
1733 |
- |
1734 |
- MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
1735 |
- LDPATH+=:${LIBPATH} |
1736 |
- [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR} |
1737 |
- done |
1738 |
- |
1739 |
- echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file} |
1740 |
- echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file} |
1741 |
- echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file} |
1742 |
- echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file} |
1743 |
- |
1744 |
- is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file} |
1745 |
- |
1746 |
- # Set which specs file to use |
1747 |
- [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file} |
1748 |
-} |
1749 |
-setup_minispecs_gcc_build_specs() { |
1750 |
- # Setup the "build.specs" file for gcc 4.3 to use when building. |
1751 |
- if hardened_gcc_works pie ; then |
1752 |
- cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs |
1753 |
- fi |
1754 |
- if hardened_gcc_works ssp ; then |
1755 |
- for s in ssp sspall ; do |
1756 |
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
1757 |
- done |
1758 |
- fi |
1759 |
- for s in nostrict znow ; do |
1760 |
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
1761 |
- done |
1762 |
- export GCC_SPECS="${WORKDIR}"/build.specs |
1763 |
-} |
1764 |
-copy_minispecs_gcc_specs() { |
1765 |
- # setup the hardenedno* specs files and the vanilla specs file. |
1766 |
- if hardened_gcc_works ; then |
1767 |
- create_gcc_env_entry hardenednopiessp |
1768 |
- fi |
1769 |
- if hardened_gcc_works pie ; then |
1770 |
- create_gcc_env_entry hardenednopie |
1771 |
- fi |
1772 |
- if hardened_gcc_works ssp ; then |
1773 |
- create_gcc_env_entry hardenednossp |
1774 |
- fi |
1775 |
- create_gcc_env_entry vanilla |
1776 |
- insinto ${LIBPATH} |
1777 |
- doins "${WORKDIR}"/specs/*.specs || die "failed to install specs" |
1778 |
- # Build system specs file which, if it exists, must be a complete set of |
1779 |
- # specs as it completely and unconditionally overrides the builtin specs. |
1780 |
- # For gcc 4.3 |
1781 |
- if ! tc_version_is_at_least 4.4 ; then |
1782 |
- $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs |
1783 |
- cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs |
1784 |
- doins "${WORKDIR}"/specs/specs || die "failed to install the specs file" |
1785 |
- fi |
1786 |
-} |
1787 |
- |
1788 |
-#----<< specs + env.d logic >>---- |
1789 |
- |
1790 |
-#---->> pkg_* <<---- |
1791 |
-toolchain_pkg_setup() { |
1792 |
- # Setup variables which would normally be in the profile |
1793 |
- if is_crosscompile ; then |
1794 |
- multilib_env ${CTARGET} |
1795 |
- if ! is_multilib ; then |
1796 |
- MULTILIB_ABIS=${DEFAULT_ABI} |
1797 |
- fi |
1798 |
- fi |
1799 |
- |
1800 |
- # we dont want to use the installed compiler's specs to build gcc! |
1801 |
- unset GCC_SPECS |
1802 |
- |
1803 |
- if ! use_if_iuse cxx ; then |
1804 |
- use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"' |
1805 |
- use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"' |
1806 |
- use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"' |
1807 |
- fi |
1808 |
- |
1809 |
- want_minispecs |
1810 |
- |
1811 |
- unset LANGUAGES #265283 |
1812 |
-} |
1813 |
- |
1814 |
-toolchain_pkg_preinst() { |
1815 |
- : |
1816 |
-} |
1817 |
- |
1818 |
-toolchain_pkg_postinst() { |
1819 |
- do_gcc_config |
1820 |
- |
1821 |
- if ! is_crosscompile ; then |
1822 |
- echo |
1823 |
- ewarn "If you have issues with packages unable to locate libstdc++.la," |
1824 |
- ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions." |
1825 |
- echo |
1826 |
- ewarn "You might want to review the GCC upgrade guide when moving between" |
1827 |
- ewarn "major versions (like 4.2 to 4.3):" |
1828 |
- ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml" |
1829 |
- echo |
1830 |
- fi |
1831 |
- |
1832 |
- # If our gcc-config version doesn't like '-' in it's version string, |
1833 |
- # tell our users that gcc-config will yell at them, but it's all good. |
1834 |
- if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then |
1835 |
- ewarn "Your version of gcc-config will issue about having an invalid profile" |
1836 |
- ewarn "when switching to this profile. It is safe to ignore this warning," |
1837 |
- ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1." |
1838 |
- fi |
1839 |
- |
1840 |
- if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then |
1841 |
- echo |
1842 |
- ewarn "You should make sure to rebuild all your C++ packages when" |
1843 |
- ewarn "upgrading between different versions of gcc. For example," |
1844 |
- ewarn "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:" |
1845 |
- ewarn " # revdep-rebuild --library libstdc++.so.5" |
1846 |
- echo |
1847 |
- fi |
1848 |
- |
1849 |
- if ! is_crosscompile ; then |
1850 |
- # hack to prevent collisions between SLOT |
1851 |
- [[ ! -d ${ROOT}/$(get_libdir)/rcscripts/awk ]] \ |
1852 |
- && mkdir -p "${ROOT}"/$(get_libdir)/rcscripts/awk |
1853 |
- [[ ! -d ${ROOT}/sbin ]] \ |
1854 |
- && mkdir -p "${ROOT}"/sbin |
1855 |
- cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/$(get_libdir)/rcscripts/awk/ || die "installing fixlafiles.awk" |
1856 |
- cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh" |
1857 |
- |
1858 |
- [[ ! -d ${ROOT}/usr/bin ]] \ |
1859 |
- && mkdir -p "${ROOT}"/usr/bin |
1860 |
- # Since these aren't critical files and portage sucks with |
1861 |
- # handling of binpkgs, don't require these to be found |
1862 |
- for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do |
1863 |
- if [[ -e ${x} ]]; then |
1864 |
- cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99" |
1865 |
- fi |
1866 |
- done |
1867 |
- fi |
1868 |
-} |
1869 |
- |
1870 |
-toolchain_pkg_prerm() { |
1871 |
- # Don't let these files be uninstalled #87647 |
1872 |
- touch -c "${ROOT}"/sbin/fix_libtool_files.sh \ |
1873 |
- "${ROOT}"/$(get_libdir)/rcscripts/awk/fixlafiles.awk |
1874 |
-} |
1875 |
- |
1876 |
-toolchain_pkg_postrm() { |
1877 |
- # to make our lives easier (and saner), we do the fix_libtool stuff here. |
1878 |
- # rather than checking SLOT's and trying in upgrade paths, we just see if |
1879 |
- # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are |
1880 |
- # unmerging. if it does, that means this was a simple re-emerge. |
1881 |
- |
1882 |
- # clean up the cruft left behind by cross-compilers |
1883 |
- if is_crosscompile ; then |
1884 |
- if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then |
1885 |
- rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET} |
1886 |
- rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET} |
1887 |
- rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} |
1888 |
- fi |
1889 |
- return 0 |
1890 |
- fi |
1891 |
- |
1892 |
- # ROOT isnt handled by the script |
1893 |
- [[ ${ROOT} != "/" ]] && return 0 |
1894 |
- |
1895 |
- if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then |
1896 |
- # make sure the profile is sane during same-slot upgrade #289403 |
1897 |
- do_gcc_config |
1898 |
- |
1899 |
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'" |
1900 |
- /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER} |
1901 |
- if [[ -n ${BRANCH_UPDATE} ]] ; then |
1902 |
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'" |
1903 |
- /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE} |
1904 |
- fi |
1905 |
- fi |
1906 |
- |
1907 |
- return 0 |
1908 |
-} |
1909 |
- |
1910 |
-#---->> pkg_* <<---- |
1911 |
- |
1912 |
-#---->> src_* <<---- |
1913 |
- |
1914 |
-guess_patch_type_in_dir() { |
1915 |
- [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \ |
1916 |
- && EPATCH_SUFFIX="patch.bz2" \ |
1917 |
- || EPATCH_SUFFIX="patch" |
1918 |
-} |
1919 |
-do_gcc_rename_java_bins() { |
1920 |
- # bug #139918 - conflict between gcc and java-config-2 for ownership of |
1921 |
- # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch |
1922 |
- # because patches would be large (thanks to the rename of man files), |
1923 |
- # and it's clear from the sed invocations that all that changes is the |
1924 |
- # rmi{c,registry} names to grmi{c,registry} names. |
1925 |
- # Kevin F. Quinn 2006-07-12 |
1926 |
- einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry." |
1927 |
- # 1) Move the man files if present (missing prior to gcc-3.4) |
1928 |
- for manfile in rmic rmiregistry; do |
1929 |
- [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue |
1930 |
- mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1 |
1931 |
- done |
1932 |
- # 2) Fixup references in the docs if present (mission prior to gcc-3.4) |
1933 |
- for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do |
1934 |
- [[ -f ${S}/${jfile} ]] || continue |
1935 |
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
1936 |
- die "Failed to fixup file ${jfile} for rename to grmiregistry" |
1937 |
- sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} || |
1938 |
- die "Failed to fixup file ${jfile} for rename to grmic" |
1939 |
- done |
1940 |
- # 3) Fixup Makefiles to build the changed executable names |
1941 |
- # These are present in all 3.x versions, and are the important bit |
1942 |
- # to get gcc to build with the new names. |
1943 |
- for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do |
1944 |
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
1945 |
- die "Failed to fixup file ${jfile} for rename to grmiregistry" |
1946 |
- # Careful with rmic on these files; it's also the name of a directory |
1947 |
- # which should be left unchanged. Replace occurrences of 'rmic$', |
1948 |
- # 'rmic_' and 'rmic '. |
1949 |
- sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} || |
1950 |
- die "Failed to fixup file ${jfile} for rename to grmic" |
1951 |
- done |
1952 |
-} |
1953 |
-toolchain_src_unpack() { |
1954 |
- export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}" |
1955 |
- |
1956 |
- [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc" |
1957 |
- |
1958 |
- [[ -z ${GCC_SVN} ]] && gcc_quick_unpack |
1959 |
- |
1960 |
- cd "${S}" |
1961 |
- |
1962 |
- if ! use vanilla ; then |
1963 |
- if [[ -n ${PATCH_VER} ]] ; then |
1964 |
- guess_patch_type_in_dir "${WORKDIR}"/patch |
1965 |
- EPATCH_MULTI_MSG="Applying Gentoo patches ..." \ |
1966 |
- epatch "${WORKDIR}"/patch |
1967 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}" |
1968 |
- fi |
1969 |
- if [[ -n ${UCLIBC_VER} ]] ; then |
1970 |
- guess_patch_type_in_dir "${WORKDIR}"/uclibc |
1971 |
- EPATCH_MULTI_MSG="Applying uClibc patches ..." \ |
1972 |
- epatch "${WORKDIR}"/uclibc |
1973 |
- fi |
1974 |
- fi |
1975 |
- do_gcc_HTB_patches |
1976 |
- do_gcc_PIE_patches |
1977 |
- epatch_user |
1978 |
- |
1979 |
- use hardened && make_gcc_hard |
1980 |
- |
1981 |
- if is_libffi ; then |
1982 |
- # move the libffi target out of gcj and into all |
1983 |
- sed -i \ |
1984 |
- -e '/^libgcj=/s:target-libffi::' \ |
1985 |
- -e '/^target_lib/s:=":="target-libffi :' \ |
1986 |
- "${S}"/configure || die |
1987 |
- fi |
1988 |
- |
1989 |
- # install the libstdc++ python into the right location |
1990 |
- # http://gcc.gnu.org/PR51368 |
1991 |
- if tc_version_is_at_least 4.5 ; then |
1992 |
- sed -i \ |
1993 |
- '/^pythondir =/s:=.*:= $(datadir)/python:' \ |
1994 |
- "${S}"/libstdc++-v3/python/Makefile.in || die |
1995 |
- fi |
1996 |
- |
1997 |
- # No idea when this first started being fixed, but let's go with 4.3.x for now |
1998 |
- if ! tc_version_is_at_least 4.3 ; then |
1999 |
- fix_files="" |
2000 |
- for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do |
2001 |
- [[ -e ${x} ]] && fix_files="${fix_files} ${x}" |
2002 |
- done |
2003 |
- ht_fix_file ${fix_files} */configure *.sh */Makefile.in |
2004 |
- fi |
2005 |
- |
2006 |
- setup_multilib_osdirnames |
2007 |
- |
2008 |
- gcc_version_patch |
2009 |
- if tc_version_is_at_least 4.1 ; then |
2010 |
- if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} || -n ${GCC_SVN} ]] ; then |
2011 |
- echo ${PV/_/-} > "${S}"/gcc/BASE-VER |
2012 |
- fi |
2013 |
- fi |
2014 |
- |
2015 |
- # >= gcc-4.3 doesn't bundle ecj.jar, so copy it |
2016 |
- if tc_version_is_at_least 4.3 && use gcj ; then |
2017 |
- if tc_version_is_at_least "4.5" ; then |
2018 |
- einfo "Copying ecj-4.5.jar" |
2019 |
- cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die |
2020 |
- elif tc_version_is_at_least "4.3" ; then |
2021 |
- einfo "Copying ecj-4.3.jar" |
2022 |
- cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die |
2023 |
- fi |
2024 |
- fi |
2025 |
- |
2026 |
- # disable --as-needed from being compiled into gcc specs |
2027 |
- # natively when using a gcc version < 3.4.4 |
2028 |
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992 |
2029 |
- if ! tc_version_is_at_least 3.4.4 ; then |
2030 |
- sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in |
2031 |
- fi |
2032 |
- |
2033 |
- # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names |
2034 |
- # in line with gcc-4. |
2035 |
- if tc_version_is_at_least 3.3 && ! tc_version_is_at_least 4.0 ; then |
2036 |
- do_gcc_rename_java_bins |
2037 |
- fi |
2038 |
- |
2039 |
- # Fixup libtool to correctly generate .la files with portage |
2040 |
- cd "${S}" |
2041 |
- elibtoolize --portage --shallow --no-uclibc |
2042 |
- |
2043 |
- gnuconfig_update |
2044 |
- |
2045 |
- # update configure files |
2046 |
- local f |
2047 |
- einfo "Fixing misc issues in configure files" |
2048 |
- tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch |
2049 |
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do |
2050 |
- ebegin " Updating ${f/${S}\/} [LANG]" |
2051 |
- patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ |
2052 |
- || eerror "Please file a bug about this" |
2053 |
- eend $? |
2054 |
- done |
2055 |
- sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828 |
2056 |
- |
2057 |
- if [[ -x contrib/gcc_update ]] ; then |
2058 |
- einfo "Touching generated files" |
2059 |
- ./contrib/gcc_update --touch | \ |
2060 |
- while read f ; do |
2061 |
- einfo " ${f%%...}" |
2062 |
- done |
2063 |
- fi |
2064 |
- |
2065 |
- disable_multilib_libjava || die "failed to disable multilib java" |
2066 |
-} |
2067 |
- |
2068 |
-gcc-abi-map() { |
2069 |
- # Convert the ABI name we use in Gentoo to what gcc uses |
2070 |
- local map=() |
2071 |
- case ${CTARGET} in |
2072 |
- mips*) map=("o32 32" "n32 n32" "n64 64") ;; |
2073 |
- x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;; |
2074 |
- esac |
2075 |
- |
2076 |
- local m |
2077 |
- for m in "${map[@]}" ; do |
2078 |
- l=( ${m} ) |
2079 |
- [[ $1 == ${l[0]} ]] && echo ${l[1]} && break |
2080 |
- done |
2081 |
-} |
2082 |
- |
2083 |
-gcc-multilib-configure() { |
2084 |
- # if multilib is disabled, get out quick! |
2085 |
- if ! is_multilib ; then |
2086 |
- confgcc+=" --disable-multilib" |
2087 |
- return |
2088 |
- else |
2089 |
- confgcc+=" --enable-multilib" |
2090 |
- fi |
2091 |
- |
2092 |
- # translate our notion of multilibs into gcc's |
2093 |
- local abi list |
2094 |
- for abi in $(get_all_abis) ; do |
2095 |
- local l=$(gcc-abi-map ${abi}) |
2096 |
- [[ -n ${l} ]] && list+=",${l}" |
2097 |
- done |
2098 |
- if [[ -n ${list} ]] ; then |
2099 |
- case ${CTARGET} in |
2100 |
- x86_64*) |
2101 |
- # drop the 4.6.2 stuff once 4.7 goes stable |
2102 |
- if tc_version_is_at_least 4.7 || |
2103 |
- ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) ) |
2104 |
- then |
2105 |
- confgcc+=" --with-multilib-list=${list:1}" |
2106 |
- fi |
2107 |
- ;; |
2108 |
- esac |
2109 |
- fi |
2110 |
-} |
2111 |
- |
2112 |
-gcc-compiler-configure() { |
2113 |
- gcc-multilib-configure |
2114 |
- |
2115 |
- if tc_version_is_at_least "4.0" ; then |
2116 |
- if in_iuse mudflap ; then |
2117 |
- confgcc+=" $(use_enable mudflap libmudflap)" |
2118 |
- else |
2119 |
- confgcc+=" --disable-libmudflap" |
2120 |
- fi |
2121 |
- |
2122 |
- if use_if_iuse libssp ; then |
2123 |
- confgcc+=" --enable-libssp" |
2124 |
- else |
2125 |
- export gcc_cv_libc_provides_ssp=yes |
2126 |
- confgcc+=" --disable-libssp" |
2127 |
- fi |
2128 |
- |
2129 |
- # If we want hardened support with the newer piepatchset for >=gcc 4.4 |
2130 |
- if tc_version_is_at_least 4.4 && want_minispecs ; then |
2131 |
- confgcc+=" $(use_enable hardened esp)" |
2132 |
- fi |
2133 |
- |
2134 |
- if tc_version_is_at_least "4.2" ; then |
2135 |
- if in_iuse openmp ; then |
2136 |
- # Make sure target has pthreads support. #326757 #335883 |
2137 |
- # There shouldn't be a chicken&egg problem here as openmp won't |
2138 |
- # build without a C library, and you can't build that w/out |
2139 |
- # already having a compiler ... |
2140 |
- if ! is_crosscompile || \ |
2141 |
- $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null |
2142 |
- then |
2143 |
- confgcc+=" $(use_enable openmp libgomp)" |
2144 |
- else |
2145 |
- # Force disable as the configure script can be dumb #359855 |
2146 |
- confgcc+=" --disable-libgomp" |
2147 |
- fi |
2148 |
- else |
2149 |
- # For gcc variants where we don't want openmp (e.g. kgcc) |
2150 |
- confgcc+=" --disable-libgomp" |
2151 |
- fi |
2152 |
- fi |
2153 |
- |
2154 |
- # Stick the python scripts in their own slotted directory |
2155 |
- # bug #279252 |
2156 |
- # |
2157 |
- # --with-python-dir=DIR |
2158 |
- # Specifies where to install the Python modules used for aot-compile. DIR |
2159 |
- # should not include the prefix used in installation. For example, if the |
2160 |
- # Python modules are to be installed in /usr/lib/python2.5/site-packages, |
2161 |
- # then --with-python-dir=/lib/python2.5/site-packages should be passed. |
2162 |
- # |
2163 |
- # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python" |
2164 |
- if tc_version_is_at_least "4.4" ; then |
2165 |
- confgcc+=" --with-python-dir=${DATAPATH/$PREFIX/}/python" |
2166 |
- fi |
2167 |
- fi |
2168 |
- |
2169 |
- # For newer versions of gcc, use the default ("release"), because no |
2170 |
- # one (even upstream apparently) tests with it disabled. #317217 |
2171 |
- if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then |
2172 |
- confgcc+=" --enable-checking=${GCC_CHECKS_LIST:-release}" |
2173 |
- else |
2174 |
- confgcc+=" --disable-checking" |
2175 |
- fi |
2176 |
- |
2177 |
- # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained |
2178 |
- # right now). Much thanks to <csm@×××.org> for the heads up. |
2179 |
- # Travis Tilley <lv@g.o> (11 Jul 2004) |
2180 |
- if ! is_gcj ; then |
2181 |
- confgcc+=" --disable-libgcj" |
2182 |
- elif use gtk ; then |
2183 |
- confgcc+=" --enable-java-awt=gtk" |
2184 |
- fi |
2185 |
- |
2186 |
- # newer gcc versions like to bootstrap themselves with C++, |
2187 |
- # so we need to manually disable it ourselves |
2188 |
- if tc_version_is_at_least 4.7 && ! is_cxx ; then |
2189 |
- confgcc+=" --disable-build-with-cxx --disable-build-poststage1-with-cxx" |
2190 |
- fi |
2191 |
- |
2192 |
- # newer gcc's come with libquadmath, but only fortran uses |
2193 |
- # it, so auto punt it when we don't care |
2194 |
- if tc_version_is_at_least 4.6 && ! is_fortran ; then |
2195 |
- confgcc+=" --disable-libquadmath" |
2196 |
- fi |
2197 |
- |
2198 |
- local with_abi_map=() |
2199 |
- case $(tc-arch) in |
2200 |
- arm) #264534 |
2201 |
- local arm_arch="${CTARGET%%-*}" |
2202 |
- # Only do this if arm_arch is armv* |
2203 |
- if [[ ${arm_arch} == armv* ]] ; then |
2204 |
- # Convert armv7{a,r,m} to armv7-{a,r,m} |
2205 |
- [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} |
2206 |
- # Remove endian ('l' / 'eb') |
2207 |
- [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l} |
2208 |
- [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb} |
2209 |
- confgcc+=" --with-arch=${arm_arch}" |
2210 |
- fi |
2211 |
- |
2212 |
- # Enable hardvfp |
2213 |
- if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \ |
2214 |
- tc_version_is_at_least "4.5" ; then |
2215 |
- confgcc+=" --with-float=hard" |
2216 |
- fi |
2217 |
- ;; |
2218 |
- # Add --with-abi flags to set default ABI |
2219 |
- mips) |
2220 |
- confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})" |
2221 |
- ;; |
2222 |
- amd64) |
2223 |
- # drop the older/ABI checks once this get's merged into some |
2224 |
- # version of gcc upstream |
2225 |
- if [[ ${PV} == "4.6.2" ]] && has x32 $(get_all_abis) ; then |
2226 |
- confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})" |
2227 |
- fi |
2228 |
- ;; |
2229 |
- # Default arch for x86 is normally i386, lets give it a bump |
2230 |
- # since glibc will do so based on CTARGET anyways |
2231 |
- x86) |
2232 |
- confgcc+=" --with-arch=${CTARGET%%-*}" |
2233 |
- ;; |
2234 |
- # Enable sjlj exceptions for backward compatibility on hppa |
2235 |
- hppa) |
2236 |
- [[ ${GCCMAJOR} == "3" ]] && confgcc+=" --enable-sjlj-exceptions" |
2237 |
- ;; |
2238 |
- # Set up defaults based on current CFLAGS |
2239 |
- ppc) |
2240 |
- is-flagq -mfloat-gprs=double && confgcc+=" --enable-e500-double" |
2241 |
- [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=" --enable-e500-double" |
2242 |
- ;; |
2243 |
- esac |
2244 |
- |
2245 |
- local GCC_LANG="c" |
2246 |
- is_cxx && GCC_LANG+=",c++" |
2247 |
- is_d && GCC_LANG+=",d" |
2248 |
- is_gcj && GCC_LANG+=",java" |
2249 |
- is_go && GCC_LANG+=",go" |
2250 |
- if is_objc || is_objcxx ; then |
2251 |
- GCC_LANG+=",objc" |
2252 |
- if tc_version_is_at_least "4.0" ; then |
2253 |
- use objc-gc && confgcc+=" --enable-objc-gc" |
2254 |
- fi |
2255 |
- is_objcxx && GCC_LANG+=",obj-c++" |
2256 |
- fi |
2257 |
- is_treelang && GCC_LANG+=",treelang" |
2258 |
- |
2259 |
- # fortran support just got sillier! the lang value can be f77 for |
2260 |
- # fortran77, f95 for fortran95, or just plain old fortran for the |
2261 |
- # currently supported standard depending on gcc version. |
2262 |
- is_fortran && GCC_LANG+=",fortran" |
2263 |
- is_f77 && GCC_LANG+=",f77" |
2264 |
- is_f95 && GCC_LANG+=",f95" |
2265 |
- |
2266 |
- # We do NOT want 'ADA support' in here! |
2267 |
- # is_ada && GCC_LANG+=",ada" |
2268 |
- |
2269 |
- einfo "configuring for GCC_LANG: ${GCC_LANG}" |
2270 |
- confgcc+=" --enable-languages=${GCC_LANG}" |
2271 |
-} |
2272 |
- |
2273 |
-gcc_do_configure() { |
2274 |
- local confgcc |
2275 |
- |
2276 |
- # Sanity check for USE=nocxx -> USE=cxx migration |
2277 |
- if in_iuse cxx && in_iuse nocxx ; then |
2278 |
- if (use cxx && use nocxx) || (use !cxx && use !nocxx) ; then |
2279 |
- eerror "We are migrating USE=nocxx to USE=cxx, but your USE settings do not make" |
2280 |
- eerror "sense. Please make sure these two flags line up logically in your setup." |
2281 |
- die "USE='cxx nocxx' and USE='-cxx -nocxx' make no sense" |
2282 |
- fi |
2283 |
- fi |
2284 |
- |
2285 |
- # Set configuration based on path variables |
2286 |
- confgcc+=" \ |
2287 |
- --prefix=${PREFIX} \ |
2288 |
- --bindir=${BINPATH} \ |
2289 |
- --includedir=${INCLUDEPATH} \ |
2290 |
- --datadir=${DATAPATH} \ |
2291 |
- --mandir=${DATAPATH}/man \ |
2292 |
- --infodir=${DATAPATH}/info \ |
2293 |
- --with-gxx-include-dir=${STDCXX_INCDIR}" |
2294 |
- # On Darwin we need libdir to be set in order to get correct install names |
2295 |
- # for things like libobjc-gnu, libgcj and libfortran. If we enable it on |
2296 |
- # non-Darwin we screw up the behaviour this eclass relies on. We in |
2297 |
- # particular need this over --libdir for bug #255315. |
2298 |
- [[ ${CTARGET} == *-darwin* ]] && \ |
2299 |
- confgcc+=" --enable-version-specific-runtime-libs" |
2300 |
- |
2301 |
- # All our cross-compile logic goes here ! woo ! |
2302 |
- confgcc+=" --host=${CHOST}" |
2303 |
- if is_crosscompile || tc-is-cross-compiler ; then |
2304 |
- # Straight from the GCC install doc: |
2305 |
- # "GCC has code to correctly determine the correct value for target |
2306 |
- # for nearly all native systems. Therefore, we highly recommend you |
2307 |
- # not provide a configure target when configuring a native compiler." |
2308 |
- confgcc+=" --target=${CTARGET}" |
2309 |
- fi |
2310 |
- [[ -n ${CBUILD} ]] && confgcc+=" --build=${CBUILD}" |
2311 |
- |
2312 |
- # ppc altivec support |
2313 |
- confgcc+=" $(use_enable altivec)" |
2314 |
- |
2315 |
- # gcc has fixed-point arithmetic support in 4.3 for mips targets that can |
2316 |
- # significantly increase compile time by several hours. This will allow |
2317 |
- # users to control this feature in the event they need the support. |
2318 |
- tc_version_is_at_least "4.3" && confgcc+=" $(use_enable fixed-point)" |
2319 |
- |
2320 |
- # Graphite support was added in 4.4, which depends on external libraries |
2321 |
- # for optimizations. Up to 4.6 we use cloog-ppl (cloog fork with Parma PPL |
2322 |
- # backend). Later versions will use upstream cloog with the ISL backend. We |
2323 |
- # disable the PPL version check so we can use >=ppl-0.11. |
2324 |
- if tc_version_is_at_least "4.4"; then |
2325 |
- confgcc+=" $(use_with graphite ppl)" |
2326 |
- confgcc+=" $(use_with graphite cloog)" |
2327 |
- if use graphite; then |
2328 |
- confgcc+=" --disable-ppl-version-check" |
2329 |
- # this will be removed when cloog-ppl-0.15.10 goes stable |
2330 |
- if has_version '>=dev-libs/cloog-ppl-0.15.10'; then |
2331 |
- confgcc+=" --with-cloog-include=/usr/include/cloog-ppl" |
2332 |
- else |
2333 |
- confgcc+=" --with-cloog-include=/usr/include/cloog" |
2334 |
- fi |
2335 |
- fi |
2336 |
- fi |
2337 |
- |
2338 |
- # LTO support was added in 4.5, which depends upon elfutils. This allows |
2339 |
- # users to enable that option, and pull in the additional library. In 4.6, |
2340 |
- # the dependency is no longer required. |
2341 |
- if tc_version_is_at_least "4.6" ; then |
2342 |
- confgcc+=" --enable-lto" |
2343 |
- elif tc_version_is_at_least "4.5" ; then |
2344 |
- confgcc+=" $(use_enable lto)" |
2345 |
- fi |
2346 |
- |
2347 |
- [[ $(tc-is-softfloat) == "yes" ]] && confgcc+=" --with-float=soft" |
2348 |
- [[ $(tc-is-hardfloat) == "yes" ]] && confgcc+=" --with-float=hard" |
2349 |
- |
2350 |
- # Native Language Support |
2351 |
- if use nls ; then |
2352 |
- confgcc+=" --enable-nls --without-included-gettext" |
2353 |
- else |
2354 |
- confgcc+=" --disable-nls" |
2355 |
- fi |
2356 |
- |
2357 |
- # reasonably sane globals (hopefully) |
2358 |
- confgcc+=" \ |
2359 |
- --with-system-zlib \ |
2360 |
- --disable-werror \ |
2361 |
- --enable-secureplt" |
2362 |
- |
2363 |
- gcc-compiler-configure || die |
2364 |
- |
2365 |
- if is_crosscompile ; then |
2366 |
- # When building a stage1 cross-compiler (just C compiler), we have to |
2367 |
- # disable a bunch of features or gcc goes boom |
2368 |
- local needed_libc="" |
2369 |
- case ${CTARGET} in |
2370 |
- *-linux) needed_libc=no-fucking-clue;; |
2371 |
- *-dietlibc) needed_libc=dietlibc;; |
2372 |
- *-elf|*-eabi) needed_libc=newlib;; |
2373 |
- *-freebsd*) needed_libc=freebsd-lib;; |
2374 |
- *-gnu*) needed_libc=glibc;; |
2375 |
- *-klibc) needed_libc=klibc;; |
2376 |
- *-uclibc*) needed_libc=uclibc;; |
2377 |
- *-cygwin) needed_libc=cygwin;; |
2378 |
- mingw*|*-mingw*) needed_libc=mingw-runtime;; |
2379 |
- avr) confgcc+=" --enable-shared --disable-threads";; |
2380 |
- esac |
2381 |
- if [[ -n ${needed_libc} ]] ; then |
2382 |
- if ! has_version ${CATEGORY}/${needed_libc} ; then |
2383 |
- confgcc+=" --disable-shared --disable-threads --without-headers" |
2384 |
- elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then |
2385 |
- confgcc+=" --disable-shared --with-sysroot=${PREFIX}/${CTARGET}" |
2386 |
- else |
2387 |
- confgcc+=" --with-sysroot=${PREFIX}/${CTARGET}" |
2388 |
- fi |
2389 |
- fi |
2390 |
- |
2391 |
- tc_version_is_at_least 4.2 && confgcc+=" --disable-bootstrap" |
2392 |
- else |
2393 |
- if tc-is-static-only ; then |
2394 |
- confgcc+=" --disable-shared" |
2395 |
- else |
2396 |
- confgcc+=" --enable-shared" |
2397 |
- fi |
2398 |
- case ${CHOST} in |
2399 |
- mingw*|*-mingw*|*-cygwin) |
2400 |
- confgcc+=" --enable-threads=win32" ;; |
2401 |
- *) |
2402 |
- confgcc+=" --enable-threads=posix" ;; |
2403 |
- esac |
2404 |
- fi |
2405 |
- # __cxa_atexit is "essential for fully standards-compliant handling of |
2406 |
- # destructors", but apparently requires glibc. |
2407 |
- case ${CTARGET} in |
2408 |
- *-uclibc*) |
2409 |
- confgcc+=" --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)" |
2410 |
- [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc+=" --enable-sjlj-exceptions" |
2411 |
- if tc_version_is_at_least 3.4 && ! tc_version_is_at_least 4.3 ; then |
2412 |
- confgcc+=" --enable-clocale=uclibc" |
2413 |
- fi |
2414 |
- ;; |
2415 |
- *-elf|*-eabi) |
2416 |
- confgcc+=" --with-newlib" |
2417 |
- ;; |
2418 |
- *-gnu*) |
2419 |
- confgcc+=" --enable-__cxa_atexit" |
2420 |
- confgcc+=" --enable-clocale=gnu" |
2421 |
- ;; |
2422 |
- *-freebsd*) |
2423 |
- confgcc+=" --enable-__cxa_atexit" |
2424 |
- ;; |
2425 |
- *-solaris*) |
2426 |
- confgcc+=" --enable-__cxa_atexit" |
2427 |
- ;; |
2428 |
- esac |
2429 |
- tc_version_is_at_least 3.4 || confgcc+=" --disable-libunwind-exceptions" |
2430 |
- |
2431 |
- # if the target can do biarch (-m32/-m64), enable it. overhead should |
2432 |
- # be small, and should simplify building of 64bit kernels in a 32bit |
2433 |
- # userland by not needing sys-devel/kgcc64. #349405 |
2434 |
- case $(tc-arch) in |
2435 |
- ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=" --enable-targets=all" ;; |
2436 |
- sparc) tc_version_is_at_least 4.4 && confgcc+=" --enable-targets=all" ;; |
2437 |
- amd64|x86) tc_version_is_at_least 4.3 && confgcc+=" --enable-targets=all" ;; |
2438 |
- esac |
2439 |
- |
2440 |
- tc_version_is_at_least 4.3 && set -- "$@" \ |
2441 |
- --with-bugurl=http://bugs.gentoo.org/ \ |
2442 |
- --with-pkgversion="${BRANDING_GCC_PKGVERSION}" |
2443 |
- set -- ${confgcc} "$@" ${EXTRA_ECONF} |
2444 |
- |
2445 |
- # Nothing wrong with a good dose of verbosity |
2446 |
- echo |
2447 |
- einfo "PREFIX: ${PREFIX}" |
2448 |
- einfo "BINPATH: ${BINPATH}" |
2449 |
- einfo "LIBPATH: ${LIBPATH}" |
2450 |
- einfo "DATAPATH: ${DATAPATH}" |
2451 |
- einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" |
2452 |
- echo |
2453 |
- einfo "Configuring GCC with: ${@//--/\n\t--}" |
2454 |
- echo |
2455 |
- |
2456 |
- # Build in a separate build tree |
2457 |
- mkdir -p "${WORKDIR}"/build |
2458 |
- pushd "${WORKDIR}"/build > /dev/null |
2459 |
- |
2460 |
- # and now to do the actual configuration |
2461 |
- addwrite /dev/zero |
2462 |
- echo "${S}"/configure "$@" |
2463 |
- "${S}"/configure "$@" || die "failed to run configure" |
2464 |
- |
2465 |
- # return to whatever directory we were in before |
2466 |
- popd > /dev/null |
2467 |
-} |
2468 |
- |
2469 |
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice" |
2470 |
-toolchain_death_notice() { |
2471 |
- pushd "${WORKDIR}"/build >/dev/null |
2472 |
- tar jcf gcc-build-logs.tar.bz2 $(find -name config.log) |
2473 |
- eerror |
2474 |
- eerror "Please include ${PWD}/gcc-build-logs.tar.bz2 in your bug report" |
2475 |
- eerror |
2476 |
- popd >/dev/null |
2477 |
-} |
2478 |
- |
2479 |
-# This function accepts one optional argument, the make target to be used. |
2480 |
-# If ommitted, gcc_do_make will try to guess whether it should use all, |
2481 |
-# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An |
2482 |
-# example of how to use this function: |
2483 |
-# |
2484 |
-# gcc_do_make all-target-libstdc++-v3 |
2485 |
-# |
2486 |
-# In addition to the target to be used, the following variables alter the |
2487 |
-# behavior of this function: |
2488 |
-# |
2489 |
-# LDFLAGS |
2490 |
-# Flags to pass to ld |
2491 |
-# |
2492 |
-# STAGE1_CFLAGS |
2493 |
-# CFLAGS to use during stage1 of a gcc bootstrap |
2494 |
-# |
2495 |
-# BOOT_CFLAGS |
2496 |
-# CFLAGS to use during stages 2+3 of a gcc bootstrap. |
2497 |
-# |
2498 |
-# Travis Tilley <lv@g.o> (04 Sep 2004) |
2499 |
-# |
2500 |
-gcc_do_make() { |
2501 |
- # Fix for libtool-portage.patch |
2502 |
- local OLDS=${S} |
2503 |
- S=${WORKDIR}/build |
2504 |
- |
2505 |
- # Set make target to $1 if passed |
2506 |
- [[ -n $1 ]] && GCC_MAKE_TARGET=$1 |
2507 |
- # default target |
2508 |
- if is_crosscompile || tc-is-cross-compiler ; then |
2509 |
- # 3 stage bootstrapping doesnt quite work when you cant run the |
2510 |
- # resulting binaries natively ^^; |
2511 |
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} |
2512 |
- else |
2513 |
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean} |
2514 |
- fi |
2515 |
- |
2516 |
- # the gcc docs state that parallel make isnt supported for the |
2517 |
- # profiledbootstrap target, as collisions in profile collecting may occur. |
2518 |
- # boundschecking also seems to introduce parallel build issues. |
2519 |
- if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || |
2520 |
- use_if_iuse boundschecking |
2521 |
- then |
2522 |
- export MAKEOPTS="${MAKEOPTS} -j1" |
2523 |
- fi |
2524 |
- |
2525 |
- if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then |
2526 |
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} |
2527 |
- elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then |
2528 |
- # See bug #79852 |
2529 |
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"} |
2530 |
- fi |
2531 |
- |
2532 |
- if is_crosscompile; then |
2533 |
- # In 3.4, BOOT_CFLAGS is never used on a crosscompile... |
2534 |
- # but I'll leave this in anyways as someone might have had |
2535 |
- # some reason for putting it in here... --eradicator |
2536 |
- BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} |
2537 |
- else |
2538 |
- # we only want to use the system's CFLAGS if not building a |
2539 |
- # cross-compiler. |
2540 |
- BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"} |
2541 |
- fi |
2542 |
- |
2543 |
- pushd "${WORKDIR}"/build |
2544 |
- |
2545 |
- emake \ |
2546 |
- LDFLAGS="${LDFLAGS}" \ |
2547 |
- STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ |
2548 |
- LIBPATH="${LIBPATH}" \ |
2549 |
- BOOT_CFLAGS="${BOOT_CFLAGS}" \ |
2550 |
- ${GCC_MAKE_TARGET} \ |
2551 |
- || die "emake failed with ${GCC_MAKE_TARGET}" |
2552 |
- |
2553 |
- if ! is_crosscompile && use cxx && use doc ; then |
2554 |
- if type -p doxygen > /dev/null ; then |
2555 |
- if tc_version_is_at_least 4.3 ; then |
2556 |
- cd "${CTARGET}"/libstdc++-v3/doc |
2557 |
- emake doc-man-doxygen || ewarn "failed to make docs" |
2558 |
- elif tc_version_is_at_least 3.0 ; then |
2559 |
- cd "${CTARGET}"/libstdc++-v3 |
2560 |
- emake doxygen-man || ewarn "failed to make docs" |
2561 |
- fi |
2562 |
- else |
2563 |
- ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed" |
2564 |
- fi |
2565 |
- fi |
2566 |
- |
2567 |
- popd |
2568 |
-} |
2569 |
- |
2570 |
-# This is mostly a stub function to be overwritten in an ebuild |
2571 |
-gcc_do_filter_flags() { |
2572 |
- strip-flags |
2573 |
- |
2574 |
- # In general gcc does not like optimization, and add -O2 where |
2575 |
- # it is safe. This is especially true for gcc 3.3 + 3.4 |
2576 |
- replace-flags -O? -O2 |
2577 |
- |
2578 |
- # ... sure, why not? |
2579 |
- strip-unsupported-flags |
2580 |
- |
2581 |
- # dont want to funk ourselves |
2582 |
- filter-flags '-mabi*' -m31 -m32 -m64 |
2583 |
- |
2584 |
- case ${GCC_BRANCH_VER} in |
2585 |
- 3.2|3.3) |
2586 |
- replace-cpu-flags k8 athlon64 opteron i686 x86-64 |
2587 |
- replace-cpu-flags pentium-m pentium3m pentium3 |
2588 |
- case $(tc-arch) in |
2589 |
- amd64|x86) filter-flags '-mtune=*' ;; |
2590 |
- # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used, |
2591 |
- # the compiler wrongly assumes a 32bit target |
2592 |
- ppc64) filter-flags "-mcpu=*";; |
2593 |
- esac |
2594 |
- case $(tc-arch) in |
2595 |
- amd64) replace-cpu-flags core2 nocona;; |
2596 |
- x86) replace-cpu-flags core2 prescott;; |
2597 |
- esac |
2598 |
- |
2599 |
- replace-cpu-flags G3 750 |
2600 |
- replace-cpu-flags G4 7400 |
2601 |
- replace-cpu-flags G5 7400 |
2602 |
- |
2603 |
- # XXX: should add a sed or something to query all supported flags |
2604 |
- # from the gcc source and trim everything else ... |
2605 |
- filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs |
2606 |
- filter-flags -f{no-,}stack-protector{,-all} |
2607 |
- filter-flags -fvisibility-inlines-hidden -fvisibility=hidden |
2608 |
- ;; |
2609 |
- 3.4|4.*) |
2610 |
- case $(tc-arch) in |
2611 |
- x86|amd64) filter-flags '-mcpu=*';; |
2612 |
- *-macos) |
2613 |
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127 |
2614 |
- [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \ |
2615 |
- filter-flags '-mcpu=*' '-march=*' '-mtune=*' |
2616 |
- ;; |
2617 |
- esac |
2618 |
- ;; |
2619 |
- esac |
2620 |
- |
2621 |
- # Compile problems with these (bug #6641 among others)... |
2622 |
- #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr" |
2623 |
- |
2624 |
- # CFLAGS logic (verified with 3.4.3): |
2625 |
- # CFLAGS: |
2626 |
- # This conflicts when creating a crosscompiler, so set to a sane |
2627 |
- # default in this case: |
2628 |
- # used in ./configure and elsewhere for the native compiler |
2629 |
- # used by gcc when creating libiberty.a |
2630 |
- # used by xgcc when creating libstdc++ (and probably others)! |
2631 |
- # this behavior should be removed... |
2632 |
- # |
2633 |
- # CXXFLAGS: |
2634 |
- # used by xgcc when creating libstdc++ |
2635 |
- # |
2636 |
- # STAGE1_CFLAGS (not used in creating a crosscompile gcc): |
2637 |
- # used by ${CHOST}-gcc for building stage1 compiler |
2638 |
- # |
2639 |
- # BOOT_CFLAGS (not used in creating a crosscompile gcc): |
2640 |
- # used by xgcc for building stage2/3 compiler |
2641 |
- |
2642 |
- if is_crosscompile ; then |
2643 |
- # Set this to something sane for both native and target |
2644 |
- CFLAGS="-O2 -pipe" |
2645 |
- |
2646 |
- local VAR="CFLAGS_"${CTARGET//-/_} |
2647 |
- CXXFLAGS=${!VAR} |
2648 |
- fi |
2649 |
- |
2650 |
- export GCJFLAGS=${GCJFLAGS:-${CFLAGS}} |
2651 |
-} |
2652 |
- |
2653 |
-toolchain_src_compile() { |
2654 |
- multilib_env ${CTARGET} |
2655 |
- gcc_do_filter_flags |
2656 |
- einfo "CFLAGS=\"${CFLAGS}\"" |
2657 |
- einfo "CXXFLAGS=\"${CXXFLAGS}\"" |
2658 |
- |
2659 |
- # Force internal zip based jar script to avoid random |
2660 |
- # issues with 3rd party jar implementations. #384291 |
2661 |
- export JAR=no |
2662 |
- |
2663 |
- # For hardened gcc 4.3 piepatchset to build the hardened specs |
2664 |
- # file (build.specs) to use when building gcc. |
2665 |
- if ! tc_version_is_at_least 4.4 && want_minispecs ; then |
2666 |
- setup_minispecs_gcc_build_specs |
2667 |
- fi |
2668 |
- # Build in a separate build tree |
2669 |
- mkdir -p "${WORKDIR}"/build |
2670 |
- pushd "${WORKDIR}"/build > /dev/null |
2671 |
- |
2672 |
- einfo "Configuring ${PN} ..." |
2673 |
- gcc_do_configure |
2674 |
- |
2675 |
- touch "${S}"/gcc/c-gperf.h |
2676 |
- |
2677 |
- # Do not make manpages if we do not have perl ... |
2678 |
- [[ ! -x /usr/bin/perl ]] \ |
2679 |
- && find "${WORKDIR}"/build -name '*.[17]' | xargs touch |
2680 |
- |
2681 |
- einfo "Compiling ${PN} ..." |
2682 |
- gcc_do_make ${GCC_MAKE_TARGET} |
2683 |
- |
2684 |
- popd > /dev/null |
2685 |
-} |
2686 |
- |
2687 |
-toolchain_src_test() { |
2688 |
- cd "${WORKDIR}"/build |
2689 |
- emake -k check || ewarn "check failed and that sucks :(" |
2690 |
-} |
2691 |
- |
2692 |
-toolchain_src_install() { |
2693 |
- local x= |
2694 |
- |
2695 |
- cd "${WORKDIR}"/build |
2696 |
- # Do allow symlinks in private gcc include dir as this can break the build |
2697 |
- find gcc/include*/ -type l -print0 | xargs -0 rm -f |
2698 |
- # Remove generated headers, as they can cause things to break |
2699 |
- # (ncurses, openssl, etc). |
2700 |
- for x in $(find gcc/include*/ -name '*.h') ; do |
2701 |
- grep -q 'It has been auto-edited by fixincludes from' "${x}" \ |
2702 |
- && rm -f "${x}" |
2703 |
- done |
2704 |
- # Do the 'make install' from the build directory |
2705 |
- S=${WORKDIR}/build \ |
2706 |
- emake -j1 DESTDIR="${D}" install || die |
2707 |
- # Punt some tools which are really only useful while building gcc |
2708 |
- find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \; |
2709 |
- # This one comes with binutils |
2710 |
- find "${D}" -name libiberty.a -exec rm -f "{}" \; |
2711 |
- |
2712 |
- # Move the libraries to the proper location |
2713 |
- gcc_movelibs |
2714 |
- |
2715 |
- # Basic sanity check |
2716 |
- if ! is_crosscompile ; then |
2717 |
- local EXEEXT |
2718 |
- eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log) |
2719 |
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}" |
2720 |
- fi |
2721 |
- |
2722 |
- dodir /etc/env.d/gcc |
2723 |
- create_gcc_env_entry |
2724 |
- |
2725 |
- # Setup the gcc_env_entry for hardened gcc 4 with minispecs |
2726 |
- if want_minispecs ; then |
2727 |
- copy_minispecs_gcc_specs |
2728 |
- fi |
2729 |
- # Make sure we dont have stuff lying around that |
2730 |
- # can nuke multiple versions of gcc |
2731 |
- |
2732 |
- gcc_slot_java |
2733 |
- |
2734 |
- # Move <cxxabi.h> to compiler-specific directories |
2735 |
- [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \ |
2736 |
- mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/ |
2737 |
- |
2738 |
- # These should be symlinks |
2739 |
- dodir /usr/bin |
2740 |
- cd "${D}"${BINPATH} |
2741 |
- for x in cpp gcc g++ c++ g77 gcj gcjh gfortran gccgo ; do |
2742 |
- # For some reason, g77 gets made instead of ${CTARGET}-g77... |
2743 |
- # this should take care of that |
2744 |
- [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x} |
2745 |
- |
2746 |
- if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then |
2747 |
- ln -sf ${CTARGET}-${x} ${x} |
2748 |
- |
2749 |
- # Create version-ed symlinks |
2750 |
- dosym ${BINPATH}/${CTARGET}-${x} \ |
2751 |
- /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER} |
2752 |
- dosym ${BINPATH}/${CTARGET}-${x} \ |
2753 |
- /usr/bin/${x}-${GCC_CONFIG_VER} |
2754 |
- fi |
2755 |
- |
2756 |
- if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then |
2757 |
- rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER} |
2758 |
- ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER} |
2759 |
- fi |
2760 |
- done |
2761 |
- |
2762 |
- # I do not know if this will break gcj stuff, so I'll only do it for |
2763 |
- # objc for now; basically "ffi.h" is the correct file to include, |
2764 |
- # but it gets installed in .../GCCVER/include and yet it does |
2765 |
- # "#include <ffitarget.h>" which (correctly, as it's an "extra" file) |
2766 |
- # is installed in .../GCCVER/include/libffi; the following fixes |
2767 |
- # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@g.o> |
2768 |
- if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then |
2769 |
- mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die |
2770 |
- rm -r "${D}"${LIBPATH}/include/libffi || die |
2771 |
- fi |
2772 |
- |
2773 |
- # Now do the fun stripping stuff |
2774 |
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}" |
2775 |
- env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}" |
2776 |
- # gcc used to install helper binaries in lib/ but then moved to libexec/ |
2777 |
- [[ -d ${D}${PREFIX}/libexec/gcc ]] && \ |
2778 |
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}" |
2779 |
- |
2780 |
- cd "${S}" |
2781 |
- if is_crosscompile; then |
2782 |
- rm -rf "${D}"/usr/share/{man,info} |
2783 |
- rm -rf "${D}"${DATAPATH}/{man,info} |
2784 |
- else |
2785 |
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man) |
2786 |
- if [[ -d ${cxx_mandir} ]] ; then |
2787 |
- # clean bogus manpages #113902 |
2788 |
- find "${cxx_mandir}" -name '*_build_*' -exec rm {} \; |
2789 |
- cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/ |
2790 |
- fi |
2791 |
- has noinfo ${FEATURES} \ |
2792 |
- && rm -r "${D}/${DATAPATH}"/info \ |
2793 |
- || prepinfo "${DATAPATH}" |
2794 |
- has noman ${FEATURES} \ |
2795 |
- && rm -r "${D}/${DATAPATH}"/man \ |
2796 |
- || prepman "${DATAPATH}" |
2797 |
- fi |
2798 |
- # prune empty dirs left behind |
2799 |
- find "${D}" -depth -type d -delete 2>/dev/null |
2800 |
- |
2801 |
- # install testsuite results |
2802 |
- if use test; then |
2803 |
- docinto testsuite |
2804 |
- find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc |
2805 |
- find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \ |
2806 |
- | xargs -0 dodoc |
2807 |
- fi |
2808 |
- |
2809 |
- # Rather install the script, else portage with changing $FILESDIR |
2810 |
- # between binary and source package borks things .... |
2811 |
- if ! is_crosscompile ; then |
2812 |
- insinto "${DATAPATH}" |
2813 |
- if tc_version_is_at_least 4.0 ; then |
2814 |
- newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die |
2815 |
- find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \; |
2816 |
- else |
2817 |
- doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die |
2818 |
- fi |
2819 |
- exeinto "${DATAPATH}" |
2820 |
- doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die |
2821 |
- doexe "${GCC_FILESDIR}"/c{89,99} || die |
2822 |
- fi |
2823 |
- |
2824 |
- # Use gid of 0 because some stupid ports don't have |
2825 |
- # the group 'root' set to gid 0. Send to /dev/null |
2826 |
- # for people who are testing as non-root. |
2827 |
- chown -R root:0 "${D}"${LIBPATH} 2>/dev/null |
2828 |
- |
2829 |
- # Move pretty-printers to gdb datadir to shut ldconfig up |
2830 |
- local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/} |
2831 |
- pushd "${D}"${LIBPATH} >/dev/null |
2832 |
- for py in $(find . -name '*-gdb.py') ; do |
2833 |
- local multidir=${py%/*} |
2834 |
- insinto "${gdbdir}/${multidir}" |
2835 |
- sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128 |
2836 |
- doins "${py}" || die |
2837 |
- rm "${py}" || die |
2838 |
- done |
2839 |
- popd >/dev/null |
2840 |
- |
2841 |
- # Don't scan .gox files for executable stacks - false positives |
2842 |
- export QA_EXECSTACK="usr/lib*/go/*/*.gox" |
2843 |
- export QA_WX_LOAD="usr/lib*/go/*/*.gox" |
2844 |
-} |
2845 |
- |
2846 |
-gcc_slot_java() { |
2847 |
- local x |
2848 |
- |
2849 |
- # Move Java headers to compiler-specific dir |
2850 |
- for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do |
2851 |
- [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/ |
2852 |
- done |
2853 |
- for x in gcj gnu java javax org ; do |
2854 |
- if [[ -d ${D}${PREFIX}/include/${x} ]] ; then |
2855 |
- dodir /${LIBPATH}/include/${x} |
2856 |
- mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/ |
2857 |
- rm -rf "${D}"${PREFIX}/include/${x} |
2858 |
- fi |
2859 |
- done |
2860 |
- |
2861 |
- if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then |
2862 |
- dodir /${LIBPATH}/security |
2863 |
- mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security |
2864 |
- rm -rf "${D}"${PREFIX}/lib*/security |
2865 |
- fi |
2866 |
- |
2867 |
- # Move random gcj files to compiler-specific directories |
2868 |
- for x in libgcj.spec logging.properties ; do |
2869 |
- x="${D}${PREFIX}/lib/${x}" |
2870 |
- [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/ |
2871 |
- done |
2872 |
- |
2873 |
- # SLOT up libgcj.pc if it's available (and let gcc-config worry about links) |
2874 |
- for x in "${D}"${PREFIX}/lib*/pkgconfig/libgcj*.pc ; do |
2875 |
- [[ -f ${x} ]] || continue |
2876 |
- sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${x}" |
2877 |
- mv "${x}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die |
2878 |
- done |
2879 |
- |
2880 |
- # Rename jar because it could clash with Kaffe's jar if this gcc is |
2881 |
- # primary compiler (aka don't have the -<version> extension) |
2882 |
- cd "${D}"${BINPATH} |
2883 |
- [[ -f jar ]] && mv -f jar gcj-jar |
2884 |
-} |
2885 |
- |
2886 |
-# Move around the libs to the right location. For some reason, |
2887 |
-# when installing gcc, it dumps internal libraries into /usr/lib |
2888 |
-# instead of the private gcc lib path |
2889 |
-gcc_movelibs() { |
2890 |
- # older versions of gcc did not support --print-multi-os-directory |
2891 |
- tc_version_is_at_least 3.0 || return 0 |
2892 |
- |
2893 |
- local multiarg removedirs="" |
2894 |
- for multiarg in $($(XGCC) -print-multi-lib) ; do |
2895 |
- multiarg=${multiarg#*;} |
2896 |
- multiarg=${multiarg//@/ -} |
2897 |
- |
2898 |
- local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory) |
2899 |
- local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory) |
2900 |
- local TODIR=${D}${LIBPATH}/${MULTIDIR} |
2901 |
- local FROMDIR= |
2902 |
- |
2903 |
- [[ -d ${TODIR} ]] || mkdir -p ${TODIR} |
2904 |
- |
2905 |
- for FROMDIR in \ |
2906 |
- ${LIBPATH}/${OS_MULTIDIR} \ |
2907 |
- ${LIBPATH}/../${MULTIDIR} \ |
2908 |
- ${PREFIX}/lib/${OS_MULTIDIR} \ |
2909 |
- ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR} |
2910 |
- do |
2911 |
- removedirs="${removedirs} ${FROMDIR}" |
2912 |
- FROMDIR=${D}${FROMDIR} |
2913 |
- if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then |
2914 |
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null) |
2915 |
- if [[ -n ${files} ]] ; then |
2916 |
- mv ${files} "${TODIR}" |
2917 |
- fi |
2918 |
- fi |
2919 |
- done |
2920 |
- fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}" |
2921 |
- done |
2922 |
- |
2923 |
- # We remove directories separately to avoid this case: |
2924 |
- # mv SRC/lib/../lib/*.o DEST |
2925 |
- # rmdir SRC/lib/../lib/ |
2926 |
- # mv SRC/lib/../lib32/*.o DEST # Bork |
2927 |
- for FROMDIR in ${removedirs} ; do |
2928 |
- rmdir "${D}"${FROMDIR} >& /dev/null |
2929 |
- done |
2930 |
- find "${D}" -type d | xargs rmdir >& /dev/null |
2931 |
-} |
2932 |
- |
2933 |
-#----<< src_* >>---- |
2934 |
- |
2935 |
-#---->> unorganized crap in need of refactoring follows |
2936 |
- |
2937 |
-# gcc_quick_unpack will unpack the gcc tarball and patches in a way that is |
2938 |
-# consistant with the behavior of get_gcc_src_uri. The only patch it applies |
2939 |
-# itself is the branch update if present. |
2940 |
-# |
2941 |
-# Travis Tilley <lv@g.o> (03 Sep 2004) |
2942 |
-# |
2943 |
-gcc_quick_unpack() { |
2944 |
- pushd "${WORKDIR}" > /dev/null |
2945 |
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
2946 |
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
2947 |
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
2948 |
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
2949 |
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
2950 |
- |
2951 |
- if [[ -n ${GCC_A_FAKEIT} ]] ; then |
2952 |
- unpack ${GCC_A_FAKEIT} |
2953 |
- elif [[ -n ${PRERELEASE} ]] ; then |
2954 |
- unpack gcc-${PRERELEASE}.tar.bz2 |
2955 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
2956 |
- unpack gcc-${SNAPSHOT}.tar.bz2 |
2957 |
- else |
2958 |
- unpack gcc-${GCC_RELEASE_VER}.tar.bz2 |
2959 |
- # We want branch updates to be against a release tarball |
2960 |
- if [[ -n ${BRANCH_UPDATE} ]] ; then |
2961 |
- pushd "${S}" > /dev/null |
2962 |
- epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2 |
2963 |
- popd > /dev/null |
2964 |
- fi |
2965 |
- fi |
2966 |
- |
2967 |
- if [[ -n ${D_VER} ]] && use d ; then |
2968 |
- pushd "${S}"/gcc > /dev/null |
2969 |
- unpack gdc-${D_VER}-src.tar.bz2 |
2970 |
- cd .. |
2971 |
- ebegin "Adding support for the D language" |
2972 |
- ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log |
2973 |
- if ! eend $? ; then |
2974 |
- eerror "The D gcc package failed to apply" |
2975 |
- eerror "Please include this log file when posting a bug report:" |
2976 |
- eerror " ${T}/dgcc.log" |
2977 |
- die "failed to include the D language" |
2978 |
- fi |
2979 |
- popd > /dev/null |
2980 |
- fi |
2981 |
- |
2982 |
- [[ -n ${PATCH_VER} ]] && \ |
2983 |
- unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2 |
2984 |
- |
2985 |
- [[ -n ${UCLIBC_VER} ]] && \ |
2986 |
- unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2 |
2987 |
- |
2988 |
- if want_pie ; then |
2989 |
- if [[ -n ${PIE_CORE} ]] ; then |
2990 |
- unpack ${PIE_CORE} |
2991 |
- else |
2992 |
- unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2 |
2993 |
- fi |
2994 |
- [[ -n ${SPECS_VER} ]] && \ |
2995 |
- unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2 |
2996 |
- fi |
2997 |
- |
2998 |
- use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
2999 |
- |
3000 |
- popd > /dev/null |
3001 |
-} |
3002 |
- |
3003 |
-do_gcc_HTB_patches() { |
3004 |
- use_if_iuse boundschecking || return 0 |
3005 |
- |
3006 |
- # modify the bounds checking patch with a regression patch |
3007 |
- epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch" |
3008 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}" |
3009 |
-} |
3010 |
- |
3011 |
-# do various updates to PIE logic |
3012 |
-do_gcc_PIE_patches() { |
3013 |
- want_pie || return 0 |
3014 |
- |
3015 |
- use vanilla && return 0 |
3016 |
- |
3017 |
- if tc_version_is_at_least 4.3.2; then |
3018 |
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/ |
3019 |
- EPATCH_MULTI_MSG="Applying pie patches ..." \ |
3020 |
- epatch "${WORKDIR}"/piepatch/ |
3021 |
- else |
3022 |
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream |
3023 |
- |
3024 |
- # corrects startfile/endfile selection and shared/static/pie flag usage |
3025 |
- EPATCH_MULTI_MSG="Applying upstream pie patches ..." \ |
3026 |
- epatch "${WORKDIR}"/piepatch/upstream |
3027 |
- # adds non-default pie support (rs6000) |
3028 |
- EPATCH_MULTI_MSG="Applying non-default pie patches ..." \ |
3029 |
- epatch "${WORKDIR}"/piepatch/nondef |
3030 |
- # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined |
3031 |
- EPATCH_MULTI_MSG="Applying default pie patches ..." \ |
3032 |
- epatch "${WORKDIR}"/piepatch/def |
3033 |
- fi |
3034 |
- # we want to be able to control the pie patch logic via something other |
3035 |
- # than ALL_CFLAGS... |
3036 |
- sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ |
3037 |
- -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ |
3038 |
- -i "${S}"/gcc/Makefile.in |
3039 |
- |
3040 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" |
3041 |
-} |
3042 |
- |
3043 |
-should_we_gcc_config() { |
3044 |
- # we always want to run gcc-config if we're bootstrapping, otherwise |
3045 |
- # we might get stuck with the c-only stage1 compiler |
3046 |
- use bootstrap && return 0 |
3047 |
- use build && return 0 |
3048 |
- |
3049 |
- # if the current config is invalid, we definitely want a new one |
3050 |
- # Note: due to bash quirkiness, the following must not be 1 line |
3051 |
- local curr_config |
3052 |
- curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0 |
3053 |
- |
3054 |
- # if the previously selected config has the same major.minor (branch) as |
3055 |
- # the version we are installing, then it will probably be uninstalled |
3056 |
- # for being in the same SLOT, make sure we run gcc-config. |
3057 |
- local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}') |
3058 |
- |
3059 |
- local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver}) |
3060 |
- |
3061 |
- # If we're using multislot, just run gcc-config if we're installing |
3062 |
- # to the same profile as the current one. |
3063 |
- use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]]) |
3064 |
- |
3065 |
- if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then |
3066 |
- return 0 |
3067 |
- else |
3068 |
- # if we're installing a genuinely different compiler version, |
3069 |
- # we should probably tell the user -how- to switch to the new |
3070 |
- # gcc version, since we're not going to do it for him/her. |
3071 |
- # We don't want to switch from say gcc-3.3 to gcc-3.4 right in |
3072 |
- # the middle of an emerge operation (like an 'emerge -e world' |
3073 |
- # which could install multiple gcc versions). |
3074 |
- einfo "The current gcc config appears valid, so it will not be" |
3075 |
- einfo "automatically switched for you. If you would like to" |
3076 |
- einfo "switch to the newly installed gcc version, do the" |
3077 |
- einfo "following:" |
3078 |
- echo |
3079 |
- einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}" |
3080 |
- einfo "source /etc/profile" |
3081 |
- echo |
3082 |
- ebeep |
3083 |
- return 1 |
3084 |
- fi |
3085 |
-} |
3086 |
- |
3087 |
-do_gcc_config() { |
3088 |
- if ! should_we_gcc_config ; then |
3089 |
- env -i ROOT="${ROOT}" gcc-config --use-old --force |
3090 |
- return 0 |
3091 |
- fi |
3092 |
- |
3093 |
- local current_gcc_config="" current_specs="" use_specs="" |
3094 |
- |
3095 |
- current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null) |
3096 |
- if [[ -n ${current_gcc_config} ]] ; then |
3097 |
- # figure out which specs-specific config is active |
3098 |
- current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}') |
3099 |
- [[ -n ${current_specs} ]] && use_specs=-${current_specs} |
3100 |
- fi |
3101 |
- if [[ -n ${use_specs} ]] && \ |
3102 |
- [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] |
3103 |
- then |
3104 |
- ewarn "The currently selected specs-specific gcc config," |
3105 |
- ewarn "${current_specs}, doesn't exist anymore. This is usually" |
3106 |
- ewarn "due to enabling/disabling hardened or switching to a version" |
3107 |
- ewarn "of gcc that doesnt create multiple specs files. The default" |
3108 |
- ewarn "config will be used, and the previous preference forgotten." |
3109 |
- ebeep |
3110 |
- epause |
3111 |
- use_specs="" |
3112 |
- fi |
3113 |
- |
3114 |
- gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs} |
3115 |
-} |
3116 |
- |
3117 |
-# This function allows us to gentoo-ize gcc's version number and bugzilla |
3118 |
-# URL without needing to use patches. |
3119 |
-gcc_version_patch() { |
3120 |
- # gcc-4.3+ has configure flags (whoo!) |
3121 |
- tc_version_is_at_least 4.3 && return 0 |
3122 |
- |
3123 |
- local version_string=${GCC_CONFIG_VER} |
3124 |
- [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}" |
3125 |
- |
3126 |
- einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" |
3127 |
- |
3128 |
- local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' ) |
3129 |
- if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then |
3130 |
- gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" ) |
3131 |
- else |
3132 |
- version_string="${version_string} (${BRANDING_GCC_PKGVERSION})" |
3133 |
- gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" ) |
3134 |
- fi |
3135 |
- sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die |
3136 |
-} |
3137 |
- |
3138 |
-# This is a historical wart. The original Gentoo/amd64 port used: |
3139 |
-# lib32 - 32bit binaries (x86) |
3140 |
-# lib64 - 64bit binaries (x86_64) |
3141 |
-# lib - "native" binaries (a symlink to lib64) |
3142 |
-# Most other distros use the logic (including mainline gcc): |
3143 |
-# lib - 32bit binaries (x86) |
3144 |
-# lib64 - 64bit binaries (x86_64) |
3145 |
-# Over time, Gentoo is migrating to the latter form. |
3146 |
-# |
3147 |
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc |
3148 |
-# versions will dynamically detect whether to use lib or lib32 for its |
3149 |
-# 32bit multilib. So, to keep the automagic from getting things wrong |
3150 |
-# while people are transitioning from the old style to the new style, |
3151 |
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets. |
3152 |
-setup_multilib_osdirnames() { |
3153 |
- is_multilib || return 0 |
3154 |
- |
3155 |
- local config |
3156 |
- local libdirs="../lib64 ../lib32" |
3157 |
- |
3158 |
- # this only makes sense for some Linux targets |
3159 |
- case ${CTARGET} in |
3160 |
- x86_64*-linux*) config="i386" ;; |
3161 |
- powerpc64*-linux*) config="rs6000" ;; |
3162 |
- sparc64*-linux*) config="sparc" ;; |
3163 |
- s390x*-linux*) config="s390" ;; |
3164 |
- *) return 0 ;; |
3165 |
- esac |
3166 |
- config+="/t-linux64" |
3167 |
- |
3168 |
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then |
3169 |
- einfo "updating multilib directories to be: ${libdirs}" |
3170 |
- # drop the 4.6.2 stuff once 4.7 goes stable |
3171 |
- if tc_version_is_at_least 4.7 || |
3172 |
- ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) ) |
3173 |
- then |
3174 |
- set -- -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' |
3175 |
- else |
3176 |
- set -- -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" |
3177 |
- fi |
3178 |
- else |
3179 |
- einfo "using upstream multilib; disabling lib32 autodetection" |
3180 |
- set -- -r -e 's:[$][(]if.*,(.*)[)]:\1:' |
3181 |
- fi |
3182 |
- sed -i "$@" "${S}"/gcc/config/${config} || die |
3183 |
-} |
3184 |
- |
3185 |
-disable_multilib_libjava() { |
3186 |
- # We dont want a multilib libjava, so lets use this hack taken from fedora |
3187 |
- sed -i -r \ |
3188 |
- -e 's/^((all:) all-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3189 |
- -e 's/^((install:) install-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3190 |
- -e 's/^((check:) check-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3191 |
- -e 's/^((all:) all-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3192 |
- -e 's/^((install:) install-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3193 |
- -e 's/^((check:) check-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \ |
3194 |
- "${S}"/libjava/Makefile.in || die |
3195 |
-} |
3196 |
- |
3197 |
-# make sure the libtool archives have libdir set to where they actually |
3198 |
-# -are-, and not where they -used- to be. also, any dependencies we have |
3199 |
-# on our own .la files need to be updated. |
3200 |
-fix_libtool_libdir_paths() { |
3201 |
- pushd "${D}" >/dev/null |
3202 |
- |
3203 |
- pushd "./${1}" >/dev/null |
3204 |
- local dir="${PWD#${D%/}}" |
3205 |
- local allarchives=$(echo *.la) |
3206 |
- allarchives="\(${allarchives// /\\|}\)" |
3207 |
- popd >/dev/null |
3208 |
- |
3209 |
- sed -i \ |
3210 |
- -e "/^libdir=/s:=.*:='${dir}':" \ |
3211 |
- ./${dir}/*.la |
3212 |
- sed -i \ |
3213 |
- -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \ |
3214 |
- $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \ |
3215 |
- ./${dir}/*.la |
3216 |
- |
3217 |
- popd >/dev/null |
3218 |
-} |
3219 |
- |
3220 |
-is_multilib() { |
3221 |
- tc_version_is_at_least 3 || return 1 |
3222 |
- use multilib |
3223 |
-} |
3224 |
- |
3225 |
-is_cxx() { |
3226 |
- gcc-lang-supported 'c++' || return 1 |
3227 |
- use cxx |
3228 |
-} |
3229 |
- |
3230 |
-is_d() { |
3231 |
- gcc-lang-supported d || return 1 |
3232 |
- use_if_iuse d |
3233 |
-} |
3234 |
- |
3235 |
-is_f77() { |
3236 |
- gcc-lang-supported f77 || return 1 |
3237 |
- use fortran |
3238 |
-} |
3239 |
- |
3240 |
-is_f95() { |
3241 |
- gcc-lang-supported f95 || return 1 |
3242 |
- use fortran |
3243 |
-} |
3244 |
- |
3245 |
-is_fortran() { |
3246 |
- gcc-lang-supported fortran || return 1 |
3247 |
- use fortran |
3248 |
-} |
3249 |
- |
3250 |
-is_gcj() { |
3251 |
- gcc-lang-supported java || return 1 |
3252 |
- use cxx && use_if_iuse gcj |
3253 |
-} |
3254 |
- |
3255 |
-is_go() { |
3256 |
- gcc-lang-supported go || return 1 |
3257 |
- use cxx && use_if_iuse go |
3258 |
-} |
3259 |
- |
3260 |
-is_libffi() { |
3261 |
- use_if_iuse libffi |
3262 |
-} |
3263 |
- |
3264 |
-is_objc() { |
3265 |
- gcc-lang-supported objc || return 1 |
3266 |
- use_if_iuse objc |
3267 |
-} |
3268 |
- |
3269 |
-is_objcxx() { |
3270 |
- gcc-lang-supported 'obj-c++' || return 1 |
3271 |
- use cxx && use_if_iuse objc++ |
3272 |
-} |
3273 |
- |
3274 |
-is_ada() { |
3275 |
- gcc-lang-supported ada || return 1 |
3276 |
- use ada |
3277 |
-} |
3278 |
- |
3279 |
-is_treelang() { |
3280 |
- use_if_iuse boundschecking && return 1 #260532 |
3281 |
- is_crosscompile && return 1 #199924 |
3282 |
- gcc-lang-supported treelang || return 1 |
3283 |
- #use treelang |
3284 |
- return 0 |
3285 |
-} |
3286 |
- |
3287 |
-# should kill these off once all the ebuilds are migrated |
3288 |
-gcc_pkg_setup() { toolchain_pkg_setup ; } |
3289 |
-gcc_src_unpack() { toolchain_src_unpack ; } |
3290 |
-gcc_src_compile() { toolchain_src_compile ; } |
3291 |
-gcc_src_test() { toolchain_src_test ; } |