Advertisement
Guest User

environment

a guest
Jan 12th, 2020
1,335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 175.04 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_PPC=""
  4. declare -x ABI_RISCV=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86="64"
  7. declare -x ADA_TARGET=""
  8. declare -x ALSA_CARDS=""
  9. declare -x ANT_HOME="/usr/share/ant"
  10. declare -x APACHE2_MODULES=""
  11. declare -x APACHE2_MPMS=""
  12. declare -x ARCH="amd64"
  13. declare BDEPEND="
  14.     python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  15.     >=dev-qt/linguist-tools-5.9.4:5
  16.     sys-devel/bison
  17.     sys-devel/flex
  18. dev-util/ninja >=dev-util/cmake-3.9.6"
  19. declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  20. declare -- BUILD_DIR="/tmp/portage/sci-geosciences/qgis-3.10.0/work/qgis-3.10.0_build"
  21. declare -x CALLIGRA_FEATURES=""
  22. declare -x CAMERAS=""
  23. declare -x CBUILD="x86_64-pc-linux-gnu"
  24. declare -x CC="gcc"
  25. declare -x CFLAGS="-march=native -O2 -pipe"
  26. declare -x CFLAGS_amd64="-m64"
  27. declare -x CFLAGS_default
  28. declare -x CFLAGS_x32="-mx32"
  29. declare -x CFLAGS_x86="-m32"
  30. declare -x CHOST="x86_64-pc-linux-gnu"
  31. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  32. declare -x CHOST_default="x86_64-pc-linux-gnu"
  33. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  34. declare -x CHOST_x86="i686-pc-linux-gnu"
  35. declare -- CMAKE_BINARY="cmake"
  36. declare -- CMAKE_BUILD_TYPE="Gentoo"
  37. declare -- CMAKE_MAKEFILE_GENERATOR="ninja"
  38. declare -- CMAKE_MIN_VERSION="3.9.6"
  39. declare -- CMAKE_REMOVE_MODULES="yes"
  40. declare -- CMAKE_REMOVE_MODULES_LIST="FindBLAS FindLAPACK"
  41. declare -- CMAKE_USE_DIR="/tmp/portage/sci-geosciences/qgis-3.10.0/work/qgis-3.10.0"
  42. declare -- CMAKE_VERBOSE="ON"
  43. declare -- CMAKE_WARN_UNUSED_CLI="yes"
  44. declare -x COLLECTD_PLUGINS=""
  45. declare -- COMMON_DEPEND="
  46.     app-crypt/qca:2[qt5(+),ssl]
  47.     >=dev-db/spatialite-4.2.0
  48.     dev-db/sqlite:3
  49.     dev-libs/expat
  50.     dev-libs/libzip:=
  51.     dev-libs/qtkeychain[qt5(+)]
  52.     >=dev-qt/designer-5.9.4:5
  53.     >=dev-qt/qtconcurrent-5.9.4:5
  54.     >=dev-qt/qtcore-5.9.4:5
  55.     >=dev-qt/qtgui-5.9.4:5
  56.     >=dev-qt/qtnetwork-5.9.4:5[ssl]
  57.     >=dev-qt/qtpositioning-5.9.4:5
  58.     >=dev-qt/qtprintsupport-5.9.4:5
  59.     >=dev-qt/qtserialport-5.9.4:5
  60.     >=dev-qt/qtsvg-5.9.4:5
  61.     >=dev-qt/qtsql-5.9.4:5
  62.     >=dev-qt/qtwidgets-5.9.4:5
  63.     >=dev-qt/qtxml-5.9.4:5
  64.     media-gfx/exiv2:=
  65.     >=sci-libs/gdal-2.2.3:=[geos]
  66.     sci-libs/geos
  67.     sci-libs/libspatialindex:=
  68.     sci-libs/proj:=
  69.     >=x11-libs/qscintilla-2.10.1:=[qt5(+)]
  70.     >=x11-libs/qwt-6.1.2:6=[qt5(+),svg]
  71.     3d? ( >=dev-qt/qt3d-5.9.4:5 )
  72.     georeferencer? ( sci-libs/gsl:= )
  73.     grass? ( =sci-geosciences/grass-7*:= )
  74.     hdf5? ( sci-libs/hdf5:= )
  75.     mapserver? ( dev-libs/fcgi )
  76.     netcdf? ( sci-libs/netcdf:= )
  77.     opencl? ( virtual/opencl )
  78.     oracle? (
  79.         dev-db/oracle-instantclient:=
  80.         sci-libs/gdal:=[oracle]
  81.     )
  82.     polar? ( >=x11-libs/qwtpolar-1.1.1-r1[qt5(+)] )
  83.     postgres? ( dev-db/postgresql:= )
  84.     python? (
  85.         python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  86.         dev-python/future[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  87.         dev-python/httplib2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  88.         dev-python/jinja[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  89.         dev-python/markupsafe[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  90.         dev-python/owslib[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  91.         dev-python/pygments[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  92.         dev-python/PyQt5[designer,network,sql,svg,webkit?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  93.         dev-python/python-dateutil[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  94.         dev-python/pytz[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  95.         dev-python/pyyaml[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  96.         >=dev-python/qscintilla-python-2.10.1[qt5(+),python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  97.         dev-python/requests[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  98.         dev-python/sip:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  99.         dev-python/six[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  100.         >=sci-libs/gdal-2.2.3[python,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  101.         postgres? ( dev-python/psycopg:2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?] )
  102.     )
  103.     qml? ( >=dev-qt/qtdeclarative-5.9.4:5 )
  104.     webkit? ( >=dev-qt/qtwebkit-5.9.1:5 )
  105. "
  106. declare -x CPPFLAGS="-march=native -O2 -pipe"
  107. declare -x CPU_FLAGS_ARM=""
  108. declare -x CPU_FLAGS_PPC=""
  109. declare -x CPU_FLAGS_X86=""
  110. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  111. declare -x CURL_SSL=""
  112. declare -x CXX="g++"
  113. declare -x CXXFLAGS="-march=native -O2 -pipe"
  114. declare -x DEFAULT_ABI="amd64"
  115. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare setup test"
  116. declare DEPEND="
  117.     app-crypt/qca:2[qt5(+),ssl]
  118.     >=dev-db/spatialite-4.2.0
  119.     dev-db/sqlite:3
  120.     dev-libs/expat
  121.     dev-libs/libzip:=
  122.     dev-libs/qtkeychain[qt5(+)]
  123.     >=dev-qt/designer-5.9.4:5
  124.     >=dev-qt/qtconcurrent-5.9.4:5
  125.     >=dev-qt/qtcore-5.9.4:5
  126.     >=dev-qt/qtgui-5.9.4:5
  127.     >=dev-qt/qtnetwork-5.9.4:5[ssl]
  128.     >=dev-qt/qtpositioning-5.9.4:5
  129.     >=dev-qt/qtprintsupport-5.9.4:5
  130.     >=dev-qt/qtserialport-5.9.4:5
  131.     >=dev-qt/qtsvg-5.9.4:5
  132.     >=dev-qt/qtsql-5.9.4:5
  133.     >=dev-qt/qtwidgets-5.9.4:5
  134.     >=dev-qt/qtxml-5.9.4:5
  135.     media-gfx/exiv2:=
  136.     >=sci-libs/gdal-2.2.3:=[geos]
  137.     sci-libs/geos
  138.     sci-libs/libspatialindex:=
  139.     sci-libs/proj:=
  140.     >=x11-libs/qscintilla-2.10.1:=[qt5(+)]
  141.     >=x11-libs/qwt-6.1.2:6=[qt5(+),svg]
  142.     3d? ( >=dev-qt/qt3d-5.9.4:5 )
  143.     georeferencer? ( sci-libs/gsl:= )
  144.     grass? ( =sci-geosciences/grass-7*:= )
  145.     hdf5? ( sci-libs/hdf5:= )
  146.     mapserver? ( dev-libs/fcgi )
  147.     netcdf? ( sci-libs/netcdf:= )
  148.     opencl? ( virtual/opencl )
  149.     oracle? (
  150.         dev-db/oracle-instantclient:=
  151.         sci-libs/gdal:=[oracle]
  152.     )
  153.     polar? ( >=x11-libs/qwtpolar-1.1.1-r1[qt5(+)] )
  154.     postgres? ( dev-db/postgresql:= )
  155.     python? (
  156.         python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  157.         dev-python/future[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  158.         dev-python/httplib2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  159.         dev-python/jinja[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  160.         dev-python/markupsafe[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  161.         dev-python/owslib[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  162.         dev-python/pygments[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  163.         dev-python/PyQt5[designer,network,sql,svg,webkit?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  164.         dev-python/python-dateutil[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  165.         dev-python/pytz[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  166.         dev-python/pyyaml[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  167.         >=dev-python/qscintilla-python-2.10.1[qt5(+),python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  168.         dev-python/requests[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  169.         dev-python/sip:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  170.         dev-python/six[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  171.         >=sci-libs/gdal-2.2.3[python,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  172.         postgres? ( dev-python/psycopg:2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?] )
  173.     )
  174.     qml? ( >=dev-qt/qtdeclarative-5.9.4:5 )
  175.     webkit? ( >=dev-qt/qtwebkit-5.9.1:5 )
  176.  
  177.     >=dev-qt/qttest-5.9.4:5
  178.     python? ( python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?] )
  179.  
  180.     dev-util/desktop-file-utils
  181.     x11-misc/shared-mime-info
  182. "
  183. declare DESCRIPTION="User friendly Geographic Information System"
  184. declare -- DESKTOP_DATABASE_DIR="/usr/share/applications"
  185. declare -x DIROPTIONS="-m0755"
  186. declare -x EAPI="7"
  187. declare -x ELIBC="glibc"
  188. declare -x ENLIGHTENMENT_MODULES=""
  189. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  190. declare -x EPYTHON="python3.6"
  191. declare -x EXEOPTIONS="-m0755"
  192. declare -x FCFLAGS="-march=native -O2 -pipe"
  193. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  194. declare -x FFLAGS="-march=native -O2 -pipe"
  195. declare -x FFTOOLS=""
  196. declare -x GCC_SPECS=""
  197. declare -x GPSD_PROTOCOLS=""
  198. declare -x GRUB_PLATFORMS=""
  199. declare -x GSETTINGS_BACKEND="dconf"
  200. declare HDEPEND=""
  201. declare HOMEPAGE="https://www.qgis.org/"
  202. declare -x HUSHLOGIN="FALSE"
  203. declare -x INHERITED=" toolchain-funcs multilib multiprocessing ninja-utils eutils flag-o-matic xdg-utils cmake-utils desktop python-utils-r1 python-single-r1 estack qmake-utils xdg"
  204. declare -x INPUT_DEVICES=""
  205. declare -x INSOPTIONS="-m0644"
  206. declare IUSE="3d examples georeferencer grass hdf5 mapserver netcdf opencl oracle polar postgres python qml webkit python_targets_python3_6 python_targets_python3_7 python_single_target_python3_6 python_single_target_python3_7"
  207. declare -x IUSE_EFFECTIVE="3d abi_x86_64 alpha amd64 amd64-fbsd amd64-linux arm arm64 elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc examples georeferencer grass hdf5 hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mapserver mips netcdf opencl oracle polar postgres ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack python python_single_target_python3_6 python_single_target_python3_7 python_targets_python3_6 python_targets_python3_7 qml riscv s390 sh sparc sparc-solaris sparc64-solaris userland_BSD userland_GNU webkit x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  208. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest prefix-stack"
  209. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  210. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  211. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  212. declare -x KERNEL="linux"
  213. declare -x KERNEL_ABI="amd64"
  214. declare -x KEYWORDS="~amd64 ~x86"
  215. declare -x L10N=""
  216. declare -x LANG="it_IT.utf8"
  217. declare -x LCD_DEVICES=""
  218. declare -x LC_COLLATE="C"
  219. declare -x LC_MESSAGES="C"
  220. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  221. declare -x LDFLAGS_amd64="-m elf_x86_64"
  222. declare -x LDFLAGS_default
  223. declare -x LDFLAGS_x32="-m elf32_x86_64"
  224. declare -x LDFLAGS_x86="-m elf_i386"
  225. declare -x LIBDIR_amd64="lib64"
  226. declare -x LIBDIR_default="lib"
  227. declare -x LIBDIR_x32="libx32"
  228. declare -x LIBDIR_x86="lib32"
  229. declare -x LIBOPTIONS="-m0644"
  230. declare -x LIBREOFFICE_EXTENSIONS=""
  231. declare -x LICENSE="GPL-2+ GPL-3+"
  232. declare -x LIRC_DEVICES=""
  233. declare -x LLVM_TARGETS=""
  234. declare -x LV2_PATH="/usr/lib64/lv2"
  235. declare -x MAIL="/var/mail/root"
  236. declare -x MAKEOPTS="-j1"
  237. declare -x MANPAGER="manpager"
  238. declare -- MIMEINFO_DATABASE_DIR="/usr/share/mime"
  239. declare -x MONKEYD_PLUGINS=""
  240. declare -x MOZ_GMP_PATH="/usr/lib64/nsbrowser/plugins/gmp-gmpopenh264/system-installed"
  241. declare -x MULTILIB_ABIS="amd64 x86"
  242. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  243. declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
  244. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  245. declare -x MVIMPACT_ACQUIRE_DATA_DIR="/opt/mvIMPACT_Acquire/data"
  246. declare -x MVIMPACT_ACQUIRE_DIR="/opt/mvIMPACT_Acquire"
  247. declare -x NETBEANS_MODULES=""
  248. declare -x NGINX_MODULES_HTTP=""
  249. declare -x NGINX_MODULES_MAIL=""
  250. declare -x NGINX_MODULES_STREAM=""
  251. declare -- NINJAOPTS="-j1 -l0"
  252. declare -x OFED_DRIVERS=""
  253. declare -x OFFICE_IMPLEMENTATION=""
  254. declare -x OMNIORB_CONFIG="/etc/omniorb/omniORB.cfg"
  255. declare -x OPENCL_PROFILE="intel"
  256. declare -x OPENGL_PROFILE="xorg-x11"
  257. declare -x OPENMPI_FABRICS=""
  258. declare -x OPENMPI_OFED_FEATURES=""
  259. declare -x OPENMPI_RM=""
  260. declare -a PATCHES=([0]="/tmp/portage/sci-geosciences/qgis-3.10.0/files/qgis-3.10.0-cmake-lib-suffix.patch" [1]="/tmp/portage/sci-geosciences/qgis-3.10.0/files/qgis-3.4.7-featuresummary.patch" [2]="/tmp/portage/sci-geosciences/qgis-3.10.0/files/qgis-3.4.7-default-qmldir.patch")
  261. declare -x PATH="/tmp/portage/sci-geosciences/qgis-3.10.0/temp/python3.6/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/lib/llvm/8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  262. declare PDEPEND=""
  263. declare -x PHP_TARGETS=""
  264. declare -x PKG_CONFIG_PATH="/tmp/portage/sci-geosciences/qgis-3.10.0/temp/python3.6/pkgconfig"
  265. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  266. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  267. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  268. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/qgis-3.10.0/html")
  269. declare -a PORTAGE_DOSTRIP=([0]="/")
  270. declare -a PORTAGE_DOSTRIP_SKIP=()
  271. declare -x PORT_LOGDIR="/var/log/portage/ebuilds"
  272. declare -x POSTGRES_TARGETS=""
  273. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  274. declare -x PROPERTIES=""
  275. declare -x PYTHON="/usr/bin/python3.6"
  276. declare -x PYTHONDONTWRITEBYTECODE="1"
  277. declare -a PYTHON_COMPAT=([0]="python3_6" [1]="python3_7")
  278. declare -- PYTHON_DEPS="python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]"
  279. declare -- PYTHON_REQUIRED_USE="^^ ( python_single_target_python3_6 python_single_target_python3_7 ) python_single_target_python3_6? ( python_targets_python3_6 ) python_single_target_python3_7? ( python_targets_python3_7 )"
  280. declare -- PYTHON_REQ_USE="sqlite"
  281. declare -x PYTHON_SINGLE_TARGET="python3_6"
  282. declare -x PYTHON_TARGETS="python3_6"
  283. declare -- PYTHON_USEDEP="python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?"
  284. declare -x QEMU_SOFTMMU_TARGETS=""
  285. declare -x QEMU_USER_TARGETS=""
  286. declare -- QT_MIN_VER="5.9.4"
  287. declare -x QT_QPA_PLATFORMTHEME="qt5ct"
  288. declare RDEPEND="
  289.     app-crypt/qca:2[qt5(+),ssl]
  290.     >=dev-db/spatialite-4.2.0
  291.     dev-db/sqlite:3
  292.     dev-libs/expat
  293.     dev-libs/libzip:=
  294.     dev-libs/qtkeychain[qt5(+)]
  295.     >=dev-qt/designer-5.9.4:5
  296.     >=dev-qt/qtconcurrent-5.9.4:5
  297.     >=dev-qt/qtcore-5.9.4:5
  298.     >=dev-qt/qtgui-5.9.4:5
  299.     >=dev-qt/qtnetwork-5.9.4:5[ssl]
  300.     >=dev-qt/qtpositioning-5.9.4:5
  301.     >=dev-qt/qtprintsupport-5.9.4:5
  302.     >=dev-qt/qtserialport-5.9.4:5
  303.     >=dev-qt/qtsvg-5.9.4:5
  304.     >=dev-qt/qtsql-5.9.4:5
  305.     >=dev-qt/qtwidgets-5.9.4:5
  306.     >=dev-qt/qtxml-5.9.4:5
  307.     media-gfx/exiv2:=
  308.     >=sci-libs/gdal-2.2.3:=[geos]
  309.     sci-libs/geos
  310.     sci-libs/libspatialindex:=
  311.     sci-libs/proj:=
  312.     >=x11-libs/qscintilla-2.10.1:=[qt5(+)]
  313.     >=x11-libs/qwt-6.1.2:6=[qt5(+),svg]
  314.     3d? ( >=dev-qt/qt3d-5.9.4:5 )
  315.     georeferencer? ( sci-libs/gsl:= )
  316.     grass? ( =sci-geosciences/grass-7*:= )
  317.     hdf5? ( sci-libs/hdf5:= )
  318.     mapserver? ( dev-libs/fcgi )
  319.     netcdf? ( sci-libs/netcdf:= )
  320.     opencl? ( virtual/opencl )
  321.     oracle? (
  322.         dev-db/oracle-instantclient:=
  323.         sci-libs/gdal:=[oracle]
  324.     )
  325.     polar? ( >=x11-libs/qwtpolar-1.1.1-r1[qt5(+)] )
  326.     postgres? ( dev-db/postgresql:= )
  327.     python? (
  328.         python_single_target_python3_6? ( dev-lang/python:3.6[sqlite] ) python_single_target_python3_7? ( dev-lang/python:3.7[sqlite] ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  329.         dev-python/future[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  330.         dev-python/httplib2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  331.         dev-python/jinja[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  332.         dev-python/markupsafe[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  333.         dev-python/owslib[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  334.         dev-python/pygments[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  335.         dev-python/PyQt5[designer,network,sql,svg,webkit?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  336.         dev-python/python-dateutil[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  337.         dev-python/pytz[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  338.         dev-python/pyyaml[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  339.         >=dev-python/qscintilla-python-2.10.1[qt5(+),python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  340.         dev-python/requests[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  341.         dev-python/sip:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  342.         dev-python/six[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  343.         >=sci-libs/gdal-2.2.3[python,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?]
  344.         postgres? ( dev-python/psycopg:2[python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_8(-),python_single_target_python3_6(+)?,python_single_target_python3_7(+)?] )
  345.     )
  346.     qml? ( >=dev-qt/qtdeclarative-5.9.4:5 )
  347.     webkit? ( >=dev-qt/qtwebkit-5.9.1:5 )
  348.  
  349.     sci-geosciences/gpsbabel
  350. "
  351. declare REPOSITORY
  352. declare REQUIRED_USE="^^ ( python_single_target_python3_6 python_single_target_python3_7 ) python_single_target_python3_6? ( python_targets_python3_6 ) python_single_target_python3_7? ( python_targets_python3_7 ) mapserver? ( python ) "
  353. declare -x RESTRICT="test"
  354. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  355. declare -x ROS_MESSAGES=""
  356. declare -x RUBY_TARGETS=""
  357. declare -x S="/tmp/portage/sci-geosciences/qgis-3.10.0/work/qgis-3.10.0"
  358. declare -x SANDBOX_DEBUG="0"
  359. declare -x SANDBOX_DENY=""
  360. declare -x SANDBOX_PREDICT="/dev/ati/card:/dev/crypto:/dev/dri/card:/dev/dri/renderD128:/dev/dri/renderD129:/dev/nvidia-uvm:/dev/nvidiactl:/dev/random:/proc/self/coredump_filter:/tmp/portage/sci-geosciences/qgis-3.10.0/homedir:/var/cache/fontconfig"
  361. declare -x SANDBOX_READ="/:/tmp/portage"
  362. declare -x SANDBOX_VERBOSE="1"
  363. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/tmp/portage:/tmp/portage/sci-geosciences/qgis-3.10.0/homedir/.bash_history:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp/"
  364. declare -x SANE_BACKENDS=""
  365. declare -x SHELL="/bin/bash"
  366. declare -x SLOT="0"
  367. declare SRC_URI="https://qgis.org/downloads/qgis-3.10.0.tar.bz2
  368.         examples? ( https://qgis.org/downloads/data/qgis_sample_data.tar.gz -> qgis_sample_data-2.8.14.tar.gz )"
  369. declare -x SYMLINK_LIB="yes"
  370. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  371. declare -x USE="abi_x86_64 amd64 elibc_glibc georeferencer grass kernel_linux netcdf polar python python_single_target_python3_6 python_targets_python3_6 qml userland_GNU webkit"
  372. declare -x USERLAND="GNU"
  373. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  374. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  375. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos riscv s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  376. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  377. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  378. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  379. declare -x UWSGI_PLUGINS=""
  380. declare -x VBOX_APP_HOME="/usr/lib64/virtualbox"
  381. declare -x VIDEO_CARDS=""
  382. declare -x VOICEMAIL_STORAGE=""
  383. declare -x XDG_CACHE_HOME="/tmp/portage/sci-geosciences/qgis-3.10.0/homedir/.cache"
  384. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  385. declare -x XDG_CONFIG_HOME="/tmp/portage/sci-geosciences/qgis-3.10.0/homedir/.config"
  386. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  387. declare -x XDG_DATA_HOME="/tmp/portage/sci-geosciences/qgis-3.10.0/homedir/.local/share"
  388. declare -x XDG_RUNTIME_DIR="/tmp/portage/sci-geosciences/qgis-3.10.0/temp/run"
  389. declare -x XDG_SESSION_COOKIE="vince-TECRA-gentoo-1578818300.956332-1040472286"
  390. declare -x XFCE_PLUGINS=""
  391. declare -x XTABLES_ADDONS=""
  392. declare -- _CMAKE_UTILS_ECLASS="1"
  393. declare -- _CMAKE_UTILS_SRC_PREPARE_HAS_RUN="1"
  394. declare -- _DESKTOP_ECLASS="1"
  395. declare -- _ESTACK_ECLASS="1"
  396. declare -- _EUTILS_ECLASS="1"
  397. declare -x _E_DESTTREE_="/usr"
  398. declare -x _E_DOCDESTTREE_=""
  399. declare -x _E_EXEDESTTREE_=""
  400. declare -x _E_INSDESTTREE_=""
  401. declare -- _FLAG_O_MATIC_ECLASS="1"
  402. declare -- _MULTILIB_ECLASS="1"
  403. declare -- _MULTIPROCESSING_ECLASS="1"
  404. declare -- _NINJA_UTILS_ECLASS="1"
  405. declare -a _PYTHON_ALL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_5" [5]="python3_6" [6]="python3_7" [7]="python3_8")
  406. declare -- _PYTHON_SINGLE_R1="1"
  407. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python3_6" [1]="python3_7")
  408. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_5" [5]="python3_8")
  409. declare -- _PYTHON_UTILS_R1="1"
  410. declare -- _QMAKE_UTILS_ECLASS="1"
  411. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  412. PYTHON ()
  413. {
  414.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#.24.28PYTHON.29.2C_.24.7BEPYTHON.7D"
  415. }
  416. __eapi6_src_install ()
  417. {
  418.     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  419.         emake DESTDIR="${D}" install;
  420.     fi;
  421.     einstalldocs
  422. }
  423. __eapi6_src_prepare ()
  424. {
  425.     if ___is_indexed_array_var PATCHES; then
  426.         [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  427.     else
  428.         if [[ -n ${PATCHES} ]]; then
  429.             eapply ${PATCHES};
  430.         fi;
  431.     fi;
  432.     eapply_user
  433. }
  434. __eapi7_ver_compare ()
  435. {
  436.     local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  437.     re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  438.     [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  439.     an=${BASH_REMATCH[1]};
  440.     al=${BASH_REMATCH[3]};
  441.     as=${BASH_REMATCH[4]};
  442.     ar=${BASH_REMATCH[7]};
  443.     [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  444.     bn=${BASH_REMATCH[1]};
  445.     bl=${BASH_REMATCH[3]};
  446.     bs=${BASH_REMATCH[4]};
  447.     br=${BASH_REMATCH[7]};
  448.     __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  449.     while [[ ${an} == *.* && ${bn} == *.* ]]; do
  450.         an=${an#*.};
  451.         bn=${bn#*.};
  452.         a=${an%%.*};
  453.         b=${bn%%.*};
  454.         if [[ ${a} == 0* || ${b} == 0* ]]; then
  455.             [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  456.            [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  457.             [[ ${a} > ${b} ]] && return 3;
  458.             [[ ${a} < ${b} ]] && return 1;
  459.         else
  460.             __eapi7_ver_compare_int "${a}" "${b}" || return;
  461.         fi;
  462.     done;
  463.     [[ ${an} == *.* ]] && return 3;
  464.     [[ ${bn} == *.* ]] && return 1;
  465.     [[ ${al} > ${bl} ]] && return 3;
  466.     [[ ${al} < ${bl} ]] && return 1;
  467.     as=${as#_}${as:+_};
  468.     bs=${bs#_}${bs:+_};
  469.     while [[ -n ${as} && -n ${bs} ]]; do
  470.         a=${as%%_*};
  471.         b=${bs%%_*};
  472.         if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  473.             __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  474.         else
  475.             [[ ${a%%[0-9]*} == p ]] && return 3;
  476.             [[ ${b%%[0-9]*} == p ]] && return 1;
  477.             [[ ${a} > ${b} ]] && return 3 || return 1;
  478.         fi;
  479.         as=${as#*_};
  480.         bs=${bs#*_};
  481.     done;
  482.     if [[ -n ${as} ]]; then
  483.         [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  484.     else
  485.         if [[ -n ${bs} ]]; then
  486.             [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  487.         fi;
  488.     fi;
  489.     __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  490.     return 2
  491. }
  492. __eapi7_ver_compare_int ()
  493. {
  494.     local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  495.     if [[ ${d} -gt 0 ]]; then
  496.         printf -v b "%0${d}d%s" 0 "${b}";
  497.     else
  498.         if [[ ${d} -lt 0 ]]; then
  499.             printf -v a "%0$(( -d ))d%s" 0 "${a}";
  500.         fi;
  501.     fi;
  502.     [[ ${a} > ${b} ]] && return 3;
  503.     [[ ${a} == "${b}" ]]
  504. }
  505. __eapi7_ver_parse_range ()
  506. {
  507.     local range=${1};
  508.     local max=${2};
  509.     [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  510.     start=${range%-*};
  511.     [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  512.     if [[ -n ${end} ]]; then
  513.         [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  514.         [[ ${end} -le ${max} ]] || end=${max};
  515.     else
  516.         end=${max};
  517.     fi
  518. }
  519. __eapi7_ver_split ()
  520. {
  521.     local v=${1} LC_ALL=C;
  522.     comp=();
  523.     local s c;
  524.     while [[ -n ${v} ]]; do
  525.         s=${v%%[a-zA-Z0-9]*};
  526.         v=${v:${#s}};
  527.         [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  528.         v=${v:${#c}};
  529.         comp+=("${s}" "${c}");
  530.     done
  531. }
  532. _clang_fullversion ()
  533. {
  534.     local ver="$1";
  535.     shift;
  536.     set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  537.     eval echo "$ver"
  538. }
  539. _cmake_check_build_dir ()
  540. {
  541.     : ${CMAKE_USE_DIR:=${S}};
  542.     if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  543.         BUILD_DIR="${CMAKE_USE_DIR}";
  544.     else
  545.         if [[ ! -n ${BUILD_DIR} && -n ${CMAKE_BUILD_DIR} ]]; then
  546.             if [[ ${EAPI} != [56] ]]; then
  547.                 eerror "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR.";
  548.                 die "The ebuild must be migrated to BUILD_DIR.";
  549.             else
  550.                 eqawarn "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR.";
  551.                 eqawarn "Please migrate the ebuild to use the new one.";
  552.             fi;
  553.             _RESPECT_CMAKE_BUILD_DIR=1;
  554.         fi;
  555.         if [[ -n ${_RESPECT_CMAKE_BUILD_DIR} ]]; then
  556.             BUILD_DIR=${CMAKE_BUILD_DIR:-${WORKDIR}/${P}_build};
  557.         else
  558.             : ${BUILD_DIR:=${WORKDIR}/${P}_build};
  559.         fi;
  560.     fi;
  561.     [[ ${EAPI} == [56] ]] && CMAKE_BUILD_DIR=${BUILD_DIR};
  562.     mkdir -p "${BUILD_DIR}" || die;
  563.     echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
  564. }
  565. _cmake_cleanup_cmake ()
  566. {
  567.     : ${CMAKE_USE_DIR:=${S}};
  568.     if [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]]; then
  569.         local name;
  570.         for name in ${CMAKE_REMOVE_MODULES_LIST};
  571.         do
  572.             find "${S}" -name ${name}.cmake -exec rm -v {} + || die;
  573.         done;
  574.     fi;
  575.     if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]]; then
  576.         eerror "Unable to locate CMakeLists.txt under:";
  577.         eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"";
  578.         eerror "Consider not inheriting the cmake eclass.";
  579.         die "FATAL: Unable to find CMakeLists.txt";
  580.     fi;
  581.     _cmake_modify-cmakelists
  582. }
  583. _cmake_emake_src_make ()
  584. {
  585.     debug-print-function ${FUNCNAME} "$@";
  586.     [[ -e Makefile ]] || die "Makefile not found. Error during configure stage.";
  587.     if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
  588.         emake VERBOSE=1 "$@" || die;
  589.     else
  590.         emake "$@" || die;
  591.     fi
  592. }
  593. _cmake_generator_to_use ()
  594. {
  595.     local generator_name;
  596.     case ${CMAKE_MAKEFILE_GENERATOR} in
  597.         ninja)
  598.             case ${EAPI} in
  599.                 5 | 6)
  600.                     if ! ROOT=/ has_version dev-util/ninja; then
  601.                         die "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed. Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR.";
  602.                     fi
  603.                 ;;
  604.                 *)
  605.                     if ! has_version -b dev-util/ninja; then
  606.                         die "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed. Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR.";
  607.                     fi
  608.                 ;;
  609.             esac;
  610.             generator_name="Ninja"
  611.         ;;
  612.         emake)
  613.             generator_name="Unix Makefiles"
  614.         ;;
  615.         *)
  616.             eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}";
  617.             die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
  618.         ;;
  619.     esac;
  620.     echo ${generator_name}
  621. }
  622. _cmake_modify-cmakelists ()
  623. {
  624.     debug-print-function ${FUNCNAME} "$@";
  625.     grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0;
  626.     find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -i {} + || die "${LINENO}: failed to disable hardcoded settings";
  627.     local x;
  628.     for x in $(find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec grep -l "^#_cmake_modify_IGNORE" {} +;);
  629.     do
  630.         einfo "Hardcoded definition(s) removed in $(echo "${x}" | cut -c $((${#CMAKE_USE_DIR}+2))-):";
  631.         einfo "$(grep -se '^#_cmake_modify_IGNORE' ${x} | cut -c 22-99)";
  632.     done;
  633.     cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt  <<-_EOF_ ||
  634.  
  635. MESSAGE(STATUS "<<< Gentoo configuration >>>
  636. Build type      \${CMAKE_BUILD_TYPE}
  637. Install path    \${CMAKE_INSTALL_PREFIX}
  638. Compiler flags:
  639. C               \${CMAKE_C_FLAGS}
  640. C++             \${CMAKE_CXX_FLAGS}
  641. Linker flags:
  642. Executable      \${CMAKE_EXE_LINKER_FLAGS}
  643. Module          \${CMAKE_MODULE_LINKER_FLAGS}
  644. Shared          \${CMAKE_SHARED_LINKER_FLAGS}\n")
  645. _EOF_
  646.  die
  647. }
  648. _cmake_ninja_src_make ()
  649. {
  650.     debug-print-function ${FUNCNAME} "$@";
  651.     [[ -e build.ninja ]] || die "build.ninja not found. Error during configure stage.";
  652.     eninja "$@"
  653. }
  654. _cmake_use_me_now ()
  655. {
  656.     debug-print-function ${FUNCNAME} "$@";
  657.     local arg=$2;
  658.     [[ ! -z $3 ]] && arg=$3;
  659.     [[ ${EAPI} == 5 ]] || die "${FUNCNAME[1]} is banned in EAPI 6 and later: use -D$1<related_CMake_variable>=\"\$(usex $2)\" instead";
  660.     local uper capitalised x;
  661.     [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  662.     if [[ ! -z $3 ]]; then
  663.         echo "-D$1$3=$(use $2 && echo ON || echo OFF)";
  664.     else
  665.         uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  666.         capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  667.         for x in $2 $uper $capitalised;
  668.         do
  669.             echo "-D$1$x=$(use $2 && echo ON || echo OFF) ";
  670.         done;
  671.     fi
  672. }
  673. _cmake_use_me_now_inverted ()
  674. {
  675.     debug-print-function ${FUNCNAME} "$@";
  676.     local arg=$2;
  677.     [[ ! -z $3 ]] && arg=$3;
  678.     if [[ ${EAPI} != 5 && "${FUNCNAME[1]}" != cmake-utils_use_find_package ]]; then
  679.         die "${FUNCNAME[1]} is banned in EAPI 6 and later: use -D$1<related_CMake_variable>=\"\$(usex $2)\" instead";
  680.     fi;
  681.     local uper capitalised x;
  682.     [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  683.     if [[ ! -z $3 ]]; then
  684.         echo "-D$1$3=$(use $2 && echo OFF || echo ON)";
  685.     else
  686.         uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  687.         capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  688.         for x in $2 $uper $capitalised;
  689.         do
  690.             echo "-D$1$x=$(use $2 && echo OFF || echo ON) ";
  691.         done;
  692.     fi
  693. }
  694. _eapply_patch ()
  695. {
  696.     local f=${1};
  697.     local prefix=${2};
  698.     ebegin "${prefix:-Applying }${f##*/}";
  699.     ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  700.     failed=${?};
  701.     if ! eend "${failed}"; then
  702.         __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  703.     fi
  704. }
  705. _filter-hardened ()
  706. {
  707.     local f;
  708.     for f in "$@";
  709.     do
  710.         case "${f}" in
  711.             -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  712.                 gcc-specs-pie || continue;
  713.                 if ! is-flagq -nopie && ! is-flagq -no-pie; then
  714.                     if test-flags -nopie > /dev/null; then
  715.                         append-flags -nopie;
  716.                     else
  717.                         append-flags -no-pie;
  718.                     fi;
  719.                 fi
  720.             ;;
  721.             -fstack-protector)
  722.                 gcc-specs-ssp || continue;
  723.                 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  724.             ;;
  725.             -fstack-protector-all)
  726.                 gcc-specs-ssp-to-all || continue;
  727.                 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  728.             ;;
  729.             -fno-strict-overflow)
  730.                 gcc-specs-nostrict || continue;
  731.                 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  732.             ;;
  733.         esac;
  734.     done
  735. }
  736. _filter-var ()
  737. {
  738.     local f x var=$1 new=();
  739.     shift;
  740.     for f in ${!var};
  741.     do
  742.         for x in "$@";
  743.         do
  744.             [[ ${f} == ${x} ]] && continue 2;
  745.         done;
  746.         new+=("${f}");
  747.     done;
  748.     export ${var}="${new[*]}"
  749. }
  750. _gcc-install-dir ()
  751. {
  752.     echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |      awk '$1=="install:" {print $2}')"
  753. }
  754. _gcc-specs-directive_raw ()
  755. {
  756.     local cc=$(tc-getCC);
  757.     local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  758.     ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  759. $1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
  760.     outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  761.     spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  762.     { spec=spec $0 }
  763. END { print spec }';
  764.     return 0
  765. }
  766. _gcc-specs-exists ()
  767. {
  768.     [[ -f $(_gcc-install-dir)/$1 ]]
  769. }
  770. _gcc_fullversion ()
  771. {
  772.     local ver="$1";
  773.     shift;
  774.     set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  775.     eval echo "$ver"
  776. }
  777. _iconins ()
  778. {
  779.     ( insopts -m 0644;
  780.     local funcname=$1;
  781.     shift;
  782.     local size dir;
  783.     local context=apps;
  784.     local theme=hicolor;
  785.     while [[ $# -gt 0 ]]; do
  786.         case $1 in
  787.             -s | --size)
  788.                 if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  789.                     size=${2%%x*};
  790.                 else
  791.                     size=${2};
  792.                 fi;
  793.                 case ${size} in
  794.                     16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  795.                         size=${size}x${size}
  796.                     ;;
  797.                     scalable)
  798.  
  799.                     ;;
  800.                     *)
  801.                         eerror "${size} is an unsupported icon size!";
  802.                         exit 1
  803.                     ;;
  804.                 esac;
  805.                 shift 2
  806.             ;;
  807.             -t | --theme)
  808.                 theme=${2};
  809.                 shift 2
  810.             ;;
  811.             -c | --context)
  812.                 context=${2};
  813.                 shift 2
  814.             ;;
  815.             *)
  816.                 if [[ -z ${size} ]]; then
  817.                     insinto /usr/share/pixmaps;
  818.                 else
  819.                     insinto /usr/share/icons/${theme}/${size}/${context};
  820.                 fi;
  821.                 if [[ ${funcname} == doicon ]]; then
  822.                     if [[ -f $1 ]]; then
  823.                         doins "${1}";
  824.                     else
  825.                         if [[ -d $1 ]]; then
  826.                             shopt -s nullglob;
  827.                             doins "${1}"/*.{png,svg};
  828.                             shopt -u nullglob;
  829.                         else
  830.                             eerror "${1} is not a valid file/directory!";
  831.                             exit 1;
  832.                         fi;
  833.                     fi;
  834.                 else
  835.                     break;
  836.                 fi;
  837.                 shift 1
  838.             ;;
  839.         esac;
  840.     done;
  841.     if [[ ${funcname} == newicon ]]; then
  842.         newins "$@";
  843.     fi ) || die
  844. }
  845. _is_flagq ()
  846. {
  847.     local x var="$1[*]";
  848.     for x in ${!var};
  849.     do
  850.         [[ ${x} == $2 ]] && return 0;
  851.     done;
  852.     return 1
  853. }
  854. _python_check_dead_variables ()
  855. {
  856.     local v;
  857.     for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  858.     do
  859.         if [[ -n ${!v} ]]; then
  860.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  861.         fi;
  862.     done;
  863.     for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  864.     do
  865.         if [[ -n ${!v} ]]; then
  866.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  867.         fi;
  868.     done;
  869.     for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  870.     do
  871.         if [[ -n ${!v} ]]; then
  872.             die "${v} is invalid for python-r1 suite";
  873.         fi;
  874.     done;
  875.     for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  876.     do
  877.         if [[ -n ${!v} ]]; then
  878.             die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  879.         fi;
  880.     done;
  881.     if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  882.         die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  883.     fi;
  884.     for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  885.     do
  886.         if [[ -n ${!v} ]]; then
  887.             die "${v} is invalid for python-r1 suite";
  888.         fi;
  889.     done
  890. }
  891. _python_check_locale_sanity ()
  892. {
  893.     local -x LC_ALL=${1};
  894.     local IFS=;
  895.     local lc=({a..z});
  896.     local uc=({A..Z});
  897.     local input="${lc[*]}${uc[*]}";
  898.     local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  899.     [[ ${output} == "${uc[*]}${lc[*]}" ]]
  900. }
  901. _python_impl_matches ()
  902. {
  903.     [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  904.     local impl=${1} pattern;
  905.     shift;
  906.     for pattern in "$@";
  907.     do
  908.         if [[ ${pattern} == -2 ]]; then
  909.             python_is_python3 "${impl}" || return 0;
  910.         else
  911.             if [[ ${pattern} == -3 ]]; then
  912.                 python_is_python3 "${impl}" && return 0;
  913.                 return;
  914.             else
  915.                 if [[ ${impl/./_} == ${pattern/./_} ]]; then
  916.                     return 0;
  917.                 fi;
  918.             fi;
  919.         fi;
  920.     done;
  921.     return 1
  922. }
  923. _python_impl_supported ()
  924. {
  925.     debug-print-function ${FUNCNAME} "${@}";
  926.     [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  927.     local impl=${1};
  928.     case "${impl}" in
  929.         python2_7 | python3_[5678] | jython2_7)
  930.             return 0
  931.         ;;
  932.         pypy1_[89] | pypy2_0 | python2_[56] | python3_[1234])
  933.             return 1
  934.         ;;
  935.         pypy | pypy3)
  936.             if [[ ${EAPI:-0} == [01234] ]]; then
  937.                 die "PyPy is supported in EAPI 5 and newer only.";
  938.             fi
  939.         ;;
  940.         *)
  941.             [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  942.             die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  943.         ;;
  944.     esac
  945. }
  946. _python_ln_rel ()
  947. {
  948.     debug-print-function ${FUNCNAME} "${@}";
  949.     local target=${1};
  950.     local symname=${2};
  951.     local tgpath=${target%/*}/;
  952.     local sympath=${symname%/*}/;
  953.     local rel_target=;
  954.     while [[ -n ${sympath} ]]; do
  955.         local tgseg= symseg=;
  956.         while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  957.             tgseg=${tgpath%%/*};
  958.             tgpath=${tgpath#${tgseg}/};
  959.         done;
  960.         while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  961.             symseg=${sympath%%/*};
  962.             sympath=${sympath#${symseg}/};
  963.         done;
  964.         if [[ ${tgseg} != ${symseg} ]]; then
  965.             rel_target=../${rel_target}${tgseg:+${tgseg}/};
  966.         fi;
  967.     done;
  968.     rel_target+=${tgpath}${target##*/};
  969.     debug-print "${FUNCNAME}: ${symname} -> ${target}";
  970.     debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  971.     ln -fs "${rel_target}" "${symname}"
  972. }
  973. _python_set_impls ()
  974. {
  975.     local i;
  976.     if ! declare -p PYTHON_COMPAT &> /dev/null; then
  977.         die 'PYTHON_COMPAT not declared.';
  978.     fi;
  979.     if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  980.         die 'PYTHON_COMPAT must be an array.';
  981.     fi;
  982.     for i in "${PYTHON_COMPAT[@]}";
  983.     do
  984.         _python_impl_supported "${i}";
  985.     done;
  986.     local supp=() unsupp=();
  987.     for i in "${_PYTHON_ALL_IMPLS[@]}";
  988.     do
  989.         if has "${i}" "${PYTHON_COMPAT[@]}"; then
  990.             supp+=("${i}");
  991.         else
  992.             unsupp+=("${i}");
  993.         fi;
  994.     done;
  995.     if [[ ! -n ${supp[@]} ]]; then
  996.         die "No supported implementation in PYTHON_COMPAT.";
  997.     fi;
  998.     if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  999.         if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  1000.             eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  1001.             eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  1002.             eerror "Now   : ${supp[*]}";
  1003.             die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  1004.         fi;
  1005.         if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  1006.             eerror "Unsupported impls changed between inherits!";
  1007.             eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  1008.             eerror "Now   : ${unsupp[*]}";
  1009.             die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  1010.         fi;
  1011.     else
  1012.         _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  1013.         _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  1014.         readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  1015.     fi
  1016. }
  1017. _tc-getPROG ()
  1018. {
  1019.     local tuple=$1;
  1020.     local v var vars=$2;
  1021.     local prog=($3);
  1022.     var=${vars%% *};
  1023.     for v in ${vars};
  1024.     do
  1025.         if [[ -n ${!v} ]]; then
  1026.             export ${var}="${!v}";
  1027.             echo "${!v}";
  1028.             return 0;
  1029.         fi;
  1030.     done;
  1031.     local search=;
  1032.     [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  1033.     [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  1034.     [[ -n ${search} ]] && prog[0]=${search##*/};
  1035.     export ${var}="${prog[*]}";
  1036.     echo "${!var}"
  1037. }
  1038. all-flag-vars ()
  1039. {
  1040.     echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  1041. }
  1042. append-cflags ()
  1043. {
  1044.     [[ $# -eq 0 ]] && return 0;
  1045.     export CFLAGS+=" $*";
  1046.     return 0
  1047. }
  1048. append-cppflags ()
  1049. {
  1050.     [[ $# -eq 0 ]] && return 0;
  1051.     export CPPFLAGS+=" $*";
  1052.     return 0
  1053. }
  1054. append-cxxflags ()
  1055. {
  1056.     [[ $# -eq 0 ]] && return 0;
  1057.     export CXXFLAGS+=" $*";
  1058.     return 0
  1059. }
  1060. append-fflags ()
  1061. {
  1062.     [[ $# -eq 0 ]] && return 0;
  1063.     export FFLAGS+=" $*";
  1064.     export FCFLAGS+=" $*";
  1065.     return 0
  1066. }
  1067. append-flags ()
  1068. {
  1069.     [[ $# -eq 0 ]] && return 0;
  1070.     case " $* " in
  1071.         *' '-[DIU]*)
  1072.             eqawarn 'please use append-cppflags for preprocessor flags'
  1073.         ;;
  1074.         *' '-L* | *' '-Wl,*)
  1075.             eqawarn 'please use append-ldflags for linker flags'
  1076.         ;;
  1077.     esac;
  1078.     append-cflags "$@";
  1079.     append-cxxflags "$@";
  1080.     append-fflags "$@";
  1081.     return 0
  1082. }
  1083. append-ldflags ()
  1084. {
  1085.     [[ $# -eq 0 ]] && return 0;
  1086.     local flag;
  1087.     for flag in "$@";
  1088.     do
  1089.         [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1090.     done;
  1091.     export LDFLAGS="${LDFLAGS} $*";
  1092.     return 0
  1093. }
  1094. append-lfs-flags ()
  1095. {
  1096.     [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1097.     append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1098. }
  1099. append-libs ()
  1100. {
  1101.     [[ $# -eq 0 ]] && return 0;
  1102.     local flag;
  1103.     for flag in "$@";
  1104.     do
  1105.         if [[ -z "${flag// }" ]]; then
  1106.             eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1107.             continue;
  1108.         fi;
  1109.         case $flag in
  1110.             -[lL]*)
  1111.                 export LIBS="${LIBS} ${flag}"
  1112.             ;;
  1113.             -*)
  1114.                 eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1115.                 export LIBS="${LIBS} ${flag}"
  1116.             ;;
  1117.             *)
  1118.                 export LIBS="${LIBS} -l${flag}"
  1119.             ;;
  1120.         esac;
  1121.     done;
  1122.     return 0
  1123. }
  1124. build_sphinx ()
  1125. {
  1126.     debug-print-function ${FUNCNAME} "${@}";
  1127.     [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes 1 arg: <directory>";
  1128.     local dir=${1};
  1129.     sed -i -e 's:^intersphinx_mapping:disabled_&:' "${dir}"/conf.py || die;
  1130.     sphinx-build -b html -d "${dir}"/_build/doctrees "${dir}" "${dir}"/_build/html || die;
  1131.     HTML_DOCS+=("${dir}/_build/html/.")
  1132. }
  1133. clang-fullversion ()
  1134. {
  1135.     _clang_fullversion '$1.$2.$3' "$@"
  1136. }
  1137. clang-major-version ()
  1138. {
  1139.     _clang_fullversion '$1' "$@"
  1140. }
  1141. clang-micro-version ()
  1142. {
  1143.     _clang_fullversion '$3' "$@"
  1144. }
  1145. clang-minor-version ()
  1146. {
  1147.     _clang_fullversion '$2' "$@"
  1148. }
  1149. clang-version ()
  1150. {
  1151.     _clang_fullversion '$1.$2' "$@"
  1152. }
  1153. cmake-utils_src_compile ()
  1154. {
  1155.     debug-print-function ${FUNCNAME} "$@";
  1156.     cmake-utils_src_make "$@"
  1157. }
  1158. cmake-utils_src_configure ()
  1159. {
  1160.     debug-print-function ${FUNCNAME} "$@";
  1161.     if [[ ! -n ${_CMAKE_UTILS_SRC_PREPARE_HAS_RUN} ]]; then
  1162.         if [[ ${EAPI} != [56] ]]; then
  1163.             die "FATAL: cmake-utils_src_prepare has not been run";
  1164.         else
  1165.             eqawarn "cmake-utils_src_prepare has not been run, please open a bug on https://bugs.gentoo.org/";
  1166.         fi;
  1167.     fi;
  1168.     [[ ${EAPI} == 5 ]] && _cmake_cleanup_cmake;
  1169.     _cmake_check_build_dir;
  1170.     xdg_environment_reset;
  1171.     if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
  1172.         if ! has debug ${IUSE//+} || ! use debug; then
  1173.             local CPPFLAGS=${CPPFLAGS};
  1174.             append-cppflags -DNDEBUG;
  1175.         fi;
  1176.     fi;
  1177.     local build_rules=${BUILD_DIR}/gentoo_rules.cmake;
  1178.     cat > "${build_rules}"  <<-_EOF_ ||
  1179. SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
  1180. SET (CMAKE_ASM-ATT_COMPILE_OBJECT "<CMAKE_ASM-ATT_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c -x assembler <SOURCE>" CACHE STRING "ASM-ATT compile command" FORCE)
  1181. SET (CMAKE_ASM-ATT_LINK_FLAGS "-nostdlib" CACHE STRING "ASM-ATT link flags" FORCE)
  1182. SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
  1183. SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
  1184. SET (CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> ${FCFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "Fortran compile command" FORCE)
  1185. _EOF_
  1186.  die
  1187.     local myCC=$(tc-getCC) myCXX=$(tc-getCXX) myFC=$(tc-getFC);
  1188.     local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake;
  1189.     cat > ${toolchain_file}  <<-_EOF_ ||
  1190. SET (CMAKE_ASM_COMPILER "${myCC/ /;}")
  1191. SET (CMAKE_ASM-ATT_COMPILER "${myCC/ /;}")
  1192. SET (CMAKE_C_COMPILER "${myCC/ /;}")
  1193. SET (CMAKE_CXX_COMPILER "${myCXX/ /;}")
  1194. SET (CMAKE_Fortran_COMPILER "${myFC/ /;}")
  1195. SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
  1196. SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
  1197. SET (CMAKE_SYSTEM_PROCESSOR "${CHOST%%-*}")
  1198. _EOF_
  1199.  die
  1200.     local -x ASMFLAGS=${CFLAGS};
  1201.     local -x PKG_CONFIG=$(tc-getPKG_CONFIG);
  1202.     if tc-is-cross-compiler; then
  1203.         local sysname;
  1204.         case "${KERNEL:-linux}" in
  1205.             Cygwin)
  1206.                 sysname="CYGWIN_NT-5.1"
  1207.             ;;
  1208.             HPUX)
  1209.                 sysname="HP-UX"
  1210.             ;;
  1211.             linux)
  1212.                 sysname="Linux"
  1213.             ;;
  1214.             Winnt)
  1215.                 sysname="Windows";
  1216.                 cat >> "${toolchain_file}"  <<-_EOF_ ||
  1217. SET (CMAKE_RC_COMPILER $(tc-getRC))
  1218. _EOF_
  1219.  die
  1220.             ;;
  1221.             *)
  1222.                 sysname="${KERNEL}"
  1223.             ;;
  1224.         esac
  1225.         cat >> "${toolchain_file}"  <<-_EOF_ ||
  1226. SET (CMAKE_SYSTEM_NAME "${sysname}")
  1227. _EOF_
  1228.  die
  1229.         if [ "${SYSROOT:-/}" != "/" ]; then
  1230.             cat >> "${toolchain_file}"  <<-_EOF_ ||
  1231. SET (CMAKE_FIND_ROOT_PATH "${SYSROOT}")
  1232. SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  1233. SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  1234. SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  1235. _EOF_
  1236.  die;
  1237.         fi;
  1238.     fi
  1239.     if use prefix-guest; then
  1240.         cat >> "${build_rules}"  <<-_EOF_ ||
  1241. # in Prefix we need rpath and must ensure cmake gets our default linker path
  1242. # right ... except for Darwin hosts
  1243. IF (NOT APPLE)
  1244. SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1245. SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
  1246. CACHE STRING "" FORCE)
  1247.  
  1248. ELSE ()
  1249.  
  1250. SET (CMAKE_PREFIX_PATH "${EPREFIX}/usr" CACHE STRING "" FORCE)
  1251. SET (CMAKE_MACOSX_RPATH ON CACHE BOOL "" FORCE)
  1252. SET (CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
  1253. SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1254. SET (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
  1255.  
  1256. ENDIF (NOT APPLE)
  1257. _EOF_
  1258.  die;
  1259.     fi
  1260.     local common_config=${BUILD_DIR}/gentoo_common_config.cmake;
  1261.     local libdir=$(get_libdir);
  1262.     cat > "${common_config}"  <<-_EOF_ ||
  1263. SET (CMAKE_GENTOO_BUILD ON CACHE BOOL "Indicate Gentoo package build")
  1264. SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
  1265. SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
  1266. SET (CMAKE_INSTALL_INFODIR "${EPREFIX}/usr/share/info" CACHE PATH "")
  1267. SET (CMAKE_INSTALL_MANDIR "${EPREFIX}/usr/share/man" CACHE PATH "")
  1268. SET (CMAKE_USER_MAKE_RULES_OVERRIDE "${build_rules}" CACHE FILEPATH "Gentoo override rules")
  1269. _EOF_
  1270.  die
  1271.     [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}";
  1272.     if [[ ${EAPI} != [56] ]]; then
  1273.         cat >> "${common_config}"  <<-_EOF_ ||
  1274. SET (CMAKE_INSTALL_DOCDIR "${EPREFIX}/usr/share/doc/${PF}" CACHE PATH "")
  1275. SET (BUILD_SHARED_LIBS ON CACHE BOOL "")
  1276. _EOF_
  1277.  die;
  1278.     fi
  1279.     if [[ ${CMAKE_BUILD_TYPE} != Gentoo && ${EAPI} != 5 ]]; then
  1280.         cat >> ${common_config}  <<-_EOF_ ||
  1281. SET (CMAKE_ASM_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1282. SET (CMAKE_ASM-ATT_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1283. SET (CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1284. SET (CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1285. SET (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1286. SET (CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1287. SET (CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1288. SET (CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1289. SET (CMAKE_STATIC_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1290. _EOF_
  1291.  die;
  1292.     fi
  1293.     local mycmakeargstype=$(declare -p mycmakeargs 2>&-);
  1294.     if [[ "${mycmakeargstype}" != "declare -a mycmakeargs="* ]]; then
  1295.         if [[ -n "${mycmakeargstype}" ]]; then
  1296.             if [[ ${EAPI} == 5 ]]; then
  1297.                 eqawarn "Declaring mycmakeargs as a variable is deprecated. Please use an array instead.";
  1298.             else
  1299.                 die "Declaring mycmakeargs as a variable is banned in EAPI=${EAPI}. Please use an array instead.";
  1300.             fi;
  1301.         fi;
  1302.         local mycmakeargs_local=(${mycmakeargs});
  1303.     else
  1304.         local mycmakeargs_local=("${mycmakeargs[@]}");
  1305.     fi;
  1306.     if [[ ${CMAKE_WARN_UNUSED_CLI} == no ]]; then
  1307.         local warn_unused_cli="--no-warn-unused-cli";
  1308.     else
  1309.         local warn_unused_cli="";
  1310.     fi;
  1311.     local cmakeargs=(${warn_unused_cli} -C "${common_config}" -G "$(_cmake_generator_to_use)" -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" "${mycmakeargs_local[@]}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" $([[ ${EAPI} == 5 ]] && echo -DCMAKE_INSTALL_DO_STRIP=OFF) -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" "${MYCMAKEARGS}");
  1312.     if [[ -n "${CMAKE_EXTRA_CACHE_FILE}" ]]; then
  1313.         cmakeargs+=(-C "${CMAKE_EXTRA_CACHE_FILE}");
  1314.     fi;
  1315.     pushd "${BUILD_DIR}" > /dev/null || die;
  1316.     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}";
  1317.     echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}";
  1318.     "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
  1319.     popd > /dev/null || die
  1320. }
  1321. cmake-utils_src_install ()
  1322. {
  1323.     debug-print-function ${FUNCNAME} "$@";
  1324.     _cmake_check_build_dir;
  1325.     pushd "${BUILD_DIR}" > /dev/null || die;
  1326.     DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install";
  1327.     popd > /dev/null || die;
  1328.     pushd "${S}" > /dev/null || die;
  1329.     einstalldocs;
  1330.     popd > /dev/null || die
  1331. }
  1332. cmake-utils_src_make ()
  1333. {
  1334.     debug-print-function ${FUNCNAME} "$@";
  1335.     _cmake_check_build_dir;
  1336.     pushd "${BUILD_DIR}" > /dev/null || die;
  1337.     _cmake_${CMAKE_MAKEFILE_GENERATOR}_src_make "$@";
  1338.     popd > /dev/null || die
  1339. }
  1340. cmake-utils_src_prepare ()
  1341. {
  1342.     debug-print-function ${FUNCNAME} "$@";
  1343.     pushd "${S}" > /dev/null || die;
  1344.     if [[ ${EAPI} != 5 ]]; then
  1345.         default_src_prepare;
  1346.         _cmake_cleanup_cmake;
  1347.     else
  1348.         debug-print "$FUNCNAME: PATCHES=$PATCHES";
  1349.         [[ -n ${PATCHES[@]} ]] && epatch "${PATCHES[@]}";
  1350.         debug-print "$FUNCNAME: applying user patches";
  1351.         epatch_user;
  1352.     fi;
  1353.     popd > /dev/null || die;
  1354.     if [[ -n ${CMAKE_UTILS_QA_SRC_DIR_READONLY} && ! -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  1355.         chmod -R a-w "${S}";
  1356.     fi;
  1357.     _CMAKE_UTILS_SRC_PREPARE_HAS_RUN=1
  1358. }
  1359. cmake-utils_src_test ()
  1360. {
  1361.     debug-print-function ${FUNCNAME} "$@";
  1362.     _cmake_check_build_dir;
  1363.     pushd "${BUILD_DIR}" > /dev/null || die;
  1364.     [[ -e CTestTestfile.cmake ]] || {
  1365.         echo "No tests found. Skipping.";
  1366.         return 0
  1367.     };
  1368.     [[ -n ${TEST_VERBOSE} ]] && myctestargs+=(--extra-verbose --output-on-failure);
  1369.     set -- ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@";
  1370.     echo "$@" 1>&2;
  1371.     if "$@"; then
  1372.         einfo "Tests succeeded.";
  1373.         popd > /dev/null || die;
  1374.         return 0;
  1375.     else
  1376.         if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]]; then
  1377.             eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:";
  1378.             eerror "--START TEST LOG--------------------------------------------------------------";
  1379.             cat "${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1380.             eerror "--END TEST LOG----------------------------------------------------------------";
  1381.             die "Tests failed.";
  1382.         else
  1383.             die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1384.         fi;
  1385.         popd > /dev/null || die;
  1386.         return 1;
  1387.     fi
  1388. }
  1389. cmake-utils_use ()
  1390. {
  1391.     _cmake_use_me_now "" "$@"
  1392. }
  1393. cmake-utils_use_build ()
  1394. {
  1395.     _cmake_use_me_now BUILD_ "$@"
  1396. }
  1397. cmake-utils_use_disable ()
  1398. {
  1399.     _cmake_use_me_now_inverted DISABLE_ "$@"
  1400. }
  1401. cmake-utils_use_enable ()
  1402. {
  1403.     _cmake_use_me_now ENABLE_ "$@"
  1404. }
  1405. cmake-utils_use_find_package ()
  1406. {
  1407.     if [[ ${EAPI} != 5 && "$#" != 2 ]]; then
  1408.         die "Usage: cmake-utils_use_find_package <USE flag> <package name>";
  1409.     fi;
  1410.     _cmake_use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@"
  1411. }
  1412. cmake-utils_use_has ()
  1413. {
  1414.     _cmake_use_me_now HAVE_ "$@"
  1415. }
  1416. cmake-utils_use_no ()
  1417. {
  1418.     _cmake_use_me_now_inverted NO_ "$@"
  1419. }
  1420. cmake-utils_use_use ()
  1421. {
  1422.     _cmake_use_me_now USE_ "$@"
  1423. }
  1424. cmake-utils_use_want ()
  1425. {
  1426.     _cmake_use_me_now WANT_ "$@"
  1427. }
  1428. cmake-utils_use_with ()
  1429. {
  1430.     _cmake_use_me_now WITH_ "$@"
  1431. }
  1432. cmake-utils_useno ()
  1433. {
  1434.     _cmake_use_me_now_inverted "" "$@"
  1435. }
  1436. cmake_comment_add_subdirectory ()
  1437. {
  1438.     if [[ -z ${1} ]]; then
  1439.         die "comment_add_subdirectory must be passed at least one directory name to comment";
  1440.     fi;
  1441.     if [[ -e "CMakeLists.txt" ]]; then
  1442.         local d;
  1443.         for d in $@;
  1444.         do
  1445.             sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${d//\//\\/}[[:space:]]*)/I s/^/#DONOTCOMPILE /" -i CMakeLists.txt || die "failed to comment add_subdirectory(${d})";
  1446.         done;
  1447.     fi
  1448. }
  1449. comment_add_subdirectory ()
  1450. {
  1451.     [[ ${EAPI} == 5 ]] || die "comment_add_subdirectory is banned in EAPI 6 and later - use cmake_comment_add_subdirectory instead";
  1452.     cmake_comment_add_subdirectory "$@"
  1453. }
  1454. doicon ()
  1455. {
  1456.     _iconins ${FUNCNAME} "$@"
  1457. }
  1458. domenu ()
  1459. {
  1460.     ( local i ret=0;
  1461.     insopts -m 0644;
  1462.     insinto /usr/share/applications;
  1463.     for i in "$@";
  1464.     do
  1465.         if [[ -d ${i} ]]; then
  1466.             doins "${i}"/*.desktop;
  1467.             ((ret|=$?));
  1468.         else
  1469.             doins "${i}";
  1470.             ((ret|=$?));
  1471.         fi;
  1472.     done;
  1473.     exit ${ret} )
  1474. }
  1475. eapply ()
  1476. {
  1477.     local failed patch_cmd=patch;
  1478.     local -x LC_COLLATE=POSIX;
  1479.     type -P gpatch > /dev/null && patch_cmd=gpatch;
  1480.     function _eapply_patch ()
  1481.     {
  1482.         local f=${1};
  1483.         local prefix=${2};
  1484.         ebegin "${prefix:-Applying }${f##*/}";
  1485.         ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1486.         failed=${?};
  1487.         if ! eend "${failed}"; then
  1488.             __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1489.         fi
  1490.     };
  1491.     local patch_options=() files=();
  1492.     local i found_doublehyphen;
  1493.     for ((i = 1; i <= ${#@}; ++i ))
  1494.     do
  1495.         if [[ ${@:i:1} == -- ]]; then
  1496.             patch_options=("${@:1:i-1}");
  1497.             files=("${@:i+1}");
  1498.             found_doublehyphen=1;
  1499.             break;
  1500.         fi;
  1501.     done;
  1502.     if [[ -z ${found_doublehyphen} ]]; then
  1503.         for ((i = 1; i <= ${#@}; ++i ))
  1504.         do
  1505.             if [[ ${@:i:1} != -* ]]; then
  1506.                 patch_options=("${@:1:i-1}");
  1507.                 files=("${@:i}");
  1508.                 break;
  1509.             fi;
  1510.         done;
  1511.         for i in "${files[@]}";
  1512.         do
  1513.             if [[ ${i} == -* ]]; then
  1514.                 die "eapply: all options must be passed before non-options";
  1515.             fi;
  1516.         done;
  1517.     fi;
  1518.     if [[ ${#files[@]} -eq 0 ]]; then
  1519.         die "eapply: no files specified";
  1520.     fi;
  1521.     local f;
  1522.     for f in "${files[@]}";
  1523.     do
  1524.         if [[ -d ${f} ]]; then
  1525.             function _eapply_get_files ()
  1526.             {
  1527.                 local LC_ALL=POSIX;
  1528.                 local prev_shopt=$(shopt -p nullglob);
  1529.                 shopt -s nullglob;
  1530.                 local f;
  1531.                 for f in "${1}"/*;
  1532.                 do
  1533.                     if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1534.                         files+=("${f}");
  1535.                     fi;
  1536.                 done;
  1537.                 ${prev_shopt}
  1538.             };
  1539.             local files=();
  1540.             _eapply_get_files "${f}";
  1541.             [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1542.             einfo "Applying patches from ${f} ...";
  1543.             local f2;
  1544.             for f2 in "${files[@]}";
  1545.             do
  1546.                 _eapply_patch "${f2}" '  ';
  1547.                 [[ ${failed} -ne 0 ]] && return "${failed}";
  1548.             done;
  1549.         else
  1550.             _eapply_patch "${f}";
  1551.             [[ ${failed} -ne 0 ]] && return "${failed}";
  1552.         fi;
  1553.     done;
  1554.     return 0
  1555. }
  1556. eapply_user ()
  1557. {
  1558.     [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1559.     local tagfile=${T}/.portage_user_patches_applied;
  1560.     [[ -f ${tagfile} ]] && return;
  1561.      >> "${tagfile}";
  1562.     local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1563.     local applied d f;
  1564.     local -A _eapply_user_patches;
  1565.     local prev_shopt=$(shopt -p nullglob);
  1566.     shopt -s nullglob;
  1567.     for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1568.     do
  1569.         for f in "${d}"/*;
  1570.         do
  1571.             if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1572.                 _eapply_user_patches[${f##*/}]=${f};
  1573.             fi;
  1574.         done;
  1575.     done;
  1576.     if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1577.         while read -r -d '' f; do
  1578.             f=${_eapply_user_patches[${f}]};
  1579.             if [[ -s ${f} ]]; then
  1580.                 eapply "${f}";
  1581.                 applied=1;
  1582.             fi;
  1583.         done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1584.                 LC_ALL=C sort -z);
  1585.     fi;
  1586.     ${prev_shopt};
  1587.     [[ -n ${applied} ]] && ewarn "User patches applied."
  1588. }
  1589. econf_build ()
  1590. {
  1591.     local CBUILD=${CBUILD:-${CHOST}};
  1592.     tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1593. }
  1594. edos2unix ()
  1595. {
  1596.     [[ $# -eq 0 ]] && return 0;
  1597.     sed -i 's/\r$//' -- "$@" || die
  1598. }
  1599. einstalldocs ()
  1600. {
  1601.     ( if ! declare -p DOCS &> /dev/null; then
  1602.         local d;
  1603.         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1604.         do
  1605.             [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1606.         done;
  1607.     else
  1608.         if ___is_indexed_array_var DOCS; then
  1609.             [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1610.         else
  1611.             [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1612.         fi;
  1613.     fi );
  1614.     ( if ___is_indexed_array_var HTML_DOCS; then
  1615.         [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1616.     else
  1617.         [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1618.     fi )
  1619. }
  1620. emktemp ()
  1621. {
  1622.     local exe="touch";
  1623.     [[ $1 == -d ]] && exe="mkdir" && shift;
  1624.     local topdir=$1;
  1625.     if [[ -z ${topdir} ]]; then
  1626.         [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1627.     fi;
  1628.     if ! type -P mktemp > /dev/null; then
  1629.         local tmp=/;
  1630.         while [[ -e ${tmp} ]]; do
  1631.             tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1632.         done;
  1633.         ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1634.         echo "${tmp}";
  1635.     else
  1636.         if [[ ${exe} == "touch" ]]; then
  1637.             TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1638.         else
  1639.             TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1640.         fi;
  1641.     fi
  1642. }
  1643. eninja ()
  1644. {
  1645.     local nonfatal_args=();
  1646.     [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=(-n);
  1647.     if [[ -z ${NINJAOPTS+set} ]]; then
  1648.         NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)";
  1649.     fi;
  1650.     set -- ninja -v ${NINJAOPTS} "$@";
  1651.     echo "$@" 1>&2;
  1652.     "$@" || die "${nonfatal_args[@]}" "${*} failed"
  1653. }
  1654. eqmake4 ()
  1655. {
  1656.     debug-print-function ${FUNCNAME} "$@";
  1657.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  1658.     has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  1659.     ebegin "Running qmake";
  1660.     local qmake_args=("$@");
  1661.     local regexp='.*\.pro';
  1662.     if ! [[ ${1} =~ ${regexp} ]]; then
  1663.         local project_file=$(qmake-utils_find_pro_file);
  1664.         if [[ -z ${project_file} ]]; then
  1665.             echo;
  1666.             eerror "No project files found in '${PWD}'";
  1667.             eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1668.             echo;
  1669.             die "eqmake4 failed";
  1670.         fi;
  1671.         qmake_args+=("${project_file}");
  1672.     fi;
  1673.     local config_add=release;
  1674.     local config_remove=debug;
  1675.     if in_iuse debug && use debug; then
  1676.         config_add=debug;
  1677.         config_remove=release;
  1678.     fi;
  1679.     local awkscript='BEGIN {
  1680.                 printf "### eqmake4 was here ###\n" > file;
  1681.                 printf "CONFIG -= debug_and_release %s\n", remove >> file;
  1682.                 printf "CONFIG += %s\n\n", add >> file;
  1683.                 fixed=0;
  1684.             }
  1685.             /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
  1686.                 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
  1687.                     fixed=1;
  1688.                 }
  1689.             }
  1690.             /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
  1691.                 if (gsub("\\<" add "\\>", "") > 0) {
  1692.                     fixed=1;
  1693.                 }
  1694.             }
  1695.             {
  1696.                 print >> file;
  1697.             }
  1698.             END {
  1699.                 print fixed;
  1700.             }';
  1701.     [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob;
  1702.     local file;
  1703.     while read file; do
  1704.         local excl;
  1705.         for excl in ${EQMAKE4_EXCLUDE};
  1706.         do
  1707.             [[ ${file} == ${excl} ]] && continue 2;
  1708.         done;
  1709.         grep -q '^### eqmake4 was here ###$' "${file}" && continue;
  1710.         local retval=$({
  1711.             rm -f "${file}" || echo FAIL
  1712.             awk -v file="${file}"               -v add=${config_add}                -v remove=${config_remove}              -- "${awkscript}" || echo FAIL
  1713.             } < "${file}");
  1714.         if [[ ${retval} == 1 ]]; then
  1715.             einfo " - fixed CONFIG in ${file}";
  1716.         else
  1717.             if [[ ${retval} != 0 ]]; then
  1718.                 eerror " - error while processing ${file}";
  1719.                 die "eqmake4 failed to process ${file}";
  1720.             fi;
  1721.         fi;
  1722.     done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null);
  1723.     [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop;
  1724.     "$(qt4_get_bindir)"/qmake -makefile QMAKE_AR="$(tc-getAR) cqs" QMAKE_CC="$(tc-getCC)" QMAKE_CXX="$(tc-getCXX)" QMAKE_LINK="$(tc-getCXX)" QMAKE_LINK_C="$(tc-getCC)" QMAKE_OBJCOPY="$(tc-getOBJCOPY)" QMAKE_RANLIB= QMAKE_STRIP= QMAKE_CFLAGS="${CFLAGS}" QMAKE_CFLAGS_RELEASE= QMAKE_CFLAGS_DEBUG= QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_CXXFLAGS_RELEASE= QMAKE_CXXFLAGS_DEBUG= QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LFLAGS_RELEASE= QMAKE_LFLAGS_DEBUG= QMAKE_LIBDIR_QT="${EPREFIX}$(qt4_get_libdir)" QMAKE_LIBDIR_X11="${EPREFIX}/usr/$(get_libdir)" QMAKE_LIBDIR_OPENGL="${EPREFIX}/usr/$(get_libdir)" "${qmake_args[@]}";
  1725.     if ! eend $?; then
  1726.         echo;
  1727.         eerror "Running qmake has failed! (see above for details)";
  1728.         eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1729.         echo;
  1730.         die "eqmake4 failed";
  1731.     fi
  1732. }
  1733. eqmake5 ()
  1734. {
  1735.     debug-print-function ${FUNCNAME} "$@";
  1736.     ebegin "Running qmake";
  1737.     "$(qt5_get_bindir)"/qmake -makefile QMAKE_AR="$(tc-getAR) cqs" QMAKE_CC="$(tc-getCC)" QMAKE_LINK_C="$(tc-getCC)" QMAKE_LINK_C_SHLIB="$(tc-getCC)" QMAKE_CXX="$(tc-getCXX)" QMAKE_LINK="$(tc-getCXX)" QMAKE_LINK_SHLIB="$(tc-getCXX)" QMAKE_OBJCOPY="$(tc-getOBJCOPY)" QMAKE_RANLIB= QMAKE_STRIP= QMAKE_CFLAGS="${CFLAGS}" QMAKE_CFLAGS_RELEASE= QMAKE_CFLAGS_DEBUG= QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_CXXFLAGS_RELEASE= QMAKE_CXXFLAGS_DEBUG= QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LFLAGS_RELEASE= QMAKE_LFLAGS_DEBUG= "$@";
  1738.     if ! eend $?; then
  1739.         echo;
  1740.         eerror "Running qmake has failed! (see above for details)";
  1741.         eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1742.         echo;
  1743.         die "eqmake5 failed";
  1744.     fi
  1745. }
  1746. eshopts_pop ()
  1747. {
  1748.     local s;
  1749.     estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1750.     eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  1751. }
  1752. eshopts_push ()
  1753. {
  1754.     estack_push eshopts "$(shopt -p -o) $(shopt -p)";
  1755.     if [[ $1 == -[su] ]]; then
  1756.         [[ $# -le 1 ]] && return 0;
  1757.         shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1758.     else
  1759.         [[ $# -eq 0 ]] && return 0;
  1760.         set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1761.     fi
  1762. }
  1763. estack_pop ()
  1764. {
  1765.     [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1766.     local _estack_name="_ESTACK_$1_";
  1767.     shift;
  1768.     local _estack_retvar=$1;
  1769.     shift;
  1770.     eval local _estack_i=\${#${_estack_name}\[@\]};
  1771.     [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  1772.     if [[ -n ${_estack_retvar} ]]; then
  1773.         eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  1774.     fi;
  1775.     eval unset \"${_estack_name}\[${_estack_i}\]\"
  1776. }
  1777. estack_push ()
  1778. {
  1779.     [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1780.     local stack_name="_ESTACK_$1_";
  1781.     shift;
  1782.     eval ${stack_name}+=\( \"\$@\" \)
  1783. }
  1784. eumask_pop ()
  1785. {
  1786.     [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1787.     local s;
  1788.     estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1789.     umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1790. }
  1791. eumask_push ()
  1792. {
  1793.     estack_push eumask "$(umask)";
  1794.     umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1795. }
  1796. evar_pop ()
  1797. {
  1798.     local cnt=${1:-bad};
  1799.     case $# in
  1800.         0)
  1801.             cnt=1
  1802.         ;;
  1803.         1)
  1804.             [[ -z ${cnt//[0-9]} ]] || die "${FUNCNAME}: first arg must be a number: $*"
  1805.         ;;
  1806.         *)
  1807.             die "${FUNCNAME}: only accepts one arg: $*"
  1808.         ;;
  1809.     esac;
  1810.     local var val;
  1811.     while (( cnt-- )); do
  1812.         estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1813.         estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1814.         [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1815.     done
  1816. }
  1817. evar_push ()
  1818. {
  1819.     local var val;
  1820.     for var in "$@";
  1821.     do
  1822.         [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1823.         estack_push evar "${var}" "${val}";
  1824.     done
  1825. }
  1826. evar_push_set ()
  1827. {
  1828.     local var=$1;
  1829.     evar_push ${var};
  1830.     case $# in
  1831.         1)
  1832.             unset ${var}
  1833.         ;;
  1834.         2)
  1835.             printf -v "${var}" '%s' "$2"
  1836.         ;;
  1837.         *)
  1838.             die "${FUNCNAME}: incorrect # of args: $*"
  1839.         ;;
  1840.     esac
  1841. }
  1842. filter-flags ()
  1843. {
  1844.     _filter-hardened "$@";
  1845.     local v;
  1846.     for v in $(all-flag-vars);
  1847.     do
  1848.         _filter-var ${v} "$@";
  1849.     done;
  1850.     return 0
  1851. }
  1852. filter-ldflags ()
  1853. {
  1854.     _filter-var LDFLAGS "$@";
  1855.     return 0
  1856. }
  1857. filter-lfs-flags ()
  1858. {
  1859.     [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1860.     filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1861. }
  1862. filter-mfpmath ()
  1863. {
  1864.     local orig_mfpmath new_math prune_math;
  1865.     orig_mfpmath=$(get-flag -mfpmath);
  1866.     new_math=$(get-flag mfpmath);
  1867.     new_math=${new_math/both/387,sse};
  1868.     new_math=" ${new_math//[,+]/ } ";
  1869.     prune_math="";
  1870.     for prune_math in "$@";
  1871.     do
  1872.         new_math=${new_math/ ${prune_math} / };
  1873.     done;
  1874.     new_math=$(echo ${new_math});
  1875.     new_math=${new_math// /,};
  1876.     if [[ -z ${new_math} ]]; then
  1877.         filter-flags ${orig_mfpmath};
  1878.     else
  1879.         replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1880.     fi;
  1881.     return 0
  1882. }
  1883. gcc-fullversion ()
  1884. {
  1885.     _gcc_fullversion '$1.$2.$3' "$@"
  1886. }
  1887. gcc-major-version ()
  1888. {
  1889.     _gcc_fullversion '$1' "$@"
  1890. }
  1891. gcc-micro-version ()
  1892. {
  1893.     _gcc_fullversion '$3' "$@"
  1894. }
  1895. gcc-minor-version ()
  1896. {
  1897.     _gcc_fullversion '$2' "$@"
  1898. }
  1899. gcc-specs-directive ()
  1900. {
  1901.     local directive subdname subdirective;
  1902.     directive="$(_gcc-specs-directive_raw $1)";
  1903.     while [[ ${directive} == *%\(*\)* ]]; do
  1904.         subdname=${directive/*%\(};
  1905.         subdname=${subdname/\)*};
  1906.         subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1907.         directive="${directive//\%(${subdname})/${subdirective}}";
  1908.     done;
  1909.     echo "${directive}";
  1910.     return 0
  1911. }
  1912. gcc-specs-nostrict ()
  1913. {
  1914.     local directive;
  1915.     directive=$(gcc-specs-directive cc1);
  1916.     [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1917. }
  1918. gcc-specs-now ()
  1919. {
  1920.     local directive;
  1921.     directive=$(gcc-specs-directive link_command);
  1922.     [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1923. }
  1924. gcc-specs-pie ()
  1925. {
  1926.     local directive;
  1927.     directive=$(gcc-specs-directive cc1);
  1928.     [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1929. }
  1930. gcc-specs-relro ()
  1931. {
  1932.     local directive;
  1933.     directive=$(gcc-specs-directive link_command);
  1934.     [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1935. }
  1936. gcc-specs-ssp ()
  1937. {
  1938.     local directive;
  1939.     directive=$(gcc-specs-directive cc1);
  1940.     [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1941. }
  1942. gcc-specs-ssp-to-all ()
  1943. {
  1944.     local directive;
  1945.     directive=$(gcc-specs-directive cc1);
  1946.     [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1947. }
  1948. gcc-specs-stack-check ()
  1949. {
  1950.     local directive;
  1951.     directive=$(gcc-specs-directive cc1);
  1952.     [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1953. }
  1954. gcc-version ()
  1955. {
  1956.     _gcc_fullversion '$1.$2' "$@"
  1957. }
  1958. gen_usr_ldscript ()
  1959. {
  1960.     ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  1961.     local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1962.     [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1963.     tc-is-static-only && return;
  1964.     if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1965.         multilib_is_native_abi || return 0;
  1966.     fi;
  1967.     case ${CTARGET:-${CHOST}} in
  1968.         *-darwin*)
  1969.  
  1970.         ;;
  1971.         *-android*)
  1972.             return 0
  1973.         ;;
  1974.         *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1975.             use prefix && return 0
  1976.         ;;
  1977.         *)
  1978.             return 0
  1979.         ;;
  1980.     esac;
  1981.     dodir /usr/${libdir};
  1982.     if [[ $1 == "-a" ]]; then
  1983.         auto=true;
  1984.         shift;
  1985.         dodir /${libdir};
  1986.     fi;
  1987.     local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1988.     if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1989.         local d="${T}/bfd-linker";
  1990.         mkdir -p "${d}";
  1991.         ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1992.         flags+=(-B"${d}");
  1993.     fi;
  1994.     output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1995.     [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1996.     for lib in "$@";
  1997.     do
  1998.         local tlib;
  1999.         if ${auto}; then
  2000.             lib="lib${lib}${suffix}";
  2001.         else
  2002.             [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2003.         fi;
  2004.         case ${CTARGET:-${CHOST}} in
  2005.             *-darwin*)
  2006.                 if ${auto}; then
  2007.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2008.                 else
  2009.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2010.                 fi;
  2011.                 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2012.                 tlib=${tlib##*/};
  2013.                 if ${auto}; then
  2014.                     mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2015.                     if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2016.                         mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2017.                     fi;
  2018.                     rm -f "${ED}"/${libdir}/${lib};
  2019.                 fi;
  2020.                 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2021.                     chmod u+w "${ED}${libdir}/${tlib}";
  2022.                     local nowrite=yes;
  2023.                 fi;
  2024.                 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2025.                 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2026.                 pushd "${ED}/usr/${libdir}" > /dev/null;
  2027.                 ln -snf "../../${libdir}/${tlib}" "${lib}";
  2028.                 popd > /dev/null
  2029.             ;;
  2030.             *)
  2031.                 if ${auto}; then
  2032.                     tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2033.                     [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2034.                     mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2035.                     if [[ ${tlib} != ${lib}* ]]; then
  2036.                         mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2037.                     fi;
  2038.                     rm -f "${ED}"/${libdir}/${lib};
  2039.                 else
  2040.                     tlib=${lib};
  2041.                 fi;
  2042.                 cat > "${ED}/usr/${libdir}/${lib}"  <<-END_LDSCRIPT
  2043. /* GNU ld script
  2044.    Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2045.    in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2046.    run into linking problems.  This "fake" dynamic lib is a linker script that
  2047.    redirects the linker to the real lib.  And yes, this works in the cross-
  2048.    compiling scenario as the sysroot-ed linker will prepend the real path.
  2049.  
  2050.    See bug https://bugs.gentoo.org/4411 for more info.
  2051.  */
  2052. ${output_format}
  2053. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2054. END_LDSCRIPT
  2055.  
  2056.             ;;
  2057.         esac
  2058.         fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2059.     done
  2060. }
  2061. get-flag ()
  2062. {
  2063.     local f var findflag="$1";
  2064.     for var in $(all-flag-vars);
  2065.     do
  2066.         for f in ${!var};
  2067.         do
  2068.             if [ "${f/${findflag}}" != "${f}" ]; then
  2069.                 printf "%s\n" "${f/-${findflag}=}";
  2070.                 return 0;
  2071.             fi;
  2072.         done;
  2073.     done;
  2074.     return 1
  2075. }
  2076. get_abi_CFLAGS ()
  2077. {
  2078.     get_abi_var CFLAGS "$@"
  2079. }
  2080. get_abi_CHOST ()
  2081. {
  2082.     get_abi_var CHOST "$@"
  2083. }
  2084. get_abi_CTARGET ()
  2085. {
  2086.     get_abi_var CTARGET "$@"
  2087. }
  2088. get_abi_FAKE_TARGETS ()
  2089. {
  2090.     get_abi_var FAKE_TARGETS "$@"
  2091. }
  2092. get_abi_LDFLAGS ()
  2093. {
  2094.     get_abi_var LDFLAGS "$@"
  2095. }
  2096. get_abi_LIBDIR ()
  2097. {
  2098.     get_abi_var LIBDIR "$@"
  2099. }
  2100. get_abi_var ()
  2101. {
  2102.     local flag=$1;
  2103.     local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2104.     local var="${flag}_${abi}";
  2105.     echo ${!var}
  2106. }
  2107. get_all_abis ()
  2108. {
  2109.     local x order="" mvar dvar;
  2110.     mvar="MULTILIB_ABIS";
  2111.     dvar="DEFAULT_ABI";
  2112.     if [[ -n $1 ]]; then
  2113.         mvar="$1_${mvar}";
  2114.         dvar="$1_${dvar}";
  2115.     fi;
  2116.     if [[ -z ${!mvar} ]]; then
  2117.         echo "default";
  2118.         return 0;
  2119.     fi;
  2120.     for x in ${!mvar};
  2121.     do
  2122.         if [[ ${x} != ${!dvar} ]]; then
  2123.             order="${order:+${order} }${x}";
  2124.         fi;
  2125.     done;
  2126.     order="${order:+${order} }${!dvar}";
  2127.     echo ${order};
  2128.     return 0
  2129. }
  2130. get_all_libdirs ()
  2131. {
  2132.     local libdirs abi;
  2133.     for abi in ${MULTILIB_ABIS};
  2134.     do
  2135.         libdirs+=" $(get_abi_LIBDIR ${abi})";
  2136.     done;
  2137.     [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2138.     echo "${libdirs}"
  2139. }
  2140. get_exeext ()
  2141. {
  2142.     case ${CHOST} in
  2143.         *-cygwin* | mingw* | *-mingw*)
  2144.             echo ".exe"
  2145.         ;;
  2146.     esac
  2147. }
  2148. get_install_abis ()
  2149. {
  2150.     local x order="";
  2151.     if [[ -z ${MULTILIB_ABIS} ]]; then
  2152.         echo "default";
  2153.         return 0;
  2154.     fi;
  2155.     if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2156.         for x in ${MULTILIB_ABIS};
  2157.         do
  2158.             if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2159.                 has ${x} ${ABI_DENY} || order="${order} ${x}";
  2160.             fi;
  2161.         done;
  2162.         has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2163.         if [[ -n ${ABI_ALLOW} ]]; then
  2164.             local ordera="";
  2165.             for x in ${order};
  2166.             do
  2167.                 if has ${x} ${ABI_ALLOW}; then
  2168.                     ordera="${ordera} ${x}";
  2169.                 fi;
  2170.             done;
  2171.             order=${ordera};
  2172.         fi;
  2173.     else
  2174.         order=${DEFAULT_ABI};
  2175.     fi;
  2176.     if [[ -z ${order} ]]; then
  2177.         die "The ABI list is empty.  Are you using a proper multilib profile?  Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
  2178.     fi;
  2179.     echo ${order};
  2180.     return 0
  2181. }
  2182. get_libdir ()
  2183. {
  2184.     local libdir_var="LIBDIR_${ABI}";
  2185.     local libdir="lib";
  2186.     [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2187.     echo "${libdir}"
  2188. }
  2189. get_libname ()
  2190. {
  2191.     local libname;
  2192.     local ver=$1;
  2193.     case ${CHOST} in
  2194.         *-cygwin*)
  2195.             libname="dll.a"
  2196.         ;;
  2197.         mingw* | *-mingw*)
  2198.             libname="dll"
  2199.         ;;
  2200.         *-darwin*)
  2201.             libname="dylib"
  2202.         ;;
  2203.         *-mint*)
  2204.             libname="irrelevant"
  2205.         ;;
  2206.         hppa*-hpux*)
  2207.             libname="sl"
  2208.         ;;
  2209.         *)
  2210.             libname="so"
  2211.         ;;
  2212.     esac;
  2213.     if [[ -z $* ]]; then
  2214.         echo ".${libname}";
  2215.     else
  2216.         for ver in "$@";
  2217.         do
  2218.             case ${CHOST} in
  2219.                 *-cygwin*)
  2220.                     echo ".${ver}.${libname}"
  2221.                 ;;
  2222.                 *-darwin*)
  2223.                     echo ".${ver}.${libname}"
  2224.                 ;;
  2225.                 *-mint*)
  2226.                     echo ".${libname}"
  2227.                 ;;
  2228.                 *)
  2229.                     echo ".${libname}.${ver}"
  2230.                 ;;
  2231.             esac;
  2232.         done;
  2233.     fi
  2234. }
  2235. get_modname ()
  2236. {
  2237.     local modname;
  2238.     local ver=$1;
  2239.     case ${CHOST} in
  2240.         *-darwin*)
  2241.             modname="bundle"
  2242.         ;;
  2243.         *)
  2244.             modname="so"
  2245.         ;;
  2246.     esac;
  2247.     echo ".${modname}"
  2248. }
  2249. get_nproc ()
  2250. {
  2251.     local nproc;
  2252.     if type -P nproc &> /dev/null; then
  2253.         nproc=$(nproc);
  2254.     fi;
  2255.     if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  2256.         nproc=$(sysctl -n hw.ncpu 2>/dev/null);
  2257.     fi;
  2258.     if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  2259.         nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null);
  2260.     fi;
  2261.     if [[ -n ${nproc} ]]; then
  2262.         echo "${nproc}";
  2263.     else
  2264.         echo "${1:-1}";
  2265.     fi
  2266. }
  2267. has_m32 ()
  2268. {
  2269.     die "${FUNCNAME}: don't use this anymore"
  2270. }
  2271. has_m64 ()
  2272. {
  2273.     die "${FUNCNAME}: don't use this anymore"
  2274. }
  2275. has_multilib_profile ()
  2276. {
  2277.     [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2278. }
  2279. in_iuse ()
  2280. {
  2281.     local use=${1};
  2282.     if [[ -z "${use}" ]]; then
  2283.         echo "!!! in_iuse() called without a parameter." 1>&2;
  2284.         echo "!!! in_iuse <USEFLAG>" 1>&2;
  2285.         die "in_iuse() called without a parameter";
  2286.     fi;
  2287.     local liuse=(${IUSE_EFFECTIVE});
  2288.     has "${use}" "${liuse[@]#[+-]}"
  2289. }
  2290. is-flag ()
  2291. {
  2292.     is-flagq "$@" && echo true
  2293. }
  2294. is-flagq ()
  2295. {
  2296.     [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2297.     local var;
  2298.     for var in $(all-flag-vars);
  2299.     do
  2300.         _is_flagq ${var} "$1" && return 0;
  2301.     done;
  2302.     return 1
  2303. }
  2304. is-ldflag ()
  2305. {
  2306.     is-ldflagq "$@" && echo true
  2307. }
  2308. is-ldflagq ()
  2309. {
  2310.     [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2311.     _is_flagq LDFLAGS $1
  2312. }
  2313. is_final_abi ()
  2314. {
  2315.     has_multilib_profile || return 0;
  2316.     set -- $(get_install_abis);
  2317.     local LAST_ABI=$#;
  2318.     [[ ${!LAST_ABI} == ${ABI} ]]
  2319. }
  2320. make_desktop_entry ()
  2321. {
  2322.     [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2323.     local exec=${1};
  2324.     local name=${2:-${PN}};
  2325.     local icon=${3:-${PN}};
  2326.     local type=${4};
  2327.     local fields=${5};
  2328.     if [[ -z ${type} ]]; then
  2329.         local catmaj=${CATEGORY%%-*};
  2330.         local catmin=${CATEGORY##*-};
  2331.         case ${catmaj} in
  2332.             app)
  2333.                 case ${catmin} in
  2334.                     accessibility)
  2335.                         type="Utility;Accessibility"
  2336.                     ;;
  2337.                     admin)
  2338.                         type=System
  2339.                     ;;
  2340.                     antivirus)
  2341.                         type=System
  2342.                     ;;
  2343.                     arch)
  2344.                         type="Utility;Archiving"
  2345.                     ;;
  2346.                     backup)
  2347.                         type="Utility;Archiving"
  2348.                     ;;
  2349.                     cdr)
  2350.                         type="AudioVideo;DiscBurning"
  2351.                     ;;
  2352.                     dicts)
  2353.                         type="Office;Dictionary"
  2354.                     ;;
  2355.                     doc)
  2356.                         type=Documentation
  2357.                     ;;
  2358.                     editors)
  2359.                         type="Utility;TextEditor"
  2360.                     ;;
  2361.                     emacs)
  2362.                         type="Development;TextEditor"
  2363.                     ;;
  2364.                     emulation)
  2365.                         type="System;Emulator"
  2366.                     ;;
  2367.                     laptop)
  2368.                         type="Settings;HardwareSettings"
  2369.                     ;;
  2370.                     office)
  2371.                         type=Office
  2372.                     ;;
  2373.                     pda)
  2374.                         type="Office;PDA"
  2375.                     ;;
  2376.                     vim)
  2377.                         type="Development;TextEditor"
  2378.                     ;;
  2379.                     xemacs)
  2380.                         type="Development;TextEditor"
  2381.                     ;;
  2382.                 esac
  2383.             ;;
  2384.             dev)
  2385.                 type="Development"
  2386.             ;;
  2387.             games)
  2388.                 case ${catmin} in
  2389.                     action | fps)
  2390.                         type=ActionGame
  2391.                     ;;
  2392.                     arcade)
  2393.                         type=ArcadeGame
  2394.                     ;;
  2395.                     board)
  2396.                         type=BoardGame
  2397.                     ;;
  2398.                     emulation)
  2399.                         type=Emulator
  2400.                     ;;
  2401.                     kids)
  2402.                         type=KidsGame
  2403.                     ;;
  2404.                     puzzle)
  2405.                         type=LogicGame
  2406.                     ;;
  2407.                     roguelike)
  2408.                         type=RolePlaying
  2409.                     ;;
  2410.                     rpg)
  2411.                         type=RolePlaying
  2412.                     ;;
  2413.                     simulation)
  2414.                         type=Simulation
  2415.                     ;;
  2416.                     sports)
  2417.                         type=SportsGame
  2418.                     ;;
  2419.                     strategy)
  2420.                         type=StrategyGame
  2421.                     ;;
  2422.                 esac;
  2423.                 type="Game;${type}"
  2424.             ;;
  2425.             gnome)
  2426.                 type="Gnome;GTK"
  2427.             ;;
  2428.             kde)
  2429.                 type="KDE;Qt"
  2430.             ;;
  2431.             mail)
  2432.                 type="Network;Email"
  2433.             ;;
  2434.             media)
  2435.                 case ${catmin} in
  2436.                     gfx)
  2437.                         type=Graphics
  2438.                     ;;
  2439.                     *)
  2440.                         case ${catmin} in
  2441.                             radio)
  2442.                                 type=Tuner
  2443.                             ;;
  2444.                             sound)
  2445.                                 type=Audio
  2446.                             ;;
  2447.                             tv)
  2448.                                 type=TV
  2449.                             ;;
  2450.                             video)
  2451.                                 type=Video
  2452.                             ;;
  2453.                         esac;
  2454.                         type="AudioVideo;${type}"
  2455.                     ;;
  2456.                 esac
  2457.             ;;
  2458.             net)
  2459.                 case ${catmin} in
  2460.                     dialup)
  2461.                         type=Dialup
  2462.                     ;;
  2463.                     ftp)
  2464.                         type=FileTransfer
  2465.                     ;;
  2466.                     im)
  2467.                         type=InstantMessaging
  2468.                     ;;
  2469.                     irc)
  2470.                         type=IRCClient
  2471.                     ;;
  2472.                     mail)
  2473.                         type=Email
  2474.                     ;;
  2475.                     news)
  2476.                         type=News
  2477.                     ;;
  2478.                     nntp)
  2479.                         type=News
  2480.                     ;;
  2481.                     p2p)
  2482.                         type=FileTransfer
  2483.                     ;;
  2484.                     voip)
  2485.                         type=Telephony
  2486.                     ;;
  2487.                 esac;
  2488.                 type="Network;${type}"
  2489.             ;;
  2490.             sci)
  2491.                 case ${catmin} in
  2492.                     astro*)
  2493.                         type=Astronomy
  2494.                     ;;
  2495.                     bio*)
  2496.                         type=Biology
  2497.                     ;;
  2498.                     calc*)
  2499.                         type=Calculator
  2500.                     ;;
  2501.                     chem*)
  2502.                         type=Chemistry
  2503.                     ;;
  2504.                     elec*)
  2505.                         type=Electronics
  2506.                     ;;
  2507.                     geo*)
  2508.                         type=Geology
  2509.                     ;;
  2510.                     math*)
  2511.                         type=Math
  2512.                     ;;
  2513.                     physics)
  2514.                         type=Physics
  2515.                     ;;
  2516.                     visual*)
  2517.                         type=DataVisualization
  2518.                     ;;
  2519.                 esac;
  2520.                 type="Education;Science;${type}"
  2521.             ;;
  2522.             sys)
  2523.                 type="System"
  2524.             ;;
  2525.             www)
  2526.                 case ${catmin} in
  2527.                     client)
  2528.                         type=WebBrowser
  2529.                     ;;
  2530.                 esac;
  2531.                 type="Network;${type}"
  2532.             ;;
  2533.             *)
  2534.                 type=
  2535.             ;;
  2536.         esac;
  2537.     fi;
  2538.     local slot=${SLOT%/*};
  2539.     if [[ ${slot} == "0" ]]; then
  2540.         local desktop_name="${PN}";
  2541.     else
  2542.         local desktop_name="${PN}-${slot}";
  2543.     fi;
  2544.     local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2545.     type=${type%;}${type:+;};
  2546.     if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2547.         ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2548.         ewarn "allowed in .desktop files if the value is not an absolute path.";
  2549.         icon=${icon%.*};
  2550.     fi;
  2551.     cat > "${desktop}"  <<-EOF ||
  2552. [Desktop Entry]
  2553. Name=${name}
  2554. Type=Application
  2555. Comment=${DESCRIPTION}
  2556. Exec=${exec}
  2557. TryExec=${exec%% *}
  2558. Icon=${icon}
  2559. Categories=${type}
  2560. EOF
  2561.  die
  2562.     if [[ ${fields:-=} != *=* ]]; then
  2563.         ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2564.         fields="Path=${fields}";
  2565.     fi;
  2566.     if [[ -n ${fields} ]]; then
  2567.         printf '%b\n' "${fields}" >> "${desktop}" || die;
  2568.     fi;
  2569.     ( insopts -m 0644;
  2570.     insinto /usr/share/applications;
  2571.     doins "${desktop}" ) || die "installing desktop file failed"
  2572. }
  2573. make_session_desktop ()
  2574. {
  2575.     [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2576.     [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2577.     local title=$1;
  2578.     local command=$2;
  2579.     local desktop=${T}/${wm:-${PN}}.desktop;
  2580.     shift 2;
  2581.     cat > "${desktop}"  <<-EOF ||
  2582. [Desktop Entry]
  2583. Name=${title}
  2584. Comment=This session logs you into ${title}
  2585. Exec=${command} $*
  2586. TryExec=${command}
  2587. Type=XSession
  2588. EOF
  2589.  die
  2590.     ( insopts -m 0644;
  2591.     insinto /usr/share/xsessions;
  2592.     doins "${desktop}" )
  2593. }
  2594. make_wrapper ()
  2595. {
  2596.     local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2597.     local tmpwrapper=$(emktemp);
  2598.     has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  2599.     ( echo '#!/bin/sh';
  2600.     if [[ -n ${libdir} ]]; then
  2601.         local var;
  2602.         if [[ ${CHOST} == *-darwin* ]]; then
  2603.             var=DYLD_LIBRARY_PATH;
  2604.         else
  2605.             var=LD_LIBRARY_PATH;
  2606.         fi;
  2607.         cat  <<-EOF
  2608. if [ "\${${var}+set}" = "set" ] ; then
  2609. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  2610. else
  2611. export ${var}="${EPREFIX}${libdir}"
  2612. fi
  2613. EOF
  2614.  
  2615.     fi
  2616.     [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  2617.     printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  2618.     chmod go+rx "${tmpwrapper}";
  2619.     if [[ -n ${path} ]]; then
  2620.         ( exeopts -m 0755;
  2621.         exeinto "${path}";
  2622.         newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2623.     else
  2624.         newbin "${tmpwrapper}" "${wrapper}" || die;
  2625.     fi
  2626. }
  2627. makeopts_jobs ()
  2628. {
  2629.     [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  2630.     local jobs=$(echo " $* " | sed -r -n        -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p'        -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p");
  2631.     echo ${jobs:-1}
  2632. }
  2633. makeopts_loadavg ()
  2634. {
  2635.     [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  2636.     local lavg=$(echo " $* " | sed -r -n        -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+(\.[0-9]+)?)[[:space:]].*:\3:p'       -e "s:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:${2:-999}:p");
  2637.     echo ${lavg:-${2:-999}}
  2638. }
  2639. multilib_env ()
  2640. {
  2641.     local CTARGET=${1:-${CTARGET}};
  2642.     local cpu=${CTARGET%%*-};
  2643.     case ${cpu} in
  2644.         aarch64*)
  2645.             export CFLAGS_arm=${CFLAGS_arm-};
  2646.             case ${cpu} in
  2647.                 aarch64*be)
  2648.                     export CHOST_arm="armv8b-${CTARGET#*-}"
  2649.                 ;;
  2650.                 *)
  2651.                     export CHOST_arm="armv8l-${CTARGET#*-}"
  2652.                 ;;
  2653.             esac;
  2654.             CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2655.             export CTARGET_arm=${CHOST_arm};
  2656.             export LIBDIR_arm="lib";
  2657.             export CFLAGS_arm64=${CFLAGS_arm64-};
  2658.             export CHOST_arm64=${CTARGET};
  2659.             export CTARGET_arm64=${CHOST_arm64};
  2660.             export LIBDIR_arm64="lib64";
  2661.             : ${MULTILIB_ABIS=arm64};
  2662.             : ${DEFAULT_ABI=arm64}
  2663.         ;;
  2664.         x86_64*)
  2665.             export CFLAGS_x86=${CFLAGS_x86--m32};
  2666.             export CHOST_x86=${CTARGET/x86_64/i686};
  2667.             CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2668.             export CTARGET_x86=${CHOST_x86};
  2669.             if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2670.                 export LIBDIR_x86="lib32";
  2671.             else
  2672.                 export LIBDIR_x86="lib";
  2673.             fi;
  2674.             export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2675.             export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2676.             export CTARGET_amd64=${CHOST_amd64};
  2677.             export LIBDIR_amd64="lib64";
  2678.             export CFLAGS_x32=${CFLAGS_x32--mx32};
  2679.             export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2680.             export CTARGET_x32=${CHOST_x32};
  2681.             export LIBDIR_x32="libx32";
  2682.             case ${CTARGET} in
  2683.                 *-gnux32)
  2684.                     : ${MULTILIB_ABIS=x32 amd64 x86};
  2685.                     : ${DEFAULT_ABI=x32}
  2686.                 ;;
  2687.                 *)
  2688.                     : ${MULTILIB_ABIS=amd64 x86};
  2689.                     : ${DEFAULT_ABI=amd64}
  2690.                 ;;
  2691.             esac
  2692.         ;;
  2693.         mips64* | mipsisa64*)
  2694.             export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2695.             export CHOST_o32=${CTARGET/mips64/mips};
  2696.             export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2697.             export CTARGET_o32=${CHOST_o32};
  2698.             export LIBDIR_o32="lib";
  2699.             export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2700.             export CHOST_n32=${CTARGET};
  2701.             export CTARGET_n32=${CHOST_n32};
  2702.             export LIBDIR_n32="lib32";
  2703.             export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2704.             export CHOST_n64=${CTARGET};
  2705.             export CTARGET_n64=${CHOST_n64};
  2706.             export LIBDIR_n64="lib64";
  2707.             : ${MULTILIB_ABIS=n64 n32 o32};
  2708.             : ${DEFAULT_ABI=n32}
  2709.         ;;
  2710.         powerpc64*)
  2711.             export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2712.             export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2713.             export CTARGET_ppc=${CHOST_ppc};
  2714.             export LIBDIR_ppc="lib";
  2715.             export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2716.             export CHOST_ppc64=${CTARGET};
  2717.             export CTARGET_ppc64=${CHOST_ppc64};
  2718.             export LIBDIR_ppc64="lib64";
  2719.             : ${MULTILIB_ABIS=ppc64 ppc};
  2720.             : ${DEFAULT_ABI=ppc64}
  2721.         ;;
  2722.         riscv64*)
  2723.             export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  2724.             export CHOST_lp64d=${CTARGET};
  2725.             export CTARGET_lp64d=${CTARGET};
  2726.             export LIBDIR_lp64d="lib64/lp64d";
  2727.             export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64};
  2728.             export CHOST_lp64=${CTARGET};
  2729.             export CTARGET_lp64=${CTARGET};
  2730.             export LIBDIR_lp64="lib64/lp64";
  2731.             : ${MULTILIB_ABIS=lp64d lp64};
  2732.             : ${DEFAULT_ABI=lp64d}
  2733.         ;;
  2734.         s390x*)
  2735.             export CFLAGS_s390=${CFLAGS_s390--m31};
  2736.             export CHOST_s390=${CTARGET/s390x/s390};
  2737.             export CTARGET_s390=${CHOST_s390};
  2738.             export LIBDIR_s390="lib";
  2739.             export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2740.             export CHOST_s390x=${CTARGET};
  2741.             export CTARGET_s390x=${CHOST_s390x};
  2742.             export LIBDIR_s390x="lib64";
  2743.             : ${MULTILIB_ABIS=s390x s390};
  2744.             : ${DEFAULT_ABI=s390x}
  2745.         ;;
  2746.         sparc64*)
  2747.             export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2748.             export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2749.             export CTARGET_sparc32=${CHOST_sparc32};
  2750.             export LIBDIR_sparc32="lib";
  2751.             export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2752.             export CHOST_sparc64=${CTARGET};
  2753.             export CTARGET_sparc64=${CHOST_sparc64};
  2754.             export LIBDIR_sparc64="lib64";
  2755.             : ${MULTILIB_ABIS=sparc64 sparc32};
  2756.             : ${DEFAULT_ABI=sparc64}
  2757.         ;;
  2758.         *)
  2759.             : ${MULTILIB_ABIS=default};
  2760.             : ${DEFAULT_ABI=default}
  2761.         ;;
  2762.     esac;
  2763.     export MULTILIB_ABIS DEFAULT_ABI
  2764. }
  2765. multilib_toolchain_setup ()
  2766. {
  2767.     local v vv;
  2768.     export ABI=$1;
  2769.     if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2770.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2771.         do
  2772.             vv="_abi_saved_${v}";
  2773.             [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2774.             unset ${vv};
  2775.         done;
  2776.         unset _DEFAULT_ABI_SAVED;
  2777.     fi;
  2778.     if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2779.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2780.         do
  2781.             vv="_abi_saved_${v}";
  2782.             [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2783.         done;
  2784.         export _DEFAULT_ABI_SAVED="true";
  2785.         if [[ ${CBUILD} == "${CHOST}" ]]; then
  2786.             export CBUILD=$(get_abi_CHOST $1);
  2787.         fi;
  2788.         export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2789.         export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2790.         export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2791.         export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2792.         export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2793.         export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2794.         export CHOST=$(get_abi_CHOST $1);
  2795.         export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2796.         export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2797.     fi
  2798. }
  2799. newicon ()
  2800. {
  2801.     _iconins ${FUNCNAME} "$@"
  2802. }
  2803. newmenu ()
  2804. {
  2805.     ( insopts -m 0644;
  2806.     insinto /usr/share/applications;
  2807.     newins "$@" )
  2808. }
  2809. no-as-needed ()
  2810. {
  2811.     case $($(tc-getLD) -v 2>&1 </dev/null) in
  2812.         *GNU*)
  2813.             echo "-Wl,--no-as-needed"
  2814.         ;;
  2815.     esac
  2816. }
  2817. number_abis ()
  2818. {
  2819.     set -- `get_install_abis`;
  2820.     echo $#
  2821. }
  2822. optfeature ()
  2823. {
  2824.     debug-print-function ${FUNCNAME} "$@";
  2825.     local i j msg;
  2826.     local desc=$1;
  2827.     local flag=0;
  2828.     shift;
  2829.     for i in "$@";
  2830.     do
  2831.         for j in ${i};
  2832.         do
  2833.             if has_version "${j}"; then
  2834.                 flag=1;
  2835.             else
  2836.                 flag=0;
  2837.                 break;
  2838.             fi;
  2839.         done;
  2840.         if [[ ${flag} -eq 1 ]]; then
  2841.             break;
  2842.         fi;
  2843.     done;
  2844.     if [[ ${flag} -eq 0 ]]; then
  2845.         for i in "$@";
  2846.         do
  2847.             msg=" ";
  2848.             for j in ${i};
  2849.             do
  2850.                 msg+=" ${j} and";
  2851.             done;
  2852.             msg="${msg:0: -4} for ${desc}";
  2853.             elog "${msg}";
  2854.         done;
  2855.     fi
  2856. }
  2857. path_exists ()
  2858. {
  2859.     eerror "path_exists has been removed.  Please see the following post";
  2860.     eerror "for a replacement snippet:";
  2861.     eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  2862.     die "path_exists is banned"
  2863. }
  2864. pkg_nofetch ()
  2865. {
  2866.     default
  2867. }
  2868. pkg_postinst ()
  2869. {
  2870.     if use postgres; then
  2871.         elog "If you don't intend to use an external PostGIS server";
  2872.         elog "you should install:";
  2873.         elog "   dev-db/postgis";
  2874.     else
  2875.         if use python; then
  2876.             elog "Support of PostgreSQL is disabled.";
  2877.             elog "But some installed python-plugins import the psycopg2 module.";
  2878.             elog "If you do not need these plugins just disable them";
  2879.             elog "in the Plugins menu, else you need to set USE=\"postgres\"";
  2880.         fi;
  2881.     fi;
  2882.     xdg_pkg_postinst
  2883. }
  2884. pkg_postrm ()
  2885. {
  2886.     xdg_pkg_postrm "$@"
  2887. }
  2888. pkg_preinst ()
  2889. {
  2890.     xdg_pkg_preinst "$@"
  2891. }
  2892. pkg_setup ()
  2893. {
  2894.     python-single-r1_pkg_setup
  2895. }
  2896. python-single-r1_pkg_setup ()
  2897. {
  2898.     debug-print-function ${FUNCNAME} "${@}";
  2899.     [[ ${MERGE_TYPE} != binary ]] && python_setup
  2900. }
  2901. python_abi_depend ()
  2902. {
  2903.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2904. }
  2905. python_byte-compile_modules ()
  2906. {
  2907.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2908. }
  2909. python_clean_byte-compiled_modules ()
  2910. {
  2911.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2912. }
  2913. python_clean_installation_image ()
  2914. {
  2915.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2916. }
  2917. python_clean_py-compile_files ()
  2918. {
  2919.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2920. }
  2921. python_convert_shebangs ()
  2922. {
  2923.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_convert_shebangs"
  2924. }
  2925. python_disable_pyc ()
  2926. {
  2927.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2928. }
  2929. python_doexe ()
  2930. {
  2931.     debug-print-function ${FUNCNAME} "${@}";
  2932.     local f;
  2933.     for f in "$@";
  2934.     do
  2935.         python_newexe "${f}" "${f##*/}";
  2936.     done
  2937. }
  2938. python_doheader ()
  2939. {
  2940.     debug-print-function ${FUNCNAME} "${@}";
  2941.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2942.     if [[ ${EAPI:-0} == [0123] ]]; then
  2943.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2944.     fi;
  2945.     local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  2946.     [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  2947.     d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  2948.     ( insopts -m 0644;
  2949.     insinto "${d}";
  2950.     doins -r "${@}" || return ${?} )
  2951. }
  2952. python_domodule ()
  2953. {
  2954.     debug-print-function ${FUNCNAME} "${@}";
  2955.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2956.     if [[ ${EAPI:-0} == [0123] ]]; then
  2957.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2958.     fi;
  2959.     local d;
  2960.     if [[ ${python_moduleroot} == /* ]]; then
  2961.         d=${python_moduleroot};
  2962.     else
  2963.         local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  2964.         [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  2965.         d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  2966.     fi;
  2967.     ( insopts -m 0644;
  2968.     insinto "${d}";
  2969.     doins -r "${@}" || return ${?} );
  2970.     python_optimize "${ED%/}/${d}"
  2971. }
  2972. python_doscript ()
  2973. {
  2974.     debug-print-function ${FUNCNAME} "${@}";
  2975.     local _PYTHON_REWRITE_SHEBANG=1;
  2976.     python_doexe "${@}"
  2977. }
  2978. python_enable_pyc ()
  2979. {
  2980.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2981. }
  2982. python_execute_function ()
  2983. {
  2984.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_execute_function"
  2985. }
  2986. python_execute_nosetests ()
  2987. {
  2988.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2989. }
  2990. python_execute_py.test ()
  2991. {
  2992.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2993. }
  2994. python_execute_trial ()
  2995. {
  2996.     die "${FUNCNAME}() is invalid for python-r1 suite"
  2997. }
  2998. python_export ()
  2999. {
  3000.     debug-print-function ${FUNCNAME} "${@}";
  3001.     local impl var;
  3002.     case "${1}" in
  3003.         python* | jython*)
  3004.             impl=${1/_/.};
  3005.             shift
  3006.         ;;
  3007.         pypy | pypy3)
  3008.             impl=${1};
  3009.             shift
  3010.         ;;
  3011.         *)
  3012.             impl=${EPYTHON};
  3013.             if [[ -z ${impl} ]]; then
  3014.                 die "python_export called without a python implementation and EPYTHON is unset";
  3015.             fi
  3016.         ;;
  3017.     esac;
  3018.     debug-print "${FUNCNAME}: implementation: ${impl}";
  3019.     for var in "$@";
  3020.     do
  3021.         case "${var}" in
  3022.             EPYTHON)
  3023.                 export EPYTHON=${impl};
  3024.                 debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  3025.             ;;
  3026.             PYTHON)
  3027.                 export PYTHON=${EPREFIX}/usr/bin/${impl};
  3028.                 debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  3029.             ;;
  3030.             PYTHON_SITEDIR)
  3031.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3032.                 PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  3033.                 export PYTHON_SITEDIR;
  3034.                 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  3035.             ;;
  3036.             PYTHON_INCLUDEDIR)
  3037.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3038.                 PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  3039.                 export PYTHON_INCLUDEDIR;
  3040.                 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  3041.                 if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  3042.                     die "${impl} does not install any header files!";
  3043.                 fi
  3044.             ;;
  3045.             PYTHON_LIBPATH)
  3046.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3047.                 PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")') || die;
  3048.                 export PYTHON_LIBPATH;
  3049.                 debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  3050.                 if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  3051.                     die "${impl} lacks a (usable) dynamic library";
  3052.                 fi
  3053.             ;;
  3054.             PYTHON_CFLAGS)
  3055.                 local val;
  3056.                 case "${impl}" in
  3057.                     python*)
  3058.                         val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  3059.                     ;;
  3060.                     *)
  3061.                         die "${impl}: obtaining ${var} not supported"
  3062.                     ;;
  3063.                 esac;
  3064.                 export PYTHON_CFLAGS=${val};
  3065.                 debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  3066.             ;;
  3067.             PYTHON_LIBS)
  3068.                 local val;
  3069.                 case "${impl}" in
  3070.                     python*)
  3071.                         val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  3072.                     ;;
  3073.                     *)
  3074.                         die "${impl}: obtaining ${var} not supported"
  3075.                     ;;
  3076.                 esac;
  3077.                 export PYTHON_LIBS=${val};
  3078.                 debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  3079.             ;;
  3080.             PYTHON_CONFIG)
  3081.                 local flags val;
  3082.                 case "${impl}" in
  3083.                     python*)
  3084.                         [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3085.                         flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  3086.                         val=${PYTHON}${flags}-config
  3087.                     ;;
  3088.                     *)
  3089.                         die "${impl}: obtaining ${var} not supported"
  3090.                     ;;
  3091.                 esac;
  3092.                 export PYTHON_CONFIG=${val};
  3093.                 debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  3094.             ;;
  3095.             PYTHON_PKG_DEP)
  3096.                 local d;
  3097.                 case ${impl} in
  3098.                     python2.7)
  3099.                         PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  3100.                     ;;
  3101.                     python3.3)
  3102.                         PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  3103.                     ;;
  3104.                     python*)
  3105.                         PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  3106.                     ;;
  3107.                     pypy)
  3108.                         PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  3109.                     ;;
  3110.                     pypy3)
  3111.                         PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  3112.                     ;;
  3113.                     jython2.7)
  3114.                         PYTHON_PKG_DEP='dev-java/jython:2.7'
  3115.                     ;;
  3116.                     *)
  3117.                         die "Invalid implementation: ${impl}"
  3118.                     ;;
  3119.                 esac;
  3120.                 if [[ -n ${PYTHON_REQ_USE} ]]; then
  3121.                     PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  3122.                 fi;
  3123.                 export PYTHON_PKG_DEP;
  3124.                 debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  3125.             ;;
  3126.             PYTHON_SCRIPTDIR)
  3127.                 local dir;
  3128.                 export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  3129.                 debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  3130.             ;;
  3131.             *)
  3132.                 die "python_export: unknown variable ${var}"
  3133.             ;;
  3134.         esac;
  3135.     done
  3136. }
  3137. python_export_utf8_locale ()
  3138. {
  3139.     debug-print-function ${FUNCNAME} "${@}";
  3140.     type locale > /dev/null || return 0;
  3141.     if [[ $(locale charmap) != UTF-8 ]]; then
  3142.         local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  3143.         for lang in ${locales};
  3144.         do
  3145.             if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  3146.                 if _python_check_locale_sanity "${lang}"; then
  3147.                     export LC_CTYPE=${lang};
  3148.                     if [[ -n ${LC_ALL} ]]; then
  3149.                         export LC_NUMERIC=${LC_ALL};
  3150.                         export LC_TIME=${LC_ALL};
  3151.                         export LC_COLLATE=${LC_ALL};
  3152.                         export LC_MONETARY=${LC_ALL};
  3153.                         export LC_MESSAGES=${LC_ALL};
  3154.                         export LC_PAPER=${LC_ALL};
  3155.                         export LC_NAME=${LC_ALL};
  3156.                         export LC_ADDRESS=${LC_ALL};
  3157.                         export LC_TELEPHONE=${LC_ALL};
  3158.                         export LC_MEASUREMENT=${LC_ALL};
  3159.                         export LC_IDENTIFICATION=${LC_ALL};
  3160.                         export LC_ALL=;
  3161.                     fi;
  3162.                     return 0;
  3163.                 fi;
  3164.             fi;
  3165.         done;
  3166.         ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  3167.         ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  3168.         ewarn "/etc/locale.gen and run locale-gen.";
  3169.         return 1;
  3170.     fi;
  3171.     return 0
  3172. }
  3173. python_fix_shebang ()
  3174. {
  3175.     debug-print-function ${FUNCNAME} "${@}";
  3176.     [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  3177.     local force quiet;
  3178.     while [[ -n ${@} ]]; do
  3179.         case "${1}" in
  3180.             -f | --force)
  3181.                 force=1;
  3182.                 shift
  3183.             ;;
  3184.             -q | --quiet)
  3185.                 quiet=1;
  3186.                 shift
  3187.             ;;
  3188.             --)
  3189.                 shift;
  3190.                 break
  3191.             ;;
  3192.             *)
  3193.                 break
  3194.             ;;
  3195.         esac;
  3196.     done;
  3197.     [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  3198.     local path f;
  3199.     for path in "$@";
  3200.     do
  3201.         local any_correct any_fixed is_recursive;
  3202.         [[ -d ${path} ]] && is_recursive=1;
  3203.         while IFS= read -r -d '' f; do
  3204.             local shebang i;
  3205.             local error= from=;
  3206.             IFS= read -r shebang < "${f}";
  3207.             if [[ ${shebang} == '#!'* ]]; then
  3208.                 local split_shebang=();
  3209.                 read -r -a split_shebang <<< ${shebang} || die;
  3210.                 for i in "${split_shebang[@]}";
  3211.                 do
  3212.                     case "${i}" in
  3213.                         *"${EPYTHON}")
  3214.                             debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3215.                             debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  3216.                             any_correct=1;
  3217.                             from=${EPYTHON};
  3218.                             break
  3219.                         ;;
  3220.                         *python | *python[23])
  3221.                             debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3222.                             debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  3223.                             if [[ ${i} == *python2 ]]; then
  3224.                                 from=python2;
  3225.                                 if [[ ! -n ${force} ]]; then
  3226.                                     python_is_python3 "${EPYTHON}" && error=1;
  3227.                                 fi;
  3228.                             else
  3229.                                 if [[ ${i} == *python3 ]]; then
  3230.                                     from=python3;
  3231.                                     if [[ ! -n ${force} ]]; then
  3232.                                         python_is_python3 "${EPYTHON}" || error=1;
  3233.                                     fi;
  3234.                                 else
  3235.                                     from=python;
  3236.                                 fi;
  3237.                             fi;
  3238.                             break
  3239.                         ;;
  3240.                         *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  3241.                             if [[ ! -n ${force} ]]; then
  3242.                                 error=1;
  3243.                             else
  3244.                                 case "${i}" in
  3245.                                     *python[23].[0123456789])
  3246.                                         from="python[23].[0123456789]"
  3247.                                     ;;
  3248.                                     *pypy)
  3249.                                         from="pypy"
  3250.                                     ;;
  3251.                                     *pypy3)
  3252.                                         from="pypy3"
  3253.                                     ;;
  3254.                                     *jython[23].[0123456789])
  3255.                                         from="jython[23].[0123456789]"
  3256.                                     ;;
  3257.                                     *)
  3258.                                         die "${FUNCNAME}: internal error in 2nd pattern match"
  3259.                                     ;;
  3260.                                 esac;
  3261.                             fi;
  3262.                             break
  3263.                         ;;
  3264.                     esac;
  3265.                 done;
  3266.             fi;
  3267.             if [[ ! -n ${error} && ! -n ${from} ]]; then
  3268.                 [[ -n ${is_recursive} ]] && continue;
  3269.                 error=1;
  3270.             fi;
  3271.             if [[ ! -n ${quiet} ]]; then
  3272.                 einfo "Fixing shebang in ${f#${D%/}}.";
  3273.             fi;
  3274.             if [[ ! -n ${error} ]]; then
  3275.                 if [[ ${shebang} == *${from}" "* ]]; then
  3276.                     sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  3277.                 else
  3278.                     sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  3279.                 fi;
  3280.                 any_fixed=1;
  3281.             else
  3282.                 eerror "The file has incompatible shebang:";
  3283.                 eerror "  file: ${f#${D%/}}";
  3284.                 eerror "  current shebang: ${shebang}";
  3285.                 eerror "  requested impl: ${EPYTHON}";
  3286.                 die "${FUNCNAME}: conversion of incompatible shebang requested";
  3287.             fi;
  3288.         done < <(find -H "${path}" -type f -print0 || die);
  3289.         if [[ ! -n ${any_fixed} ]]; then
  3290.             local cmd=eerror;
  3291.             [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  3292.             "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  3293.             if [[ -n ${any_correct} ]]; then
  3294.                 "${cmd}" "All files have ${EPYTHON} shebang already.";
  3295.             else
  3296.                 "${cmd}" "There are no Python files in specified directory.";
  3297.             fi;
  3298.             [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  3299.         fi;
  3300.     done
  3301. }
  3302. python_gen_cond_dep ()
  3303. {
  3304.     debug-print-function ${FUNCNAME} "${@}";
  3305.     local flag_prefix impl matches=();
  3306.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  3307.         flag_prefix=python_targets;
  3308.     else
  3309.         flag_prefix=python_single_target;
  3310.     fi;
  3311.     local dep=${1};
  3312.     shift;
  3313.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3314.     do
  3315.         if _python_impl_matches "${impl}" "${@}"; then
  3316.             if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  3317.                 local usedep=$(python_gen_usedep "${@}");
  3318.                 dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  3319.             fi;
  3320.             matches+=("${flag_prefix}_${impl}? ( ${dep} )");
  3321.         fi;
  3322.     done;
  3323.     echo "${matches[@]}"
  3324. }
  3325. python_gen_impl_dep ()
  3326. {
  3327.     debug-print-function ${FUNCNAME} "${@}";
  3328.     local impl pattern;
  3329.     local matches=();
  3330.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  3331.         flag_prefix=python_targets;
  3332.     else
  3333.         flag_prefix=python_single_target;
  3334.     fi;
  3335.     local PYTHON_REQ_USE=${1};
  3336.     shift;
  3337.     local patterns=("${@-*}");
  3338.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3339.     do
  3340.         if _python_impl_matches "${impl}" "${patterns[@]}"; then
  3341.             local PYTHON_PKG_DEP;
  3342.             python_export "${impl}" PYTHON_PKG_DEP;
  3343.             matches+=("${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )");
  3344.         fi;
  3345.     done;
  3346.     echo "${matches[@]}"
  3347. }
  3348. python_gen_usedep ()
  3349. {
  3350.     debug-print-function ${FUNCNAME} "${@}";
  3351.     local impl matches=();
  3352.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3353.     do
  3354.         if _python_impl_matches "${impl}" "${@}"; then
  3355.             matches+=("python_targets_${impl}(-)?" "python_single_target_${impl}(+)?");
  3356.         fi;
  3357.     done;
  3358.     [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  3359.     local out=${matches[@]};
  3360.     echo "${out// /,}"
  3361. }
  3362. python_gen_useflags ()
  3363. {
  3364.     debug-print-function ${FUNCNAME} "${@}";
  3365.     local flag_prefix impl matches=();
  3366.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  3367.         flag_prefix=python_targets;
  3368.     else
  3369.         flag_prefix=python_single_target;
  3370.     fi;
  3371.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3372.     do
  3373.         if _python_impl_matches "${impl}" "${@}"; then
  3374.             matches+=("${flag_prefix}_${impl}");
  3375.         fi;
  3376.     done;
  3377.     echo "${matches[@]}"
  3378. }
  3379. python_generate_cffi_modules ()
  3380. {
  3381.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3382. }
  3383. python_generate_wrapper_scripts ()
  3384. {
  3385.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3386. }
  3387. python_get_CFLAGS ()
  3388. {
  3389.     debug-print-function ${FUNCNAME} "${@}";
  3390.     python_export "${@}" PYTHON_CFLAGS;
  3391.     echo "${PYTHON_CFLAGS}"
  3392. }
  3393. python_get_LIBS ()
  3394. {
  3395.     debug-print-function ${FUNCNAME} "${@}";
  3396.     python_export "${@}" PYTHON_LIBS;
  3397.     echo "${PYTHON_LIBS}"
  3398. }
  3399. python_get_PYTHON_CONFIG ()
  3400. {
  3401.     debug-print-function ${FUNCNAME} "${@}";
  3402.     python_export "${@}" PYTHON_CONFIG;
  3403.     echo "${PYTHON_CONFIG}"
  3404. }
  3405. python_get_extension_module_suffix ()
  3406. {
  3407.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3408. }
  3409. python_get_implementation ()
  3410. {
  3411.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3412. }
  3413. python_get_implementation_and_version ()
  3414. {
  3415.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3416. }
  3417. python_get_implementational_package ()
  3418. {
  3419.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3420. }
  3421. python_get_includedir ()
  3422. {
  3423.     debug-print-function ${FUNCNAME} "${@}";
  3424.     python_export "${@}" PYTHON_INCLUDEDIR;
  3425.     echo "${PYTHON_INCLUDEDIR}"
  3426. }
  3427. python_get_libdir ()
  3428. {
  3429.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3430. }
  3431. python_get_library ()
  3432. {
  3433.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3434. }
  3435. python_get_library_path ()
  3436. {
  3437.     debug-print-function ${FUNCNAME} "${@}";
  3438.     python_export "${@}" PYTHON_LIBPATH;
  3439.     echo "${PYTHON_LIBPATH}"
  3440. }
  3441. python_get_scriptdir ()
  3442. {
  3443.     debug-print-function ${FUNCNAME} "${@}";
  3444.     python_export "${@}" PYTHON_SCRIPTDIR;
  3445.     echo "${PYTHON_SCRIPTDIR}"
  3446. }
  3447. python_get_sitedir ()
  3448. {
  3449.     debug-print-function ${FUNCNAME} "${@}";
  3450.     python_export "${@}" PYTHON_SITEDIR;
  3451.     echo "${PYTHON_SITEDIR}"
  3452. }
  3453. python_get_version ()
  3454. {
  3455.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3456. }
  3457. python_install_executables ()
  3458. {
  3459.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3460. }
  3461. python_is_installed ()
  3462. {
  3463.     local impl=${1:-${EPYTHON}};
  3464.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  3465.     local hasv_args=();
  3466.     case ${EAPI:-0} in
  3467.         0 | 1 | 2 | 3 | 4)
  3468.             local -x ROOT=/
  3469.         ;;
  3470.         5 | 6)
  3471.             hasv_args+=(--host-root)
  3472.         ;;
  3473.         *)
  3474.             hasv_args+=(-b)
  3475.         ;;
  3476.     esac;
  3477.     case "${impl}" in
  3478.         pypy | pypy3)
  3479.             local append=;
  3480.             if [[ -n ${PYTHON_REQ_USE} ]]; then
  3481.                 append=[${PYTHON_REQ_USE}];
  3482.             fi;
  3483.             has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  3484.         ;;
  3485.         *)
  3486.             local PYTHON_PKG_DEP;
  3487.             python_export "${impl}" PYTHON_PKG_DEP;
  3488.             has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  3489.         ;;
  3490.     esac
  3491. }
  3492. python_is_python3 ()
  3493. {
  3494.     local impl=${1:-${EPYTHON}};
  3495.     [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  3496.     [[ ${impl} == python3* || ${impl} == pypy3 ]]
  3497. }
  3498. python_merge_intermediate_installation_images ()
  3499. {
  3500.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3501. }
  3502. python_mod_cleanup ()
  3503. {
  3504.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  3505. }
  3506. python_mod_optimize ()
  3507. {
  3508.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  3509. }
  3510. python_moduleinto ()
  3511. {
  3512.     debug-print-function ${FUNCNAME} "${@}";
  3513.     python_moduleroot=${1}
  3514. }
  3515. python_need_rebuild ()
  3516. {
  3517.     die "${FUNCNAME}() is invalid for python-r1 suite"
  3518. }
  3519. python_newexe ()
  3520. {
  3521.     debug-print-function ${FUNCNAME} "${@}";
  3522.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3523.     [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3524.     if [[ ${EAPI:-0} == [0123] ]]; then
  3525.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  3526.     fi;
  3527.     local wrapd=${python_scriptroot:-/usr/bin};
  3528.     local f=${1};
  3529.     local newfn=${2};
  3530.     local PYTHON_SCRIPTDIR d;
  3531.     python_export PYTHON_SCRIPTDIR;
  3532.     d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  3533.     ( dodir "${wrapd}";
  3534.     exeopts -m 0755;
  3535.     exeinto "${d}";
  3536.     newexe "${f}" "${newfn}" || return ${?} );
  3537.     _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  3538.     if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3539.         python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3540.     fi
  3541. }
  3542. python_newscript ()
  3543. {
  3544.     debug-print-function ${FUNCNAME} "${@}";
  3545.     local _PYTHON_REWRITE_SHEBANG=1;
  3546.     python_newexe "${@}"
  3547. }
  3548. python_optimize ()
  3549. {
  3550.     debug-print-function ${FUNCNAME} "${@}";
  3551.     if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  3552.         eerror "The new Python eclasses expect the compiled Python files to";
  3553.         eerror "be controlled by the Package Manager. For this reason,";
  3554.         eerror "the python_optimize function can be used only during src_* phases";
  3555.         eerror "(src_install most commonly) and not during pkg_* phases.";
  3556.         echo;
  3557.         die "python_optimize is not to be used in pre/post* phases";
  3558.     fi;
  3559.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3560.     local PYTHON=${PYTHON};
  3561.     [[ -n ${PYTHON} ]] || python_export PYTHON;
  3562.     if [[ ${#} -eq 0 ]]; then
  3563.         local f;
  3564.         while IFS= read -r -d '' f; do
  3565.             if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  3566.                 set -- "${D%/}${f}" "${@}";
  3567.             fi;
  3568.         done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for x in sys.path))' || die);
  3569.         debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  3570.     fi;
  3571.     local d;
  3572.     for d in "$@";
  3573.     do
  3574.         local instpath=${d#${D%/}};
  3575.         instpath=/${instpath##/};
  3576.         case "${EPYTHON}" in
  3577.             python2.7 | python3.[34])
  3578.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3579.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3580.             ;;
  3581.             python* | pypy3)
  3582.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3583.                 "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  3584.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3585.             ;;
  3586.             *)
  3587.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  3588.             ;;
  3589.         esac;
  3590.     done
  3591. }
  3592. python_pkg_setup ()
  3593. {
  3594.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3595. }
  3596. python_scriptinto ()
  3597. {
  3598.     debug-print-function ${FUNCNAME} "${@}";
  3599.     python_scriptroot=${1}
  3600. }
  3601. python_set_active_version ()
  3602. {
  3603.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3604. }
  3605. python_setup ()
  3606. {
  3607.     debug-print-function ${FUNCNAME} "${@}";
  3608.     unset EPYTHON;
  3609.     if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  3610.         local impls=(${PYTHON_COMPAT_OVERRIDE});
  3611.         [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1";
  3612.         ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  3613.         ewarn "implementation will be used:";
  3614.         ewarn;
  3615.         ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  3616.         ewarn;
  3617.         ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored.";
  3618.         python_export "${impls[0]}" EPYTHON PYTHON;
  3619.         python_wrapper_setup;
  3620.         return;
  3621.     fi;
  3622.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  3623.         if use "python_targets_${_PYTHON_SUPPORTED_IMPLS[0]}"; then
  3624.             python_export "${_PYTHON_SUPPORTED_IMPLS[0]}" EPYTHON PYTHON;
  3625.             python_wrapper_setup;
  3626.         fi;
  3627.     else
  3628.         local impl;
  3629.         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3630.         do
  3631.             if use "python_single_target_${impl}"; then
  3632.                 if [[ -n ${EPYTHON} ]]; then
  3633.                     eerror "Your PYTHON_SINGLE_TARGET setting lists more than a single Python";
  3634.                     eerror "implementation. Please set it to just one value. If you need";
  3635.                     eerror "to override the value for a single package, please use package.env";
  3636.                     eerror "or an equivalent solution (man 5 portage).";
  3637.                     echo;
  3638.                     die "More than one implementation in PYTHON_SINGLE_TARGET.";
  3639.                 fi;
  3640.                 if ! use "python_targets_${impl}"; then
  3641.                     eerror "The implementation chosen as PYTHON_SINGLE_TARGET must be added";
  3642.                     eerror "to PYTHON_TARGETS as well. This is in order to ensure that";
  3643.                     eerror "dependencies are satisfied correctly. We're sorry";
  3644.                     eerror "for the inconvenience.";
  3645.                     echo;
  3646.                     die "Build target (${impl}) not in PYTHON_TARGETS.";
  3647.                 fi;
  3648.                 python_export "${impl}" EPYTHON PYTHON;
  3649.                 python_wrapper_setup;
  3650.             fi;
  3651.         done;
  3652.     fi;
  3653.     if [[ ! -n ${EPYTHON} ]]; then
  3654.         eerror "No Python implementation selected for the build. Please set";
  3655.         if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  3656.             eerror "the PYTHON_TARGETS variable in your make.conf to include one";
  3657.         else
  3658.             eerror "the PYTHON_SINGLE_TARGET variable in your make.conf to one";
  3659.         fi;
  3660.         eerror "of the following values:";
  3661.         eerror;
  3662.         eerror "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3663.         echo;
  3664.         die "No supported Python implementation in PYTHON_SINGLE_TARGET/PYTHON_TARGETS.";
  3665.     fi
  3666. }
  3667. python_wrapper_setup ()
  3668. {
  3669.     debug-print-function ${FUNCNAME} "${@}";
  3670.     local workdir=${1:-${T}/${EPYTHON}};
  3671.     local impl=${2:-${EPYTHON}};
  3672.     [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  3673.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  3674.     if [[ ! -x ${workdir}/bin/python ]]; then
  3675.         _python_check_dead_variables;
  3676.         mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  3677.         rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  3678.         rm -f "${workdir}"/bin/2to3 || die;
  3679.         rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  3680.         local EPYTHON PYTHON;
  3681.         python_export "${impl}" EPYTHON PYTHON;
  3682.         local pyver pyother;
  3683.         if python_is_python3; then
  3684.             pyver=3;
  3685.             pyother=2;
  3686.         else
  3687.             pyver=2;
  3688.             pyother=3;
  3689.         fi;
  3690.         cat > "${workdir}/bin/python"  <<-_EOF_ ||
  3691. #!/bin/sh
  3692. exec "${PYTHON}" "\${@}"
  3693. _EOF_
  3694.  die
  3695.         cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3696.         chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3697.         local nonsupp=("python${pyother}" "python${pyother}-config");
  3698.         if [[ ${EPYTHON} == python* ]]; then
  3699.             cat > "${workdir}/bin/python-config"  <<-_EOF_ ||
  3700. #!/bin/sh
  3701. exec "${PYTHON}-config" "\${@}"
  3702. _EOF_
  3703.  die
  3704.             cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3705.             chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3706.             ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  3707.             ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  3708.             ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  3709.         else
  3710.             nonsupp+=(2to3 python-config "python${pyver}-config");
  3711.         fi;
  3712.         local x;
  3713.         for x in "${nonsupp[@]}";
  3714.         do
  3715.             cat > "${workdir}"/bin/${x}  <<-_EOF_ ||
  3716. #!/bin/sh
  3717. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  3718. exit 127
  3719. _EOF_
  3720.  die
  3721.             chmod +x "${workdir}"/bin/${x} || die;
  3722.         done;
  3723.     fi;
  3724.     if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  3725.         PATH=${workdir}/bin${PATH:+:${PATH}};
  3726.     fi;
  3727.     if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  3728.         PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  3729.     fi;
  3730.     export PATH PKG_CONFIG_PATH
  3731. }
  3732. qmake-utils_find_pro_file ()
  3733. {
  3734.     local dir_name=$(basename "${S}");
  3735.     eshopts_push -s nullglob;
  3736.     local pro_files=(*.pro);
  3737.     eshopts_pop;
  3738.     case ${#pro_files[@]} in
  3739.         0)
  3740.             :
  3741.         ;;
  3742.         1)
  3743.             echo "${pro_files}"
  3744.         ;;
  3745.         *)
  3746.             for pro_file in "${pro_files[@]}";
  3747.             do
  3748.                 if [[ ${pro_file%.pro} == ${dir_name} || ${pro_file%.pro} == ${PN} ]]; then
  3749.                     echo "${pro_file}";
  3750.                     break;
  3751.                 fi;
  3752.             done
  3753.         ;;
  3754.     esac
  3755. }
  3756. qt4_get_bindir ()
  3757. {
  3758.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  3759.     has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  3760.     local qtbindir=${EPREFIX}$(qt4_get_libdir)/bin;
  3761.     if [[ -d ${qtbindir} ]]; then
  3762.         echo ${qtbindir};
  3763.     else
  3764.         echo ${EPREFIX}/usr/bin;
  3765.     fi
  3766. }
  3767. qt4_get_headerdir ()
  3768. {
  3769.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  3770.     echo /usr/include/qt4
  3771. }
  3772. qt4_get_libdir ()
  3773. {
  3774.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  3775.     echo /usr/$(get_libdir)/qt4
  3776. }
  3777. qt4_get_mkspecsdir ()
  3778. {
  3779.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  3780.     echo /usr/share/qt4/mkspecs
  3781. }
  3782. qt4_get_plugindir ()
  3783. {
  3784.     [[ ${EAPI:-0} == [0123456] ]] || die "${FUNCNAME[1]} is banned in EAPI 7 and later";
  3785.     echo $(qt4_get_libdir)/plugins
  3786. }
  3787. qt5_get_bindir ()
  3788. {
  3789.     has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  3790.     echo ${EPREFIX}$(qt5_get_libdir)/qt5/bin
  3791. }
  3792. qt5_get_headerdir ()
  3793. {
  3794.     echo /usr/include/qt5
  3795. }
  3796. qt5_get_libdir ()
  3797. {
  3798.     echo /usr/$(get_libdir)
  3799. }
  3800. qt5_get_mkspecsdir ()
  3801. {
  3802.     echo $(qt5_get_libdir)/qt5/mkspecs
  3803. }
  3804. qt5_get_plugindir ()
  3805. {
  3806.     echo $(qt5_get_libdir)/qt5/plugins
  3807. }
  3808. raw-ldflags ()
  3809. {
  3810.     local x input="$@";
  3811.     [[ -z ${input} ]] && input=${LDFLAGS};
  3812.     set --;
  3813.     for x in ${input};
  3814.     do
  3815.         case ${x} in
  3816.             -Wl,*)
  3817.                 x=${x#-Wl,};
  3818.                 set -- "$@" ${x//,/ }
  3819.             ;;
  3820.             *)
  3821.  
  3822.             ;;
  3823.         esac;
  3824.     done;
  3825.     echo "$@"
  3826. }
  3827. replace-cpu-flags ()
  3828. {
  3829.     local newcpu="$#";
  3830.     newcpu="${!newcpu}";
  3831.     while [ $# -gt 1 ]; do
  3832.         replace-flags "-march=${1}" "-march=${newcpu}";
  3833.         replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3834.         replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3835.         shift;
  3836.     done;
  3837.     return 0
  3838. }
  3839. replace-flags ()
  3840. {
  3841.     [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3842.     local f var new;
  3843.     for var in $(all-flag-vars);
  3844.     do
  3845.         new=();
  3846.         for f in ${!var};
  3847.         do
  3848.             [[ ${f} == ${1} ]] && f=${2};
  3849.             new+=("${f}");
  3850.         done;
  3851.         export ${var}="${new[*]}";
  3852.     done;
  3853.     return 0
  3854. }
  3855. replace-sparc64-flags ()
  3856. {
  3857.     local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3858.     if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3859.         for x in ${SPARC64_CPUS};
  3860.         do
  3861.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3862.         done;
  3863.     else
  3864.         for x in ${SPARC64_CPUS};
  3865.         do
  3866.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3867.         done;
  3868.     fi;
  3869.     if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3870.         for x in ${SPARC64_CPUS};
  3871.         do
  3872.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3873.         done;
  3874.     else
  3875.         for x in ${SPARC64_CPUS};
  3876.         do
  3877.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3878.         done;
  3879.     fi;
  3880.     export CFLAGS CXXFLAGS
  3881. }
  3882. setup-allowed-flags ()
  3883. {
  3884.     ALLOWED_FLAGS=(-pipe -O '-O[12sg]' -mcpu -march -mtune '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check -fbounds-check -fbounds-checking -fno-strict-overflow -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -gz -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld');
  3885.     ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  3886.     ALLOWED_FLAGS+=(-mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi -mfix-r10000 -mno-fix-r10000 -mthumb -marm -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha);
  3887.     ALLOWED_FLAGS+=(-mstackrealign)
  3888. }
  3889. src_compile ()
  3890. {
  3891.     cmake-utils_src_compile "$@"
  3892. }
  3893. src_configure ()
  3894. {
  3895.     local mycmakeargs=(-DQGIS_MANUAL_SUBDIR=share/man/ -DQGIS_LIB_SUBDIR=$(get_libdir) -DQGIS_PLUGIN_SUBDIR=$(get_libdir)/qgis -DQWT_INCLUDE_DIR=/usr/include/qwt6 -DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6-qt5.so -DPEDANTIC=OFF -DUSE_CCACHE=OFF -DWITH_ANALYSIS=ON -DWITH_APIDOC=OFF -DWITH_GUI=ON -DWITH_INTERNAL_MDAL=ON -DWITH_QSPATIALITE=ON -DENABLE_TESTS=OFF -DWITH_3D=$(usex 3d) -DWITH_GEOREFERENCER=$(usex georeferencer) -DWITH_GRASS7=$(usex grass) $(cmake-utils_use_find_package hdf5 HDF5) -DWITH_SERVER=$(usex mapserver) $(cmake-utils_use_find_package netcdf NetCDF) -DUSE_OPENCL=$(usex opencl) -DWITH_ORACLE=$(usex oracle) -DWITH_QWTPOLAR=$(usex polar) -DWITH_POSTGRESQL=$(usex postgres) -DWITH_BINDINGS=$(usex python) -DWITH_CUSTOM_WIDGETS=$(usex python) -DWITH_QUICK=$(usex qml) -DWITH_QTWEBKIT=$(usex webkit));
  3896.     if use grass; then
  3897.         mycmakeargs+=(-DGRASS_PREFIX7=/usr/$(get_libdir)/grass70);
  3898.     fi;
  3899.     use python && mycmakeargs+=(-DBINDINGS_GLOBAL_INSTALL=ON);
  3900.     addpredict /dev/dri/renderD128;
  3901.     addpredict /dev/dri/renderD129;
  3902.     cmake-utils_src_configure
  3903. }
  3904. src_install ()
  3905. {
  3906.     cmake-utils_src_install;
  3907.     insinto /usr/share/mime/packages;
  3908.     doins debian/qgis.xml;
  3909.     if use examples; then
  3910.         docinto examples;
  3911.         dodoc -r "${WORKDIR}"/qgis_sample_data/.;
  3912.         docompress -x /usr/share/doc/${PF}/examples;
  3913.     fi;
  3914.     if use python; then
  3915.         python_optimize;
  3916.         python_optimize "${ED}"/usr/share/qgis/python;
  3917.     fi;
  3918.     if use grass; then
  3919.         python_fix_shebang "${ED}"/usr/share/qgis/grass/scripts;
  3920.     fi
  3921. }
  3922. src_prepare ()
  3923. {
  3924.     cmake-utils_src_prepare
  3925. }
  3926. src_test ()
  3927. {
  3928.     cmake-utils_src_test "$@"
  3929. }
  3930. src_unpack ()
  3931. {
  3932.     default
  3933. }
  3934. strip-flags ()
  3935. {
  3936.     local x y var;
  3937.     local ALLOWED_FLAGS;
  3938.     setup-allowed-flags;
  3939.     set -f;
  3940.     for var in $(all-flag-vars);
  3941.     do
  3942.         local new=();
  3943.         for x in ${!var};
  3944.         do
  3945.             local flag=${x%%=*};
  3946.             for y in "${ALLOWED_FLAGS[@]}";
  3947.             do
  3948.                 if [[ -z ${flag%%${y}} ]]; then
  3949.                     new+=("${x}");
  3950.                     break;
  3951.                 fi;
  3952.             done;
  3953.         done;
  3954.         if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  3955.             new+=(-O2);
  3956.         fi;
  3957.         if [[ ${!var} != "${new[*]}" ]]; then
  3958.             einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  3959.         fi;
  3960.         export ${var}="${new[*]}";
  3961.     done;
  3962.     set +f;
  3963.     return 0
  3964. }
  3965. strip-linguas ()
  3966. {
  3967.     local ls newls nols;
  3968.     if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  3969.         local op=$1;
  3970.         shift;
  3971.         ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  3972.         shift;
  3973.         local d f;
  3974.         for d in "$@";
  3975.         do
  3976.             if [[ ${op} == "-u" ]]; then
  3977.                 newls=${ls};
  3978.             else
  3979.                 newls="";
  3980.             fi;
  3981.             for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  3982.             do
  3983.                 if [[ ${op} == "-i" ]]; then
  3984.                     has ${f} ${ls} && newls="${newls} ${f}";
  3985.                 else
  3986.                     has ${f} ${ls} || newls="${newls} ${f}";
  3987.                 fi;
  3988.             done;
  3989.             ls=${newls};
  3990.         done;
  3991.     else
  3992.         ls="$@";
  3993.     fi;
  3994.     nols="";
  3995.     newls="";
  3996.     for f in ${LINGUAS};
  3997.     do
  3998.         if has ${f} ${ls}; then
  3999.             newls="${newls} ${f}";
  4000.         else
  4001.             nols="${nols} ${f}";
  4002.         fi;
  4003.     done;
  4004.     [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  4005.     export LINGUAS=${newls:1}
  4006. }
  4007. strip-unsupported-flags ()
  4008. {
  4009.     export CFLAGS=$(test-flags-CC ${CFLAGS});
  4010.     export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  4011.     export FFLAGS=$(test-flags-F77 ${FFLAGS});
  4012.     export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  4013.     export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  4014. }
  4015. tc-arch ()
  4016. {
  4017.     tc-ninja_magic_to_arch portage "$@"
  4018. }
  4019. tc-arch-kernel ()
  4020. {
  4021.     tc-ninja_magic_to_arch kern "$@"
  4022. }
  4023. tc-check-openmp ()
  4024. {
  4025.     if ! tc-has-openmp; then
  4026.         eerror "Your current compiler does not support OpenMP!";
  4027.         if tc-is-gcc; then
  4028.             eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  4029.         else
  4030.             if tc-is-clang; then
  4031.                 eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  4032.             fi;
  4033.         fi;
  4034.         die "Active compiler does not have required support for OpenMP";
  4035.     fi
  4036. }
  4037. tc-cpp-is-true ()
  4038. {
  4039.     local CONDITION=${1};
  4040.     shift;
  4041.     $(tc-getTARGET_CPP) "${@}" -P - > /dev/null 2>&1  <<-EOF
  4042. #if ${CONDITION}
  4043. true
  4044. #else
  4045. #error false
  4046. #endif
  4047. EOF
  4048.  
  4049. }
  4050. tc-detect-is-softfloat ()
  4051. {
  4052.     [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  4053.     case ${CTARGET:-${CHOST}} in
  4054.         *-newlib | *-elf | *-eabi)
  4055.             return 1
  4056.         ;;
  4057.         arm*)
  4058.             if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  4059.                 echo "no";
  4060.             else
  4061.                 if tc-cpp-is-true "defined(__SOFTFP__)"; then
  4062.                     echo "yes";
  4063.                 else
  4064.                     echo "softfp";
  4065.                 fi;
  4066.             fi;
  4067.             return 0
  4068.         ;;
  4069.         *)
  4070.             return 1
  4071.         ;;
  4072.     esac
  4073. }
  4074. tc-enables-pie ()
  4075. {
  4076.     tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  4077. }
  4078. tc-enables-ssp ()
  4079. {
  4080.     tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4081. }
  4082. tc-enables-ssp-all ()
  4083. {
  4084.     tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4085. }
  4086. tc-enables-ssp-strong ()
  4087. {
  4088.     tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4089. }
  4090. tc-endian ()
  4091. {
  4092.     local host=$1;
  4093.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4094.     host=${host%%-*};
  4095.     case ${host} in
  4096.         aarch64*be)
  4097.             echo big
  4098.         ;;
  4099.         aarch64)
  4100.             echo little
  4101.         ;;
  4102.         alpha*)
  4103.             echo little
  4104.         ;;
  4105.         arm*b*)
  4106.             echo big
  4107.         ;;
  4108.         arm*)
  4109.             echo little
  4110.         ;;
  4111.         cris*)
  4112.             echo little
  4113.         ;;
  4114.         hppa*)
  4115.             echo big
  4116.         ;;
  4117.         i?86*)
  4118.             echo little
  4119.         ;;
  4120.         ia64*)
  4121.             echo little
  4122.         ;;
  4123.         m68*)
  4124.             echo big
  4125.         ;;
  4126.         mips*l*)
  4127.             echo little
  4128.         ;;
  4129.         mips*)
  4130.             echo big
  4131.         ;;
  4132.         powerpc*le)
  4133.             echo little
  4134.         ;;
  4135.         powerpc*)
  4136.             echo big
  4137.         ;;
  4138.         riscv*)
  4139.             echo little
  4140.         ;;
  4141.         s390*)
  4142.             echo big
  4143.         ;;
  4144.         sh*b*)
  4145.             echo big
  4146.         ;;
  4147.         sh*)
  4148.             echo little
  4149.         ;;
  4150.         sparc*)
  4151.             echo big
  4152.         ;;
  4153.         x86_64*)
  4154.             echo little
  4155.         ;;
  4156.         *)
  4157.             echo wtf
  4158.         ;;
  4159.     esac
  4160. }
  4161. tc-env_build ()
  4162. {
  4163.     tc-export_build_env;
  4164.     CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
  4165. }
  4166. tc-export ()
  4167. {
  4168.     local var;
  4169.     for var in "$@";
  4170.     do
  4171.         [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4172.         "tc-get${var}" > /dev/null;
  4173.     done
  4174. }
  4175. tc-export_build_env ()
  4176. {
  4177.     tc-export "$@";
  4178.     if tc-is-cross-compiler; then
  4179.         : ${BUILD_CFLAGS:=-O1 -pipe};
  4180.         : ${BUILD_CXXFLAGS:=-O1 -pipe};
  4181.         : ${BUILD_CPPFLAGS:= };
  4182.         : ${BUILD_LDFLAGS:= };
  4183.     else
  4184.         : ${BUILD_CFLAGS:=${CFLAGS}};
  4185.         : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  4186.         : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  4187.         : ${BUILD_LDFLAGS:=${LDFLAGS}};
  4188.     fi;
  4189.     export BUILD_{C,CXX,CPP,LD}FLAGS;
  4190.     local v;
  4191.     for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4192.     do
  4193.         export ${v#BUILD_}_FOR_BUILD="${!v}";
  4194.     done
  4195. }
  4196. tc-get-compiler-type ()
  4197. {
  4198.     local code='
  4199. #if defined(__PATHSCALE__)
  4200.     HAVE_PATHCC
  4201. #elif defined(__clang__)
  4202.     HAVE_CLANG
  4203. #elif defined(__GNUC__)
  4204.     HAVE_GCC
  4205. #endif
  4206. ';
  4207.     local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4208.     case ${res} in
  4209.         *HAVE_PATHCC*)
  4210.             echo pathcc
  4211.         ;;
  4212.         *HAVE_CLANG*)
  4213.             echo clang
  4214.         ;;
  4215.         *HAVE_GCC*)
  4216.             echo gcc
  4217.         ;;
  4218.         *)
  4219.             echo unknown
  4220.         ;;
  4221.     esac
  4222. }
  4223. tc-getAR ()
  4224. {
  4225.     tc-getPROG AR ar "$@"
  4226. }
  4227. tc-getAS ()
  4228. {
  4229.     tc-getPROG AS as "$@"
  4230. }
  4231. tc-getBUILD_AR ()
  4232. {
  4233.     tc-getBUILD_PROG AR ar "$@"
  4234. }
  4235. tc-getBUILD_AS ()
  4236. {
  4237.     tc-getBUILD_PROG AS as "$@"
  4238. }
  4239. tc-getBUILD_CC ()
  4240. {
  4241.     tc-getBUILD_PROG CC gcc "$@"
  4242. }
  4243. tc-getBUILD_CPP ()
  4244. {
  4245.     tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4246. }
  4247. tc-getBUILD_CXX ()
  4248. {
  4249.     tc-getBUILD_PROG CXX g++ "$@"
  4250. }
  4251. tc-getBUILD_LD ()
  4252. {
  4253.     tc-getBUILD_PROG LD ld "$@"
  4254. }
  4255. tc-getBUILD_NM ()
  4256. {
  4257.     tc-getBUILD_PROG NM nm "$@"
  4258. }
  4259. tc-getBUILD_OBJCOPY ()
  4260. {
  4261.     tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4262. }
  4263. tc-getBUILD_PKG_CONFIG ()
  4264. {
  4265.     tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4266. }
  4267. tc-getBUILD_PROG ()
  4268. {
  4269.     local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4270.     tc-is-cross-compiler || vars+=" $1";
  4271.     _tc-getPROG CBUILD "${vars}" "${@:2}"
  4272. }
  4273. tc-getBUILD_RANLIB ()
  4274. {
  4275.     tc-getBUILD_PROG RANLIB ranlib "$@"
  4276. }
  4277. tc-getBUILD_STRIP ()
  4278. {
  4279.     tc-getBUILD_PROG STRIP strip "$@"
  4280. }
  4281. tc-getCC ()
  4282. {
  4283.     tc-getPROG CC gcc "$@"
  4284. }
  4285. tc-getCPP ()
  4286. {
  4287.     tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4288. }
  4289. tc-getCXX ()
  4290. {
  4291.     tc-getPROG CXX g++ "$@"
  4292. }
  4293. tc-getDLLWRAP ()
  4294. {
  4295.     tc-getPROG DLLWRAP dllwrap "$@"
  4296. }
  4297. tc-getF77 ()
  4298. {
  4299.     tc-getPROG F77 gfortran "$@"
  4300. }
  4301. tc-getFC ()
  4302. {
  4303.     tc-getPROG FC gfortran "$@"
  4304. }
  4305. tc-getGCJ ()
  4306. {
  4307.     tc-getPROG GCJ gcj "$@"
  4308. }
  4309. tc-getGO ()
  4310. {
  4311.     tc-getPROG GO gccgo "$@"
  4312. }
  4313. tc-getLD ()
  4314. {
  4315.     tc-getPROG LD ld "$@"
  4316. }
  4317. tc-getNM ()
  4318. {
  4319.     tc-getPROG NM nm "$@"
  4320. }
  4321. tc-getOBJCOPY ()
  4322. {
  4323.     tc-getPROG OBJCOPY objcopy "$@"
  4324. }
  4325. tc-getOBJDUMP ()
  4326. {
  4327.     tc-getPROG OBJDUMP objdump "$@"
  4328. }
  4329. tc-getPKG_CONFIG ()
  4330. {
  4331.     tc-getPROG PKG_CONFIG pkg-config "$@"
  4332. }
  4333. tc-getPROG ()
  4334. {
  4335.     _tc-getPROG CHOST "$@"
  4336. }
  4337. tc-getRANLIB ()
  4338. {
  4339.     tc-getPROG RANLIB ranlib "$@"
  4340. }
  4341. tc-getRC ()
  4342. {
  4343.     tc-getPROG RC windres "$@"
  4344. }
  4345. tc-getSTRIP ()
  4346. {
  4347.     tc-getPROG STRIP strip "$@"
  4348. }
  4349. tc-getTARGET_CPP ()
  4350. {
  4351.     if [[ -n ${CTARGET} ]]; then
  4352.         _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4353.     else
  4354.         tc-getCPP "$@";
  4355.     fi
  4356. }
  4357. tc-has-openmp ()
  4358. {
  4359.     local base="${T}/test-tc-openmp";
  4360.     cat > "${base}.c"  <<-EOF
  4361. #include <omp.h>
  4362. int main() {
  4363. int nthreads, tid, ret = 0;
  4364. #pragma omp parallel private(nthreads, tid)
  4365. {
  4366. tid = omp_get_thread_num();
  4367. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  4368. }
  4369. return ret;
  4370. }
  4371. EOF
  4372.  
  4373.     $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  4374.     local ret=$?;
  4375.     rm -f "${base}"*;
  4376.     return ${ret}
  4377. }
  4378. tc-has-tls ()
  4379. {
  4380.     local base="${T}/test-tc-tls";
  4381.     cat > "${base}.c"  <<-EOF
  4382. int foo(int *i) {
  4383. static __thread int j = 0;
  4384. return *i ? j : *i;
  4385. }
  4386. EOF
  4387.  
  4388.     local flags;
  4389.     case $1 in
  4390.         -s)
  4391.             flags="-S"
  4392.         ;;
  4393.         -c)
  4394.             flags="-c"
  4395.         ;;
  4396.         -l)
  4397.  
  4398.         ;;
  4399.         -*)
  4400.             die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4401.         ;;
  4402.     esac;
  4403.     : ${flags:=-fPIC -shared -Wl,-z,defs};
  4404.     [[ $1 == -* ]] && shift;
  4405.     $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4406.     local ret=$?;
  4407.     rm -f "${base}"*;
  4408.     return ${ret}
  4409. }
  4410. tc-is-clang ()
  4411. {
  4412.     [[ $(tc-get-compiler-type) == clang ]]
  4413. }
  4414. tc-is-cross-compiler ()
  4415. {
  4416.     [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4417. }
  4418. tc-is-gcc ()
  4419. {
  4420.     [[ $(tc-get-compiler-type) == gcc ]]
  4421. }
  4422. tc-is-softfloat ()
  4423. {
  4424.     tc-detect-is-softfloat || tc-tuple-is-softfloat
  4425. }
  4426. tc-is-static-only ()
  4427. {
  4428.     local host=${CTARGET:-${CHOST}};
  4429.     [[ ${host} == *-mint* ]]
  4430. }
  4431. tc-ld-disable-gold ()
  4432. {
  4433.     if ! tc-ld-is-gold "$@"; then
  4434.         return;
  4435.     fi;
  4436.     ewarn "Forcing usage of the BFD linker instead of GOLD";
  4437.     local ld=$(tc-getLD "$@");
  4438.     local bfd_ld="${ld%% *}.bfd";
  4439.     local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  4440.     [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  4441.     local fallback="true";
  4442.     if tc-is-gcc; then
  4443.         local major=$(gcc-major-version "$@");
  4444.         local minor=$(gcc-minor-version "$@");
  4445.         if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  4446.             export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4447.             fallback="false";
  4448.         fi;
  4449.     else
  4450.         if tc-is-clang; then
  4451.             local major=$(clang-major-version "$@");
  4452.             local minor=$(clang-minor-version "$@");
  4453.             if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  4454.                 export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4455.                 fallback="false";
  4456.             fi;
  4457.         fi;
  4458.     fi;
  4459.     if [[ ${fallback} == "true" ]]; then
  4460.         if [[ -e ${path_ld} ]]; then
  4461.             local d="${T}/bfd-linker";
  4462.             mkdir -p "${d}";
  4463.             ln -sf "${path_ld}" "${d}"/ld;
  4464.             export LDFLAGS="${LDFLAGS} -B${d}";
  4465.         else
  4466.             die "unable to locate a BFD linker to bypass gold";
  4467.         fi;
  4468.     fi
  4469. }
  4470. tc-ld-is-gold ()
  4471. {
  4472.     local out;
  4473.     out=$($(tc-getLD "$@") --version 2>&1);
  4474.     if [[ ${out} == *"GNU gold"* ]]; then
  4475.         return 0;
  4476.     fi;
  4477.     local base="${T}/test-tc-gold";
  4478.     cat > "${base}.c"  <<-EOF
  4479. int main() { return 0; }
  4480. EOF
  4481.  
  4482.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4483.     rm -f "${base}"*;
  4484.     if [[ ${out} == *"GNU gold"* ]]; then
  4485.         return 0;
  4486.     fi;
  4487.     return 1
  4488. }
  4489. tc-ld-is-lld ()
  4490. {
  4491.     local out;
  4492.     out=$($(tc-getLD "$@") --version 2>&1);
  4493.     if [[ ${out} == *"LLD"* ]]; then
  4494.         return 0;
  4495.     fi;
  4496.     local base="${T}/test-tc-lld";
  4497.     cat > "${base}.c"  <<-EOF
  4498. int main() { return 0; }
  4499. EOF
  4500.  
  4501.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4502.     rm -f "${base}"*;
  4503.     if [[ ${out} == *"LLD"* ]]; then
  4504.         return 0;
  4505.     fi;
  4506.     return 1
  4507. }
  4508. tc-ninja_magic_to_arch ()
  4509. {
  4510.     function ninj ()
  4511.     {
  4512.         [[ ${type} == "kern" ]] && echo $1 || echo $2
  4513.     };
  4514.     local type=$1;
  4515.     local host=$2;
  4516.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4517.     case ${host} in
  4518.         aarch64*)
  4519.             echo arm64
  4520.         ;;
  4521.         alpha*)
  4522.             echo alpha
  4523.         ;;
  4524.         arm*)
  4525.             echo arm
  4526.         ;;
  4527.         avr*)
  4528.             ninj avr32 avr
  4529.         ;;
  4530.         bfin*)
  4531.             ninj blackfin bfin
  4532.         ;;
  4533.         c6x*)
  4534.             echo c6x
  4535.         ;;
  4536.         cris*)
  4537.             echo cris
  4538.         ;;
  4539.         frv*)
  4540.             echo frv
  4541.         ;;
  4542.         hexagon*)
  4543.             echo hexagon
  4544.         ;;
  4545.         hppa*)
  4546.             ninj parisc hppa
  4547.         ;;
  4548.         i?86*)
  4549.             if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  4550.                 echo i386;
  4551.             else
  4552.                 echo x86;
  4553.             fi
  4554.         ;;
  4555.         ia64*)
  4556.             echo ia64
  4557.         ;;
  4558.         m68*)
  4559.             echo m68k
  4560.         ;;
  4561.         metag*)
  4562.             echo metag
  4563.         ;;
  4564.         microblaze*)
  4565.             echo microblaze
  4566.         ;;
  4567.         mips*)
  4568.             echo mips
  4569.         ;;
  4570.         nios2*)
  4571.             echo nios2
  4572.         ;;
  4573.         nios*)
  4574.             echo nios
  4575.         ;;
  4576.         or1k | or32*)
  4577.             echo openrisc
  4578.         ;;
  4579.         powerpc*)
  4580.             if [[ ${type} == "kern" ]]; then
  4581.                 echo powerpc;
  4582.             else
  4583.                 if [[ ${host} == powerpc64* ]]; then
  4584.                     echo ppc64;
  4585.                 else
  4586.                     echo ppc;
  4587.                 fi;
  4588.             fi
  4589.         ;;
  4590.         riscv*)
  4591.             echo riscv
  4592.         ;;
  4593.         s390*)
  4594.             echo s390
  4595.         ;;
  4596.         score*)
  4597.             echo score
  4598.         ;;
  4599.         sh64*)
  4600.             ninj sh64 sh
  4601.         ;;
  4602.         sh*)
  4603.             echo sh
  4604.         ;;
  4605.         sparc64*)
  4606.             ninj sparc64 sparc
  4607.         ;;
  4608.         sparc*)
  4609.             [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  4610.         ;;
  4611.         tile*)
  4612.             echo tile
  4613.         ;;
  4614.         vax*)
  4615.             echo vax
  4616.         ;;
  4617.         x86_64*freebsd*)
  4618.             echo amd64
  4619.         ;;
  4620.         x86_64*)
  4621.             if [[ ${type} == "kern" ]]; then
  4622.                 echo x86;
  4623.             else
  4624.                 echo amd64;
  4625.             fi
  4626.         ;;
  4627.         xtensa*)
  4628.             echo xtensa
  4629.         ;;
  4630.         *)
  4631.             echo unknown
  4632.         ;;
  4633.     esac
  4634. }
  4635. tc-stack-grows-down ()
  4636. {
  4637.     case ${ARCH} in
  4638.         hppa | metag)
  4639.             return 1
  4640.         ;;
  4641.     esac;
  4642.     return 0
  4643. }
  4644. tc-tuple-is-softfloat ()
  4645. {
  4646.     local CTARGET=${CTARGET:-${CHOST}};
  4647.     case ${CTARGET//_/-} in
  4648.         bfin* | h8300*)
  4649.             echo "only"
  4650.         ;;
  4651.         *-softfloat-*)
  4652.             echo "yes"
  4653.         ;;
  4654.         *-softfp-*)
  4655.             echo "softfp"
  4656.         ;;
  4657.         arm*-hardfloat-* | arm*eabihf)
  4658.             echo "no"
  4659.         ;;
  4660.         *-newlib | *-elf | *-eabi)
  4661.             echo "no"
  4662.         ;;
  4663.         arm*)
  4664.             echo "yes"
  4665.         ;;
  4666.         *)
  4667.             echo "no"
  4668.         ;;
  4669.     esac
  4670. }
  4671. test-flag-CC ()
  4672. {
  4673.     test-flag-PROG "CC" c "$@"
  4674. }
  4675. test-flag-CXX ()
  4676. {
  4677.     test-flag-PROG "CXX" c++ "$@"
  4678. }
  4679. test-flag-F77 ()
  4680. {
  4681.     test-flag-PROG "F77" f77 "$@"
  4682. }
  4683. test-flag-FC ()
  4684. {
  4685.     test-flag-PROG "FC" f95 "$@"
  4686. }
  4687. test-flag-PROG ()
  4688. {
  4689.     local comp=$1;
  4690.     local lang=$2;
  4691.     shift 2;
  4692.     [[ -z ${comp} || -z $1 ]] && return 1;
  4693.     comp=($(tc-get${comp}));
  4694.     type -p ${comp[0]} > /dev/null || return 1;
  4695.     local cmdline=("${comp[@]}" -Werror -c -o /dev/null);
  4696.     if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  4697.         cmdline+=("$@" -x${lang} -);
  4698.     else
  4699.         cmdline+=("$@" -c -o /dev/null /dev/null);
  4700.     fi;
  4701.     if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  4702.         cmdline+=(-Qunused-arguments);
  4703.         "${cmdline[@]}" < /dev/null &> /dev/null;
  4704.     fi
  4705. }
  4706. test-flags ()
  4707. {
  4708.     test-flags-CC "$@"
  4709. }
  4710. test-flags-CC ()
  4711. {
  4712.     test-flags-PROG "CC" "$@"
  4713. }
  4714. test-flags-CXX ()
  4715. {
  4716.     test-flags-PROG "CXX" "$@"
  4717. }
  4718. test-flags-F77 ()
  4719. {
  4720.     test-flags-PROG "F77" "$@"
  4721. }
  4722. test-flags-FC ()
  4723. {
  4724.     test-flags-PROG "FC" "$@"
  4725. }
  4726. test-flags-PROG ()
  4727. {
  4728.     local comp=$1;
  4729.     local flags=();
  4730.     local x;
  4731.     shift;
  4732.     [[ -z ${comp} ]] && return 1;
  4733.     while (( $# )); do
  4734.         case "$1" in
  4735.             --param | -B)
  4736.                 if test-flag-${comp} "$1" "$2"; then
  4737.                     flags+=("$1" "$2");
  4738.                 fi;
  4739.                 shift 2
  4740.             ;;
  4741.             *)
  4742.                 if test-flag-${comp} "$1"; then
  4743.                     flags+=("$1");
  4744.                 fi;
  4745.                 shift 1
  4746.             ;;
  4747.         esac;
  4748.     done;
  4749.     echo "${flags[*]}";
  4750.     [[ ${#flags[@]} -gt 0 ]]
  4751. }
  4752. test_version_info ()
  4753. {
  4754.     if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  4755.         return 0;
  4756.     else
  4757.         return 1;
  4758.     fi
  4759. }
  4760. use_if_iuse ()
  4761. {
  4762.     in_iuse $1 || return 1;
  4763.     use $1
  4764. }
  4765. ver_cut ()
  4766. {
  4767.     local range=${1};
  4768.     local v=${2:-${PV}};
  4769.     local start end;
  4770.     local -a comp;
  4771.     __eapi7_ver_split "${v}";
  4772.     local max=$((${#comp[@]}/2));
  4773.     __eapi7_ver_parse_range "${range}" "${max}";
  4774.     local IFS=;
  4775.     if [[ ${start} -gt 0 ]]; then
  4776.         start=$(( start*2 - 1 ));
  4777.     fi;
  4778.     echo "${comp[*]:start:end*2-start}"
  4779. }
  4780. ver_rs ()
  4781. {
  4782.     local v;
  4783.     (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  4784.     local start end i;
  4785.     local -a comp;
  4786.     __eapi7_ver_split "${v}";
  4787.     local max=$((${#comp[@]}/2 - 1));
  4788.     while [[ ${#} -ge 2 ]]; do
  4789.         __eapi7_ver_parse_range "${1}" "${max}";
  4790.         for ((i = start*2; i <= end*2; i+=2 ))
  4791.         do
  4792.             [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  4793.             comp[i]=${2};
  4794.         done;
  4795.         shift 2;
  4796.     done;
  4797.     local IFS=;
  4798.     echo "${comp[*]}"
  4799. }
  4800. ver_test ()
  4801. {
  4802.     local va op vb;
  4803.     if [[ $# -eq 3 ]]; then
  4804.         va=${1};
  4805.         shift;
  4806.     else
  4807.         va=${PVR};
  4808.     fi;
  4809.     [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  4810.     op=${1};
  4811.     vb=${2};
  4812.     case ${op} in
  4813.         -eq | -ne | -lt | -le | -gt | -ge)
  4814.  
  4815.         ;;
  4816.         *)
  4817.             die "${FUNCNAME}: invalid operator: ${op}"
  4818.         ;;
  4819.     esac;
  4820.     __eapi7_ver_compare "${va}" "${vb}";
  4821.     test $? "${op}" 2
  4822. }
  4823. xdg_desktop_database_update ()
  4824. {
  4825.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4826.         die "xdg_desktop_database_update must be used in pkg_post* phases.";
  4827.     fi;
  4828.     if ! type update-desktop-database &> /dev/null; then
  4829.         debug-print "update-desktop-database is not found";
  4830.         return;
  4831.     fi;
  4832.     ebegin "Updating .desktop files database";
  4833.     update-desktop-database -q "${EROOT%/}${DESKTOP_DATABASE_DIR}";
  4834.     eend $?
  4835. }
  4836. xdg_environment_reset ()
  4837. {
  4838.     export XDG_DATA_HOME="${HOME}/.local/share";
  4839.     export XDG_CONFIG_HOME="${HOME}/.config";
  4840.     export XDG_CACHE_HOME="${HOME}/.cache";
  4841.     export XDG_RUNTIME_DIR="${T}/run";
  4842.     mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_RUNTIME_DIR}" || die;
  4843.     chmod 0700 "${XDG_RUNTIME_DIR}" || die;
  4844.     unset DBUS_SESSION_BUS_ADDRESS
  4845. }
  4846. xdg_icon_cache_update ()
  4847. {
  4848.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4849.         die "xdg_icon_cache_update must be used in pkg_post* phases.";
  4850.     fi;
  4851.     if ! type gtk-update-icon-cache &> /dev/null; then
  4852.         debug-print "gtk-update-icon-cache is not found";
  4853.         return;
  4854.     fi;
  4855.     ebegin "Updating icons cache";
  4856.     local dir f retval=0;
  4857.     local fails=();
  4858.     for dir in "${EROOT%/}"/usr/share/icons/*;
  4859.     do
  4860.         if [[ -f "${dir}/index.theme" ]]; then
  4861.             local rv=0;
  4862.             gtk-update-icon-cache -qf "${dir}";
  4863.             rv=$?;
  4864.             if [[ ! $rv -eq 0 ]]; then
  4865.                 debug-print "Updating cache failed on ${dir}";
  4866.                 fails+=("${dir}");
  4867.                 retval=2;
  4868.             fi;
  4869.         else
  4870.             if [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
  4871.                 rm "${dir}/icon-theme.cache";
  4872.             fi;
  4873.         fi;
  4874.         if [[ -z $(ls "${dir}") ]]; then
  4875.             rmdir "${dir}";
  4876.         fi;
  4877.     done;
  4878.     eend ${retval};
  4879.     for f in "${fails[@]}";
  4880.     do
  4881.         eerror "Failed to update cache with icon $f";
  4882.     done
  4883. }
  4884. xdg_mimeinfo_database_update ()
  4885. {
  4886.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4887.         die "xdg_mimeinfo_database_update must be used in pkg_post* phases.";
  4888.     fi;
  4889.     if ! type update-mime-database &> /dev/null; then
  4890.         debug-print "update-mime-database is not found";
  4891.         return;
  4892.     fi;
  4893.     ebegin "Updating shared mime info database";
  4894.     update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}";
  4895.     eend $?
  4896. }
  4897. xdg_pkg_postinst ()
  4898. {
  4899.     if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  4900.         xdg_desktop_database_update;
  4901.     else
  4902.         debug-print "No .desktop files to add to database";
  4903.     fi;
  4904.     if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
  4905.         xdg_icon_cache_update;
  4906.     else
  4907.         debug-print "No icon files to add to cache";
  4908.     fi;
  4909.     if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  4910.         xdg_mimeinfo_database_update;
  4911.     else
  4912.         debug-print "No mime info files to add to database";
  4913.     fi
  4914. }
  4915. xdg_pkg_postrm ()
  4916. {
  4917.     if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  4918.         xdg_desktop_database_update;
  4919.     else
  4920.         debug-print "No .desktop files to add to database";
  4921.     fi;
  4922.     if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
  4923.         xdg_icon_cache_update;
  4924.     else
  4925.         debug-print "No icon files to add to cache";
  4926.     fi;
  4927.     if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  4928.         xdg_mimeinfo_database_update;
  4929.     else
  4930.         debug-print "No mime info files to add to database";
  4931.     fi
  4932. }
  4933. xdg_pkg_preinst ()
  4934. {
  4935.     local f;
  4936.     XDG_ECLASS_DESKTOPFILES=();
  4937.     while IFS= read -r -d '' f; do
  4938.         XDG_ECLASS_DESKTOPFILES+=(${f});
  4939.     done < <(cd "${ED}" && find 'usr/share/applications' -type f -print0 2>/dev/null);
  4940.     XDG_ECLASS_ICONFILES=();
  4941.     while IFS= read -r -d '' f; do
  4942.         XDG_ECLASS_ICONFILES+=(${f});
  4943.     done < <(cd "${ED}" && find 'usr/share/icons' -type f -print0 2>/dev/null);
  4944.     XDG_ECLASS_MIMEINFOFILES=();
  4945.     while IFS= read -r -d '' f; do
  4946.         XDG_ECLASS_MIMEINFOFILES+=(${f});
  4947.     done < <(cd "${ED}" && find 'usr/share/mime' -type f -print0 2>/dev/null)
  4948. }
  4949. xdg_src_prepare ()
  4950. {
  4951.     xdg_environment_reset;
  4952.     [[ ${EAPI:-0} != [45] ]] && default
  4953. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement