Gentoo Archives: gentoo-commits

From: David Seifert <soap@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 06 May 2017 16:36:30
Message-Id: 1494088562.9f1785bcb8a698a85818b5abe13141fb44eaf124.soap@gentoo
1 commit: 9f1785bcb8a698a85818b5abe13141fb44eaf124
2 Author: David Seifert <soap <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 6 16:34:34 2017 +0000
4 Commit: David Seifert <soap <AT> gentoo <DOT> org>
5 CommitDate: Sat May 6 16:36:02 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f1785bc
7
8 gnat.eclass: Remove last-rited eclass
9
10 eclass/gnat.eclass | 459 -----------------------------------------------------
11 1 file changed, 459 deletions(-)
12
13 diff --git a/eclass/gnat.eclass b/eclass/gnat.eclass
14 deleted file mode 100644
15 index e9ffa5b1f10..00000000000
16 --- a/eclass/gnat.eclass
17 +++ /dev/null
18 @@ -1,459 +0,0 @@
19 -# Copyright 1999-2015 Gentoo Foundation
20 -# Distributed under the terms of the GNU General Public License v2
21 -
22 -# @DEAD
23 -# Removal on 2017-03-24.
24 -
25 -# Author: George Shapovalov <george@g.o>
26 -# No maintainer <maintainer-needed@g.o>
27 -#
28 -# This eclass provides the framework for ada lib installation with the split and
29 -# SLOTted gnat compilers (gnat-xxx, gnatbuild.eclass). Each lib gets built once
30 -# for every installed gnat compiler. Activation of a particular bunary module is
31 -# performed by eselect-gnat, when the active compiler gets switched
32 -#
33 -# The ebuilds should define the lib_compile and lib_install functions that are
34 -# called from the (exported) gnat_src_compile function of eclass. These
35 -# functions should operate similarly to the starndard src_compile and
36 -# src_install. The only difference, that they should use $SL variable instead of
37 -# $S (this is where the working copy of source is held) and $DL instead of $D as
38 -# its installation point.
39 -
40 -inherit flag-o-matic eutils multilib
41 -
42 -# The environment is set locally in src_compile and src_install functions
43 -# by the common code sourced here and in gnat-eselect module.
44 -# This is the standard location for this code (belongs to eselect-gnat,
45 -# since eselect should work even in the absense of portage tree and we can
46 -# guarantee to some extent presence of gnat-eselect when anything gnat-related
47 -# gets processed. See #192505)
48 -#
49 -# Note!
50 -# It may not be safe to source this at top level. Only source inside local
51 -# functions!
52 -GnatCommon="/usr/share/gnat/lib/gnat-common.bash"
53 -
54 -# !!NOTE!!
55 -# src_install should not be exported!
56 -# Instead gnat_src_install should be explicitly called from within src_install.
57 -EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile
58 -
59 -DESCRIPTION="Common procedures for building Ada libs using split gnat compilers"
60 -
61 -# make sure we have an appropriately recent eselect-gnat installed, as we are
62 -# using some common code here.
63 -DEPEND=">=app-eselect/eselect-gnat-1.3"
64 -
65 -
66 -# ----------------------------------
67 -# Globals
68 -
69 -# Lib install locations
70 -#
71 -# Gnat profile dependent files go under ${LibTop}/${Gnat_Profile}/${PN}
72 -# and common files go under SpecsDir, DataDir..
73 -# In order not to pollute PATH and LDPATH attempt should be mabe to install
74 -# binaries and what makes sence for individual packages under
75 -# ${AdalibLibTop}/${Gnat_Profile}/bin
76 -PREFIX=/usr
77 -AdalibSpecsDir=${PREFIX}/include/ada
78 -AdalibDataDir=${PREFIX}/share/ada
79 -AdalibLibTop=${PREFIX}/$(get_libdir)/ada
80 -
81 -# build-time locations
82 -# SL is a "localized" S, - location where sources are copied for
83 -#bi profile-specific build
84 -SL=${WORKDIR}/LocalSource
85 -
86 -# DL* are "localized destinations" where ARCH/SLOT dependent stuff should be
87 -# installed in lib_install. There are three:
88 -#
89 -DL=${WORKDIR}/LocalDest
90 -# a generic location for the lib (.a, .so) files
91 -#
92 -DLbin=${WORKDIR}/LocalBinDest
93 -# binaries that should be in the PATH, will be moved to common Ada bin dir
94 -#
95 -DLgpr=${WORKDIR}/LocalGPRDest
96 -# gpr's should go here.
97 -
98 -# file containing environment formed by gnat-eselect (build-time)
99 -BuildEnv=${WORKDIR}/BuildEnv
100 -
101 -# environment for installed lib. Profile-specific stuff should use %DL% as a top
102 -# of their location. This (%DL%) will be substituted with a proper location upon
103 -# install
104 -LibEnv=${WORKDIR}/LibEnv
105 -
106 -
107 -# env file prepared by gnat.eselect only lists new settings for env vars
108 -# we need to change that to prepend, rather than replace action..
109 -# Takes one argument - the file to expand. This file should contain only
110 -# var=value like lines.. (commenst are Ok)
111 -expand_BuildEnv() {
112 - local line
113 - for line in $(cat $1); do
114 - EnvVar=$(echo ${line}|cut -d"=" -f1)
115 - if [[ "${EnvVar}" == "PATH" ]] ; then
116 - echo "export ${line}:\${${EnvVar}}" >> $1.tmp
117 - else
118 - echo "export ${line}" >> $1.tmp
119 - fi
120 - done
121 - mv $1.tmp $1
122 -}
123 -
124 -
125 -# ------------------------------------
126 -# Dependency processing related stuff
127 -
128 -# A simple wrapper to get the relevant part of the DEPEND
129 -# params:
130 -# $1 - should contain dependency specification analogous to DEPEND,
131 -# if omitted, DEPEND is processed
132 -get_ada_dep() {
133 - [[ -z "$1" ]] && DEP="${DEPEND}" || DEP="$1"
134 - local TempStr
135 - for fn in $DEP; do # here $DEP should *not* be in ""
136 - [[ $fn =~ "virtual/ada" ]] && TempStr=${fn/*virtual\//}
137 - # above match should be to full virtual/ada, as simply "ada" is a common
138 - # part of ${PN}, even for some packages under dev-ada
139 - done
140 -# debug-print-function $FUNCNAME "TempStr=${TempStr:0:8}"
141 - [[ -n ${TempStr} ]] && echo ${TempStr:0:8}
142 -}
143 -
144 -# This function is used to check whether the requested gnat profile matches the
145 -# requested Ada standard
146 -# !!ATTN!!
147 -# This must match dependencies as specified in virtual/ada !!!
148 -#
149 -# params:
150 -# $1 - the requested gnat profile in usual form (e.g. x86_64-pc-linux-gnu-gnat-gcc-4.1)
151 -# $2 - Ada standard specification, as would be specified in DEPEND.
152 -# Valid values: ada-1995, ada-2005, ada
153 -#
154 -# This used to treat ada-1995 and ada alike, but some packages (still
155 -# requested by users) no longer compile with new compilers (not the
156 -# standard issue, but rather compiler becoming stricter most of the time).
157 -# Plus there are some "intermediary versions", not fully 2005 compliant
158 -# but already causing problems. Therefore, now we do exact matching.
159 -belongs_to_standard() {
160 -# debug-print-function $FUNCNAME $*
161 - . ${GnatCommon} || die "failed to source gnat-common lib"
162 - local GnatSlot=$(get_gnat_SLOT $1)
163 - local ReducedSlot=${GnatSlot//\./}
164 - #
165 - if [[ $2 == 'ada' ]] ; then
166 -# debug-print-function "ada or ada-1995 match"
167 - return 0 # no restrictions imposed
168 - elif [[ "$2" == 'ada-1995' ]] ; then
169 - if [[ $(get_gnat_Pkg $1) == "gcc" ]]; then
170 -# debug-print-function "got gcc profile, GnatSlot=${ReducedSlot}"
171 - [[ ${ReducedSlot} -le "42" ]] && return 0 || return 1
172 - elif [[ $(get_gnat_Pkg $1) == "gpl" ]]; then
173 -# debug-print-function "got gpl profile, GnatSlot=${ReducedSlot}"
174 - [[ ${ReducedSlot} -lt "41" ]] && return 0 || return 1
175 - else
176 - return 1 # unknown compiler encountered
177 - fi
178 - elif [[ "$2" == 'ada-2005' ]] ; then
179 - if [[ $(get_gnat_Pkg $1) == "gcc" ]]; then
180 -# debug-print-function "got gcc profile, GnatSlot=${ReducedSlot}"
181 - [[ ${ReducedSlot} -ge "43" ]] && return 0 || return 1
182 - elif [[ $(get_gnat_Pkg $1) == "gpl" ]]; then
183 -# debug-print-function "got gpl profile, GnatSlot=${ReducedSlot}"
184 - [[ ${ReducedSlot} -ge "41" ]] && return 0 || return 1
185 - else
186 - return 1 # unknown compiler encountered
187 - fi
188 - else
189 - return 1 # unknown standard requested, check spelling!
190 - fi
191 -}
192 -
193 -
194 -# ------------------------------------
195 -# Helpers
196 -#
197 -
198 -
199 -# The purpose of this one is to remove all parts of the env entry specific to a
200 -# given lib. Usefull when some lib wants to act differently upon detecting
201 -# itself installed..
202 -#
203 -# params:
204 -# $1 - name of env var to process
205 -# $2 (opt) - name of the lib to filter out (defaults to ${PN})
206 -filter_env_var() {
207 - local entries=(${!1//:/ })
208 - local libName=${2:-${PN}}
209 - local env_str
210 - for entry in ${entries[@]} ; do
211 - # this simply checks if $libname is a substring of the $entry, should
212 - # work fine with all the present libs
213 - if [[ ${entry/${libName}/} == ${entry} ]] ; then
214 - env_str="${env_str}:${entry}"
215 - fi
216 - done
217 - echo ${env_str}
218 -}
219 -
220 -# A simpler helper, for the libs that need to extract active gnat location
221 -# Returns a first entry for a specified env var. Relies on the (presently true)
222 -# convention that first gnat's entries are listed and then of the other
223 -# installed libs.
224 -#
225 -# params:
226 -# $1 - name of env var to process
227 -get_gnat_value() {
228 - local entries=(${!1//:/ })
229 - echo ${entries[0]}
230 -}
231 -
232 -
233 -# Returns a name of active gnat profile. Performs some validity checks. No input
234 -# parameters, analyzes the system setup directly.
235 -get_active_profile() {
236 - # get common code and settings
237 - . ${GnatCommon} || die "failed to source gnat-common lib"
238 -
239 - local profiles=( $(get_env_list) )
240 -
241 - if [[ ${profiles[@]} == "${MARKER}*" ]]; then
242 - return
243 - # returning empty string
244 - fi
245 -
246 - if (( 1 == ${#profiles[@]} )); then
247 - local active=${profiles[0]#${MARKER}}
248 - else
249 - die "${ENVDIR} contains multiple gnat profiles, please cleanup!"
250 - fi
251 -
252 - if [[ -f ${SPECSDIR}/${active} ]]; then
253 - echo ${active}
254 - else
255 - die "The profile active in ${ENVDIR} does not correspond to any installed gnat!"
256 - fi
257 -}
258 -
259 -
260 -
261 -# ------------------------------------
262 -# Functions
263 -
264 -# Checks the gnat backend SLOT and filters flags correspondingly
265 -# To be called from scr_compile for each profile, before actual compilation
266 -# Parameters:
267 -# $1 - gnat profile, e.g. x86_64-pc-linux-gnu-gnat-gcc-3.4
268 -gnat_filter_flags() {
269 - debug-print-function $FUNCNAME $*
270 -
271 - # We only need to filter so severely if backends < 3.4 is detected, which
272 - # means basically gnat-3.15
273 - GnatProfile=$1
274 - if [ -z ${GnatProfile} ]; then
275 - # should not get here!
276 - die "please specify a valid gnat profile for flag stripping!"
277 - fi
278 -
279 - local GnatSLOT="${GnatProfile//*-/}"
280 - if [[ ${GnatSLOT} < 3.4 ]] ; then
281 - filter-mfpmath sse 387
282 -
283 - filter-flags -mmmx -msse -mfpmath -frename-registers \
284 - -fprefetch-loop-arrays -falign-functions=4 -falign-jumps=4 \
285 - -falign-loops=4 -msse2 -frerun-loop-opt -maltivec -mabi=altivec \
286 - -fsigned-char -fno-strict-aliasing -pipe
287 -
288 - export ADACFLAGS=${ADACFLAGS:-${CFLAGS}}
289 - export ADACFLAGS=${ADACFLAGS//-Os/-O2}
290 - export ADACFLAGS=${ADACFLAGS//pentium-mmx/i586}
291 - export ADACFLAGS=${ADACFLAGS//pentium[234]/i686}
292 - export ADACFLAGS=${ADACFLAGS//k6-[23]/k6}
293 - export ADACFLAGS=${ADACFLAGS//athlon-tbird/i686}
294 - export ADACFLAGS=${ADACFLAGS//athlon-4/i686}
295 - export ADACFLAGS=${ADACFLAGS//athlon-[xm]p/i686}
296 - # gcc-2.8.1 has no amd64 support, so the following two are safe
297 - export ADACFLAGS=${ADACFLAGS//athlon64/i686}
298 - export ADACFLAGS=${ADACFLAGS//athlon/i686}
299 - else
300 - export ADACFLAGS=${ADACFLAGS:-${CFLAGS}}
301 - fi
302 -
303 - export ADAMAKEFLAGS=${ADAMAKEFLAGS:-"-cargs ${ADACFLAGS} -margs"}
304 - export ADABINDFLAGS=${ADABINDFLAGS:-""}
305 -}
306 -
307 -gnat_pkg_setup() {
308 - debug-print-function $FUNCNAME $*
309 -
310 - # check whether all the primary compilers are installed
311 - . ${GnatCommon} || die "failed to source gnat-common lib"
312 - for fn in $(cat ${PRIMELIST}); do
313 - if [[ ! -f ${SPECSDIR}/${fn} ]]; then
314 - elog "The ${fn} Ada compiler profile is specified as primary, but is not installed."
315 - elog "Please rectify the situation before emerging Ada library!"
316 - elog "Please either install again all the missing compilers listed"
317 - elog "as primary, or edit /etc/ada/primary_compilers and update the"
318 - elog "list of primary compilers there."
319 - einfo ""
320 - ewarn "If you do the latter, please don't forget to rebuild all"
321 - ewarn "affected libs!"
322 - die "Primary compiler is missing"
323 - fi
324 - done
325 -
326 - export ADAC=${ADAC:-gnatgcc}
327 - export ADAMAKE=${ADAMAKE:-gnatmake}
328 - export ADABIND=${ADABIND:-gnatbind}
329 -}
330 -
331 -
332 -gnat_pkg_postinst() {
333 - einfo "Updating gnat configuration to pick up ${PN} library..."
334 - eselect gnat update
335 - elog "The environment has been set up to make gnat automatically find files"
336 - elog "for the installed library. In order to immediately activate these"
337 - elog "settings please run:"
338 - elog
339 - #elog "env-update"
340 - elog "source /etc/profile"
341 - einfo
342 - einfo "Otherwise the settings will become active next time you login"
343 -}
344 -
345 -
346 -
347 -
348 -# standard lib_compile plug. Adapted from base.eclass
349 -lib_compile() {
350 - debug-print-function $FUNCNAME $*
351 - [ -z "$1" ] && lib_compile all
352 -
353 - cd ${SL}
354 -
355 - while [ "$1" ]; do
356 - case $1 in
357 - configure)
358 - debug-print-section configure
359 - econf || die "died running econf, $FUNCNAME:configure"
360 - ;;
361 - make)
362 - debug-print-section make
363 - emake || die "died running emake, $FUNCNAME:make"
364 - ;;
365 - all)
366 - debug-print-section all
367 - lib_compile configure make
368 - ;;
369 - esac
370 - shift
371 - done
372 -}
373 -
374 -# Cycles through installed gnat profiles and calls lib_compile and then
375 -# lib_install in turn.
376 -# Use this function to build/install profile-specific binaries. The code
377 -# building/installing common stuff (docs, etc) can go before/after, as needed,
378 -# so that it is called only once..
379 -#
380 -# lib_compile and lib_install are passed the active gnat profile name - may be used or
381 -# discarded as needed..
382 -gnat_src_compile() {
383 - debug-print-function $FUNCNAME $*
384 -
385 - # We source the eselect-gnat module and use its functions directly, instead of
386 - # duplicating code or trying to violate sandbox in some way..
387 - . ${GnatCommon} || die "failed to source gnat-common lib"
388 -
389 - compilers=( $(find_primary_compilers ) )
390 - if [[ -n ${compilers[@]} ]] ; then
391 - local i
392 - local AdaDep=$(get_ada_dep)
393 - for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
394 - if $(belongs_to_standard ${compilers[${i}]} ${AdaDep}); then
395 - einfo "compiling for gnat profile ${compilers[${i}]}"
396 -
397 - # copy sources
398 - mkdir "${DL}" "${DLbin}" "${DLgpr}"
399 - cp -dpR "${S}" "${SL}"
400 -
401 - # setup environment
402 - # As eselect-gnat also manages the libs, this will ensure the right
403 - # lib profiles are activated too (in case we depend on some Ada lib)
404 - generate_envFile ${compilers[${i}]} ${BuildEnv} && \
405 - expand_BuildEnv "${BuildEnv}" && \
406 - . "${BuildEnv}" || die "failed to switch to ${compilers[${i}]}"
407 - # many libs (notably xmlada and gtkada) do not like to see
408 - # themselves installed. Need to strip them from ADA_*_PATH
409 - # NOTE: this should not be done in pkg_setup, as we setup
410 - # environment right above
411 - export ADA_INCLUDE_PATH=$(filter_env_var ADA_INCLUDE_PATH)
412 - export ADA_OBJECTS_PATH=$(filter_env_var ADA_OBJECTS_PATH)
413 -
414 - # call compilation callback
415 - cd "${SL}"
416 - gnat_filter_flags ${compilers[${i}]}
417 - lib_compile ${compilers[${i}]} || die "failed compiling for ${compilers[${i}]}"
418 -
419 - # call install callback
420 - cd "${SL}"
421 - lib_install ${compilers[${i}]} || die "failed installing profile-specific part for ${compilers[${i}]}"
422 - # move installed and cleanup
423 - mv "${DL}" "${DL}-${compilers[${i}]}"
424 - mv "${DLbin}" "${DLbin}-${compilers[${i}]}"
425 - mv "${DLgpr}" "${DLgpr}-${compilers[${i}]}"
426 - rm -rf "${SL}"
427 - else
428 - einfo "skipping gnat profile ${compilers[${i}]}"
429 - fi
430 - done
431 - else
432 - ewarn "Please note!"
433 - elog "Treatment of installed Ada compilers has recently changed!"
434 - elog "Libs are now being built only for \"primary\" compilers."
435 - elog "Please list gnat profiles (as reported by \"eselect gnat list\")"
436 - elog "that you want to regularly use (i.e., not just for testing)"
437 - elog "in ${PRIMELIST}, one per line."
438 - die "please make sure you have at least one gnat compiler installed and set as primary!"
439 - fi
440 -}
441 -
442 -
443 -# This function simply moves gnat-profile-specific stuff into proper locations.
444 -# Use src_install in ebuild to install the rest of the package
445 -gnat_src_install() {
446 - debug-print-function $FUNCNAME $*
447 -
448 - # prep lib specs directory
449 - . ${GnatCommon} || die "failed to source gnat-common lib"
450 - dodir ${SPECSDIR}/${PN}
451 -
452 - compilers=( $(find_primary_compilers) )
453 - if [[ -n ${compilers[@]} ]] ; then
454 - local i
455 - local AdaDep=$(get_ada_dep)
456 - for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
457 - if $(belongs_to_standard ${compilers[${i}]} ${AdaDep}); then
458 - debug-print-section "installing for gnat profile ${compilers[${i}]}"
459 -
460 - local DLlocation=${AdalibLibTop}/${compilers[${i}]}
461 - dodir ${DLlocation}
462 - cp -dpR "${DL}-${compilers[${i}]}" "${D}/${DLlocation}/${PN}"
463 - cp -dpR "${DLbin}-${compilers[${i}]}" "${D}/${DLlocation}"/bin
464 - cp -dpR "${DLgpr}-${compilers[${i}]}" "${D}/${DLlocation}"/gpr
465 - # create profile-specific specs file
466 - cp ${LibEnv} "${D}/${SPECSDIR}/${PN}/${compilers[${i}]}"
467 - sed -i -e "s:%DL%:${DLlocation}/${PN}:g" "${D}/${SPECSDIR}/${PN}/${compilers[${i}]}"
468 - sed -i -e "s:%DLbin%:${DLlocation}/bin:g" "${D}/${SPECSDIR}/${PN}/${compilers[${i}]}"
469 - sed -i -e "s:%DLgpr%:${DLlocation}/gpr:g" "${D}/${SPECSDIR}/${PN}/${compilers[${i}]}"
470 - else
471 - einfo "skipping gnat profile ${compilers[${i}]}"
472 - fi
473 - done
474 - else
475 - die "please make sure you have at least one gnat compiler installed!"
476 - fi
477 -}