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

Contents of /eclass/gnatbuild.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (show annotations) (download)
Sat Sep 15 16:16:53 2012 UTC (2 years, 1 month ago) by zmedico
Branch: MAIN
Changes since 1.54: +2 -4 lines
Remove redundant DESCRIPTION variable settings.

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

  ViewVC Help
Powered by ViewVC 1.1.20