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

Contents of /eclass/gnatbuild.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.56 - (show annotations) (download)
Fri Aug 2 17:38:57 2013 UTC (16 months, 3 weeks ago) by george
Branch: MAIN
Changes since 1.55: +11 -4 lines
added basic checks for empty patch dirs

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.55 2012/09/15 16:16:53 zmedico 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 # first, the common patches
341 if [[ -d "${FILESDIR}"/patches ]] && [[ ! -z $(ls "${FILESDIR}"/patches/*.patch 2>/dev/null) ]] ; then
342 EPATCH_MULTI_MSG="Applying common Gentoo patches ..." \
343 epatch "${FILESDIR}"/patches/*.patch
344 fi
345 #
346 # then per SLOT
347 if [[ -d "${FILESDIR}"/patches/${SLOT} ]] && [[ ! -z $(ls "${FILESDIR}"/patches/${SLOT}/*.patch 2>/dev/null) ]] ; then
348 EPATCH_MULTI_MSG="Applying SLOT-specific Gentoo patches ..." \
349 epatch "${FILESDIR}"/patches/${SLOT}/*.patch
350 fi
351 # Replacing obsolete head/tail with POSIX compliant ones
352 ht_fix_file */configure
353
354 # if ! is_crosscompile && is_multilib && \
355 # [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then
356 # disgusting_gcc_multilib_HACK || die "multilib hack failed"
357 # fi
358
359 # Fixup libtool to correctly generate .la files with portage
360 cd "${S}"
361 elibtoolize --portage --shallow --no-uclibc
362
363 gnuconfig_update
364 # update configure files
365 einfo "Fixing misc issues in configure files"
366 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
367 ebegin " Updating ${f}"
368 patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
369 || eerror "Please file a bug about this"
370 eend $?
371 done
372
373 # this is only needed for gnat-gpl-4.1 and breaks for gnat-gcc, so
374 # this block was moved to corresponding ebuild
375 # pushd "${S}"/gnattools &> /dev/null
376 # eautoconf
377 # popd &> /dev/null
378 ;;
379
380 common_prep)
381 # Prepare the gcc source directory
382 cd "${S}/gcc"
383 touch cstamp-h.in
384 touch ada/[es]info.h
385 touch ada/nmake.ad[bs]
386 # set the compiler name to gnatgcc
387 for i in `find ada/ -name '*.ad[sb]'`; do \
388 sed -i -e "s/\"gcc\"/\"gnatgcc\"/g" ${i}; \
389 done
390 # add -fPIC flag to shared libs for 3.4* backend
391 if [ "3.4" == "${GCCBRANCH}" ] ; then
392 cd ada
393 epatch "${FILESDIR}"/gnat-Make-lang.in.patch
394 fi
395
396 # gcc 4.3 sources seem to have a common omission of $(DESTDIR),
397 # that leads to make install trying to rm -f file on live system.
398 # As we do not need this rm, we simply remove the whole line
399 if [ "4.3" == "${GCCBRANCH}" ] ; then
400 sed -i -e "/\$(RM) \$(bindir)/d" "${S}"/gcc/ada/Make-lang.in
401 fi
402
403 mkdir -p "${GNATBUILD}"
404 ;;
405
406 all)
407 gnatbuild_src_unpack base_unpack common_prep
408 ;;
409 esac
410 shift
411 done
412 }
413
414 # it would be nice to split configure and make steps
415 # but both need to operate inside specially tuned evironment
416 # so just do sections for now (as in eclass section of handbook)
417 # sections are: configure, make-tools, bootstrap,
418 # gnatlib_and_tools, gnatlib-shared
419 gnatbuild_src_compile() {
420 debug-print-function ${FUNCNAME} $@
421 if [[ -z "$1" ]]; then
422 gnatbuild_src_compile all
423 return $?
424 fi
425
426 if [[ "all" == "$1" ]]
427 then # specialcasing "all" to avoid scanning sources unnecessarily
428 gnatbuild_src_compile configure make-tools \
429 bootstrap gnatlib_and_tools gnatlib-shared
430
431 else
432 # Set some paths to our bootstrap compiler.
433 export PATH="${GNATBOOT}/bin:${PATH}"
434 # !ATTN! the bootstrap compilers have a very simplystic structure,
435 # so many paths are not identical to the installed ones.
436 # Plus it was simplified even more in new releases.
437 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
438 GNATLIB="${GNATBOOT}/lib"
439 else
440 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
441 fi
442
443 export CC="${GNATBOOT}/bin/gnatgcc"
444 # CPATH is supposed to be applied for any language, thus
445 # superceding either of C/CPLUS/OBJC_INCLUDE_PATHs
446 export CPATH="${GNATLIB}/include"
447 #export INCLUDE_DIR="${GNATLIB}/include"
448 #export C_INCLUDE_PATH="${GNATLIB}/include"
449 #export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
450 export LIB_DIR="${GNATLIB}"
451 export LDFLAGS="-L${GNATLIB}"
452
453 # additional vars from gnuada and elsewhere
454 #export LD_RUN_PATH="${LIBPATH}"
455 export LIBRARY_PATH="${GNATLIB}"
456 #export LD_LIBRARY_PATH="${GNATLIB}"
457 # export COMPILER_PATH="${GNATBOOT}/bin/"
458
459 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
460 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
461
462 # einfo "CC=${CC},
463 # ADA_INCLUDE_PATH=${ADA_INCLUDE_PATH},
464 # LDFLAGS=${LDFLAGS},
465 # PATH=${PATH}"
466
467 while [ "$1" ]; do
468 case $1 in
469 configure)
470 debug-print-section configure
471 # Configure gcc
472 local confgcc
473
474 # some cross-compile logic from toolchain
475 confgcc="${confgcc} --host=${CHOST}"
476 if is_crosscompile || tc-is-cross-compiler ; then
477 confgcc="${confgcc} --target=${CTARGET}"
478 fi
479 [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}"
480
481 # Native Language Support
482 if use nls ; then
483 confgcc="${confgcc} --enable-nls --without-included-gettext"
484 else
485 confgcc="${confgcc} --disable-nls"
486 fi
487
488 # reasonably sane globals (from toolchain)
489 # also disable mudflap and ssp
490 confgcc="${confgcc} \
491 --with-system-zlib \
492 --disable-checking \
493 --disable-werror \
494 --disable-libmudflap \
495 --disable-libssp \
496 --disable-libunwind-exceptions"
497
498 # ACT's gnat-gpl does not like libada for whatever reason..
499 if version_is_at_least 4.2 ; then
500 confgcc="${confgcc} --enable-libada"
501 # else
502 # einfo "ACT's gnat-gpl does not like libada, disabling"
503 # confgcc="${confgcc} --disable-libada"
504 fi
505
506 # set some specifics available in later versions
507 if version_is_at_least 4.3 ; then
508 einfo "setting gnat thread model"
509 confgcc="${confgcc} --enable-threads=gnat"
510 confgcc="${confgcc} --enable-shared=boehm-gc,ada,libada"
511 else
512 confgcc="${confgcc} --enable-threads=posix"
513 confgcc="${confgcc} --enable-shared"
514 fi
515
516 # multilib support
517 if is_multilib ; then
518 confgcc="${confgcc} --enable-multilib"
519 else
520 confgcc="${confgcc} --disable-multilib"
521 fi
522
523 # __cxa_atexit is "essential for fully standards-compliant handling of
524 # destructors", but apparently requires glibc.
525 if [[ ${CTARGET} == *-gnu* ]] ; then
526 confgcc="${confgcc} --enable-__cxa_atexit"
527 confgcc="${confgcc} --enable-clocale=gnu"
528 fi
529
530 einfo "confgcc=${confgcc}"
531
532 cd "${GNATBUILD}"
533 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" "${S}"/configure \
534 --prefix=${PREFIX} \
535 --bindir=${BINPATH} \
536 --includedir=${INCLUDEPATH} \
537 --libdir="${LIBPATH}" \
538 --libexecdir="${LIBEXECPATH}" \
539 --datadir=${DATAPATH} \
540 --mandir=${DATAPATH}/man \
541 --infodir=${DATAPATH}/info \
542 --program-prefix=gnat \
543 --enable-languages="c,ada" \
544 --with-gcc \
545 ${confgcc} || die "configure failed"
546 ;;
547
548 make-tools)
549 debug-print-section make-tools
550 # Compile helper tools
551 cd "${GNATBOOT}"
552 cp "${S}"/gcc/ada/xtreeprs.adb .
553 cp "${S}"/gcc/ada/xsinfo.adb .
554 cp "${S}"/gcc/ada/xeinfo.adb .
555 cp "${S}"/gcc/ada/xnmake.adb .
556 cp "${S}"/gcc/ada/xutil.ad{s,b} .
557 gnatmake xtreeprs && \
558 gnatmake xsinfo && \
559 gnatmake xeinfo && \
560 gnatmake xnmake || die "building helper tools"
561 ;;
562
563 bootstrap)
564 debug-print-section bootstrap
565 # and, finally, the build itself
566 cd "${GNATBUILD}"
567 emake bootstrap || die "bootstrap failed"
568 ;;
569
570 gnatlib_and_tools)
571 debug-print-section gnatlib_and_tools
572 einfo "building gnatlib_and_tools"
573 cd "${GNATBUILD}"
574 emake -j1 -C gcc gnatlib_and_tools || \
575 die "gnatlib_and_tools failed"
576 ;;
577
578 gnatlib-shared)
579 debug-print-section gnatlib-shared
580 einfo "building shared lib"
581 cd "${GNATBUILD}"
582 rm -f gcc/ada/rts/*.{o,ali} || die
583 #otherwise make tries to reuse already compiled (without -fPIC) objs..
584 emake -j1 -C gcc gnatlib-shared LIBRARY_VERSION="${GCCBRANCH}" || \
585 die "gnatlib-shared failed"
586 ;;
587
588 esac
589 shift
590 done # while
591 fi # "all" == "$1"
592 }
593 # -- end gnatbuild_src_compile
594
595
596 gnatbuild_src_install() {
597 debug-print-function ${FUNCNAME} $@
598
599 if [[ -z "$1" ]] ; then
600 gnatbuild_src_install all
601 return $?
602 fi
603
604 while [ "$1" ]; do
605 case $1 in
606 install) # runs provided make install
607 debug-print-section install
608
609 # Looks like we need an access to the bootstrap compiler here too
610 # as gnat apparently wants to compile something during the installation
611 # The spotted obuser was xgnatugn, used to process gnat_ugn_urw.texi,
612 # during preparison of the docs.
613 export PATH="${GNATBOOT}/bin:${PATH}"
614 if [[ ${BOOT_SLOT} > 4.1 ]] ; then
615 GNATLIB="${GNATBOOT}/lib"
616 else
617 GNATLIB="${GNATBOOT}/lib/gnatgcc/${BOOT_TARGET}/${BOOT_SLOT}"
618 fi
619
620 export CC="${GNATBOOT}/bin/gnatgcc"
621 export INCLUDE_DIR="${GNATLIB}/include"
622 export C_INCLUDE_PATH="${GNATLIB}/include"
623 export CPLUS_INCLUDE_PATH="${GNATLIB}/include"
624 export LIB_DIR="${GNATLIB}"
625 export LDFLAGS="-L${GNATLIB}"
626 export ADA_OBJECTS_PATH="${GNATLIB}/adalib"
627 export ADA_INCLUDE_PATH="${GNATLIB}/adainclude"
628
629 # Do not allow symlinks in /usr/lib/gcc/${CHOST}/${MY_PV}/include as
630 # this can break the build.
631 for x in "${GNATBUILD}"/gcc/include/* ; do
632 if [ -L ${x} ] ; then
633 rm -f ${x}
634 fi
635 done
636 # Remove generated headers, as they can cause things to break
637 # (ncurses, openssl, etc). (from toolchain.eclass)
638 for x in $(find "${WORKDIR}"/build/gcc/include/ -name '*.h') ; do
639 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
640 && rm -f "${x}"
641 done
642
643
644 cd "${GNATBUILD}"
645 make DESTDIR="${D}" install || die
646
647 #make a convenience info link
648 dosym ${DATAPATH}/info/gnat_ugn_unw.info ${DATAPATH}/info/gnat.info
649 ;;
650
651 move_libs)
652 debug-print-section move_libs
653
654 # first we need to remove some stuff to make moving easier
655 rm -rf "${D}${LIBPATH}"/{32,include,libiberty.a}
656 # gcc insists on installing libs in its own place
657 mv "${D}${LIBPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBPATH}"
658 mv "${D}${LIBEXECPATH}/gcc/${CTARGET}/${GCCRELEASE}"/* "${D}${LIBEXECPATH}"
659
660 # libgcc_s and, with gcc>=4.0, other libs get installed in multilib specific locations by gcc
661 # we pull everything together to simplify working environment
662 if has_multilib_profile ; then
663 case $(tc-arch) in
664 amd64)
665 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR amd64)/* "${D}${LIBPATH}"
666 mv "${D}${LIBPATH}"/../$(get_abi_LIBDIR x86)/* "${D}${LIBPATH}"/32
667 ;;
668 ppc64)
669 # not supported yet, will have to be adjusted when we
670 # actually build gnat for that arch
671 ;;
672 esac
673 fi
674
675 # force gnatgcc to use its own specs - versions prior to 3.4.6 read specs
676 # from system gcc location. Do the simple wrapper trick for now
677 # !ATTN! change this if eselect-gnat starts to follow eselect-compiler
678 if [[ ${GCCVER} < 3.4.6 ]] ; then
679 # gcc 4.1 uses builtin specs. What about 4.0?
680 cd "${D}${BINPATH}"
681 mv gnatgcc gnatgcc_2wrap
682 cat > gnatgcc << EOF
683 #! /bin/bash
684 # wrapper to cause gnatgcc read appropriate specs and search for the right .h
685 # files (in case no matching gcc is installed)
686 BINDIR=\$(dirname \$0)
687 # The paths in the next line have to be absolute, as gnatgcc may be called from
688 # any location
689 \${BINDIR}/gnatgcc_2wrap -specs="${LIBPATH}/specs" -I"${LIBPATH}/include" \$@
690 EOF
691 chmod a+x gnatgcc
692 fi
693
694 # earlier gnat's generate some Makefile's at generic location, need to
695 # move to avoid collisions
696 [ -f "${D}${PREFIX}"/share/gnat/Makefile.generic ] &&
697 mv "${D}${PREFIX}"/share/gnat/Makefile.* "${D}${DATAPATH}"
698
699 # use gid of 0 because some stupid ports don't have
700 # the group 'root' set to gid 0 (toolchain.eclass)
701 chown -R root:0 "${D}${LIBPATH}"
702 ;;
703
704 cleanup)
705 debug-print-section cleanup
706
707 rm -rf "${D}${LIBPATH}"/{gcc,install-tools,../lib{32,64}}
708 rm -rf "${D}${LIBEXECPATH}"/{gcc,install-tools}
709
710 # this one is installed by gcc and is a duplicate even here anyway
711 rm -f "${D}${BINPATH}/${CTARGET}-gcc-${GCCRELEASE}"
712
713 # remove duplicate docs
714 rm -f "${D}${DATAPATH}"/info/{dir,gcc,cpp}*
715 rm -rf "${D}${DATAPATH}"/man/man7/
716 ;;
717
718 prep_env)
719 # instead of putting junk under /etc/env.d/gnat we recreate env files as
720 # needed with eselect
721 create_eselect_conf
722 ;;
723
724 all)
725 gnatbuild_src_install install move_libs cleanup prep_env
726 ;;
727 esac
728 shift
729 done # while
730 }
731 # -- end gnatbuild_src_install

  ViewVC Help
Powered by ViewVC 1.1.20