1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # Author: George Shapovalov <george@gentoo.org>
5 # Author: Steve Arnold <nerdboy@gentoo.org>
6 # No maintainer <maintainer-needed@gentoo.org>
9 # HOMEPAGE and LICENSE are set in appropriate ebuild, as
10 # gnat is developed by FSF and AdaCore "in parallel"
12 # The following vars can be set in ebuild before inheriting this eclass. They
15 # BOOT_SLOT - where old bootstrap is used as it works fine
20 inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator
22 FEATURES=${FEATURES/multilib-strict/}
24 EXPORT_FUNCTIONS="pkg_setup pkg_postinst pkg_postrm src_unpack src_configure src_compile src_install"
27 # multilib is supported via profiles now, multilib usevar is deprecated
29 RDEPEND="app-eselect/eselect-gnat
31 nls? ( virtual/libintl )"
34 >=app-eselect/eselect-gnat-1.3-r1
36 >=sys-devel/binutils-2.23
38 >=sys-devel/bison-1.875
39 >=sys-devel/flex-2.5.4
40 nls? ( sys-devel/gettext )"
43 # It may not be safe to source this at top level. Only source inside local
45 GnatCommon="/usr/share/gnat/lib/gnat-common.bash"
47 #---->> globals and SLOT <<----
49 # just a check, this location seems to vary too much, easier to track it in
51 #[ -z "${GNATSOURCE}" ] && die "please set GNATSOURCE in ebuild! (before inherit)"
54 # because of gnatpro/gnatgpl we need to track both gcc and gnat versions
56 # these simply default to $PV
57 GNATMAJOR=$(get_version_component_range 1)
58 GNATMINOR=$(get_version_component_range 2)
59 GNATBRANCH=$(get_version_component_range 1-2)
60 GNATRELEASE=$(get_version_component_range 1-3)
61 # this one is for the gnat-gpl which is versioned by gcc backend and ACT version
63 ACT_Ver=$(get_version_component_range 4)
65 # GCCVER and SLOT logic
67 # I better define vars for package names, as there was discussion on proper
68 # naming and it may change
72 # ATTN! GCCVER stands for the provided backend gcc, not the one on the system
73 # so tc-* functions are of no use here. The present versioning scheme makes
74 # GCCVER basically a part of PV, but *this may change*!!
76 # GCCVER can be set in the ebuild.
77 [[ -z ${GCCVER} ]] && GCCVER="${GNATRELEASE}"
80 # finally extract GCC version strings
81 GCCMAJOR=$(get_version_component_range 1 "${GCCVER}")
82 GCCMINOR=$(get_version_component_range 2 "${GCCVER}")
83 GCCBRANCH=$(get_version_component_range 1-2 "${GCCVER}")
84 GCCRELEASE=$(get_version_component_range 1-3 "${GCCVER}")
86 # SLOT logic, make it represent gcc backend, as this is what matters most
87 # There are some special cases, so we allow it to be defined in the ebuild
88 # ATTN!! If you set SLOT in the ebuild, don't forget to make sure that
89 # BOOT_SLOT is also set properly!
90 [[ -z ${SLOT} ]] && SLOT="${GCCBRANCH}"
92 # possible future crosscompilation support
93 export CTARGET=${CTARGET:-${CHOST}}
96 [[ ${CHOST} != ${CTARGET} ]]
99 # Bootstrap CTARGET and SLOT logic. For now BOOT_TARGET=CHOST is "guaranteed" by
100 # profiles, so mostly watch out for the right SLOT used in the bootstrap.
101 # As above, with SLOT, it may need to be defined in the ebuild
102 BOOT_TARGET=${CTARGET}
103 [[ -z ${BOOT_SLOT} ]] && BOOT_SLOT=${SLOT}
105 # set our install locations
106 PREFIX=${GNATBUILD_PREFIX:-/usr} # not sure we need this hook, but may be..
107 LIBPATH=${PREFIX}/$(get_libdir)/${PN}/${CTARGET}/${SLOT}
108 LIBEXECPATH=${PREFIX}/libexec/${PN}/${CTARGET}/${SLOT}
109 INCLUDEPATH=${LIBPATH}/include
110 BINPATH=${PREFIX}/${CTARGET}/${PN}-bin/${SLOT}
111 DATAPATH=${PREFIX}/share/${PN}-data/${CTARGET}/${SLOT}
112 # ATTN! the one below should match the path defined in eselect-gnat module
113 CONFIG_PATH="/usr/share/gnat/eselect"
114 gnat_profile="${CTARGET}-${PN}-${SLOT}"
115 gnat_config_file="${CONFIG_PATH}/${gnat_profile}"
119 if [[ ${PN} == "${PN_GnatPro}" ]] && [[ ${GNATMAJOR} == "3" ]]; then
120 DEPEND="x86? ( >=app-shells/tcsh-6.0 )"
122 S="${WORKDIR}/gcc-${GCCVER}"
124 # bootstrap globals, common to src_unpack and src_compile
125 GNATBOOT="${WORKDIR}/usr"
126 GNATBUILD="${WORKDIR}/build"
128 # necessary for detecting lib locations and creating env.d entry
129 #XGCC="${GNATBUILD}/gcc/xgcc -B${GNATBUILD}/gcc"
131 #----<< globals and SLOT >>----
133 # set SRC_URI's in ebuilds for now
135 #----<< support checks >>----
136 # skipping this section - do not care about hardened/multilib for now
138 #---->> specs + env.d logic <<----
141 #----<< specs + env.d logic >>----
144 #---->> some helper functions <<----
146 [[ ${GCCMAJOR} < 3 ]] && return 1
148 mips64*|powerpc64*|s390x*|sparc64*|x86_64*)
149 has_multilib_profile ;;
154 # adapted from toolchain,
155 # left only basic multilib functionality and cut off mips stuff
157 create_specs_file() {
158 einfo "Creating a vanilla gcc specs file"
159 "${WORKDIR}"/build/gcc/xgcc -dumpspecs > "${WORKDIR}"/build/vanilla.specs
163 # eselect stuff taken straight from toolchain.eclass and greatly simplified
164 add_profile_eselect_conf() {
165 local gnat_config_file=$1
169 echo >> "${D}/${gnat_config_file}"
170 if ! is_multilib ; then
171 echo " ctarget=${CTARGET}" >> "${D}/${gnat_config_file}"
173 echo "[${abi}]" >> "${D}/${gnat_config_file}"
175 if [[ -n ${!var} ]] ; then
176 echo " ctarget=${!var}" >> "${D}/${gnat_config_file}"
179 if [[ -n ${!var} ]] ; then
180 echo " ctarget=${!var}" >> "${D}/${gnat_config_file}"
182 echo " ctarget=${CTARGET}" >> "${D}/${gnat_config_file}"
188 if [[ -n ${!var} ]] ; then
189 echo " cflags=${!var}" >> "${D}/${gnat_config_file}"
194 create_eselect_conf() {
199 echo "[global]" > "${D}/${gnat_config_file}"
200 echo " version=${CTARGET}-${SLOT}" >> "${D}/${gnat_config_file}"
201 echo " binpath=${BINPATH}" >> "${D}/${gnat_config_file}"
202 echo " libexecpath=${LIBEXECPATH}" >> "${D}/${gnat_config_file}"
203 echo " ldpath=${LIBPATH}" >> "${D}/${gnat_config_file}"
204 echo " manpath=${DATAPATH}/man" >> "${D}/${gnat_config_file}"
205 echo " infopath=${DATAPATH}/info" >> "${D}/${gnat_config_file}"
206 echo " bin_prefix=${CTARGET}" >> "${D}/${gnat_config_file}"
208 for abi in $(get_all_abis) ; do
209 add_profile_eselect_conf "${gnat_config_file}" "${abi}"
215 should_we_eselect_gnat() {
216 # we only want to switch compilers if installing to / or /tmp/stage1root
217 [[ ${ROOT} == "/" ]] || return 1
219 # if the current config is invalid, we definitely want a new one
220 # Note: due to bash quirkiness, the following must not be 1 line
222 curr_config=$(eselect --colour=no gnat show | grep ${CTARGET} | awk '{ print $1 }') || return 0
223 [[ -z ${curr_config} ]] && return 0
225 # The logic is basically "try to keep the same profile if possible"
227 if [[ ${curr_config} == ${CTARGET}-${PN}-${SLOT} ]] ; then
230 elog "The current gcc config appears valid, so it will not be"
231 elog "automatically switched for you. If you would like to"
232 elog "switch to the newly installed gcc version, do the"
235 elog "eselect gnat set <profile>"
242 # active compiler selection, called from pkg_postinst
244 eselect gnat set ${CTARGET}-${PN}-${SLOT} &> /dev/null
246 elog "The following gnat profile has been activated:"
247 elog "${CTARGET}-${PN}-${SLOT}"
249 elog "The compiler has been installed as gnatgcc, and the coverage testing"
250 elog "tool as gnatgcov."
252 elog "Ada handling in Gentoo allows you to have multiple gnat variants"
253 elog "installed in parallel and automatically manage Ada libs."
254 elog "Please take a look at the Ada project page for some documentation:"
255 elog "http://www.gentoo.org/proj/en/prog_lang/ada/index.xml"
259 # Taken straight from the toolchain.eclass. Only removed the "obsolete hunk"
261 # The purpose of this DISGUSTING gcc multilib hack is to allow 64bit libs
262 # to live in lib instead of lib64 where they belong, with 32bit libraries
263 # in lib32. This hack has been around since the beginning of the amd64 port,
264 # and we're only now starting to fix everything that's broken. Eventually
265 # this should go away.
267 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
269 disgusting_gcc_multilib_HACK() {
272 if has_multilib_profile ; then
275 config="i386/t-linux64"
276 libdirs="../$(get_abi_LIBDIR amd64) ../$(get_abi_LIBDIR x86)" \
279 config="rs6000/t-linux64"
280 libdirs="../$(get_abi_LIBDIR ppc64) ../$(get_abi_LIBDIR ppc)" \
284 die "Your profile is no longer supported by portage."
287 einfo "updating multilib directories to be: ${libdirs}"
288 sed -i -e "s:^MULTILIB_OSDIRNAMES.*:MULTILIB_OSDIRNAMES = ${libdirs}:" "${S}"/gcc/config/${config}
293 gnatbuild_pkg_setup() {
294 debug-print-function ${FUNCNAME} $@
296 # Setup variables which would normally be in the profile
297 if is_crosscompile ; then
298 multilib_env ${CTARGET}
301 # we dont want to use the installed compiler's specs to build gnat!
305 gnatbuild_pkg_postinst() {
306 if should_we_eselect_gnat; then
312 # if primary compiler list is empty, add this profile to the list, so
313 # that users are not left without active compilers (making sure that
314 # libs are getting built for at least one)
316 . ${GnatCommon} || die "failed to source common code"
317 if [[ ! -f ${PRIMELIST} ]] || [[ ! -s ${PRIMELIST} ]]; then
318 echo "${gnat_profile}" > ${PRIMELIST}
319 elog "The list of primary compilers was empty and got assigned ${gnat_profile}."
321 elog "Please edit ${PRIMELIST} and list there gnat profiles intended"
322 elog "for common use."
326 gnatbuild_pkg_postrm() {
327 # "eselect gnat update" now removes the env.d file if the corresponding
328 # gnat profile was unmerged
330 elog "If you just unmerged the last gnat in this SLOT, your active gnat"
331 elog "profile got unset. Please check what eselect gnat show tells you"
332 elog "and set the desired profile"
338 # common unpack stuff
339 gnatbuild_src_unpack() {
340 debug-print-function ${FUNCNAME} $@
341 if [[ -z "$1" ]]; then
342 gnatbuild_src_unpack all
350 pax-mark E $(find ${GNATBOOT} -name gnat1)
353 # patching gcc sources, following the toolchain
354 # first, the common patches
355 if [[ -d "${FILESDIR}"/patches ]] && [[ ! -z $(ls "${FILESDIR}"/patches/*.patch 2>/dev/null) ]] ; then
356 EPATCH_MULTI_MSG="Applying common Gentoo patches ..." \
357 epatch "${FILESDIR}"/patches/*.patch
361 if [[ -d "${FILESDIR}"/patches/${SLOT} ]] && [[ ! -z $(ls "${FILESDIR}"/patches/${SLOT}/*.patch 2>/dev/null) ]] ; then
362 EPATCH_MULTI_MSG="Applying SLOT-specific Gentoo patches ..." \
363 epatch "${FILESDIR}"/patches/${SLOT}/*.patch
365 # Replacing obsolete head/tail with POSIX compliant ones
366 ht_fix_file */configure
368 # if ! is_crosscompile && is_multilib && \
369 # [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then
370 # disgusting_gcc_multilib_HACK || die "multilib hack failed"
373 # Fixup libtool to correctly generate .la files with portage
375 elibtoolize --portage --shallow --no-uclibc
378 # update configure files
379 einfo "Fixing misc issues in configure files"
380 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
381 ebegin " Updating ${f}"
382 patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
383 || eerror "Please file a bug about this"
387 # this is only needed for gnat-gpl-4.1 and breaks for gnat-gcc, so
388 # this block was moved to corresponding ebuild
389 # pushd "${S}"/gnattools &> /dev/null
395 # Prepare the gcc source directory
399 touch ada/nmake.ad[bs]
400 # set the compiler name to gnatgcc
401 for i in `find ada/ -name '*.ad[sb]'`; do \
402 sed -i -e "s/\"gcc\"/\"gnatgcc\"/g" ${i}; \
404 # add -fPIC flag to shared libs for 3.4* backend
405 if [ "3.4" == "${GCCBRANCH}" ] ; then
407 epatch "${FILESDIR}"/gnat-Make-lang.in.patch
410 # gcc 4.3 sources seem to have a common omission of $(DESTDIR),
411 # that leads to make install trying to rm -f file on live system.
412 # As we do not need this rm, we simply remove the whole line
413 if [ "4.3" == "${GCCBRANCH}" ] ; then
414 sed -i -e "/\$(RM) \$(bindir)/d" "${S}"/gcc/ada/Make-lang.in
417 mkdir -p "${GNATBUILD}"
421 gnatbuild_src_unpack base_unpack common_prep
428 # for now just dont run default configure
429 gnatbuild_src_configure() {
434 # it would be nice to split configure and make steps
435 # but both need to operate inside specially tuned evironment
436 # so just do sections for now (as in eclass section of handbook)
437 # sections are: configure, make-tools, bootstrap,
438 # gnatlib_and_tools, gnatlib-shared
439 gnatbuild_src_compile() {
440 debug-print-function ${FUNCNAME} $@
441 if [[ -z "$1" ]]; then
442 gnatbuild_src_compile all
446 if [[ "all" == "$1" ]]
447 then # specialcasing "all" to avoid scanning sources unnecessarily
448 gnatbuild_src_compile configure make-tools \
449 bootstrap gnatlib_and_tools gnatlib-shared
452 # Set some paths to our bootstrap compiler.
453 export PATH="${GNATBOOT}/bin:${PATH}"
454 # !ATTN! the bootstrap compilers have a very simplystic structure,
455 # so many paths are not identical to the installed ones.
456 # Plus it was simplified even more in new releases.
457 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
460 GNATLIB="${GNATBOOT}/lib/gcc/${BOOT_TARGET}/${BOOT_SLOT}"
463 GNATLIB="${GNATBOOT}/lib"
467 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
470 export CC="${GNATBOOT}/bin/gnatgcc"
471 # CPATH is supposed to be applied for any language, thus
472 # superceding either of C/CPLUS/OBJC_INCLUDE_PATHs
473 export CPATH="${GNATLIB}/include"
474 #export INCLUDE_DIR="${GNATLIB}/include"
475 #export C_INCLUDE_PATH="${GNATLIB}/include"
476 #export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
477 export LIB_DIR="${GNATLIB}"
478 export LDFLAGS="-L${GNATLIB}"
480 # additional vars from gnuada and elsewhere
481 #export LD_RUN_PATH="${LIBPATH}"
482 export LIBRARY_PATH="${GNATLIB}"
483 #export LD_LIBRARY_PATH="${GNATLIB}"
484 # export COMPILER_PATH="${GNATBOOT}/bin/"
486 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
487 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
490 ADA_INCLUDE_PATH=${ADA_INCLUDE_PATH},
497 debug-print-section configure
501 # some cross-compile logic from toolchain
502 confgcc="${confgcc} --host=${CHOST}"
503 if is_crosscompile || tc-is-cross-compiler ; then
504 confgcc="${confgcc} --target=${CTARGET}"
506 [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}"
508 # Native Language Support
510 confgcc="${confgcc} --enable-nls --without-included-gettext"
512 confgcc="${confgcc} --disable-nls"
515 if version_is_at_least 4.6 ; then
516 confgcc="${confgcc} --enable-lto"
517 elif tc_version_is_at_least 4.5 ; then
518 confgcc="${confgcc} --disable-lto --disable-plugin"
521 # reasonably sane globals (from toolchain)
522 # also disable mudflap and ssp
523 confgcc="${confgcc} \
527 --disable-libmudflap \
530 --disable-fixed-point \
532 --disable-libcilkrts \
533 --disable-libsanitizer \
534 --disable-libunwind-exceptions"
536 if in_iuse openmp ; then
537 # Make sure target has pthreads support. #326757 #335883
538 # There shouldn't be a chicken&egg problem here as openmp won't
539 # build without a C library, and you can't build that w/out
540 # already having a compiler ...
541 if ! is_crosscompile || \
542 $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
546 confgcc="${confgcc} --disable-libgomp"
549 confgcc="${confgcc} $(use_enable openmp libgomp)"
553 # Force disable as the configure script can be dumb #359855
554 confgcc="${confgcc} --disable-libgomp"
557 # For gcc variants where we don't want openmp (e.g. kgcc)
558 confgcc="${confgcc} --disable-libgomp"
561 # ACT's gnat-gpl does not like libada for whatever reason..
562 if version_is_at_least 4.2 ; then
563 confgcc="${confgcc} --enable-libada"
565 # einfo "ACT's gnat-gpl does not like libada, disabling"
566 # confgcc="${confgcc} --disable-libada"
569 # set some specifics available in later versions
570 if version_is_at_least 4.7 ; then
571 einfo "setting gnat thread model"
572 confgcc="${confgcc} --enable-threads=posix"
573 confgcc="${confgcc} --enable-shared=boehm-gc,ada,libada"
574 elif version_is_at_least 4.3 ; then
575 confgcc="${confgcc} --enable-threads=gnat"
576 confgcc="${confgcc} --enable-shared=boehm-gc,ada,libada"
578 confgcc="${confgcc} --enable-threads=posix"
579 confgcc="${confgcc} --enable-shared"
583 if is_multilib ; then
584 confgcc="${confgcc} --enable-multilib"
586 confgcc="${confgcc} --disable-multilib"
589 # __cxa_atexit is "essential for fully standards-compliant handling of
590 # destructors", but apparently requires glibc.
591 if [[ ${CTARGET} == *-gnu* ]] ; then
592 confgcc="${confgcc} --enable-__cxa_atexit"
593 confgcc="${confgcc} --enable-clocale=gnu"
596 einfo "confgcc=${confgcc}"
598 export gcc_cv_lto_plugin=1 # okay to build, default to opt-in
599 export gcc_cv_prog_makeinfo_modern=no
600 export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
601 export gcc_cv_libc_provides_ssp=yes
603 # need to strip graphite/lto flags or we'll get the
604 # dreaded C compiler cannot create executables...
607 replace-flags -O? -O2
608 filter-flags '-mabi*' -m31 -m32 -m64
609 filter-flags -frecord-gcc-switches
610 filter-flags -mno-rtm -mno-htm
611 #filter-flags -floop-interchange -floop-strip-mine -floop-block
612 #filter-flags -fuse-linker-plugin -flto*
615 CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CFLAGS}" "${S}"/configure \
616 --prefix="${PREFIX}" \
617 --bindir="${BINPATH}" \
618 --includedir="${INCLUDEPATH}" \
619 --libdir="${LIBPATH}" \
620 --libexecdir="${LIBEXECPATH}" \
621 --datadir="${DATAPATH}" \
622 --mandir="${DATAPATH}"/man \
623 --infodir="${DATAPATH}"/info \
624 --enable-languages=c,ada \
626 ${confgcc} || die "configure failed"
630 debug-print-section make-tools
631 # Compile helper tools
633 cp "${S}"/gcc/ada/xtreeprs.adb .
634 cp "${S}"/gcc/ada/xsinfo.adb .
635 cp "${S}"/gcc/ada/xeinfo.adb .
636 cp "${S}"/gcc/ada/xnmake.adb .
637 cp "${S}"/gcc/ada/xutil.ad{s,b} .
638 if (( ${GNATMINOR} > 5 )) ; then
639 cp "${S}"/gcc/ada/einfo.ad{s,b} .
640 cp "${S}"/gcc/ada/csinfo.adb .
641 cp "${S}"/gcc/ada/ceinfo.adb .
643 gnatmake xtreeprs && \
646 gnatmake xnmake || die "building helper tools"
648 mv xeinfo xnmake xsinfo xtreeprs bin/
652 debug-print-section bootstrap
653 # and, finally, the build itself
656 LDFLAGS="${LDFLAGS}" \
657 LIBPATH="${LIBPATH}" \
659 bootstrap-lean || die "bootstrap failed"
663 debug-print-section gnatlib_and_tools
664 einfo "building gnatlib_and_tools"
666 emake -j1 -C gcc gnatlib_and_tools || \
667 die "gnatlib_and_tools failed"
671 debug-print-section gnatlib-shared
672 einfo "building shared lib"
674 rm -f gcc/ada/rts/*.{o,ali} || die
675 #otherwise make tries to reuse already compiled (without -fPIC) objs..
676 emake -j1 -C gcc gnatlib-shared LIBRARY_VERSION="${GCCBRANCH}" || \
677 die "gnatlib-shared failed"
685 # -- end gnatbuild_src_compile
688 gnatbuild_src_install() {
689 debug-print-function ${FUNCNAME} $@
691 if [[ -z "$1" ]] ; then
692 gnatbuild_src_install all
698 install) # runs provided make install
699 debug-print-section install
701 # Looks like we need an access to the bootstrap compiler here too
702 # as gnat apparently wants to compile something during the installation
703 # The spotted obuser was xgnatugn, used to process gnat_ugn_urw.texi,
704 # during preparison of the docs.
705 export PATH="${GNATBOOT}/bin:${PATH}"
706 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
707 GNATLIB="${GNATBOOT}/lib"
709 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
712 export CC="${GNATBOOT}/bin/gnatgcc"
713 export INCLUDE_DIR="${GNATLIB}/include"
714 export C_INCLUDE_PATH="${GNATLIB}/include"
715 export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
716 export LIB_DIR="${GNATLIB}"
717 export LDFLAGS="-L${GNATLIB}"
718 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
719 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
721 # Do not allow symlinks in /usr/lib/gcc/${CHOST}/${MY_PV}/include as
722 # this can break the build.
723 for x in "${GNATBUILD}"/gcc/include/* ; do
724 if [ -L ${x} ] ; then
728 # Remove generated headers, as they can cause things to break
729 # (ncurses, openssl, etc). (from toolchain.eclass)
730 for x in $(find "${WORKDIR}"/build/gcc/include/ -name '*.h') ; do
731 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
737 make DESTDIR="${D}" install || die
739 # Disable RANDMMAP so PCH works. #301299
740 pax-mark r "${D}"${LIBEXECPATH}/{gnat1,cc1,cc1plus}
741 # Quiet QA warnings, wait for adacore exec stack patch in gcc 7
742 export QA_EXECSTACK="${BINPATH:1}/gnatls ${BINPATH:1}/gnatname
743 ${BINPATH:1}/gnatmake ${BINPATH:1}/gnatclean ${BINPATH:1}/gnat"
746 if (( $(bc <<< "${GNATBRANCH} > 4.3") )) ; then
747 #make a convenience info link
748 ewarn "Yay! Math works."
749 dosym gnat_ugn.info ${DATAPATH}/info/gnat.info
755 debug-print-section move_libs
757 # first we need to remove some stuff to make moving easier
758 rm -rf "${D}${LIBPATH}"/{32,include,libiberty.a}
759 # gcc insists on installing libs in its own place
760 mv "${D}${LIBPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBPATH}"
761 mv "${D}${LIBEXECPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBEXECPATH}"
763 # libgcc_s and, with gcc>=4.0, other libs get installed in multilib specific locations by gcc
764 # we pull everything together to simplify working environment
765 if has_multilib_profile ; then
768 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR amd64)/* "${D}${LIBPATH}"
769 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR x86)/* "${D}${LIBPATH}"/32
772 # not supported yet, will have to be adjusted when we
773 # actually build gnat for that arch
778 # force gnatgcc to use its own specs - versions prior to 3.4.6 read specs
779 # from system gcc location. Do the simple wrapper trick for now
780 # !ATTN! change this if eselect-gnat starts to follow eselect-compiler
782 if [[ ${GCCVER} < 3.4.6 ]] ; then
783 # gcc 4.1 uses builtin specs. What about 4.0?
784 mv gnatgcc gnatgcc_2wrap
787 # wrapper to cause gnatgcc read appropriate specs and search for the right .h
788 # files (in case no matching gcc is installed)
789 BINDIR=\$(dirname \$0)
790 # The paths in the next line have to be absolute, as gnatgcc may be called from
792 \${BINDIR}/gnatgcc_2wrap -specs="${LIBPATH}/specs" -I"${LIBPATH}/include" \$@
797 for i in cpp gcc gcov ; do
802 # earlier gnat's generate some Makefile's at generic location, need to
803 # move to avoid collisions
804 [ -f "${D}${PREFIX}"/share/gnat/Makefile.generic ] &&
805 mv "${D}${PREFIX}"/share/gnat/Makefile.* "${D}${DATAPATH}"
807 # use gid of 0 because some stupid ports don't have
808 # the group 'root' set to gid 0 (toolchain.eclass)
809 # chown -R root:0 "${D}${LIBPATH}"
813 debug-print-section cleanup
815 rm -rf "${D}${LIBPATH}"/{gcc,install-tools,../lib{32,64}}
816 rm -rf "${D}${LIBEXECPATH}"/{gcc,install-tools}
818 # this one is installed by gcc and is a duplicate even here anyway
819 rm -f "${D}${BINPATH}/${CTARGET}-gcc-${GCCRELEASE}"
821 # remove duplicate docs
822 rm -f "${D}${DATAPATH}"/info/{dir,gcc,cpp}*
823 rm -rf "${D}${DATAPATH}"/man/man7/
825 # fix .la path for lto plugin
828 "/libdir=/c\libdir='${LIBEXECPATH}'" \
829 "${D}${LIBEXECPATH}"/liblto_plugin.la \
830 || die "sed update of .la file failed!"
835 # instead of putting junk under /etc/env.d/gnat we recreate env files as
836 # needed with eselect
841 gnatbuild_src_install install move_libs cleanup prep_env
847 # -- end gnatbuild_src_install