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

Contents of /eclass/gnatbuild.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.60 - (show annotations) (download)
Mon Nov 25 07:06:23 2013 UTC (8 months, 3 weeks ago) by nerdboy
Branch: MAIN
Changes since 1.59: +5 -3 lines
Extended symlink fix back to 4.4 (see bug #363839).

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/gnatbuild.eclass,v 1.59 2013/11/25 02:49:47 nerdboy Exp $
4 #
5 # Authors: George Shapovalov <george@gentoo.org>
6 # Steve Arnold <nerdboy@gentoo.org>
7 #
8 # Belongs to: ada herd <ada@gentoo.org>
9 #
10 # Notes:
11 # HOMEPAGE and LICENSE are set in appropriate ebuild, as
12 # gnat is developed by FSF and AdaCore "in parallel"
13 #
14 # The following vars can be set in ebuild before inheriting this eclass. They
15 # will be respected:
16 # SLOT
17 # BOOT_SLOT - where old bootstrap is used as it works fine
18
19 #WANT_AUTOMAKE="1.8"
20 #WANT_AUTOCONF="2.1"
21
22 inherit eutils versionator toolchain-funcs flag-o-matic multilib autotools \
23 libtool fixheadtails gnuconfig pax-utils
24
25 EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_postrm src_unpack src_compile src_install
26
27 IUSE="nls"
28 # multilib is supported via profiles now, multilib usevar is deprecated
29
30 DEPEND=">=app-admin/eselect-gnat-1.3
31 sys-devel/bc
32 "
33
34 RDEPEND="app-admin/eselect-gnat"
35
36 # Note!
37 # It may not be safe to source this at top level. Only source inside local
38 # functions!
39 GnatCommon="/usr/share/gnat/lib/gnat-common.bash"
40
41 #---->> globals and SLOT <<----
42
43 # just a check, this location seems to vary too much, easier to track it in
44 # ebuild
45 #[ -z "${GNATSOURCE}" ] && die "please set GNATSOURCE in ebuild! (before inherit)"
46
47 # versioning
48 # because of gnatpro/gnatgpl we need to track both gcc and gnat versions
49
50 # these simply default to $PV
51 GNATMAJOR=$(get_version_component_range 1)
52 GNATMINOR=$(get_version_component_range 2)
53 GNATBRANCH=$(get_version_component_range 1-2)
54 GNATRELEASE=$(get_version_component_range 1-3)
55 # this one is for the gnat-gpl which is versioned by gcc backend and ACT version
56 # number added on top
57 ACT_Ver=$(get_version_component_range 4)
58
59 # GCCVER and SLOT logic
60 #
61 # I better define vars for package names, as there was discussion on proper
62 # naming and it may change
63 PN_GnatGCC="gnat-gcc"
64 PN_GnatGpl="gnat-gpl"
65
66 # ATTN! GCCVER stands for the provided backend gcc, not the one on the system
67 # so tc-* functions are of no use here. The present versioning scheme makes
68 # GCCVER basically a part of PV, but *this may change*!!
69 #
70 # GCCVER can be set in the ebuild.
71 [[ -z ${GCCVER} ]] && GCCVER="${GNATRELEASE}"
72
73
74 # finally extract GCC version strings
75 GCCMAJOR=$(get_version_component_range 1 "${GCCVER}")
76 GCCMINOR=$(get_version_component_range 2 "${GCCVER}")
77 GCCBRANCH=$(get_version_component_range 1-2 "${GCCVER}")
78 GCCRELEASE=$(get_version_component_range 1-3 "${GCCVER}")
79
80 # SLOT logic, make it represent gcc backend, as this is what matters most
81 # There are some special cases, so we allow it to be defined in the ebuild
82 # ATTN!! If you set SLOT in the ebuild, don't forget to make sure that
83 # BOOT_SLOT is also set properly!
84 [[ -z ${SLOT} ]] && SLOT="${GCCBRANCH}"
85
86 # possible future crosscompilation support
87 export CTARGET=${CTARGET:-${CHOST}}
88
89 is_crosscompile() {
90 [[ ${CHOST} != ${CTARGET} ]]
91 }
92
93 # Bootstrap CTARGET and SLOT logic. For now BOOT_TARGET=CHOST is "guaranteed" by
94 # profiles, so mostly watch out for the right SLOT used in the bootstrap.
95 # As above, with SLOT, it may need to be defined in the ebuild
96 BOOT_TARGET=${CTARGET}
97 [[ -z ${BOOT_SLOT} ]] && BOOT_SLOT=${SLOT}
98
99 # set our install locations
100 PREFIX=${GNATBUILD_PREFIX:-/usr} # not sure we need this hook, but may be..
101 LIBPATH=${PREFIX}/$(get_libdir)/${PN}/${CTARGET}/${SLOT}
102 LIBEXECPATH=${PREFIX}/libexec/${PN}/${CTARGET}/${SLOT}
103 INCLUDEPATH=${LIBPATH}/include
104 BINPATH=${PREFIX}/${CTARGET}/${PN}-bin/${SLOT}
105 DATAPATH=${PREFIX}/share/${PN}-data/${CTARGET}/${SLOT}
106 # ATTN! the one below should match the path defined in eselect-gnat module
107 CONFIG_PATH="/usr/share/gnat/eselect"
108 gnat_profile="${CTARGET}-${PN}-${SLOT}"
109 gnat_config_file="${CONFIG_PATH}/${gnat_profile}"
110
111
112 # ebuild globals
113 if [[ ${PN} == "${PN_GnatPro}" ]] && [[ ${GNATMAJOR} == "3" ]]; then
114 DEPEND="x86? ( >=app-shells/tcsh-6.0 )"
115 fi
116 S="${WORKDIR}/gcc-${GCCVER}"
117
118 # bootstrap globals, common to src_unpack and src_compile
119 GNATBOOT="${WORKDIR}/usr"
120 GNATBUILD="${WORKDIR}/build"
121
122 # necessary for detecting lib locations and creating env.d entry
123 #XGCC="${GNATBUILD}/gcc/xgcc -B${GNATBUILD}/gcc"
124
125 #----<< globals and SLOT >>----
126
127 # set SRC_URI's in ebuilds for now
128
129 #----<< support checks >>----
130 # skipping this section - do not care about hardened/multilib for now
131
132 #---->> specs + env.d logic <<----
133 # TODO!!!
134 # set MANPATH, etc..
135 #----<< specs + env.d logic >>----
136
137
138 #---->> some helper functions <<----
139 is_multilib() {
140 [[ ${GCCMAJOR} < 3 ]] && return 1
141 case ${CTARGET} in
142 mips64*|powerpc64*|s390x*|sparc64*|x86_64*)
143 has_multilib_profile || use multilib ;;
144 *) false ;;
145 esac
146 }
147
148 # adapted from toolchain,
149 # left only basic multilib functionality and cut off mips stuff
150
151 create_specs_file() {
152 einfo "Creating a vanilla gcc specs file"
153 "${WORKDIR}"/build/gcc/xgcc -dumpspecs > "${WORKDIR}"/build/vanilla.specs
154 }
155
156
157 # eselect stuff taken straight from toolchain.eclass and greatly simplified
158 add_profile_eselect_conf() {
159 local gnat_config_file=$1
160 local abi=$2
161 local var
162
163 echo >> "${D}/${gnat_config_file}"
164 if ! is_multilib ; then
165 echo " ctarget=${CTARGET}" >> "${D}/${gnat_config_file}"
166 else
167 echo "[${abi}]" >> "${D}/${gnat_config_file}"
168 var="CTARGET_${abi}"
169 if [[ -n ${!var} ]] ; then
170 echo " ctarget=${!var}" >> "${D}/${gnat_config_file}"
171 else
172 var="CHOST_${abi}"
173 if [[ -n ${!var} ]] ; then
174 echo " ctarget=${!var}" >> "${D}/${gnat_config_file}"
175 else
176 echo " ctarget=${CTARGET}" >> "${D}/${gnat_config_file}"
177 fi
178 fi
179 fi
180
181 var="CFLAGS_${abi}"
182 if [[ -n ${!var} ]] ; then
183 echo " cflags=${!var}" >> "${D}/${gnat_config_file}"
184 fi
185 }
186
187
188 create_eselect_conf() {
189 local abi
190
191 dodir ${CONFIG_PATH}
192
193 echo "[global]" > "${D}/${gnat_config_file}"
194 echo " version=${CTARGET}-${SLOT}" >> "${D}/${gnat_config_file}"
195 echo " binpath=${BINPATH}" >> "${D}/${gnat_config_file}"
196 echo " libexecpath=${LIBEXECPATH}" >> "${D}/${gnat_config_file}"
197 echo " ldpath=${LIBPATH}" >> "${D}/${gnat_config_file}"
198 echo " manpath=${DATAPATH}/man" >> "${D}/${gnat_config_file}"
199 echo " infopath=${DATAPATH}/info" >> "${D}/${gnat_config_file}"
200 echo " bin_prefix=${CTARGET}" >> "${D}/${gnat_config_file}"
201
202 for abi in $(get_all_abis) ; do
203 add_profile_eselect_conf "${D}/${gnat_config_file}" "${abi}"
204 done
205 }
206
207
208
209 should_we_eselect_gnat() {
210 # we only want to switch compilers if installing to / or /tmp/stage1root
211 [[ ${ROOT} == "/" ]] || return 1
212
213 # if the current config is invalid, we definitely want a new one
214 # Note: due to bash quirkiness, the following must not be 1 line
215 local curr_config
216 curr_config=$(eselect --no-color gnat show | grep ${CTARGET} | awk '{ print $1 }') || return 0
217 [[ -z ${curr_config} ]] && return 0
218
219 # The logic is basically "try to keep the same profile if possible"
220
221 if [[ ${curr_config} == ${CTARGET}-${PN}-${SLOT} ]] ; then
222 return 0
223 else
224 elog "The current gcc config appears valid, so it will not be"
225 elog "automatically switched for you. If you would like to"
226 elog "switch to the newly installed gcc version, do the"
227 elog "following:"
228 echo
229 elog "eselect gnat set <profile>"
230 echo
231 ebeep
232 return 1
233 fi
234 }
235
236 # active compiler selection, called from pkg_postinst
237 do_gnat_config() {
238 eselect gnat set ${CTARGET}-${PN}-${SLOT} &> /dev/null
239
240 elog "The following gnat profile has been activated:"
241 elog "${CTARGET}-${PN}-${SLOT}"
242 elog ""
243 elog "The compiler has been installed as gnatgcc, and the coverage testing"
244 elog "tool as gnatgcov."
245 elog ""
246 elog "Ada handling in Gentoo allows you to have multiple gnat variants"
247 elog "installed in parallel and automatically manage Ada libs."
248 elog "Please take a look at the Ada project page for some documentation:"
249 elog "http://www.gentoo.org/proj/en/prog_lang/ada/index.xml"
250 }
251
252
253 # Taken straight from the toolchain.eclass. Only removed the "obsolete hunk"
254 #
255 # The purpose of this DISGUSTING gcc multilib hack is to allow 64bit libs
256 # to live in lib instead of lib64 where they belong, with 32bit libraries
257 # in lib32. This hack has been around since the beginning of the amd64 port,
258 # and we're only now starting to fix everything that's broken. Eventually
259 # this should go away.
260 #
261 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
262 #
263 disgusting_gcc_multilib_HACK() {
264 local config
265 local libdirs
266 if has_multilib_profile ; then
267 case $(tc-arch) in
268 amd64)
269 config="i386/t-linux64"
270 libdirs="../$(get_abi_LIBDIR amd64) ../$(get_abi_LIBDIR x86)" \
271 ;;
272 ppc64)
273 config="rs6000/t-linux64"
274 libdirs="../$(get_abi_LIBDIR ppc64) ../$(get_abi_LIBDIR ppc)" \
275 ;;
276 esac
277 else
278 die "Your profile is no longer supported by portage."
279 fi
280
281 einfo "updating multilib directories to be: ${libdirs}"
282 sed -i -e "s:^MULTILIB_OSDIRNAMES.*:MULTILIB_OSDIRNAMES = ${libdirs}:" "${S}"/gcc/config/${config}
283 }
284
285
286 #---->> pkg_* <<----
287 gnatbuild_pkg_setup() {
288 debug-print-function ${FUNCNAME} $@
289
290 # Setup variables which would normally be in the profile
291 if is_crosscompile ; then
292 multilib_env ${CTARGET}
293 fi
294
295 # we dont want to use the installed compiler's specs to build gnat!
296 unset GCC_SPECS
297 }
298
299 gnatbuild_pkg_postinst() {
300 if should_we_eselect_gnat; then
301 do_gnat_config
302 else
303 eselect gnat update
304 fi
305
306 # if primary compiler list is empty, add this profile to the list, so
307 # that users are not left without active compilers (making sure that
308 # libs are getting built for at least one)
309 elog
310 . ${GnatCommon} || die "failed to source common code"
311 if [[ ! -f ${PRIMELIST} ]] || [[ ! -s ${PRIMELIST} ]]; then
312 echo "${gnat_profile}" > ${PRIMELIST}
313 elog "The list of primary compilers was empty and got assigned ${gnat_profile}."
314 fi
315 elog "Please edit ${PRIMELIST} and list there gnat profiles intended"
316 elog "for common use."
317 }
318
319
320 gnatbuild_pkg_postrm() {
321 # "eselect gnat update" now removes the env.d file if the corresponding
322 # gnat profile was unmerged
323 eselect gnat update
324 elog "If you just unmerged the last gnat in this SLOT, your active gnat"
325 elog "profile got unset. Please check what eselect gnat show tells you"
326 elog "and set the desired profile"
327 }
328 #---->> pkg_* <<----
329
330 #---->> src_* <<----
331
332 # common unpack stuff
333 gnatbuild_src_unpack() {
334 debug-print-function ${FUNCNAME} $@
335 [ -z "$1" ] && gnatbuild_src_unpack all
336
337 while [ "$1" ]; do
338 case $1 in
339 base_unpack)
340 unpack ${A}
341 pax-mark E $(find ${GNATBOOT} -name gnat1)
342
343 cd "${S}"
344 # patching gcc sources, following the toolchain
345 # first, the common patches
346 if [[ -d "${FILESDIR}"/patches ]] && [[ ! -z $(ls "${FILESDIR}"/patches/*.patch 2>/dev/null) ]] ; then
347 EPATCH_MULTI_MSG="Applying common Gentoo patches ..." \
348 epatch "${FILESDIR}"/patches/*.patch
349 fi
350 #
351 # then per SLOT
352 if [[ -d "${FILESDIR}"/patches/${SLOT} ]] && [[ ! -z $(ls "${FILESDIR}"/patches/${SLOT}/*.patch 2>/dev/null) ]] ; then
353 EPATCH_MULTI_MSG="Applying SLOT-specific Gentoo patches ..." \
354 epatch "${FILESDIR}"/patches/${SLOT}/*.patch
355 fi
356 # Replacing obsolete head/tail with POSIX compliant ones
357 ht_fix_file */configure
358
359 # if ! is_crosscompile && is_multilib && \
360 # [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then
361 # disgusting_gcc_multilib_HACK || die "multilib hack failed"
362 # fi
363
364 # Fixup libtool to correctly generate .la files with portage
365 cd "${S}"
366 elibtoolize --portage --shallow --no-uclibc
367
368 gnuconfig_update
369 # update configure files
370 einfo "Fixing misc issues in configure files"
371 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
372 ebegin " Updating ${f}"
373 patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
374 || eerror "Please file a bug about this"
375 eend $?
376 done
377
378 # this is only needed for gnat-gpl-4.1 and breaks for gnat-gcc, so
379 # this block was moved to corresponding ebuild
380 # pushd "${S}"/gnattools &> /dev/null
381 # eautoconf
382 # popd &> /dev/null
383 ;;
384
385 common_prep)
386 # Prepare the gcc source directory
387 cd "${S}/gcc"
388 touch cstamp-h.in
389 touch ada/[es]info.h
390 touch ada/nmake.ad[bs]
391 # set the compiler name to gnatgcc
392 for i in `find ada/ -name '*.ad[sb]'`; do \
393 sed -i -e "s/\"gcc\"/\"gnatgcc\"/g" ${i}; \
394 done
395 # add -fPIC flag to shared libs for 3.4* backend
396 if [ "3.4" == "${GCCBRANCH}" ] ; then
397 cd ada
398 epatch "${FILESDIR}"/gnat-Make-lang.in.patch
399 fi
400
401 # gcc 4.3 sources seem to have a common omission of $(DESTDIR),
402 # that leads to make install trying to rm -f file on live system.
403 # As we do not need this rm, we simply remove the whole line
404 if [ "4.3" == "${GCCBRANCH}" ] ; then
405 sed -i -e "/\$(RM) \$(bindir)/d" "${S}"/gcc/ada/Make-lang.in
406 fi
407
408 mkdir -p "${GNATBUILD}"
409 ;;
410
411 all)
412 gnatbuild_src_unpack base_unpack common_prep
413 ;;
414 esac
415 shift
416 done
417 }
418
419 # it would be nice to split configure and make steps
420 # but both need to operate inside specially tuned evironment
421 # so just do sections for now (as in eclass section of handbook)
422 # sections are: configure, make-tools, bootstrap,
423 # gnatlib_and_tools, gnatlib-shared
424 gnatbuild_src_compile() {
425 debug-print-function ${FUNCNAME} $@
426 if [[ -z "$1" ]]; then
427 gnatbuild_src_compile all
428 return $?
429 fi
430
431 if [[ "all" == "$1" ]]
432 then # specialcasing "all" to avoid scanning sources unnecessarily
433 gnatbuild_src_compile configure make-tools \
434 bootstrap gnatlib_and_tools gnatlib-shared
435
436 else
437 # Set some paths to our bootstrap compiler.
438 export PATH="${GNATBOOT}/bin:${PATH}"
439 # !ATTN! the bootstrap compilers have a very simplystic structure,
440 # so many paths are not identical to the installed ones.
441 # Plus it was simplified even more in new releases.
442 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
443 GNATLIB="${GNATBOOT}/lib"
444 else
445 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
446 fi
447
448 export CC="${GNATBOOT}/bin/gnatgcc"
449 # CPATH is supposed to be applied for any language, thus
450 # superceding either of C/CPLUS/OBJC_INCLUDE_PATHs
451 export CPATH="${GNATLIB}/include"
452 #export INCLUDE_DIR="${GNATLIB}/include"
453 #export C_INCLUDE_PATH="${GNATLIB}/include"
454 #export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
455 export LIB_DIR="${GNATLIB}"
456 export LDFLAGS="-L${GNATLIB}"
457
458 # additional vars from gnuada and elsewhere
459 #export LD_RUN_PATH="${LIBPATH}"
460 export LIBRARY_PATH="${GNATLIB}"
461 #export LD_LIBRARY_PATH="${GNATLIB}"
462 # export COMPILER_PATH="${GNATBOOT}/bin/"
463
464 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
465 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
466
467 # einfo "CC=${CC},
468 # ADA_INCLUDE_PATH=${ADA_INCLUDE_PATH},
469 # LDFLAGS=${LDFLAGS},
470 # PATH=${PATH}"
471
472 while [ "$1" ]; do
473 case $1 in
474 configure)
475 debug-print-section configure
476 # Configure gcc
477 local confgcc
478
479 # some cross-compile logic from toolchain
480 confgcc="${confgcc} --host=${CHOST}"
481 if is_crosscompile || tc-is-cross-compiler ; then
482 confgcc="${confgcc} --target=${CTARGET}"
483 fi
484 [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}"
485
486 # Native Language Support
487 if use nls ; then
488 confgcc="${confgcc} --enable-nls --without-included-gettext"
489 else
490 confgcc="${confgcc} --disable-nls"
491 fi
492
493 if version_is_at_least 4.6 ; then
494 confgcc+=( $(use_enable lto) )
495 else
496 confgcc+=( --disable-lto )
497 fi
498
499 # reasonably sane globals (from toolchain)
500 # also disable mudflap and ssp
501 confgcc="${confgcc} \
502 --with-system-zlib \
503 --disable-checking \
504 --disable-werror \
505 --disable-libgomp \
506 --disable-libmudflap \
507 --disable-libssp \
508 --disable-libunwind-exceptions"
509
510 if in_iuse openmp ; then
511 # Make sure target has pthreads support. #326757 #335883
512 # There shouldn't be a chicken&egg problem here as openmp won't
513 # build without a C library, and you can't build that w/out
514 # already having a compiler ...
515 if ! is_crosscompile || \
516 $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
517 then
518 case $(tc-arch) in
519 arm)
520 confgcc+=( --disable-libgomp )
521 ;;
522 *)
523 confgcc+=( $(use_enable openmp libgomp) )
524 ;;
525 esac
526 else
527 # Force disable as the configure script can be dumb #359855
528 confgcc+=( --disable-libgomp )
529 fi
530 else
531 # For gcc variants where we don't want openmp (e.g. kgcc)
532 confgcc+=( --disable-libgomp )
533 fi
534
535 # ACT's gnat-gpl does not like libada for whatever reason..
536 if version_is_at_least 4.2 ; then
537 confgcc="${confgcc} --enable-libada"
538 # else
539 # einfo "ACT's gnat-gpl does not like libada, disabling"
540 # confgcc="${confgcc} --disable-libada"
541 fi
542
543 # set some specifics available in later versions
544 if version_is_at_least 4.3 ; then
545 einfo "setting gnat thread model"
546 confgcc="${confgcc} --enable-threads=gnat"
547 confgcc="${confgcc} --enable-shared=boehm-gc,ada,libada"
548 else
549 confgcc="${confgcc} --enable-threads=posix"
550 confgcc="${confgcc} --enable-shared"
551 fi
552
553 # multilib support
554 if is_multilib ; then
555 confgcc="${confgcc} --enable-multilib"
556 else
557 confgcc="${confgcc} --disable-multilib"
558 fi
559
560 # __cxa_atexit is "essential for fully standards-compliant handling of
561 # destructors", but apparently requires glibc.
562 if [[ ${CTARGET} == *-gnu* ]] ; then
563 confgcc="${confgcc} --enable-__cxa_atexit"
564 confgcc="${confgcc} --enable-clocale=gnu"
565 fi
566
567 einfo "confgcc=${confgcc}"
568
569 # need to strip graphite flags or we'll get the
570 # dreaded C compiler cannot create executables...
571 # error.
572 strip-flags -floop-interchange -floop-strip-mine -floop-block
573
574 cd "${GNATBUILD}"
575 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" "${S}"/configure \
576 --prefix=${PREFIX} \
577 --bindir=${BINPATH} \
578 --includedir=${INCLUDEPATH} \
579 --libdir="${LIBPATH}" \
580 --libexecdir="${LIBEXECPATH}" \
581 --datadir=${DATAPATH} \
582 --mandir=${DATAPATH}/man \
583 --infodir=${DATAPATH}/info \
584 --program-prefix=gnat \
585 --enable-languages="c,ada" \
586 --with-gcc \
587 ${confgcc} || die "configure failed"
588 ;;
589
590 make-tools)
591 debug-print-section make-tools
592 # Compile helper tools
593 cd "${GNATBOOT}"
594 cp "${S}"/gcc/ada/xtreeprs.adb .
595 cp "${S}"/gcc/ada/xsinfo.adb .
596 cp "${S}"/gcc/ada/xeinfo.adb .
597 cp "${S}"/gcc/ada/xnmake.adb .
598 cp "${S}"/gcc/ada/xutil.ad{s,b} .
599 if (( ${GNATMINOR} > 5 )) ; then
600 cp "${S}"/gcc/ada/einfo.ad{s,b} .
601 cp "${S}"/gcc/ada/csinfo.adb .
602 cp "${S}"/gcc/ada/ceinfo.adb .
603 fi
604 gnatmake xtreeprs && \
605 gnatmake xsinfo && \
606 gnatmake xeinfo && \
607 gnatmake xnmake || die "building helper tools"
608 ;;
609
610 bootstrap)
611 debug-print-section bootstrap
612 # and, finally, the build itself
613 cd "${GNATBUILD}"
614 emake bootstrap || die "bootstrap failed"
615 ;;
616
617 gnatlib_and_tools)
618 debug-print-section gnatlib_and_tools
619 einfo "building gnatlib_and_tools"
620 cd "${GNATBUILD}"
621 emake -j1 -C gcc gnatlib_and_tools || \
622 die "gnatlib_and_tools failed"
623 ;;
624
625 gnatlib-shared)
626 debug-print-section gnatlib-shared
627 einfo "building shared lib"
628 cd "${GNATBUILD}"
629 rm -f gcc/ada/rts/*.{o,ali} || die
630 #otherwise make tries to reuse already compiled (without -fPIC) objs..
631 emake -j1 -C gcc gnatlib-shared LIBRARY_VERSION="${GCCBRANCH}" || \
632 die "gnatlib-shared failed"
633 ;;
634
635 esac
636 shift
637 done # while
638 fi # "all" == "$1"
639 }
640 # -- end gnatbuild_src_compile
641
642
643 gnatbuild_src_install() {
644 debug-print-function ${FUNCNAME} $@
645
646 if [[ -z "$1" ]] ; then
647 gnatbuild_src_install all
648 return $?
649 fi
650
651 while [ "$1" ]; do
652 case $1 in
653 install) # runs provided make install
654 debug-print-section install
655
656 # Looks like we need an access to the bootstrap compiler here too
657 # as gnat apparently wants to compile something during the installation
658 # The spotted obuser was xgnatugn, used to process gnat_ugn_urw.texi,
659 # during preparison of the docs.
660 export PATH="${GNATBOOT}/bin:${PATH}"
661 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
662 GNATLIB="${GNATBOOT}/lib"
663 else
664 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
665 fi
666
667 export CC="${GNATBOOT}/bin/gnatgcc"
668 export INCLUDE_DIR="${GNATLIB}/include"
669 export C_INCLUDE_PATH="${GNATLIB}/include"
670 export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
671 export LIB_DIR="${GNATLIB}"
672 export LDFLAGS="-L${GNATLIB}"
673 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
674 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
675
676 # Do not allow symlinks in /usr/lib/gcc/${CHOST}/${MY_PV}/include as
677 # this can break the build.
678 for x in "${GNATBUILD}"/gcc/include/* ; do
679 if [ -L ${x} ] ; then
680 rm -f ${x}
681 fi
682 done
683 # Remove generated headers, as they can cause things to break
684 # (ncurses, openssl, etc). (from toolchain.eclass)
685 for x in $(find "${WORKDIR}"/build/gcc/include/ -name '*.h') ; do
686 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
687 && rm -f "${x}"
688 done
689
690
691 cd "${GNATBUILD}"
692 make DESTDIR="${D}" install || die
693
694 if use doc ; then
695 if (( $(bc <<< "${GNATBRANCH} > 4.3") )) ; then
696 #make a convenience info link
697 elog "Yay! Math is good."
698 dosym gnat_ugn.info ${DATAPATH}/info/gnat.info
699 fi
700 fi
701 ;;
702
703 move_libs)
704 debug-print-section move_libs
705
706 # first we need to remove some stuff to make moving easier
707 rm -rf "${D}${LIBPATH}"/{32,include,libiberty.a}
708 # gcc insists on installing libs in its own place
709 mv "${D}${LIBPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBPATH}"
710 mv "${D}${LIBEXECPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBEXECPATH}"
711
712 # libgcc_s and, with gcc>=4.0, other libs get installed in multilib specific locations by gcc
713 # we pull everything together to simplify working environment
714 if has_multilib_profile ; then
715 case $(tc-arch) in
716 amd64)
717 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR amd64)/* "${D}${LIBPATH}"
718 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR x86)/* "${D}${LIBPATH}"/32
719 ;;
720 ppc64)
721 # not supported yet, will have to be adjusted when we
722 # actually build gnat for that arch
723 ;;
724 esac
725 fi
726
727 # force gnatgcc to use its own specs - versions prior to 3.4.6 read specs
728 # from system gcc location. Do the simple wrapper trick for now
729 # !ATTN! change this if eselect-gnat starts to follow eselect-compiler
730 if [[ ${GCCVER} < 3.4.6 ]] ; then
731 # gcc 4.1 uses builtin specs. What about 4.0?
732 cd "${D}${BINPATH}"
733 mv gnatgcc gnatgcc_2wrap
734 cat > gnatgcc << EOF
735 #! /bin/bash
736 # wrapper to cause gnatgcc read appropriate specs and search for the right .h
737 # files (in case no matching gcc is installed)
738 BINDIR=\$(dirname \$0)
739 # The paths in the next line have to be absolute, as gnatgcc may be called from
740 # any location
741 \${BINDIR}/gnatgcc_2wrap -specs="${LIBPATH}/specs" -I"${LIBPATH}/include" \$@
742 EOF
743 chmod a+x gnatgcc
744 fi
745
746 # earlier gnat's generate some Makefile's at generic location, need to
747 # move to avoid collisions
748 [ -f "${D}${PREFIX}"/share/gnat/Makefile.generic ] &&
749 mv "${D}${PREFIX}"/share/gnat/Makefile.* "${D}${DATAPATH}"
750
751 # use gid of 0 because some stupid ports don't have
752 # the group 'root' set to gid 0 (toolchain.eclass)
753 chown -R root:0 "${D}${LIBPATH}"
754 ;;
755
756 cleanup)
757 debug-print-section cleanup
758
759 rm -rf "${D}${LIBPATH}"/{gcc,install-tools,../lib{32,64}}
760 rm -rf "${D}${LIBEXECPATH}"/{gcc,install-tools}
761
762 # this one is installed by gcc and is a duplicate even here anyway
763 rm -f "${D}${BINPATH}/${CTARGET}-gcc-${GCCRELEASE}"
764
765 # remove duplicate docs
766 rm -f "${D}${DATAPATH}"/info/{dir,gcc,cpp}*
767 rm -rf "${D}${DATAPATH}"/man/man7/
768
769 # fix .la path for lto plugin
770 if use lto ; then
771 sed -i -e \
772 "/libdir=/c\libdir='${LIBEXECPATH}'" \
773 "${D}${LIBEXECPATH}"/liblto_plugin.la \
774 || die "sed update of .la file failed!"
775 fi
776 ;;
777
778 prep_env)
779 # instead of putting junk under /etc/env.d/gnat we recreate env files as
780 # needed with eselect
781 create_eselect_conf
782 ;;
783
784 all)
785 gnatbuild_src_install install move_libs cleanup prep_env
786 ;;
787 esac
788 shift
789 done # while
790 }
791 # -- end gnatbuild_src_install

  ViewVC Help
Powered by ViewVC 1.1.20