SHARE
TWEET

libcaca build env

geekt Jun 13th, 2017 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. declare -x ABI="amd64"
  2. declare -x ABI_X86="64"
  3. declare -a ALL_AUTOTOOLS_MACROS='([0]="AC_PROG_LIBTOOL" [1]="AM_PROG_LIBTOOL" [2]="LT_INIT" [3]="LT_CONFIG_LTDL_DIR" [4]="AC_CONFIG_HEADERS" [5]="AC_CONFIG_HEADER" [6]="AM_CONFIG_HEADERS" [7]="AM_CONFIG_HEADER" [8]="AC_CONFIG_SUBDIRS" [9]="AC_CONFIG_AUX_DIR" [10]="AC_CONFIG_MACRO_DIR" [11]="AM_INIT_AUTOMAKE" [12]="AM_GLIB_GNU_GETTEXT" [13]="AM_GNU_GETTEXT_VERSION" [14]="AM_GNU_GETTEXT_REQUIRE_VERSION" [15]="AC_PROG_INTLTOOL" [16]="IT_PROG_INTLTOOL" [17]="GTK_DOC_CHECK" [18]="GNOME_DOC_INIT")'
  4. declare -x ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel ice1724 intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci"
  5. declare -x ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
  6. declare -x ANDROID_HOME="/opt/android-sdk-update-manager"
  7. declare -x ANDROID_SWT="//usr/share/swt-3.7/lib"
  8. declare -x ANT_HOME="/usr/share/ant"
  9. declare -x APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
  10. declare -x ARCH="amd64"
  11. declare -x ASFLAGS_x86="--32"
  12. declare -- AT_M4DIR=""
  13. declare -- AT_SYS_M4DIR=""
  14. declare -- AUTOTOOLS_AUTO_DEPEND="yes"
  15. declare -- AUTOTOOLS_DEPEND="!<sys-devel/gettext-0.18.1.1-r3
  16.     || ( >=sys-devel/automake-1.15:1.15  )
  17.     >=sys-devel/autoconf-2.69
  18.     >=sys-devel/libtool-2.4"
  19. declare -x BOOTSTRAP_USE="cxx unicode internal-glib python_targets_python3_4 python_targets_python2_7"
  20. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
  21. declare -x CBUILD="x86_64-pc-linux-gnu"
  22. declare -x CDEFINE_amd64="__x86_64__"
  23. declare -x CDEFINE_x86="__i386__"
  24. declare -x CFLAGS="-march=sandybridge -O2 -pipe"
  25. declare -x CFLAGS_default
  26. declare -x CFLAGS_x86="-m32"
  27. declare -x CHOST="x86_64-pc-linux-gnu"
  28. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  29. declare -x CHOST_default="x86_64-pc-linux-gnu"
  30. declare -x CHOST_x86="i686-pc-linux-gnu"
  31. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  32. declare -- COMMON_DEPEND="imlib? ( >=media-libs/imlib2-1.4.6-r2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  33.     mono? ( dev-lang/mono )
  34.     ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  35.     opengl? (
  36.         >=virtual/glu-9.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  37.         >=virtual/opengl-7.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  38.         >=media-libs/freeglut-2.8.1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  39.         truetype? ( >=media-libs/ftgl-2.1.3_rc5 )
  40.     )
  41.     python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)] )
  42.     ruby? (  ruby_targets_ruby21? ( dev-lang/ruby:2.1 ) ruby_targets_ruby22? ( dev-lang/ruby:2.2 ) ruby_targets_ruby23? ( dev-lang/ruby:2.3 ) ruby_targets_ruby24? ( dev-lang/ruby:2.4 ) )
  43.     slang? ( >=sys-libs/slang-2.2.4-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  44.     X? ( >=x11-libs/libX11-1.6.2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] >=x11-libs/libXt-1.1.4[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )"
  45. declare -x CONF_PREFIX="/usr"
  46. declare -x CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
  47. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  48. declare -x CUDA_HOME="/opt/cuda"
  49. declare -x CXXFLAGS="-march=sandybridge -O2 -pipe"
  50. declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-ZYvvimTQwQ,guid=57aece2934c93b9e6e461b5d594015ba"
  51. declare -x DEFAULT_ABI="amd64"
  52. declare -x DEFINED_PHASES=" compile configure install preinst prepare setup test unpack"
  53. declare DEPEND="imlib? ( >=media-libs/imlib2-1.4.6-r2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  54.     mono? ( dev-lang/mono )
  55.     ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  56.     opengl? (
  57.         >=virtual/glu-9.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  58.         >=virtual/opengl-7.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  59.         >=media-libs/freeglut-2.8.1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  60.         truetype? ( >=media-libs/ftgl-2.1.3_rc5 )
  61.     )
  62.     python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)] )
  63.     ruby? (  ruby_targets_ruby21? ( dev-lang/ruby:2.1 ) ruby_targets_ruby22? ( dev-lang/ruby:2.2 ) ruby_targets_ruby23? ( dev-lang/ruby:2.3 ) ruby_targets_ruby24? ( dev-lang/ruby:2.4 ) )
  64.     slang? ( >=sys-libs/slang-2.2.4-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  65.     X? ( >=x11-libs/libX11-1.6.2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] >=x11-libs/libXt-1.1.4[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  66.     virtual/pkgconfig
  67.     doc? (
  68.         app-doc/doxygen
  69.         virtual/latex-base
  70.         >=dev-texlive/texlive-fontsrecommended-2012
  71.         >=dev-texlive/texlive-latexextra-2012
  72.         dev-tex/xcolor
  73.     )
  74.     java? ( >=virtual/jdk-1.5 )
  75.     test? ( dev-util/cppunit ) >=app-portage/elt-patches-20170317 !<sys-devel/gettext-0.18.1.1-r3
  76.     || ( >=sys-devel/automake-1.15:1.15  )
  77.     >=sys-devel/autoconf-2.69
  78.     >=sys-devel/libtool-2.4 java? ( >=dev-java/java-config-2.2.0-r3  )"
  79. declare DESCRIPTION="A library that creates colored ASCII-art graphics"
  80. declare -x DESKTOP_SESSION="/usr/share/xsessions/xfce"
  81. declare -x DESTTREE="/usr"
  82. declare -x DIROPTIONS="-m0755"
  83. declare -a DOCS='([0]="AUTHORS" [1]="ChangeLog" [2]="NEWS" [3]="NOTES" [4]="README" [5]="THANKS")'
  84. declare -x EAPI="5"
  85. declare -- EBUILD_DEATH_HOOKS=" java-pkg_die"
  86. declare -x ELIBC="glibc"
  87. declare -x ELT_APPLIED_PATCHES=" portage/1.2.0 sed/1.5.6 as-needed/2.4.3"
  88. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  89. declare -- EPATCH_EXCLUDE=""
  90. declare -- EPATCH_FORCE="no"
  91. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  92. declare -- EPATCH_N_APPLIED_PATCHES="2"
  93. declare -- EPATCH_OPTS=""
  94. declare -- EPATCH_SINGLE_MSG=""
  95. declare -- EPATCH_SOURCE="/var/tmp/portage/media-libs/libcaca-0.99_beta19/work/patch"
  96. declare -- EPATCH_SUFFIX="patch.bz2"
  97. declare -- EPATCH_USER_SOURCE="/etc/portage/patches"
  98. declare -x EPYTHON="python2.7"
  99. declare -x EXEOPTIONS="-m0755"
  100. declare -x FCFLAGS="-march=sandybridge -O2 -pipe"
  101. 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}\""
  102. declare -x FFLAGS="-march=sandybridge -O2 -pipe"
  103. declare -x GCC_SPECS=""
  104. declare -x GLADE_CATALOG_PATH=":"
  105. declare -x GLADE_MODULE_PATH=":"
  106. declare -x GLADE_PIXMAP_PATH=":"
  107. declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx"
  108. declare -x GRUB_PLATFORMS="efi-64 pc"
  109. declare -x GSETTINGS_BACKEND="dconf"
  110. declare -x GTK_MODULES="canberra-gtk-module"
  111. declare HDEPEND=""
  112. declare HOMEPAGE="http://libcaca.zoy.org/"
  113. declare -x INHERITED=" multilib toolchain-funcs libtool autotools estack epatch epunt-cxx ltprune eutils versionator java-utils-2 ruby-utils ruby-ng flag-o-matic mono-env java-pkg-opt-2 python-utils-r1 python-single-r1 multibuild multilib-build multilib-minimal"
  114. declare -x INPUT_DEVICES="evdev synaptics"
  115. declare -x INSDESTTREE=""
  116. declare -x INSOPTIONS="-m0644"
  117. declare IUSE="cxx doc imlib java mono ncurses opengl python ruby slang static-libs test truetype X elibc_FreeBSD  ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23 ruby_targets_ruby24 elibc_FreeBSD  java python_targets_python2_7 abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64"
  118. declare -x IUSE_EFFECTIVE="X abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 cxx doc 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 hppa ia64 imlib java kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mips mono ncurses nios2 opengl ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest python python_targets_python2_7 riscv ruby ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23 ruby_targets_ruby24 s390 sh slang sparc sparc-fbsd sparc-solaris sparc64-solaris static-libs test truetype userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  119. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  120. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  121. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  122. declare -- JAVA_PKG_ALLOW_VM_CHANGE="yes"
  123. declare -- JAVA_PKG_BUILD_DEPEND_FILE="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/java-pkg-build-depend"
  124. declare -- JAVA_PKG_COMPILERS_CONF="/etc/java-config-2/build/compilers.conf"
  125. declare -- JAVA_PKG_COMPILER_DIR="/usr/share/java-config-2/compiler"
  126. declare -- JAVA_PKG_DEPEND_FILE="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/java-pkg-depend"
  127. declare -- JAVA_PKG_EXTRA_ENV="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/java-pkg-extra-env"
  128. declare -- JAVA_PKG_EXTRA_ENV_VARS=""
  129. declare -- JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3 "
  130. declare -- JAVA_PKG_OPTIONAL_DEPEND_FILE="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/java-pkg-optional-depend"
  131. declare -- JAVA_PKG_OPT_USE="java"
  132. declare -- JAVA_PKG_QA_VIOLATIONS="0"
  133. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  134. declare -x KERNEL="linux"
  135. declare -x KERNEL_ABI="amd64"
  136. declare -x KEYWORDS="alpha amd64 arm hppa ~ia64 ~mips ppc ppc64 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd"
  137. declare -x LADSPA_PATH="/usr/lib64/ladspa"
  138. declare -x LANG="en_US.UTF-8"
  139. declare -x LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
  140. declare -x LC_COLLATE="POSIX"
  141. declare -x LC_MESSAGES="C"
  142. declare -x LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
  143. declare -x LDFLAGS_default
  144. declare -x LDFLAGS_x86="-m elf_i386"
  145. declare -x LD_LIBRARY_PATH="/opt/cuda/lib64:"
  146. declare -x LIBDIR_amd64="lib64"
  147. declare -x LIBDIR_amd64_fbsd="lib64"
  148. declare -x LIBDIR_default="lib"
  149. declare -x LIBDIR_ppc="lib32"
  150. declare -x LIBDIR_ppc64="lib64"
  151. declare -x LIBDIR_sparc32="lib32"
  152. declare -x LIBDIR_sparc64="lib64"
  153. declare -x LIBDIR_x86="lib32"
  154. declare -x LIBDIR_x86_fbsd="lib32"
  155. declare -x LIBOPTIONS="-m0644"
  156. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  157. declare -x LICENSE="GPL-2 ISC LGPL-2.1 WTFPL-2"
  158. declare -x MAIL="/var/mail/isi"
  159. declare -x MAKEOPTS="-j9 -l8"
  160. declare -x MANPAGER="manpager"
  161. declare -x MULTILIB_ABIS="amd64 x86"
  162. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  163. 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"
  164. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage)"
  165. declare -- MULTILIB_USEDEP="abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?"
  166. declare -- MY_P="libcaca-0.99.beta19"
  167. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  168. declare -x OFFICE_IMPLEMENTATION="libreoffice"
  169. declare -x OPENCL_PROFILE="nvidia"
  170. declare -x OPENGL_PROFILE="nvidia"
  171. declare -x PAM_KWALLET5_LOGIN="/tmp/kwallet5_isi.socke"
  172. declare -x PAM_KWALLET_LOGIN="/tmp/kwallet_isi.socke"
  173. declare -x PATH="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/python2.7/bin:/usr/lib/portage/python3.5/ebuild-helpers/xattr:/usr/lib/portage/python3.5/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/5.3.0:/opt/cuda/bin"
  174. declare PDEPEND=""
  175. declare -x PHP_TARGETS="php5-6"
  176. declare -x PKG_CONFIG_PATH="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/python2.7/pkgconfig"
  177. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  178. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  179. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/libcaca-0.99_beta19/html")'
  180. declare -x PORTAGE_NICENESS="19"
  181. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc"
  182. 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"
  183. declare -x PROPERTIES=""
  184. declare -x PROVIDE=""
  185. declare -x PYTHON="/usr/bin/python2.7"
  186. declare -x PYTHONDONTWRITEBYTECODE="1"
  187. declare -x PYTHON_ABIS="2.7 3.4 3.5"
  188. declare -a PYTHON_COMPAT='([0]="python2_7")'
  189. declare -- PYTHON_DEPS="python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)]"
  190. declare -- PYTHON_REQUIRED_USE="python_targets_python2_7"
  191. declare -x PYTHON_SINGLE_TARGET="python3_4"
  192. declare -x PYTHON_TARGETS="python2_7"
  193. declare -- PYTHON_USEDEP="python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)"
  194. declare -x QEMU_SOFTMMU_TARGETS="i386 x86_64"
  195. declare -x QEMU_USER_TARGETS="i386 x86_64"
  196. declare -x QT_GRAPHICSSYSTEM="raster"
  197. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins"
  198. declare RDEPEND="imlib? ( >=media-libs/imlib2-1.4.6-r2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  199.     mono? ( dev-lang/mono )
  200.     ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  201.     opengl? (
  202.         >=virtual/glu-9.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  203.         >=virtual/opengl-7.0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  204.         >=media-libs/freeglut-2.8.1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  205.         truetype? ( >=media-libs/ftgl-2.1.3_rc5 )
  206.     )
  207.     python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),python_single_target_python2_7(+)] )
  208.     ruby? (  ruby_targets_ruby21? ( dev-lang/ruby:2.1 ) ruby_targets_ruby22? ( dev-lang/ruby:2.2 ) ruby_targets_ruby23? ( dev-lang/ruby:2.3 ) ruby_targets_ruby24? ( dev-lang/ruby:2.4 ) )
  209.     slang? ( >=sys-libs/slang-2.2.4-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  210.     X? ( >=x11-libs/libX11-1.6.2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] >=x11-libs/libXt-1.1.4[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  211.     java? ( >=virtual/jre-1.5 ) java? ( >=dev-java/java-config-2.2.0-r3  )"
  212. declare REPOSITORY
  213. declare REQUIRED_USE="
  214.     python? ( python_targets_python2_7 )
  215.      "
  216. declare -x RESTRICT=""
  217. 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}\""
  218. declare -- RUBY_OPTIONAL="yes"
  219. declare -x RUBY_TARGETS="ruby21 ruby22 ruby23 ruby24"
  220. declare -- RUBY_TARGETS_PREFERENCE="ruby22 ruby21 ruby23 ruby24"
  221. declare -x R_HOME="/usr/lib64/R"
  222. declare -x S="/var/tmp/portage/media-libs/libcaca-0.99_beta19/work/libcaca-0.99.beta19"
  223. declare -x SANDBOX_DEBUG="0"
  224. declare -x SANDBOX_DENY=""
  225. declare -x SANDBOX_PREDICT="/var/tmp/portage/media-libs/libcaca-0.99_beta19/homedir:/dev/crypto:/dev/random:/proc/self/coredump_filter:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  226. declare -x SANDBOX_READ="/:/var/tmp"
  227. declare -x SANDBOX_VERBOSE="1"
  228. 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/:/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:/var/tmp/:/var/tmp/portage/media-libs/libcaca-0.99_beta19/homedir/.bash_history"
  229. declare -x SESSION_MANAGER="local/blulite:@/tmp/.ICE-unix/3516,unix/blulite:/tmp/.ICE-unix/3516"
  230. declare -x SHELL="/bin/bash"
  231. declare -x SLOT="0"
  232. declare SRC_URI="http://libcaca.zoy.org/files/libcaca/libcaca-0.99.beta19.tar.gz"
  233. declare -x STAGE1_USE="multilib nptl nptlonly unicode"
  234. declare -x SYMLINK_LIB="yes"
  235. declare -x TERMINOLOGY="1"
  236. declare -x USE="X abi_x86_64 amd64 cxx elibc_glibc kernel_linux ncurses opengl python python_targets_python2_7 ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23 ruby_targets_ruby24 truetype userland_GNU"
  237. declare -x USERLAND="GNU"
  238. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  239. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  240. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 hppa ia64 m68k m68k-mint mips nios2 ppc ppc64 ppc64-linux ppc-aix ppc-macos riscv s390 sh sparc sparc64-solaris sparc-fbsd sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  241. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  242. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  243. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  244. declare -- USE_RUBY="ruby21 ruby22 ruby23 ruby24"
  245. declare -x VARTEXFONTS="/var/tmp/portage/media-libs/libcaca-0.99_beta19/temp/fonts"
  246. declare -x VBOX_APP_HOME="/usr/lib64/virtualbox"
  247. declare -x VIDEO_CARDS="nvidia"
  248. declare -x WANT_AUTOCONF="2.5"
  249. declare -x WANT_AUTOMAKE="1.15"
  250. declare -x WANT_JAVA_CONFIG="2"
  251. declare -x WANT_LIBTOOL="latest"
  252. declare -x XDG_CONFIG_DIRS="/etc/xdg:/etc/xdg"
  253. declare -x XDG_CURRENT_DESKTOP="XFCE"
  254. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share:/usr/share"
  255. declare -x XDG_MENU_PREFIX="xfce-"
  256. declare -x XDG_RUNTIME_DIR="/var/run/user/1000"
  257. declare -x XDG_SEAT="seat0"
  258. declare -x XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
  259. declare -x XDG_SESSION_CLASS="user"
  260. declare -x XDG_SESSION_COOKIE="blulite-1497372092.356979-1313850614"
  261. declare -x XDG_SESSION_DESKTOP="XFCE"
  262. declare -x XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session1"
  263. declare -x XDG_SESSION_TYPE="x11"
  264. declare -x XDG_VTNR="7"
  265. declare -x XSESSION="sway"
  266. declare -x XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
  267. declare -x XTERM_256_COLORS="1"
  268. declare -- _AUTOTOOLS_ECLASS="1"
  269. declare -- _ELT_NOTED_TMP="true"
  270. declare -- _EPATCH_ECLASS="1"
  271. declare -- _EPUNT_CXX_ECLASS="1"
  272. declare -- _ESTACK_ECLASS="1"
  273. declare -- _EUTILS_ECLASS="1"
  274. declare -- _EUTILS_ECLASSDIR_LOCAL="/usr/portage/eclass"
  275. declare -x _E_DOCDESTTREE_=""
  276. declare -x _E_EXEDESTTREE_=""
  277. declare -- _FLAG_O_MATIC_ECLASS="1"
  278. declare -a _LATEST_AUTOMAKE='([0]="1.15:1.15")'
  279. declare -- _LIBTOOL_ECLASS="1"
  280. declare -- _LTPRUNE_ECLASS="1"
  281. declare -- _MONO_ENV="1"
  282. declare -- _MULTIBUILD="1"
  283. declare -- _MULTILIB_BUILD="1"
  284. declare -- _MULTILIB_ECLASS="1"
  285. declare -a _MULTILIB_FLAGS='([0]="abi_x86_32:x86,x86_fbsd,x86_freebsd,x86_linux,x86_macos,x86_solaris" [1]="abi_x86_64:amd64,amd64_fbsd,x64_freebsd,amd64_linux,x64_macos,x64_solaris" [2]="abi_x86_x32:x32" [3]="abi_mips_n32:n32" [4]="abi_mips_n64:n64" [5]="abi_mips_o32:o32" [6]="abi_ppc_32:ppc,ppc_aix,ppc_macos" [7]="abi_ppc_64:ppc64" [8]="abi_s390_32:s390" [9]="abi_s390_64:s390x")'
  286. declare -a _PYTHON_ALL_IMPLS='([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_4" [5]="python3_5" [6]="python3_6")'
  287. declare -- _PYTHON_SINGLE_R1="1"
  288. declare -a _PYTHON_SUPPORTED_IMPLS='([0]="python2_7")'
  289. declare -a _PYTHON_UNSUPPORTED_IMPLS='([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python3_4" [4]="python3_5" [5]="python3_6")'
  290. declare -- _PYTHON_UTILS_R1="1"
  291. declare -- _RUBY_UTILS="1"
  292. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  293. declare -- _VERSIONATOR_ECLASS="1"
  294. declare -- __AUTOTOOLS_AUTO_DEPEND="yes"
  295. declare -- _libtool_atom=">=sys-devel/libtool-2.4"
  296. declare -- conf="libcaca-0.99_beta19-r0"
  297. declare -- phase_func
  298. ELT_libtool_version ()
  299. {
  300.     ( unset VERSION;
  301.     eval $(grep -e '^[[:space:]]*VERSION=' "$1");
  302.     echo "${VERSION:-0}" )
  303. }
  304. ELT_try_and_apply_patch ()
  305. {
  306.     local ret=0;
  307.     local file=$1;
  308.     local patch=$2;
  309.     local src=$3;
  310.     local disp="${src} patch";
  311.     local log="${T}/elibtool.log";
  312.     if [[ -z ${_ELT_NOTED_TMP} ]]; then
  313.         _ELT_NOTED_TMP=true;
  314.         printf 'temp patch: %s\n' "${patch}" > "${log}";
  315.     fi;
  316.     printf '\nTrying %s\n' "${disp}" >> "${log}";
  317.     if [[ ! -e ${file} ]]; then
  318.         echo "File not found: ${file}" >> "${log}";
  319.         return 1;
  320.     fi;
  321.     local perms="$(find ${file} -maxdepth 0 -printf '%m')";
  322.     if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1; then
  323.         einfo "  Applying ${disp} ...";
  324.         patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1;
  325.         ret=$?;
  326.         export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}";
  327.     else
  328.         ret=1;
  329.     fi;
  330.     chmod "${perms}" "${file}";
  331.     return "${ret}"
  332. }
  333. ELT_walk_patches ()
  334. {
  335.     local patch tmp;
  336.     local ret=1;
  337.     local file=$1;
  338.     local patch_set=$2;
  339.     local patch_dir="$(libtool_elt_patch_dir)/${patch_set}";
  340.     local rem_int_dep=$3;
  341.     [[ -z ${patch_set} ]] && return 1;
  342.     [[ ! -d ${patch_dir} ]] && return 1;
  343.     local sed_args=(-e "s:@GENTOO_LIBDIR@:$(get_libdir):g");
  344.     if [[ -n ${rem_int_dep} ]]; then
  345.         sed_args+=(-e "s|@REM_INT_DEP@|${rem_int_dep}|g");
  346.     fi;
  347.     pushd "$(libtool_elt_patch_dir)" > /dev/null || die;
  348.     for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r);
  349.     do
  350.         tmp="${T}/libtool-elt.patch";
  351.         sed "${sed_args[@]}" "${patch}" > "${tmp}" || die;
  352.         if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}"; then
  353.             ret=0;
  354.             break;
  355.         fi;
  356.     done;
  357.     popd > /dev/null;
  358.     return ${ret}
  359. }
  360. PYTHON ()
  361. {
  362.     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"
  363. }
  364. VER_major ()
  365. {
  366.     [[ -z $1 ]] && return 1;
  367.     local VER=$@;
  368.     echo "${VER%%[^[:digit:]]*}"
  369. }
  370. VER_micro ()
  371. {
  372.     [[ -z $1 ]] && return 1;
  373.     local VER=$@;
  374.     VER=${VER#*.*.};
  375.     echo "${VER%%[^[:digit:]]*}"
  376. }
  377. VER_minor ()
  378. {
  379.     [[ -z $1 ]] && return 1;
  380.     local VER=$@;
  381.     VER=${VER#*.};
  382.     echo "${VER%%[^[:digit:]]*}"
  383. }
  384. VER_to_int ()
  385. {
  386.     [[ -z $1 ]] && return 1;
  387.     local VER_MAJOR=$(VER_major "$1");
  388.     local VER_MINOR=$(VER_minor "$1");
  389.     local VER_MICRO=$(VER_micro "$1");
  390.     local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ));
  391.     if [[ ${VER_int} -ge 65536 ]]; then
  392.         echo "${VER_int}";
  393.         return 0;
  394.     fi;
  395.     echo 1;
  396.     return 1
  397. }
  398. __eapi6_src_install ()
  399. {
  400.     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  401.         emake DESTDIR="${D}" install;
  402.     fi;
  403.     einstalldocs
  404. }
  405. __eapi6_src_prepare ()
  406. {
  407.     if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  408.         [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}";
  409.     else
  410.         if [[ -n ${PATCHES} ]]; then
  411.             eapply ${PATCHES};
  412.         fi;
  413.     fi;
  414.     eapply_user
  415. }
  416. _at_uses_autoheader ()
  417. {
  418.     _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  419. }
  420. _at_uses_automake ()
  421. {
  422.     _at_uses_pkg AM_INIT_AUTOMAKE
  423. }
  424. _at_uses_gettext ()
  425. {
  426.     _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  427. }
  428. _at_uses_glibgettext ()
  429. {
  430.     _at_uses_pkg AM_GLIB_GNU_GETTEXT
  431. }
  432. _at_uses_gnomedoc ()
  433. {
  434.     _at_uses_pkg GNOME_DOC_INIT
  435. }
  436. _at_uses_gtkdoc ()
  437. {
  438.     _at_uses_pkg GTK_DOC_CHECK
  439. }
  440. _at_uses_intltool ()
  441. {
  442.     _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  443. }
  444. _at_uses_libltdl ()
  445. {
  446.     _at_uses_pkg LT_CONFIG_LTDL_DIR
  447. }
  448. _at_uses_libtool ()
  449. {
  450.     _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  451. }
  452. _at_uses_pkg ()
  453. {
  454.     if [[ -n $(autotools_check_macro "$@") ]]; then
  455.         return 0;
  456.     else
  457.         local macro args=();
  458.         for macro in "$@";
  459.         do
  460.             args+=(-e "^[[:space:]]*${macro}\>");
  461.         done;
  462.         egrep -q "${args[@]}" configure.??;
  463.     fi
  464. }
  465. _automake_version ()
  466. {
  467.     autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  468. }
  469. _autotools_m4dir_include ()
  470. {
  471.     local x include_opts flag;
  472.     [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  473.     for x in "$@";
  474.     do
  475.         case ${x} in
  476.             -${flag})
  477.  
  478.             ;;
  479.             *)
  480.                 [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  481.                 include_opts+=" -${flag} ${x}"
  482.             ;;
  483.         esac;
  484.     done;
  485.     echo ${include_opts}
  486. }
  487. _clang_fullversion ()
  488. {
  489.     local ver="$1";
  490.     shift;
  491.     set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  492.     eval echo "$ver"
  493. }
  494. _each_ruby_check_install ()
  495. {
  496.     local scancmd=scanelf;
  497.     [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho;
  498.     has "${EAPI}" 2 && ! use prefix && EPREFIX=;
  499.     local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]');
  500.     local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null);
  501.     local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]');
  502.     local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]');
  503.     [[ -z ${libruby_soname} ]] && return 0;
  504.     ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" | fgrep -v "${libruby_soname}" | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log;
  505.     if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
  506.         ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}";
  507.         ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log );
  508.         die "Missing links to ${libruby_soname}";
  509.     fi
  510. }
  511. _elibtoolize ()
  512. {
  513.     local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  514.     if [[ $1 == "--auto-ltdl" ]]; then
  515.         shift;
  516.         _at_uses_libltdl && set -- "$@" --ltdl;
  517.     fi;
  518.     [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  519.     autotools_run_tool ${LIBTOOLIZE} "$@"
  520. }
  521. _epatch_draw_line ()
  522. {
  523.     [[ -z $1 ]] && set "$(printf "%65s" '')";
  524.     echo "${1//?/=}"
  525. }
  526. _eutils_eprefix_init ()
  527. {
  528.     has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
  529. }
  530. _filter-hardened ()
  531. {
  532.     local f;
  533.     for f in "$@";
  534.     do
  535.         case "${f}" in
  536.             -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  537.                 gcc-specs-pie || continue;
  538.                 if ! is-flagq -nopie && ! is-flagq -no-pie; then
  539.                     if test-flags -nopie > /dev/null; then
  540.                         append-flags -nopie;
  541.                     else
  542.                         append-flags -no-pie;
  543.                     fi;
  544.                 fi
  545.             ;;
  546.             -fstack-protector)
  547.                 gcc-specs-ssp || continue;
  548.                 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  549.             ;;
  550.             -fstack-protector-all)
  551.                 gcc-specs-ssp-to-all || continue;
  552.                 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  553.             ;;
  554.             -fno-strict-overflow)
  555.                 gcc-specs-nostrict || continue;
  556.                 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  557.             ;;
  558.         esac;
  559.     done
  560. }
  561. _filter-var ()
  562. {
  563.     local f x var=$1 new=();
  564.     shift;
  565.     for f in ${!var};
  566.     do
  567.         for x in "$@";
  568.         do
  569.             [[ ${f} == ${x} ]] && continue 2;
  570.         done;
  571.         new+=("${f}");
  572.     done;
  573.     eval export ${var}=\""${new[*]}"\"
  574. }
  575. _gcc-install-dir ()
  576. {
  577.     echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |      awk '$1=="install:" {print $2}')"
  578. }
  579. _gcc-specs-directive_raw ()
  580. {
  581.     local cc=$(tc-getCC);
  582.     local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  583.     ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  584. $1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
  585.     outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  586.     spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  587.     { spec=spec $0 }
  588. END { print spec }';
  589.     return 0
  590. }
  591. _gcc-specs-exists ()
  592. {
  593.     [[ -f $(_gcc-install-dir)/$1 ]]
  594. }
  595. _gcc_fullversion ()
  596. {
  597.     local ver="$1";
  598.     shift;
  599.     set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  600.     eval echo "$ver"
  601. }
  602. _iconins ()
  603. {
  604.     ( local funcname=$1;
  605.     shift;
  606.     local size dir;
  607.     local context=apps;
  608.     local theme=hicolor;
  609.     while [[ $# -gt 0 ]]; do
  610.         case $1 in
  611.             -s | --size)
  612.                 if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  613.                     size=${2%%x*};
  614.                 else
  615.                     size=${2};
  616.                 fi;
  617.                 case ${size} in
  618.                     16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  619.                         size=${size}x${size}
  620.                     ;;
  621.                     scalable)
  622.  
  623.                     ;;
  624.                     *)
  625.                         eerror "${size} is an unsupported icon size!";
  626.                         exit 1
  627.                     ;;
  628.                 esac;
  629.                 shift 2
  630.             ;;
  631.             -t | --theme)
  632.                 theme=${2};
  633.                 shift 2
  634.             ;;
  635.             -c | --context)
  636.                 context=${2};
  637.                 shift 2
  638.             ;;
  639.             *)
  640.                 if [[ -z ${size} ]]; then
  641.                     insinto /usr/share/pixmaps;
  642.                 else
  643.                     insinto /usr/share/icons/${theme}/${size}/${context};
  644.                 fi;
  645.                 if [[ ${funcname} == doicon ]]; then
  646.                     if [[ -f $1 ]]; then
  647.                         doins "${1}";
  648.                     else
  649.                         if [[ -d $1 ]]; then
  650.                             shopt -s nullglob;
  651.                             doins "${1}"/*.{png,svg};
  652.                             shopt -u nullglob;
  653.                         else
  654.                             eerror "${1} is not a valid file/directory!";
  655.                             exit 1;
  656.                         fi;
  657.                     fi;
  658.                 else
  659.                     break;
  660.                 fi;
  661.                 shift 1
  662.             ;;
  663.         esac;
  664.     done;
  665.     if [[ ${funcname} == newicon ]]; then
  666.         newins "$@";
  667.     fi ) || die
  668. }
  669. _is_flagq ()
  670. {
  671.     local x var;
  672.     eval var=\""\${$1[*]}"\";
  673.     for x in ${var};
  674.     do
  675.         [[ ${x} == $2 ]] && return 0;
  676.     done;
  677.     return 1
  678. }
  679. _multibuild_run ()
  680. {
  681.     local i=1;
  682.     while [[ ${!i} == _* ]]; do
  683.         (( i += 1 ));
  684.     done;
  685.     [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  686.     "${@}"
  687. }
  688. _multilib_multibuild_wrapper ()
  689. {
  690.     debug-print-function ${FUNCNAME} "${@}";
  691.     local ABI=${MULTIBUILD_VARIANT#*.};
  692.     local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  693.     multilib_toolchain_setup "${ABI}";
  694.     readonly ABI;
  695.     "${@}"
  696. }
  697. _python_check_dead_variables ()
  698. {
  699.     local v;
  700.     for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  701.     do
  702.         if [[ -n ${!v} ]]; then
  703.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  704.         fi;
  705.     done;
  706.     for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  707.     do
  708.         if [[ -n ${!v} ]]; then
  709.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  710.         fi;
  711.     done;
  712.     for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  713.     do
  714.         if [[ -n ${!v} ]]; then
  715.             die "${v} is invalid for python-r1 suite";
  716.         fi;
  717.     done;
  718.     for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  719.     do
  720.         if [[ -n ${!v} ]]; then
  721.             die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  722.         fi;
  723.     done;
  724.     if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  725.         die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  726.     fi;
  727.     for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  728.     do
  729.         if [[ -n ${!v} ]]; then
  730.             die "${v} is invalid for python-r1 suite";
  731.         fi;
  732.     done
  733. }
  734. _python_check_locale_sanity ()
  735. {
  736.     local -x LC_ALL=${1};
  737.     local IFS=;
  738.     local lc=({a..z});
  739.     local uc=({A..Z});
  740.     local input="${lc[*]}${uc[*]}";
  741.     local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  742.     [[ ${output} == "${uc[*]}${lc[*]}" ]]
  743. }
  744. _python_impl_matches ()
  745. {
  746.     [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  747.     local impl=${1} pattern;
  748.     shift;
  749.     for pattern in "$@";
  750.     do
  751.         if [[ ${pattern} == -2 ]]; then
  752.             ! python_is_python3 "${impl}";
  753.             return;
  754.         else
  755.             if [[ ${pattern} == -3 ]]; then
  756.                 python_is_python3 "${impl}";
  757.                 return;
  758.             else
  759.                 if [[ ${impl/./_} == ${pattern/./_} ]]; then
  760.                     return 0;
  761.                 fi;
  762.             fi;
  763.         fi;
  764.     done;
  765.     return 1
  766. }
  767. _python_impl_supported ()
  768. {
  769.     debug-print-function ${FUNCNAME} "${@}";
  770.     [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  771.     local impl=${1};
  772.     case "${impl}" in
  773.         python2_7 | python3_[456] | jython2_7)
  774.             return 0
  775.         ;;
  776.         pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  777.             return 1
  778.         ;;
  779.         pypy | pypy3)
  780.             if [[ ${EAPI:-0} == [01234] ]]; then
  781.                 die "PyPy is supported in EAPI 5 and newer only.";
  782.             fi
  783.         ;;
  784.         *)
  785.             [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  786.             die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  787.         ;;
  788.     esac
  789. }
  790. _python_ln_rel ()
  791. {
  792.     debug-print-function ${FUNCNAME} "${@}";
  793.     local target=${1};
  794.     local symname=${2};
  795.     local tgpath=${target%/*}/;
  796.     local sympath=${symname%/*}/;
  797.     local rel_target=;
  798.     while [[ -n ${sympath} ]]; do
  799.         local tgseg= symseg=;
  800.         while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  801.             tgseg=${tgpath%%/*};
  802.             tgpath=${tgpath#${tgseg}/};
  803.         done;
  804.         while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  805.             symseg=${sympath%%/*};
  806.             sympath=${sympath#${symseg}/};
  807.         done;
  808.         if [[ ${tgseg} != ${symseg} ]]; then
  809.             rel_target=../${rel_target}${tgseg:+${tgseg}/};
  810.         fi;
  811.     done;
  812.     rel_target+=${tgpath}${target##*/};
  813.     debug-print "${FUNCNAME}: ${symname} -> ${target}";
  814.     debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  815.     ln -fs "${rel_target}" "${symname}"
  816. }
  817. _python_set_impls ()
  818. {
  819.     local i;
  820.     if ! declare -p PYTHON_COMPAT &> /dev/null; then
  821.         die 'PYTHON_COMPAT not declared.';
  822.     fi;
  823.     if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  824.         die 'PYTHON_COMPAT must be an array.';
  825.     fi;
  826.     for i in "${PYTHON_COMPAT[@]}";
  827.     do
  828.         _python_impl_supported "${i}";
  829.     done;
  830.     local supp=() unsupp=();
  831.     for i in "${_PYTHON_ALL_IMPLS[@]}";
  832.     do
  833.         if has "${i}" "${PYTHON_COMPAT[@]}"; then
  834.             supp+=("${i}");
  835.         else
  836.             unsupp+=("${i}");
  837.         fi;
  838.     done;
  839.     if [[ ! -n ${supp[@]} ]]; then
  840.         die "No supported implementation in PYTHON_COMPAT.";
  841.     fi;
  842.     if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  843.         if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  844.             eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  845.             eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  846.             eerror "Now   : ${supp[*]}";
  847.             die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  848.         fi;
  849.         if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  850.             eerror "Unsupported impls changed between inherits!";
  851.             eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  852.             eerror "Now   : ${unsupp[*]}";
  853.             die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  854.         fi;
  855.     else
  856.         _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  857.         _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  858.         readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  859.     fi
  860. }
  861. _ruby_apply_patches ()
  862. {
  863.     case ${EAPI} in
  864.         2 | 3 | 4 | 5)
  865.             for patch in "${RUBY_PATCHES[@]}";
  866.             do
  867.                 if [ -f "${patch}" ]; then
  868.                     epatch "${patch}";
  869.                 else
  870.                     if [ -f "${FILESDIR}/${patch}" ]; then
  871.                         epatch "${FILESDIR}/${patch}";
  872.                     else
  873.                         die "Cannot find patch ${patch}";
  874.                     fi;
  875.                 fi;
  876.             done
  877.         ;;
  878.         6)
  879.             if [[ -n ${RUBY_PATCHES[@]} ]]; then
  880.                 eqawarn "RUBY_PATCHES is no longer supported, use PATCHES instead";
  881.             fi
  882.         ;;
  883.     esac;
  884.     type all_ruby_prepare &> /dev/null && all_ruby_prepare
  885. }
  886. _ruby_atoms_samelib ()
  887. {
  888.     local atoms=$(_ruby_atoms_samelib_generic "$*");
  889.     for _ruby_implementation in $(_ruby_get_all_impls);
  890.     do
  891.         echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}";
  892.     done
  893. }
  894. _ruby_atoms_samelib_generic ()
  895. {
  896.     eshopts_push -o noglob;
  897.     echo "RUBYTARGET? (";
  898.     for token in $*;
  899.     do
  900.         case "$token" in
  901.             "||" | "(" | ")" | *"?")
  902.                 echo "${token}"
  903.             ;;
  904.             *])
  905.                 echo "${token%[*}[RUBYTARGET,${token/*[}"
  906.             ;;
  907.             *)
  908.                 echo "${token}[RUBYTARGET]"
  909.             ;;
  910.         esac;
  911.     done;
  912.     echo ")";
  913.     eshopts_pop
  914. }
  915. _ruby_each_implementation ()
  916. {
  917.     local invoked=no;
  918.     for _ruby_implementation in $(_ruby_get_all_impls);
  919.     do
  920.         use ruby_targets_${_ruby_implementation} || continue;
  921.         RUBY=$(ruby_implementation_command ${_ruby_implementation});
  922.         invoked=yes;
  923.         if [[ -n "$1" ]]; then
  924.             _ruby_invoke_environment ${_ruby_implementation} "$@";
  925.         fi;
  926.         unset RUBY;
  927.     done;
  928.     if [[ ${invoked} == "no" ]]; then
  929.         eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf.";
  930.         eerror "Compatible targets for this package are: $(_ruby_get_all_impls)";
  931.         eerror;
  932.         eerror "See https://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information.";
  933.         eerror;
  934.         die "No compatible Ruby target selected.";
  935.     fi
  936. }
  937. _ruby_get_all_impls ()
  938. {
  939.     local i;
  940.     for i in ${USE_RUBY};
  941.     do
  942.         case ${i} in
  943.             ruby19 | ruby20 | jruby)
  944.  
  945.             ;;
  946.             *)
  947.                 echo ${i}
  948.             ;;
  949.         esac;
  950.     done
  951. }
  952. _ruby_implementation_depend ()
  953. {
  954.     local rubypn=;
  955.     local rubyslot=;
  956.     case $1 in
  957.         ruby18)
  958.             rubypn="dev-lang/ruby";
  959.             rubyslot=":1.8"
  960.         ;;
  961.         ruby19)
  962.             rubypn="dev-lang/ruby";
  963.             rubyslot=":1.9"
  964.         ;;
  965.         ruby20)
  966.             rubypn="dev-lang/ruby";
  967.             rubyslot=":2.0"
  968.         ;;
  969.         ruby21)
  970.             rubypn="dev-lang/ruby";
  971.             rubyslot=":2.1"
  972.         ;;
  973.         ruby22)
  974.             rubypn="dev-lang/ruby";
  975.             rubyslot=":2.2"
  976.         ;;
  977.         ruby23)
  978.             rubypn="dev-lang/ruby";
  979.             rubyslot=":2.3"
  980.         ;;
  981.         ruby24)
  982.             rubypn="dev-lang/ruby";
  983.             rubyslot=":2.4"
  984.         ;;
  985.         ree18)
  986.             rubypn="dev-lang/ruby-enterprise";
  987.             rubyslot=":1.8"
  988.         ;;
  989.         jruby)
  990.             rubypn="dev-java/jruby";
  991.             rubyslot=""
  992.         ;;
  993.         rbx)
  994.             rubypn="dev-lang/rubinius";
  995.             rubyslot=""
  996.         ;;
  997.         *)
  998.             die "$1: unknown Ruby implementation"
  999.         ;;
  1000.     esac;
  1001.     echo "$2${rubypn}$3${rubyslot}"
  1002. }
  1003. _ruby_invoke_environment ()
  1004. {
  1005.     old_S=${S};
  1006.     case ${EAPI} in
  1007.         4 | 5 | 6)
  1008.             if [ -z "${RUBY_S}" ]; then
  1009.                 sub_S=${P};
  1010.             else
  1011.                 sub_S=${RUBY_S};
  1012.             fi
  1013.         ;;
  1014.         *)
  1015.             sub_S=${S#${WORKDIR}/}
  1016.         ;;
  1017.     esac;
  1018.     if [[ "${sub_S}" = *"*"* ]]; then
  1019.         case ${EAPI} in
  1020.             2 | 3)
  1021.                 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
  1022.             ;;
  1023.         esac;
  1024.         pushd "${WORKDIR}"/all &> /dev/null || die;
  1025.         sub_S=(${sub_S});
  1026.         if [[ ${#sub_S[@]} -gt 1 ]]; then
  1027.             die "sub_S did expand to multiple paths: ${sub_S[*]}";
  1028.         fi;
  1029.         popd &> /dev/null || die;
  1030.     fi;
  1031.     environment=$1;
  1032.     shift;
  1033.     my_WORKDIR="${WORKDIR}"/${environment};
  1034.     S="${my_WORKDIR}"/"${sub_S}";
  1035.     if [[ -d "${S}" ]]; then
  1036.         pushd "$S" &> /dev/null || die;
  1037.     else
  1038.         if [[ -d "${my_WORKDIR}" ]]; then
  1039.             pushd "${my_WORKDIR}" &> /dev/null || die;
  1040.         else
  1041.             pushd "${WORKDIR}" &> /dev/null || die;
  1042.         fi;
  1043.     fi;
  1044.     ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment";
  1045.     "$@";
  1046.     popd &> /dev/null || die;
  1047.     S=${old_S}
  1048. }
  1049. _ruby_source_copy ()
  1050. {
  1051.     cp -prlP all ${_ruby_implementation} || die "Unable to copy ${_ruby_implementation} environment"
  1052. }
  1053. _ruby_wrap_conditions ()
  1054. {
  1055.     local conditions="$1";
  1056.     local atoms="$2";
  1057.     for condition in $conditions;
  1058.     do
  1059.         atoms="${condition}? ( ${atoms} )";
  1060.     done;
  1061.     echo "$atoms"
  1062. }
  1063. _tc-getPROG ()
  1064. {
  1065.     local tuple=$1;
  1066.     local v var vars=$2;
  1067.     local prog=($3);
  1068.     var=${vars%% *};
  1069.     for v in ${vars};
  1070.     do
  1071.         if [[ -n ${!v} ]]; then
  1072.             export ${var}="${!v}";
  1073.             echo "${!v}";
  1074.             return 0;
  1075.         fi;
  1076.     done;
  1077.     local search=;
  1078.     [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  1079.     [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  1080.     [[ -n ${search} ]] && prog[0]=${search##*/};
  1081.     export ${var}="${prog[*]}";
  1082.     echo "${!var}"
  1083. }
  1084. all-flag-vars ()
  1085. {
  1086.     echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  1087. }
  1088. append-cflags ()
  1089. {
  1090.     [[ $# -eq 0 ]] && return 0;
  1091.     export CFLAGS+=" $*";
  1092.     return 0
  1093. }
  1094. append-cppflags ()
  1095. {
  1096.     [[ $# -eq 0 ]] && return 0;
  1097.     export CPPFLAGS+=" $*";
  1098.     return 0
  1099. }
  1100. append-cxxflags ()
  1101. {
  1102.     [[ $# -eq 0 ]] && return 0;
  1103.     export CXXFLAGS+=" $*";
  1104.     return 0
  1105. }
  1106. append-fflags ()
  1107. {
  1108.     [[ $# -eq 0 ]] && return 0;
  1109.     export FFLAGS+=" $*";
  1110.     export FCFLAGS+=" $*";
  1111.     return 0
  1112. }
  1113. append-flags ()
  1114. {
  1115.     [[ $# -eq 0 ]] && return 0;
  1116.     case " $* " in
  1117.         *' '-[DIU]*)
  1118.             eqawarn 'please use append-cppflags for preprocessor flags'
  1119.         ;;
  1120.         *' '-L* | *' '-Wl,*)
  1121.             eqawarn 'please use append-ldflags for linker flags'
  1122.         ;;
  1123.     esac;
  1124.     append-cflags "$@";
  1125.     append-cxxflags "$@";
  1126.     append-fflags "$@";
  1127.     return 0
  1128. }
  1129. append-ldflags ()
  1130. {
  1131.     [[ $# -eq 0 ]] && return 0;
  1132.     local flag;
  1133.     for flag in "$@";
  1134.     do
  1135.         [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1136.     done;
  1137.     export LDFLAGS="${LDFLAGS} $*";
  1138.     return 0
  1139. }
  1140. append-lfs-flags ()
  1141. {
  1142.     [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1143.     append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1144. }
  1145. append-libs ()
  1146. {
  1147.     [[ $# -eq 0 ]] && return 0;
  1148.     local flag;
  1149.     for flag in "$@";
  1150.     do
  1151.         if [[ -z "${flag// }" ]]; then
  1152.             eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1153.             continue;
  1154.         fi;
  1155.         case $flag in
  1156.             -[lL]*)
  1157.                 export LIBS="${LIBS} ${flag}"
  1158.             ;;
  1159.             -*)
  1160.                 eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1161.                 export LIBS="${LIBS} ${flag}"
  1162.             ;;
  1163.             *)
  1164.                 export LIBS="${LIBS} -l${flag}"
  1165.             ;;
  1166.         esac;
  1167.     done;
  1168.     return 0
  1169. }
  1170. autotools_check_macro ()
  1171. {
  1172.     [[ -f configure.ac || -f configure.in ]] || return 0;
  1173.     local trace_file=".__autoconf_trace_data";
  1174.     if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  1175.         WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  1176.     fi;
  1177.     local macro args=();
  1178.     for macro in "$@";
  1179.     do
  1180.         has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  1181.         args+=(-e ":${macro}:");
  1182.     done;
  1183.     grep "${args[@]}" ${trace_file}
  1184. }
  1185. autotools_check_macro_val ()
  1186. {
  1187.     local macro scan_out;
  1188.     for macro in "$@";
  1189.     do
  1190.         autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  1191.                     if (match($0, macro ":(.*)$", res))
  1192.                         print res[1]
  1193.                 }' | uniq;
  1194.     done;
  1195.     return 0
  1196. }
  1197. autotools_env_setup ()
  1198. {
  1199.     if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  1200.         local pv;
  1201.         for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  1202.         do
  1203.             ROOT=/ has_version "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}";
  1204.         done;
  1205.         [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  1206.     fi;
  1207.     [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  1208. }
  1209. autotools_m4dir_include ()
  1210. {
  1211.     _autotools_m4dir_include ${AT_M4DIR}
  1212. }
  1213. autotools_m4sysdir_include ()
  1214. {
  1215.     local paths=($(eval echo ${AT_SYS_M4DIR}));
  1216.     if [[ ${#paths[@]} -eq 0 && -n ${SYSROOT} ]]; then
  1217.         local path="${SYSROOT}/usr/share/aclocal";
  1218.         [[ -d ${path} ]] && paths+=("${path}");
  1219.     fi;
  1220.     _autotools_m4dir_include "${paths[@]}"
  1221. }
  1222. autotools_run_tool ()
  1223. {
  1224.     local autofail=true m4flags=false missing_ok=false return_output=false;
  1225.     while [[ -n $1 ]]; do
  1226.         case $1 in
  1227.             --at-no-fail)
  1228.                 autofail=false
  1229.             ;;
  1230.             --at-m4flags)
  1231.                 m4flags=true
  1232.             ;;
  1233.             --at-missing)
  1234.                 missing_ok=true
  1235.             ;;
  1236.             --at-output)
  1237.                 return_output=true
  1238.             ;;
  1239.             *)
  1240.                 break
  1241.             ;;
  1242.         esac;
  1243.         shift;
  1244.     done;
  1245.     if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  1246.         ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  1247.     fi;
  1248.     if ${missing_ok} && ! type -P ${1} > /dev/null; then
  1249.         einfo "Skipping '$*' due $1 not installed";
  1250.         return 0;
  1251.     fi;
  1252.     autotools_env_setup;
  1253.     local STDERR_TARGET="${T}/${1##*/}.out";
  1254.     if [[ -e ${STDERR_TARGET} ]]; then
  1255.         local i=1;
  1256.         while :; do
  1257.             STDERR_TARGET="${T}/${1##*/}-${i}.out";
  1258.             [[ -e ${STDERR_TARGET} ]] || break;
  1259.             : $(( i++ ));
  1260.         done;
  1261.     fi;
  1262.     if ${m4flags}; then
  1263.         set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  1264.     fi;
  1265.     if ${return_output}; then
  1266.         "$@";
  1267.         return;
  1268.     fi;
  1269.     printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  1270.     ebegin "Running $@";
  1271.     "$@" >> "${STDERR_TARGET}" 2>&1;
  1272.     if ! eend $? && ${autofail}; then
  1273.         echo;
  1274.         eerror "Failed Running $1 !";
  1275.         eerror;
  1276.         eerror "Include in your bugreport the contents of:";
  1277.         eerror;
  1278.         eerror "  ${STDERR_TARGET}";
  1279.         echo;
  1280.         die "Failed Running $1 !";
  1281.     fi
  1282. }
  1283. built_with_use ()
  1284. {
  1285.     _eutils_eprefix_init;
  1286.     local hidden="no";
  1287.     if [[ $1 == "--hidden" ]]; then
  1288.         hidden="yes";
  1289.         shift;
  1290.     fi;
  1291.     local missing_action="die";
  1292.     if [[ $1 == "--missing" ]]; then
  1293.         missing_action=$2;
  1294.         shift;
  1295.         shift;
  1296.         case ${missing_action} in
  1297.             true | false | die)
  1298.  
  1299.             ;;
  1300.             *)
  1301.                 die "unknown action '${missing_action}'"
  1302.             ;;
  1303.         esac;
  1304.     fi;
  1305.     local opt=$1;
  1306.     [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  1307.     local PKG=$(best_version $1);
  1308.     [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  1309.     shift;
  1310.     local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE;
  1311.     local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE;
  1312.     if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  1313.         case ${missing_action} in
  1314.             true)
  1315.                 return 0
  1316.             ;;
  1317.             false)
  1318.                 return 1
  1319.             ;;
  1320.             die)
  1321.                 die "Unable to determine what USE flags $PKG was built with"
  1322.             ;;
  1323.         esac;
  1324.     fi;
  1325.     if [[ ${hidden} == "no" ]]; then
  1326.         local IUSE_BUILT=($(<"${IUSEFILE}"));
  1327.         local expand;
  1328.         for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  1329.         do
  1330.             if [[ $1 == ${expand}_* ]]; then
  1331.                 expand="";
  1332.                 break;
  1333.             fi;
  1334.         done;
  1335.         if [[ -n ${expand} ]]; then
  1336.             if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  1337.                 case ${missing_action} in
  1338.                     true)
  1339.                         return 0
  1340.                     ;;
  1341.                     false)
  1342.                         return 1
  1343.                     ;;
  1344.                     die)
  1345.                         die "$PKG does not actually support the $1 USE flag!"
  1346.                     ;;
  1347.                 esac;
  1348.             fi;
  1349.         fi;
  1350.     fi;
  1351.     local USE_BUILT=$(<${USEFILE});
  1352.     while [[ $# -gt 0 ]]; do
  1353.         if [[ ${opt} = "-o" ]]; then
  1354.             has $1 ${USE_BUILT} && return 0;
  1355.         else
  1356.             has $1 ${USE_BUILT} || return 1;
  1357.         fi;
  1358.         shift;
  1359.     done;
  1360.     [[ ${opt} = "-a" ]]
  1361. }
  1362. check_license ()
  1363. {
  1364.     die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  1365. }
  1366. clang-fullversion ()
  1367. {
  1368.     _clang_fullversion '$1.$2.$3' "$@"
  1369. }
  1370. clang-major-version ()
  1371. {
  1372.     _clang_fullversion '$1' "$@"
  1373. }
  1374. clang-micro-version ()
  1375. {
  1376.     _clang_fullversion '$3' "$@"
  1377. }
  1378. clang-minor-version ()
  1379. {
  1380.     _clang_fullversion '$2' "$@"
  1381. }
  1382. clang-version ()
  1383. {
  1384.     _clang_fullversion '$1.$2' "$@"
  1385. }
  1386. config_rpath_update ()
  1387. {
  1388.     local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  1389.     [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  1390.     [[ $# -eq 0 ]] && return 0;
  1391.     einfo "Updating all config.rpath files";
  1392.     for dst in "$@";
  1393.     do
  1394.         einfo "   ${dst}";
  1395.         cp "${src}" "${dst}" || die;
  1396.     done
  1397. }
  1398. darwintoolize ()
  1399. {
  1400.     die "Use elibtoolize"
  1401. }
  1402. delete_all_version_separators ()
  1403. {
  1404.     replace_all_version_separators "" "${1}"
  1405. }
  1406. delete_version_separator ()
  1407. {
  1408.     replace_version_separator "${1}" "" "${2}"
  1409. }
  1410. doicon ()
  1411. {
  1412.     _iconins ${FUNCNAME} "$@"
  1413. }
  1414. domenu ()
  1415. {
  1416.     ( local i j ret=0;
  1417.     insinto /usr/share/applications;
  1418.     for i in "$@";
  1419.     do
  1420.         if [[ -f ${i} ]]; then
  1421.             doins "${i}";
  1422.             ((ret+=$?));
  1423.         else
  1424.             if [[ -d ${i} ]]; then
  1425.                 for j in "${i}"/*.desktop;
  1426.                 do
  1427.                     doins "${j}";
  1428.                     ((ret+=$?));
  1429.                 done;
  1430.             else
  1431.                 ((++ret));
  1432.             fi;
  1433.         fi;
  1434.     done;
  1435.     exit ${ret} )
  1436. }
  1437. doruby ()
  1438. {
  1439.     [[ -z ${RUBY} ]] && die "\$RUBY is not set";
  1440.     has "${EAPI}" 2 && ! use prefix && EPREFIX=;
  1441.     ( sitelibdir=$(ruby_rbconfig_value 'sitelibdir');
  1442.     insinto ${sitelibdir#${EPREFIX}};
  1443.     insopts -m 0644;
  1444.     doins "$@" ) || die "failed to install $@"
  1445. }
  1446. eaclocal ()
  1447. {
  1448.     [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  1449. }
  1450. eaclocal_amflags ()
  1451. {
  1452.     local aclocal_opts amflags_file;
  1453.     for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  1454.     do
  1455.         [[ -e ${amflags_file} ]] || continue;
  1456.         autotools_env_setup;
  1457.         aclocal_opts=$(sed -n           "/^ACLOCAL_AMFLAGS[[:space:]]*=/{             # match the first line
  1458.               s:[^=]*=::p;            # then gobble up all escaped lines
  1459.               : nextline /\\\\$/{ n; p; b nextline; }           }" ${amflags_file});
  1460.         eval aclocal_opts=\""${aclocal_opts}"\";
  1461.         break;
  1462.     done;
  1463.     echo ${aclocal_opts}
  1464. }
  1465. eant ()
  1466. {
  1467.     debug-print-function ${FUNCNAME} $*;
  1468.     if [[ ${EBUILD_PHASE} = compile ]]; then
  1469.         java-ant-2_src_configure;
  1470.     fi;
  1471.     if ! has java-ant-2 ${INHERITED}; then
  1472.         local msg="You should inherit java-ant-2 when using eant";
  1473.         java-pkg_announce-qa-violation "${msg}";
  1474.     fi;
  1475.     local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore";
  1476.     java-pkg_init-compiler_;
  1477.     local compiler="${GENTOO_COMPILER}";
  1478.     local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}";
  1479.     local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})";
  1480.     if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
  1481.         die "ANT_BUILD_COMPILER undefined in ${compiler_env}";
  1482.     fi;
  1483.     if [[ ${compiler} != "javac" ]]; then
  1484.         antflags="${antflags} -Dbuild.compiler=${build_compiler}";
  1485.         local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})";
  1486.         if [[ -n ${build_compiler_deps} ]]; then
  1487.             antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})";
  1488.         fi;
  1489.     fi;
  1490.     for arg in "${@}";
  1491.     do
  1492.         if [[ ${arg} = -lib ]]; then
  1493.             if is-java-strict; then
  1494.                 eerror "You should not use the -lib argument to eant because it will fail";
  1495.                 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from";
  1496.                 eerror "or ant properties to make dependencies available.";
  1497.                 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from.";
  1498.                 eerror "split ant (>=dev-java/ant-core-1.7).";
  1499.                 die "eant -lib is deprecated/forbidden";
  1500.             else
  1501.                 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for";
  1502.                 echo "more info.";
  1503.             fi;
  1504.         fi;
  1505.     done;
  1506.     local want_ant_tasks;
  1507.     for i in ${WANT_ANT_TASKS};
  1508.     do
  1509.         if [[ ${i} = */*:* ]]; then
  1510.             i=${i#*/};
  1511.             i=${i%:0};
  1512.             want_ant_tasks+="${i/:/-} ";
  1513.         else
  1514.             want_ant_tasks+="${i} ";
  1515.         fi;
  1516.     done;
  1517.     ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}";
  1518.     ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}";
  1519.     ANT_TASKS="${ANT_TASKS:-none}";
  1520.     if [[ "${ANT_TASKS}" == "all" ]]; then
  1521.         einfo "Using all available ANT_TASKS";
  1522.     else
  1523.         if [[ "${ANT_TASKS}" == "none" ]]; then
  1524.             einfo "Disabling all optional ANT_TASKS";
  1525.         else
  1526.             einfo "Using following ANT_TASKS: ${ANT_TASKS}";
  1527.         fi;
  1528.     fi;
  1529.     export ANT_TASKS;
  1530.     [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug";
  1531.     [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q";
  1532.     local gcp="${EANT_GENTOO_CLASSPATH}";
  1533.     local getjarsarg="";
  1534.     if [[ ${EBUILD_PHASE} = "test" ]]; then
  1535.         antflags="${antflags} -DJunit.present=true";
  1536.         getjarsarg="--with-dependencies";
  1537.         local re="\bant-junit4?([-:]\S+)?\b";
  1538.         [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}";
  1539.     else
  1540.         antflags="${antflags} -Dmaven.test.skip=true";
  1541.     fi;
  1542.     local cp;
  1543.     for atom in ${gcp};
  1544.     do
  1545.         cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})";
  1546.     done;
  1547.     [[ -n ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)";
  1548.     [[ -n ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}";
  1549.     if [[ -n ${cp#:} ]]; then
  1550.         antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"";
  1551.     fi;
  1552.     [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}";
  1553.     debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}";
  1554.     ant ${antflags} "${@}" || die "eant failed"
  1555. }
  1556. eautoconf ()
  1557. {
  1558.     if [[ ! -f configure.ac && ! -f configure.in ]]; then
  1559.         echo;
  1560.         eerror "No configure.{ac,in} present in '${PWD}'!";
  1561.         echo;
  1562.         die "No configure.{ac,in} present!";
  1563.     fi;
  1564.     if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  1565.         eqawarn "This package has a configure.in file which has long been deprecated.  Please";
  1566.         eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  1567.         eqawarn "when it finds this file.  See https://bugs.gentoo.org/426262 for details.";
  1568.     fi;
  1569.     autotools_run_tool --at-m4flags autoconf "$@"
  1570. }
  1571. eautoheader ()
  1572. {
  1573.     _at_uses_autoheader || return 0;
  1574.     autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  1575. }
  1576. eautomake ()
  1577. {
  1578.     local extra_opts=();
  1579.     local makefile_name;
  1580.     for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  1581.     do
  1582.         [[ -f ${makefile_name} ]] && break;
  1583.     done;
  1584.     function _automake_version ()
  1585.     {
  1586.         autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  1587.     };
  1588.     if [[ -z ${makefile_name} ]]; then
  1589.         _at_uses_automake || return 0;
  1590.     else
  1591.         if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  1592.             local used_automake;
  1593.             local installed_automake;
  1594.             installed_automake=$(WANT_AUTOMAKE= _automake_version);
  1595.             used_automake=$(head -n 1 < ${makefile_name%.am}.in |           sed -e 's:.*by automake \(.*\) from .*:\1:');
  1596.             if [[ ${installed_automake} != ${used_automake} ]]; then
  1597.                 ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  1598.                 ewarn "Forcing a full rebuild of the autotools to workaround.";
  1599.                 eautoreconf;
  1600.                 return 0;
  1601.             fi;
  1602.         fi;
  1603.     fi;
  1604.     [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  1605.     case $(_automake_version) in
  1606.         1.4 | 1.4[.-]*)
  1607.  
  1608.         ;;
  1609.         *)
  1610.             extra_opts+=(--force-missing)
  1611.         ;;
  1612.     esac;
  1613.     autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  1614. }
  1615. eautopoint ()
  1616. {
  1617.     autotools_run_tool autopoint "$@"
  1618. }
  1619. eautoreconf ()
  1620. {
  1621.     local x g;
  1622.     if [[ -z ${AT_NO_RECURSIVE} ]]; then
  1623.         for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  1624.         do
  1625.             if [[ -d ${x} ]]; then
  1626.                 pushd "${x}" > /dev/null;
  1627.                 AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  1628.                 popd > /dev/null;
  1629.             fi;
  1630.         done;
  1631.     fi;
  1632.     einfo "Running eautoreconf in '${PWD}' ...";
  1633.     local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  1634.     [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  1635.     local i tools=(glibgettext false "autotools_run_tool glib-gettextize --copy --force" gettext false "autotools_run_tool --at-missing autopoint --force" intltool false "autotools_run_tool intltoolize --automake --copy --force" gtkdoc false "autotools_run_tool --at-missing gtkdocize --copy" gnomedoc false "autotools_run_tool --at-missing gnome-doc-prepare --copy --force" libtool false "_elibtoolize --auto-ltdl --install --copy --force");
  1636.     for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1637.     do
  1638.         if _at_uses_${tools[i]}; then
  1639.             tools[i+1]=true;
  1640.             ${tools[i+2]};
  1641.         fi;
  1642.     done;
  1643.     local rerun_aclocal=false;
  1644.     eaclocal;
  1645.     for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1646.     do
  1647.         if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  1648.             ${tools[i+2]};
  1649.             rerun_aclocal=true;
  1650.         fi;
  1651.     done;
  1652.     ${rerun_aclocal} && eaclocal;
  1653.     if [[ ${WANT_AUTOCONF} = 2.1 ]]; then
  1654.         eautoconf;
  1655.     else
  1656.         eautoconf --force;
  1657.     fi;
  1658.     eautoheader;
  1659.     [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  1660.     if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  1661.         elibtoolize --force "${PWD}";
  1662.     fi;
  1663.     return 0
  1664. }
  1665. ebeep ()
  1666. {
  1667.     ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1668. }
  1669. econf_build ()
  1670. {
  1671.     local CBUILD=${CBUILD:-${CHOST}};
  1672.     tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1673. }
  1674. ecvs_clean ()
  1675. {
  1676.     [[ $# -eq 0 ]] && set -- .;
  1677.     find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  1678.     find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  1679. }
  1680. edos2unix ()
  1681. {
  1682.     [[ $# -eq 0 ]] && return 0;
  1683.     sed -i 's/\r$//' -- "$@" || die
  1684. }
  1685. egit_clean ()
  1686. {
  1687.     [[ $# -eq 0 ]] && set -- .;
  1688.     find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
  1689. }
  1690. einstalldocs ()
  1691. {
  1692.     debug-print-function ${FUNCNAME} "${@}";
  1693.     local dodoc_opts=-r;
  1694.     has ${EAPI} 0 1 2 3 && dodoc_opts=;
  1695.     if ! declare -p DOCS &> /dev/null; then
  1696.         local d;
  1697.         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1698.         do
  1699.             if [[ -s ${d} ]]; then
  1700.                 dodoc "${d}" || die;
  1701.             fi;
  1702.         done;
  1703.     else
  1704.         if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1705.             if [[ -n ${DOCS[@]} ]]; then
  1706.                 dodoc ${dodoc_opts} "${DOCS[@]}" || die;
  1707.             fi;
  1708.         else
  1709.             if [[ -n ${DOCS} ]]; then
  1710.                 dodoc ${dodoc_opts} ${DOCS} || die;
  1711.             fi;
  1712.         fi;
  1713.     fi;
  1714.     if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1715.         if [[ -n ${HTML_DOCS[@]} ]]; then
  1716.             dohtml -r "${HTML_DOCS[@]}" || die;
  1717.         fi;
  1718.     else
  1719.         if [[ -n ${HTML_DOCS} ]]; then
  1720.             dohtml -r ${HTML_DOCS} || die;
  1721.         fi;
  1722.     fi;
  1723.     return 0
  1724. }
  1725. ejavac ()
  1726. {
  1727.     debug-print-function ${FUNCNAME} $*;
  1728.     local compiler_executable;
  1729.     compiler_executable=$(java-pkg_get-javac);
  1730.     local javac_args;
  1731.     javac_args="$(java-pkg_javac-args)";
  1732.     if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  1733.         einfo "Verbose logging for \"${FUNCNAME}\" function";
  1734.         einfo "Compiler executable: ${compiler_executable}";
  1735.         einfo "Extra arguments: ${javac_args}";
  1736.         einfo "Complete command:";
  1737.         einfo "${compiler_executable} ${javac_args} ${@}";
  1738.     fi;
  1739.     ebegin "Compiling";
  1740.     ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
  1741. }
  1742. ejavadoc ()
  1743. {
  1744.     debug-print-function ${FUNCNAME} $*;
  1745.     local javadoc_args="";
  1746.     if java-pkg_is-vm-version-ge "1.8"; then
  1747.         javadoc_args="-Xdoclint:none";
  1748.     fi;
  1749.     if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  1750.         einfo "Verbose logging for \"${FUNCNAME}\" function";
  1751.         einfo "Javadoc executable: javadoc";
  1752.         einfo "Extra arguments: ${javadoc_args}";
  1753.         einfo "Complete command:";
  1754.         einfo "javadoc ${javadoc_args} ${@}";
  1755.     fi;
  1756.     ebegin "Generating JavaDoc";
  1757.     javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
  1758. }
  1759. ejunit ()
  1760. {
  1761.     debug-print-function ${FUNCNAME} $*;
  1762.     ejunit_ "junit" "${@}"
  1763. }
  1764. ejunit4 ()
  1765. {
  1766.     debug-print-function ${FUNCNAME} $*;
  1767.     ejunit_ "junit-4" "${@}"
  1768. }
  1769. ejunit_ ()
  1770. {
  1771.     debug-print-function ${FUNCNAME} $*;
  1772.     local pkgs;
  1773.     if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
  1774.         for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' ');
  1775.         do
  1776.             pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//");
  1777.         done;
  1778.     fi;
  1779.     local junit=${1};
  1780.     shift 1;
  1781.     local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs});
  1782.     if [[ ${1} = -cp || ${1} = -classpath ]]; then
  1783.         cp="${2}:${cp}";
  1784.         shift 2;
  1785.     else
  1786.         cp=".:${cp}";
  1787.     fi;
  1788.     local runner=junit.textui.TestRunner;
  1789.     if [[ "${junit}" == "junit-4" ]]; then
  1790.         runner=org.junit.runner.JUnitCore;
  1791.     fi;
  1792.     debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}";
  1793.     java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
  1794. }
  1795. elibtoolize ()
  1796. {
  1797.     local x;
  1798.     local dirs=();
  1799.     local do_portage="no";
  1800.     local do_reversedeps="yes";
  1801.     local do_only_patches="no";
  1802.     local do_uclibc="yes";
  1803.     local deptoremove=;
  1804.     local do_shallow="no";
  1805.     local force="false";
  1806.     local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm ppc64le";
  1807.     for x in "$@";
  1808.     do
  1809.         case ${x} in
  1810.             --portage)
  1811.                 do_portage="yes"
  1812.             ;;
  1813.             --reverse-deps)
  1814.                 do_reversedeps="yes";
  1815.                 elt_patches+=" fix-relink"
  1816.             ;;
  1817.             --patch-only)
  1818.                 do_only_patches="yes"
  1819.             ;;
  1820.             --remove-internal-dep=*)
  1821.                 deptoremove=${x#--remove-internal-dep=};
  1822.                 [[ -n ${deptoremove} ]] && elt_patches+=" rem-int-dep"
  1823.             ;;
  1824.             --shallow)
  1825.                 do_shallow="yes"
  1826.             ;;
  1827.             --no-uclibc)
  1828.                 do_uclibc="no"
  1829.             ;;
  1830.             --force)
  1831.                 force="true"
  1832.             ;;
  1833.             -*)
  1834.                 eerror "Invalid elibtoolize option: ${x}";
  1835.                 die "elibtoolize called with ${x} ??"
  1836.             ;;
  1837.             *)
  1838.                 dirs+=("${x}")
  1839.             ;;
  1840.         esac;
  1841.     done;
  1842.     [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf";
  1843.     case ${CHOST} in
  1844.         *-aix*)
  1845.             elt_patches+=" hardcode aixrtl"
  1846.         ;;
  1847.         *-darwin*)
  1848.             elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf"
  1849.         ;;
  1850.         *-solaris*)
  1851.             elt_patches+=" sol2-conf sol2-ltmain"
  1852.         ;;
  1853.         *-freebsd*)
  1854.             elt_patches+=" fbsd-conf fbsd-ltconf"
  1855.         ;;
  1856.         *-hpux*)
  1857.             elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc"
  1858.         ;;
  1859.         *-irix*)
  1860.             elt_patches+=" irix-ltmain"
  1861.         ;;
  1862.         *-mint*)
  1863.             elt_patches+=" mint-conf"
  1864.         ;;
  1865.     esac;
  1866.     if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then
  1867.         elt_patches+=" gold-conf";
  1868.     fi;
  1869.     if [[ ${do_shallow} == "yes" ]]; then
  1870.         [[ ${#dirs[@]} -ne 0 ]] && die "Using --shallow with explicit dirs doesn't make sense";
  1871.         [[ -f ${S}/ltmain.sh || -f ${S}/configure ]] && dirs+=("${S}");
  1872.     else
  1873.         [[ ${#dirs[@]} -eq 0 ]] && dirs+=("${S}");
  1874.         dirs=($(find "${dirs[@]}" '(' -name ltmain.sh -o -name configure ')' -printf '%h\n' | sort -u));
  1875.     fi;
  1876.     local d p ret;
  1877.     for d in "${dirs[@]}";
  1878.     do
  1879.         export ELT_APPLIED_PATCHES=;
  1880.         if [[ -f ${d}/.elibtoolized ]]; then
  1881.             ${force} || continue;
  1882.         fi;
  1883.         local outfunc="einfo";
  1884.         [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn";
  1885.         ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/";
  1886.         if [[ ${outfunc} == "ewarn" ]]; then
  1887.             ewarn "  We've already been run in this tree; you should";
  1888.             ewarn "  avoid this if possible (perhaps by filing a bug)";
  1889.         fi;
  1890.         [[ -f ${d}/ltmain.sh ]] && for p in ${elt_patches};
  1891.         do
  1892.             ret=0;
  1893.             case ${p} in
  1894.                 portage)
  1895.                     if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1896.                         ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1897.                         ret=$?;
  1898.                     fi
  1899.                 ;;
  1900.                 rem-int-dep)
  1901.                     ELT_walk_patches "${d}/ltmain.sh" "${p}" "${deptoremove}";
  1902.                     ret=$?
  1903.                 ;;
  1904.                 fix-relink)
  1905.                     if grep -qs 'inst_prefix_dir' "${d}/ltmain.sh"; then
  1906.                         ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1907.                         ret=$?;
  1908.                     fi
  1909.                 ;;
  1910.                 max_cmd_len)
  1911.                     if grep -qs 'max_cmd_len' "${d}/ltmain.sh"; then
  1912.                         ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1913.                         ret=$?;
  1914.                     fi
  1915.                 ;;
  1916.                 as-needed)
  1917.                     ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1918.                     ret=$?
  1919.                 ;;
  1920.                 uclibc-ltconf)
  1921.                     if [[ -s ${d}/ltconfig ]]; then
  1922.                         ELT_walk_patches "${d}/ltconfig" "${p}";
  1923.                         ret=$?;
  1924.                     fi
  1925.                 ;;
  1926.                 fbsd-ltconf)
  1927.                     if [[ -s ${d}/ltconfig ]]; then
  1928.                         ELT_walk_patches "${d}/ltconfig" "${p}";
  1929.                         ret=$?;
  1930.                     fi
  1931.                 ;;
  1932.                 darwin-ltconf)
  1933.                     if [[ -s ${d}/ltconfig ]]; then
  1934.                         ELT_walk_patches "${d}/ltconfig" "${p}";
  1935.                         ret=$?;
  1936.                     fi
  1937.                 ;;
  1938.                 darwin-ltmain)
  1939.                     if [[ -e ${d}/ltmain.sh ]] && ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh"; then
  1940.                         ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1941.                         ret=$?;
  1942.                     fi
  1943.                 ;;
  1944.                 install-sh)
  1945.                     ELT_walk_patches "${d}/install-sh" "${p}";
  1946.                     ret=$?
  1947.                 ;;
  1948.                 cross)
  1949.                     if tc-is-cross-compiler; then
  1950.                         ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1951.                         ret=$?;
  1952.                     fi
  1953.                 ;;
  1954.                 *)
  1955.                     ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1956.                     ret=$?
  1957.                 ;;
  1958.             esac;
  1959.             if [[ ${ret} -ne 0 ]]; then
  1960.                 case ${p} in
  1961.                     relink)
  1962.                         local version=$(ELT_libtool_version "${d}/ltmain.sh");
  1963.                         if ! grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" && [[ $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]]; then
  1964.                             ewarn "  Could not apply relink.patch!";
  1965.                         fi
  1966.                     ;;
  1967.                     portage)
  1968.                         if [[ ${do_portage} == "yes" ]]; then
  1969.                             if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1970.                                 echo;
  1971.                                 eerror "Portage patch requested, but failed to apply!";
  1972.                                 eerror "Please file a bug report to add a proper patch.";
  1973.                                 die "Portage patch requested, but failed to apply!";
  1974.                             fi;
  1975.                         else
  1976.                             if grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1977.                                 :;
  1978.                             else
  1979.                                 local version=$(ELT_libtool_version "${d}"/ltmain.sh);
  1980.                                 echo;
  1981.                                 eerror "Portage patch failed to apply (ltmain.sh version ${version})!";
  1982.                                 eerror "Please file a bug report to add a proper patch.";
  1983.                                 die "Portage patch failed to apply!";
  1984.                             fi;
  1985.                             ELT_APPLIED_PATCHES="portage";
  1986.                         fi
  1987.                     ;;
  1988.                     darwin-*)
  1989.                         [[ ${CHOST} == *"-darwin"* ]] && ewarn "  Darwin patch set '${p}' failed to apply!"
  1990.                     ;;
  1991.                 esac;
  1992.             fi;
  1993.         done;
  1994.         [[ -f ${d}/ltmain.sh ]] && if [[ -z ${ELT_APPLIED_PATCHES} ]]; then
  1995.             if [[ ${do_portage} == "no" && ${do_reversedeps} == "no" && ${do_only_patches} == "no" && ${deptoremove} == "" ]]; then
  1996.                 ewarn "Cannot apply any patches, please file a bug about this";
  1997.                 die;
  1998.             fi;
  1999.         fi;
  2000.         [[ -f ${d}/configure ]] && for p in ${elt_patches};
  2001.         do
  2002.             ret=0;
  2003.             case ${p} in
  2004.                 uclibc-conf)
  2005.                     if grep -qs 'Transform linux' "${d}/configure"; then
  2006.                         ELT_walk_patches "${d}/configure" "${p}";
  2007.                         ret=$?;
  2008.                     fi
  2009.                 ;;
  2010.                 fbsd-conf)
  2011.                     if grep -qs 'version_type=freebsd-' "${d}/configure"; then
  2012.                         ELT_walk_patches "${d}/configure" "${p}";
  2013.                         ret=$?;
  2014.                     fi
  2015.                 ;;
  2016.                 darwin-conf)
  2017.                     if grep -qs '&& echo \.so ||' "${d}/configure"; then
  2018.                         ELT_walk_patches "${d}/configure" "${p}";
  2019.                         ret=$?;
  2020.                     fi
  2021.                 ;;
  2022.                 aixrtl | hpux-conf)
  2023.                     ret=1;
  2024.                     local subret=0;
  2025.                     while [[ $subret -eq 0 ]]; do
  2026.                         subret=1;
  2027.                         if [[ -e ${d}/configure ]]; then
  2028.                             ELT_walk_patches "${d}/configure" "${p}";
  2029.                             subret=$?;
  2030.                         fi;
  2031.                         if [[ $subret -eq 0 ]]; then
  2032.                             ret=0;
  2033.                         fi;
  2034.                     done
  2035.                 ;;
  2036.                 mint-conf | gold-conf | sol2-conf)
  2037.                     ELT_walk_patches "${d}/configure" "${p}";
  2038.                     ret=$?
  2039.                 ;;
  2040.                 target-nm)
  2041.                     ELT_walk_patches "${d}/configure" "${p}";
  2042.                     ret=$?
  2043.                 ;;
  2044.                 ppc64le)
  2045.                     ELT_walk_patches "${d}/configure" "${p}";
  2046.                     ret=$?
  2047.                 ;;
  2048.                 *)
  2049.  
  2050.                 ;;
  2051.             esac;
  2052.             if [[ ${ret} -ne 0 ]]; then
  2053.                 case ${p} in
  2054.                     uclibc-*)
  2055.                         [[ ${CHOST} == *-uclibc ]] && ewarn "  uClibc patch set '${p}' failed to apply!"
  2056.                     ;;
  2057.                     fbsd-*)
  2058.                         if [[ ${CHOST} == *-freebsd* ]]; then
  2059.                             if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux'                                 "${d}/configure" 2>/dev/null) ]]; then
  2060.                                 eerror "  FreeBSD patch set '${p}' failed to apply!";
  2061.                                 die "FreeBSD patch set '${p}' failed to apply!";
  2062.                             fi;
  2063.                         fi
  2064.                     ;;
  2065.                     darwin-*)
  2066.                         [[ ${CHOST} == *"-darwin"* ]] && ewarn "  Darwin patch set '${p}' failed to apply!"
  2067.                     ;;
  2068.                 esac;
  2069.             fi;
  2070.         done;
  2071.         rm -f "${d}/libtool";
  2072.          > "${d}/.elibtoolized";
  2073.     done
  2074. }
  2075. emktemp ()
  2076. {
  2077.     local exe="touch";
  2078.     [[ $1 == -d ]] && exe="mkdir" && shift;
  2079.     local topdir=$1;
  2080.     if [[ -z ${topdir} ]]; then
  2081.         [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  2082.     fi;
  2083.     if ! type -P mktemp > /dev/null; then
  2084.         local tmp=/;
  2085.         while [[ -e ${tmp} ]]; do
  2086.             tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  2087.         done;
  2088.         ${exe} "${tmp}" || ${exe} -p "${tmp}";
  2089.         echo "${tmp}";
  2090.     else
  2091.         if [[ ${exe} == "touch" ]]; then
  2092.             TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  2093.         else
  2094.             TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  2095.         fi;
  2096.     fi
  2097. }
  2098. epatch ()
  2099. {
  2100.     function _epatch_draw_line ()
  2101.     {
  2102.         [[ -z $1 ]] && set "$(printf "%65s" '')";
  2103.         echo "${1//?/=}"
  2104.     };
  2105.     unset P4CONFIG P4PORT P4USER;
  2106.     local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  2107.     while [[ $# -gt 0 ]]; do
  2108.         case $1 in
  2109.             -*)
  2110.                 EPATCH_OPTS+=("$1")
  2111.             ;;
  2112.             *)
  2113.                 break
  2114.             ;;
  2115.         esac;
  2116.         shift;
  2117.     done;
  2118.     if [[ $# -gt 1 ]]; then
  2119.         local m;
  2120.         for m in "$@";
  2121.         do
  2122.             epatch "${m}";
  2123.         done;
  2124.         return 0;
  2125.     fi;
  2126.     local SINGLE_PATCH="no";
  2127.     [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  2128.     if [[ -f $1 ]]; then
  2129.         SINGLE_PATCH="yes";
  2130.         set -- "$1";
  2131.         local EPATCH_SUFFIX=$1;
  2132.     else
  2133.         if [[ -d $1 ]]; then
  2134.             evar_push_set LC_COLLATE C;
  2135.             set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  2136.             evar_pop;
  2137.         else
  2138.             if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  2139.                 epatch "${EPATCH_SOURCE}/$1";
  2140.                 return $?;
  2141.             else
  2142.                 [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  2143.                 echo;
  2144.                 eerror "Cannot find \$EPATCH_SOURCE!  Value for \$EPATCH_SOURCE is:";
  2145.                 eerror;
  2146.                 eerror "  ${EPATCH_SOURCE}";
  2147.                 eerror "  ( ${EPATCH_SOURCE##*/} )";
  2148.                 echo;
  2149.                 die "Cannot find \$EPATCH_SOURCE!";
  2150.             fi;
  2151.         fi;
  2152.     fi;
  2153.     EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  2154.     local PIPE_CMD;
  2155.     case ${EPATCH_SUFFIX##*\.} in
  2156.         xz)
  2157.             PIPE_CMD="xz -dc"
  2158.         ;;
  2159.         lzma)
  2160.             PIPE_CMD="lzma -dc"
  2161.         ;;
  2162.         bz2)
  2163.             PIPE_CMD="bzip2 -dc"
  2164.         ;;
  2165.         gz | Z | z)
  2166.             PIPE_CMD="gzip -dc"
  2167.         ;;
  2168.         ZIP | zip)
  2169.             PIPE_CMD="unzip -p"
  2170.         ;;
  2171.         *)
  2172.  
  2173.         ;;
  2174.     esac;
  2175.     [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  2176.     local x;
  2177.     for x in "$@";
  2178.     do
  2179.         [[ ! -f ${x} ]] && continue;
  2180.         local patchname=${x##*/};
  2181.         local a=${patchname#*_};
  2182.         a=${a%%_*};
  2183.         if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  2184.             continue;
  2185.         fi;
  2186.         if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  2187.             eshopts_push -o noglob;
  2188.             local ex;
  2189.             for ex in ${EPATCH_EXCLUDE};
  2190.             do
  2191.                 if [[ ${patchname} == ${ex} ]]; then
  2192.                     einfo "  Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  2193.                     eshopts_pop;
  2194.                     continue 2;
  2195.                 fi;
  2196.             done;
  2197.             for ex in ${EPATCH_USER_EXCLUDE};
  2198.             do
  2199.                 if [[ ${patchname} == ${ex} ]]; then
  2200.                     einfo "  Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  2201.                     eshopts_pop;
  2202.                     continue 2;
  2203.                 fi;
  2204.             done;
  2205.             eshopts_pop;
  2206.         fi;
  2207.         if [[ ${SINGLE_PATCH} == "yes" ]]; then
  2208.             if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  2209.                 einfo "${EPATCH_SINGLE_MSG}";
  2210.             else
  2211.                 einfo "Applying ${patchname} ...";
  2212.             fi;
  2213.         else
  2214.             einfo "  ${patchname} ...";
  2215.         fi;
  2216.         local patch="patch";
  2217.         eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  2218.         local STDERR_TARGET="${T}/${patchname}.out";
  2219.         if [[ -e ${STDERR_TARGET} ]]; then
  2220.             STDERR_TARGET="${T}/${patchname}-$$.out";
  2221.         fi;
  2222.         printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  2223.         local count=0;
  2224.         local PATCH_TARGET;
  2225.         if [[ -n ${PIPE_CMD} ]]; then
  2226.             PATCH_TARGET="${T}/$$.patch";
  2227.             echo "PIPE_COMMAND:  ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  2228.             if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  2229.                 echo;
  2230.                 eerror "Could not extract patch!";
  2231.                 count=5;
  2232.                 break;
  2233.             fi;
  2234.         else
  2235.             PATCH_TARGET=${x};
  2236.         fi;
  2237.         local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  2238.         if [[ -n ${abs_paths} ]]; then
  2239.             count=1;
  2240.             printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  2241.         fi;
  2242.         local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  2243.         if [[ -n ${rel_paths} ]]; then
  2244.             echo;
  2245.             eerror "Rejected Patch: ${patchname} !";
  2246.             eerror " ( ${PATCH_TARGET} )";
  2247.             eerror;
  2248.             eerror "Your patch uses relative paths '../':";
  2249.             eerror "${rel_paths}";
  2250.             echo;
  2251.             die "you need to fix the relative paths in patch";
  2252.         fi;
  2253.         local patch_cmd;
  2254.         while [[ ${count} -lt 5 ]]; do
  2255.             patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  2256.             ( _epatch_draw_line "***** ${patchname} *****";
  2257.             echo;
  2258.             echo "PATCH COMMAND:  ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  2259.             echo;
  2260.             _epatch_draw_line "***** ${patchname} *****";
  2261.             ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  2262.             ret=$?;
  2263.             echo;
  2264.             echo "patch program exited with status ${ret}";
  2265.             exit ${ret} ) >> "${STDERR_TARGET}";
  2266.             if [ $? -eq 0 ]; then
  2267.                 ( _epatch_draw_line "***** ${patchname} *****";
  2268.                 echo;
  2269.                 echo "ACTUALLY APPLYING ${patchname} ...";
  2270.                 echo "PATCH COMMAND:  ${patch_cmd} < '${PATCH_TARGET}'";
  2271.                 echo;
  2272.                 _epatch_draw_line "***** ${patchname} *****";
  2273.                 ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  2274.                 ret=$?;
  2275.                 echo;
  2276.                 echo "patch program exited with status ${ret}";
  2277.                 exit ${ret} ) >> "${STDERR_TARGET}";
  2278.                 if [ $? -ne 0 ]; then
  2279.                     echo;
  2280.                     eerror "A dry-run of patch command succeeded, but actually";
  2281.                     eerror "applying the patch failed!";
  2282.                     count=5;
  2283.                 fi;
  2284.                 break;
  2285.             fi;
  2286.             : $(( count++ ));
  2287.         done;
  2288.         (( EPATCH_N_APPLIED_PATCHES++ ));
  2289.         if [[ -n ${PIPE_CMD} ]]; then
  2290.             rm -f "${PATCH_TARGET}";
  2291.         fi;
  2292.         if [[ ${count} -ge 5 ]]; then
  2293.             echo;
  2294.             eerror "Failed Patch: ${patchname} !";
  2295.             eerror " ( ${PATCH_TARGET} )";
  2296.             eerror;
  2297.             eerror "Include in your bugreport the contents of:";
  2298.             eerror;
  2299.             eerror "  ${STDERR_TARGET}";
  2300.             echo;
  2301.             die "Failed Patch: ${patchname}!";
  2302.         fi;
  2303.         rm -f "${STDERR_TARGET}";
  2304.         cat >> "${T}/epatch.log"  <<-EOF
  2305. PATCH: ${x}
  2306. CMD: ${patch_cmd}
  2307. PWD: ${PWD}
  2308.  
  2309. EOF
  2310.  
  2311.         eend 0;
  2312.     done;
  2313.     [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  2314.     :
  2315. }
  2316. epatch_user ()
  2317. {
  2318.     [[ $# -ne 0 ]] && die "epatch_user takes no options";
  2319.     local applied="${T}/epatch_user.log";
  2320.     [[ -e ${applied} ]] && return 2;
  2321.     local EPATCH_SOURCE check;
  2322.     for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}};
  2323.     do
  2324.         EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CTARGET}/${check};
  2325.         [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CHOST}/${check};
  2326.         [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${check};
  2327.         if [[ -d ${EPATCH_SOURCE} ]]; then
  2328.             local old_n_applied_patches=${EPATCH_N_APPLIED_PATCHES:-0};
  2329.             EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  2330.             echo "${EPATCH_SOURCE}" > "${applied}";
  2331.             if [[ ${old_n_applied_patches} -lt ${EPATCH_N_APPLIED_PATCHES} ]]; then
  2332.                 has epatch_user_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" epatch_user_death_notice";
  2333.             fi;
  2334.             return 0;
  2335.         fi;
  2336.     done;
  2337.     echo "none" > "${applied}";
  2338.     return 1
  2339. }
  2340. epatch_user_death_notice ()
  2341. {
  2342.     ewarn "!!! User patches were applied to this build!"
  2343. }
  2344. epause ()
  2345. {
  2346.     ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  2347. }
  2348. epunt_cxx ()
  2349. {
  2350.     local dir=$1;
  2351.     [[ -z ${dir} ]] && dir=${S};
  2352.     ebegin "Removing useless C++ checks";
  2353.     local f p any_found;
  2354.     while IFS= read -r -d '' f; do
  2355.         for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch;
  2356.         do
  2357.             if patch --no-backup-if-mismatch -p1 "${f}" "${p}" > /dev/null; then
  2358.                 any_found=1;
  2359.                 break;
  2360.             fi;
  2361.         done;
  2362.     done < <(find "${dir}" -name configure -print0);
  2363.     if [[ -z ${any_found} ]]; then
  2364.         eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt).";
  2365.     fi;
  2366.     eend 0
  2367. }
  2368. eshopts_pop ()
  2369. {
  2370.     local s;
  2371.     estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  2372.     if [[ ${s} == "shopt -"* ]]; then
  2373.         eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  2374.     else
  2375.         set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  2376.         set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  2377.     fi
  2378. }
  2379. eshopts_push ()
  2380. {
  2381.     if [[ $1 == -[su] ]]; then
  2382.         estack_push eshopts "$(shopt -p)";
  2383.         [[ $# -eq 0 ]] && return 0;
  2384.         shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  2385.     else
  2386.         estack_push eshopts $-;
  2387.         [[ $# -eq 0 ]] && return 0;
  2388.         set "$@" || die "${FUNCNAME}: bad options to set: $*";
  2389.     fi
  2390. }
  2391. estack_pop ()
  2392. {
  2393.     [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  2394.     local _estack_name="_ESTACK_$1_";
  2395.     shift;
  2396.     local _estack_retvar=$1;
  2397.     shift;
  2398.     eval local _estack_i=\${#${_estack_name}\[@\]};
  2399.     [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  2400.     if [[ -n ${_estack_retvar} ]]; then
  2401.         eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  2402.     fi;
  2403.     eval unset \"${_estack_name}\[${_estack_i}\]\"
  2404. }
  2405. estack_push ()
  2406. {
  2407.     [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  2408.     local stack_name="_ESTACK_$1_";
  2409.     shift;
  2410.     eval ${stack_name}+=\( \"\$@\" \)
  2411. }
  2412. esvn_clean ()
  2413. {
  2414.     [[ $# -eq 0 ]] && set -- .;
  2415.     find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  2416. }
  2417. eumask_pop ()
  2418. {
  2419.     [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  2420.     local s;
  2421.     estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  2422.     umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  2423. }
  2424. eumask_push ()
  2425. {
  2426.     estack_push eumask "$(umask)";
  2427.     umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  2428. }
  2429. eutils_elt_patch_dir ()
  2430. {
  2431.     local d="${ECLASSDIR}/ELT-patches";
  2432.     if [[ ! -d ${d} ]]; then
  2433.         d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches";
  2434.     fi;
  2435.     echo "${d}"
  2436. }
  2437. evar_pop ()
  2438. {
  2439.     local cnt=${1:-bad};
  2440.     case $# in
  2441.         0)
  2442.             cnt=1
  2443.         ;;
  2444.         1)
  2445.             isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  2446.         ;;
  2447.         *)
  2448.             die "${FUNCNAME}: only accepts one arg: $*"
  2449.         ;;
  2450.     esac;
  2451.     local var val;
  2452.     while (( cnt-- )); do
  2453.         estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  2454.         estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  2455.         [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  2456.     done
  2457. }
  2458. evar_push ()
  2459. {
  2460.     local var val;
  2461.     for var in "$@";
  2462.     do
  2463.         [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  2464.         estack_push evar "${var}" "${val}";
  2465.     done
  2466. }
  2467. evar_push_set ()
  2468. {
  2469.     local var=$1;
  2470.     evar_push ${var};
  2471.     case $# in
  2472.         1)
  2473.             unset ${var}
  2474.         ;;
  2475.         2)
  2476.             printf -v "${var}" '%s' "$2"
  2477.         ;;
  2478.         *)
  2479.             die "${FUNCNAME}: incorrect # of args: $*"
  2480.         ;;
  2481.     esac
  2482. }
  2483. filter-flags ()
  2484. {
  2485.     _filter-hardened "$@";
  2486.     local v;
  2487.     for v in $(all-flag-vars);
  2488.     do
  2489.         _filter-var ${v} "$@";
  2490.     done;
  2491.     return 0
  2492. }
  2493. filter-ldflags ()
  2494. {
  2495.     _filter-var LDFLAGS "$@";
  2496.     return 0
  2497. }
  2498. filter-lfs-flags ()
  2499. {
  2500.     [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2501.     filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  2502. }
  2503. filter-mfpmath ()
  2504. {
  2505.     local orig_mfpmath new_math prune_math;
  2506.     orig_mfpmath=$(get-flag -mfpmath);
  2507.     new_math=$(get-flag mfpmath);
  2508.     new_math=${new_math/both/387,sse};
  2509.     new_math=" ${new_math//[,+]/ } ";
  2510.     prune_math="";
  2511.     for prune_math in "$@";
  2512.     do
  2513.         new_math=${new_math/ ${prune_math} / };
  2514.     done;
  2515.     new_math=$(echo ${new_math});
  2516.     new_math=${new_math// /,};
  2517.     if [[ -z ${new_math} ]]; then
  2518.         filter-flags ${orig_mfpmath};
  2519.     else
  2520.         replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2521.     fi;
  2522.     return 0
  2523. }
  2524. gcc-fullversion ()
  2525. {
  2526.     _gcc_fullversion '$1.$2.$3' "$@"
  2527. }
  2528. gcc-major-version ()
  2529. {
  2530.     _gcc_fullversion '$1' "$@"
  2531. }
  2532. gcc-micro-version ()
  2533. {
  2534.     _gcc_fullversion '$3' "$@"
  2535. }
  2536. gcc-minor-version ()
  2537. {
  2538.     _gcc_fullversion '$2' "$@"
  2539. }
  2540. gcc-specs-directive ()
  2541. {
  2542.     local directive subdname subdirective;
  2543.     directive="$(_gcc-specs-directive_raw $1)";
  2544.     while [[ ${directive} == *%\(*\)* ]]; do
  2545.         subdname=${directive/*%\(};
  2546.         subdname=${subdname/\)*};
  2547.         subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2548.         directive="${directive//\%(${subdname})/${subdirective}}";
  2549.     done;
  2550.     echo "${directive}";
  2551.     return 0
  2552. }
  2553. gcc-specs-nostrict ()
  2554. {
  2555.     local directive;
  2556.     directive=$(gcc-specs-directive cc1);
  2557.     [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2558. }
  2559. gcc-specs-now ()
  2560. {
  2561.     local directive;
  2562.     directive=$(gcc-specs-directive link_command);
  2563.     [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2564. }
  2565. gcc-specs-pie ()
  2566. {
  2567.     local directive;
  2568.     directive=$(gcc-specs-directive cc1);
  2569.     [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2570. }
  2571. gcc-specs-relro ()
  2572. {
  2573.     local directive;
  2574.     directive=$(gcc-specs-directive link_command);
  2575.     [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2576. }
  2577. gcc-specs-ssp ()
  2578. {
  2579.     local directive;
  2580.     directive=$(gcc-specs-directive cc1);
  2581.     [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2582. }
  2583. gcc-specs-ssp-to-all ()
  2584. {
  2585.     local directive;
  2586.     directive=$(gcc-specs-directive cc1);
  2587.     [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2588. }
  2589. gcc-specs-stack-check ()
  2590. {
  2591.     local directive;
  2592.     directive=$(gcc-specs-directive cc1);
  2593.     [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2594. }
  2595. gcc-version ()
  2596. {
  2597.     _gcc_fullversion '$1.$2' "$@"
  2598. }
  2599. gen_usr_ldscript ()
  2600. {
  2601.     local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2602.     [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2603.     tc-is-static-only && return;
  2604.     if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2605.         multilib_is_native_abi || return 0;
  2606.     fi;
  2607.     case ${CTARGET:-${CHOST}} in
  2608.         *-darwin*)
  2609.  
  2610.         ;;
  2611.         *-android*)
  2612.             return 0
  2613.         ;;
  2614.         *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  2615.             use prefix && return 0
  2616.         ;;
  2617.         *)
  2618.             return 0
  2619.         ;;
  2620.     esac;
  2621.     dodir /usr/${libdir};
  2622.     if [[ $1 == "-a" ]]; then
  2623.         auto=true;
  2624.         shift;
  2625.         dodir /${libdir};
  2626.     fi;
  2627.     local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2628.     if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2629.         local d="${T}/bfd-linker";
  2630.         mkdir -p "${d}";
  2631.         ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  2632.         flags+=(-B"${d}");
  2633.     fi;
  2634.     output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2635.     [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2636.     for lib in "$@";
  2637.     do
  2638.         local tlib;
  2639.         if ${auto}; then
  2640.             lib="lib${lib}${suffix}";
  2641.         else
  2642.             [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2643.         fi;
  2644.         case ${CTARGET:-${CHOST}} in
  2645.             *-darwin*)
  2646.                 if ${auto}; then
  2647.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2648.                 else
  2649.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2650.                 fi;
  2651.                 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2652.                 tlib=${tlib##*/};
  2653.                 if ${auto}; then
  2654.                     mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2655.                     if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2656.                         mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2657.                     fi;
  2658.                     rm -f "${ED}"/${libdir}/${lib};
  2659.                 fi;
  2660.                 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2661.                     chmod u+w "${ED}${libdir}/${tlib}";
  2662.                     local nowrite=yes;
  2663.                 fi;
  2664.                 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2665.                 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2666.                 pushd "${ED}/usr/${libdir}" > /dev/null;
  2667.                 ln -snf "../../${libdir}/${tlib}" "${lib}";
  2668.                 popd > /dev/null
  2669.             ;;
  2670.             *)
  2671.                 if ${auto}; then
  2672.                     tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2673.                     [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2674.                     mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2675.                     if [[ ${tlib} != ${lib}* ]]; then
  2676.                         mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2677.                     fi;
  2678.                     rm -f "${ED}"/${libdir}/${lib};
  2679.                 else
  2680.                     tlib=${lib};
  2681.                 fi;
  2682.                 cat > "${ED}/usr/${libdir}/${lib}"  <<-END_LDSCRIPT
  2683. /* GNU ld script
  2684.    Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2685.    in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2686.    run into linking problems.  This "fake" dynamic lib is a linker script that
  2687.    redirects the linker to the real lib.  And yes, this works in the cross-
  2688.    compiling scenario as the sysroot-ed linker will prepend the real path.
  2689.  
  2690.    See bug https://bugs.gentoo.org/4411 for more info.
  2691.  */
  2692. ${output_format}
  2693. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2694. END_LDSCRIPT
  2695.  
  2696.             ;;
  2697.         esac
  2698.         fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2699.     done
  2700. }
  2701. get-flag ()
  2702. {
  2703.     local f var findflag="$1";
  2704.     for var in $(all-flag-vars);
  2705.     do
  2706.         for f in ${!var};
  2707.         do
  2708.             if [ "${f/${findflag}}" != "${f}" ]; then
  2709.                 printf "%s\n" "${f/-${findflag}=}";
  2710.                 return 0;
  2711.             fi;
  2712.         done;
  2713.     done;
  2714.     return 1
  2715. }
  2716. get_abi_CFLAGS ()
  2717. {
  2718.     get_abi_var CFLAGS "$@"
  2719. }
  2720. get_abi_CHOST ()
  2721. {
  2722.     get_abi_var CHOST "$@"
  2723. }
  2724. get_abi_CTARGET ()
  2725. {
  2726.     get_abi_var CTARGET "$@"
  2727. }
  2728. get_abi_FAKE_TARGETS ()
  2729. {
  2730.     get_abi_var FAKE_TARGETS "$@"
  2731. }
  2732. get_abi_LDFLAGS ()
  2733. {
  2734.     get_abi_var LDFLAGS "$@"
  2735. }
  2736. get_abi_LIBDIR ()
  2737. {
  2738.     get_abi_var LIBDIR "$@"
  2739. }
  2740. get_abi_var ()
  2741. {
  2742.     local flag=$1;
  2743.     local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2744.     local var="${flag}_${abi}";
  2745.     echo ${!var}
  2746. }
  2747. get_after_major_version ()
  2748. {
  2749.     echo $(get_version_component_range 2- "${1:-${PV}}")
  2750. }
  2751. get_all_abis ()
  2752. {
  2753.     local x order="" mvar dvar;
  2754.     mvar="MULTILIB_ABIS";
  2755.     dvar="DEFAULT_ABI";
  2756.     if [[ -n $1 ]]; then
  2757.         mvar="$1_${mvar}";
  2758.         dvar="$1_${dvar}";
  2759.     fi;
  2760.     if [[ -z ${!mvar} ]]; then
  2761.         echo "default";
  2762.         return 0;
  2763.     fi;
  2764.     for x in ${!mvar};
  2765.     do
  2766.         if [[ ${x} != ${!dvar} ]]; then
  2767.             order="${order:+${order} }${x}";
  2768.         fi;
  2769.     done;
  2770.     order="${order:+${order} }${!dvar}";
  2771.     echo ${order};
  2772.     return 0
  2773. }
  2774. get_all_libdirs ()
  2775. {
  2776.     local libdirs abi;
  2777.     for abi in ${MULTILIB_ABIS};
  2778.     do
  2779.         libdirs+=" $(get_abi_LIBDIR ${abi})";
  2780.     done;
  2781.     [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2782.     echo "${libdirs}"
  2783. }
  2784. get_all_version_components ()
  2785. {
  2786.     eshopts_push -s extglob;
  2787.     local ver_str=${1:-${PV}} result;
  2788.     result=();
  2789.     if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  2790.         echo ${VERSIONATOR_CACHE_RESULT};
  2791.         eshopts_pop;
  2792.         return;
  2793.     fi;
  2794.     export VERSIONATOR_CACHE_VER_STR=${ver_str};
  2795.     while [[ -n $ver_str ]]; do
  2796.         case "${ver_str::1}" in
  2797.             [[:digit:]])
  2798.                 result+=("${ver_str%%[^[:digit:]]*}");
  2799.                 ver_str=${ver_str##+([[:digit:]])}
  2800.             ;;
  2801.             [-_.])
  2802.                 result+=("${ver_str::1}");
  2803.                 ver_str=${ver_str:1}
  2804.             ;;
  2805.             [[:alpha:]])
  2806.                 local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  2807.                 result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2808.                 ver_str=${not_match}
  2809.             ;;
  2810.             *)
  2811.                 result+=("${ver_str::1}");
  2812.                 ver_str=${ver_str:1}
  2813.             ;;
  2814.         esac;
  2815.     done;
  2816.     export VERSIONATOR_CACHE_RESULT=${result[*]};
  2817.     echo ${result[@]};
  2818.     eshopts_pop
  2819. }
  2820. get_exeext ()
  2821. {
  2822.     case ${CHOST} in
  2823.         *-cygwin* | mingw* | *-mingw*)
  2824.             echo ".exe"
  2825.         ;;
  2826.     esac
  2827. }
  2828. get_install_abis ()
  2829. {
  2830.     local x order="";
  2831.     if [[ -z ${MULTILIB_ABIS} ]]; then
  2832.         echo "default";
  2833.         return 0;
  2834.     fi;
  2835.     if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2836.         for x in ${MULTILIB_ABIS};
  2837.         do
  2838.             if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2839.                 has ${x} ${ABI_DENY} || order="${order} ${x}";
  2840.             fi;
  2841.         done;
  2842.         has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2843.         if [[ -n ${ABI_ALLOW} ]]; then
  2844.             local ordera="";
  2845.             for x in ${order};
  2846.             do
  2847.                 if has ${x} ${ABI_ALLOW}; then
  2848.                     ordera="${ordera} ${x}";
  2849.                 fi;
  2850.             done;
  2851.             order=${ordera};
  2852.         fi;
  2853.     else
  2854.         order=${DEFAULT_ABI};
  2855.     fi;
  2856.     if [[ -z ${order} ]]; then
  2857.         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.";
  2858.     fi;
  2859.     echo ${order};
  2860.     return 0
  2861. }
  2862. get_last_version_component_index ()
  2863. {
  2864.     echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2865. }
  2866. get_libdir ()
  2867. {
  2868.     local CONF_LIBDIR;
  2869.     if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2870.         echo ${CONF_LIBDIR_OVERRIDE};
  2871.     else
  2872.         get_abi_LIBDIR;
  2873.     fi
  2874. }
  2875. get_libname ()
  2876. {
  2877.     local libname;
  2878.     local ver=$1;
  2879.     case ${CHOST} in
  2880.         *-cygwin*)
  2881.             libname="dll.a"
  2882.         ;;
  2883.         mingw* | *-mingw*)
  2884.             libname="dll"
  2885.         ;;
  2886.         *-darwin*)
  2887.             libname="dylib"
  2888.         ;;
  2889.         *-mint*)
  2890.             libname="irrelevant"
  2891.         ;;
  2892.         hppa*-hpux*)
  2893.             libname="sl"
  2894.         ;;
  2895.         *)
  2896.             libname="so"
  2897.         ;;
  2898.     esac;
  2899.     if [[ -z $* ]]; then
  2900.         echo ".${libname}";
  2901.     else
  2902.         for ver in "$@";
  2903.         do
  2904.             case ${CHOST} in
  2905.                 *-cygwin*)
  2906.                     echo ".${ver}.${libname}"
  2907.                 ;;
  2908.                 *-darwin*)
  2909.                     echo ".${ver}.${libname}"
  2910.                 ;;
  2911.                 *-mint*)
  2912.                     echo ".${libname}"
  2913.                 ;;
  2914.                 *)
  2915.                     echo ".${libname}.${ver}"
  2916.                 ;;
  2917.             esac;
  2918.         done;
  2919.     fi
  2920. }
  2921. get_major_version ()
  2922. {
  2923.     local c=($(get_all_version_components "${1:-${PV}}"));
  2924.     echo ${c[0]}
  2925. }
  2926. get_modname ()
  2927. {
  2928.     local modname;
  2929.     local ver=$1;
  2930.     case ${CHOST} in
  2931.         *-darwin*)
  2932.             modname="bundle"
  2933.         ;;
  2934.         *)
  2935.             modname="so"
  2936.         ;;
  2937.     esac;
  2938.     echo ".${modname}"
  2939. }
  2940. get_version_component_count ()
  2941. {
  2942.     local a=($(get_version_components "${1:-${PV}}"));
  2943.     echo ${#a[@]}
  2944. }
  2945. get_version_component_range ()
  2946. {
  2947.     eshopts_push -s extglob;
  2948.     local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2949.     local -i i=-1 j=0;
  2950.     c=($(get_all_version_components "${v}"));
  2951.     range_start=${range%-*};
  2952.     range_start=${range_start:-1};
  2953.     range_end=${range#*-};
  2954.     range_end=${range_end:-${#c[@]}};
  2955.     while ((j < range_start)); do
  2956.         i+=1;
  2957.         ((i > ${#c[@]})) && eshopts_pop && return;
  2958.         [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2959.     done;
  2960.     while ((j <= range_end)); do
  2961.         echo -n ${c[i]};
  2962.         ((i > ${#c[@]})) && eshopts_pop && return;
  2963.         [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2964.         i+=1;
  2965.     done;
  2966.     eshopts_pop
  2967. }
  2968. get_version_components ()
  2969. {
  2970.     local c=$(get_all_version_components "${1:-${PV}}");
  2971.     echo ${c//[-._]/ }
  2972. }
  2973. has_m32 ()
  2974. {
  2975.     die "${FUNCNAME}: don't use this anymore"
  2976. }
  2977. has_m64 ()
  2978. {
  2979.     die "${FUNCNAME}: don't use this anymore"
  2980. }
  2981. has_multilib_profile ()
  2982. {
  2983.     [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2984. }
  2985. in_iuse ()
  2986. {
  2987.     debug-print-function ${FUNCNAME} "${@}";
  2988.     [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2989.     local flag=${1};
  2990.     local liuse=(${IUSE});
  2991.     has "${flag}" "${liuse[@]#[+-]}"
  2992. }
  2993. increment-qa-violations ()
  2994. {
  2995.     let "JAVA_PKG_QA_VIOLATIONS+=1";
  2996.     export JAVA_PKG_QA_VIOLATIONS
  2997. }
  2998. is-flag ()
  2999. {
  3000.     is-flagq "$@" && echo true
  3001. }
  3002. is-flagq ()
  3003. {
  3004.     [[ -n $2 ]] && die "Usage: is-flag <flag>";
  3005.     local var;
  3006.     for var in $(all-flag-vars);
  3007.     do
  3008.         _is_flagq ${var} "$1" && return 0;
  3009.     done;
  3010.     return 1
  3011. }
  3012. is-java-strict ()
  3013. {
  3014.     [[ -n ${JAVA_PKG_STRICT} ]];
  3015.     return $?
  3016. }
  3017. is-ldflag ()
  3018. {
  3019.     is-ldflagq "$@" && echo true
  3020. }
  3021. is-ldflagq ()
  3022. {
  3023.     [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  3024.     _is_flagq LDFLAGS $1
  3025. }
  3026. is_final_abi ()
  3027. {
  3028.     has_multilib_profile || return 0;
  3029.     set -- $(get_install_abis);
  3030.     local LAST_ABI=$#;
  3031.     [[ ${!LAST_ABI} == ${ABI} ]]
  3032. }
  3033. isdigit ()
  3034. {
  3035.     local d;
  3036.     for d in "$@";
  3037.     do
  3038.         [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  3039.     done;
  3040.     return 0
  3041. }
  3042. java-pkg-opt-2_pkg_preinst ()
  3043. {
  3044.     use ${JAVA_PKG_OPT_USE} && java-utils-2_pkg_preinst
  3045. }
  3046. java-pkg-opt-2_pkg_setup ()
  3047. {
  3048.     use ${JAVA_PKG_OPT_USE} && java-pkg_init
  3049. }
  3050. java-pkg-opt-2_src_prepare ()
  3051. {
  3052.     use ${JAVA_PKG_OPT_USE} && java-utils-2_src_prepare
  3053. }
  3054. java-pkg_addcp ()
  3055. {
  3056.     java-pkg_append_ JAVA_PKG_CLASSPATH "${@}";
  3057.     java-pkg_do_write_
  3058. }
  3059. java-pkg_addres ()
  3060. {
  3061.     debug-print-function ${FUNCNAME} $*;
  3062.     [[ ${#} -lt 2 ]] && die "at least two arguments needed";
  3063.     local jar=$(realpath "$1" || die "realpath $1 failed");
  3064.     local dir="$2";
  3065.     shift 2;
  3066.     pushd "${dir}" > /dev/null || die "pushd ${dir} failed";
  3067.     find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -r0 jar uf "${jar}" || die "jar failed";
  3068.     popd > /dev/null || die "popd failed"
  3069. }
  3070. java-pkg_announce-qa-violation ()
  3071. {
  3072.     local nodie;
  3073.     if [[ ${1} == "--nodie" ]]; then
  3074.         nodie="true";
  3075.         shift;
  3076.     fi;
  3077.     echo "Java QA Notice: $@" 1>&2;
  3078.     increment-qa-violations;
  3079.     [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
  3080. }
  3081. java-pkg_ant-tasks-depend ()
  3082. {
  3083.     debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS};
  3084.     if [[ -n "${WANT_ANT_TASKS}" ]]; then
  3085.         local DEP="";
  3086.         for i in ${WANT_ANT_TASKS};
  3087.         do
  3088.             if [[ ${i} = ant-* ]]; then
  3089.                 DEP="${DEP}dev-java/${i} ";
  3090.             else
  3091.                 if [[ ${i} = */*:* ]]; then
  3092.                     DEP="${DEP}${i} ";
  3093.                 else
  3094.                     echo "Invalid atom in WANT_ANT_TASKS: ${i}";
  3095.                     return 1;
  3096.                 fi;
  3097.             fi;
  3098.         done;
  3099.         echo ${DEP};
  3100.         return 0;
  3101.     else
  3102.         return 0;
  3103.     fi
  3104. }
  3105. java-pkg_append_ ()
  3106. {
  3107.     debug-print-function ${FUNCNAME} $*;
  3108.     local var="${1}" value="${2}";
  3109.     if [[ -z "${!var}" ]]; then
  3110.         export ${var}="${value}";
  3111.     else
  3112.         local oldIFS=${IFS} cur haveit;
  3113.         IFS=':';
  3114.         for cur in ${!var};
  3115.         do
  3116.             if [[ ${cur} == ${value} ]]; then
  3117.                 haveit="yes";
  3118.                 break;
  3119.             fi;
  3120.         done;
  3121.         [[ -z ${haveit} ]] && export ${var}="${!var}:${value}";
  3122.         IFS=${oldIFS};
  3123.     fi
  3124. }
  3125. java-pkg_build-vm-from-handle ()
  3126. {
  3127.     debug-print-function ${FUNCNAME} "$*";
  3128.     local vm;
  3129.     vm=$(java-pkg_get-current-vm 2>/dev/null);
  3130.     if [[ $? -eq 0 ]]; then
  3131.         if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
  3132.             echo ${vm};
  3133.             return 0;
  3134.         fi;
  3135.     fi;
  3136.     for vm in ${JAVA_PKG_WANT_BUILD_VM};
  3137.     do
  3138.         if java-config-2 --select-vm=${vm} 2> /dev/null; then
  3139.             echo ${vm};
  3140.             return 0;
  3141.         fi;
  3142.     done;
  3143.     eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}";
  3144.     return 1
  3145. }
  3146. java-pkg_check-jikes ()
  3147. {
  3148.     if has jikes ${IUSE}; then
  3149.         java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE";
  3150.     fi
  3151. }
  3152. java-pkg_check-phase ()
  3153. {
  3154.     local phase=${1};
  3155.     local funcname=${FUNCNAME[1]};
  3156.     if [[ ${EBUILD_PHASE} != ${phase} ]]; then
  3157.         local msg="${funcname} used outside of src_${phase}";
  3158.         java-pkg_announce-qa-violation "${msg}";
  3159.     fi
  3160. }
  3161. java-pkg_check-versioned-jar ()
  3162. {
  3163.     local jar=${1};
  3164.     if [[ ${jar} =~ ${PV} ]]; then
  3165.         java-pkg_announce-qa-violation "installing versioned jar '${jar}'";
  3166.     fi
  3167. }
  3168. java-pkg_clean ()
  3169. {
  3170.     if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then
  3171.         find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die;
  3172.     fi
  3173. }
  3174. java-pkg_current-vm-matches ()
  3175. {
  3176.     has $(java-pkg_get-current-vm) ${@};
  3177.     return $?
  3178. }
  3179. java-pkg_die ()
  3180. {
  3181.     echo "!!! When you file a bug report, please include the following information:" 1>&2;
  3182.     echo "GENTOO_VM=${GENTOO_VM}  CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" 1>&2;
  3183.     echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" 1>&2;
  3184.     echo "and of course, the output of emerge --info =${P}" 1>&2
  3185. }
  3186. java-pkg_do_write_ ()
  3187. {
  3188.     debug-print-function ${FUNCNAME} $*;
  3189.     java-pkg_init_paths_;
  3190.     dodir "${JAVA_PKG_SHAREPATH}";
  3191.     ( echo "DESCRIPTION=\"${DESCRIPTION}\"";
  3192.     echo "GENERATION=\"2\"";
  3193.     echo "SLOT=\"${SLOT}\"";
  3194.     echo "CATEGORY=\"${CATEGORY}\"";
  3195.     echo "PVR=\"${PVR}\"";
  3196.     [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"";
  3197.     [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"";
  3198.     [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"";
  3199.     [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\"";
  3200.     [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\"";
  3201.     echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"";
  3202.     [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\"" ) > "${JAVA_PKG_ENV}";
  3203.     local target="$(java-pkg_get-target)";
  3204.     local source="$(java-pkg_get-source)";
  3205.     [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}";
  3206.     [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}";
  3207.     [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" >> ${JAVA_PKG_ENV};
  3208.     [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" >> ${JAVA_PKG_ENV};
  3209.     echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}";
  3210.     [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}";
  3211.     if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
  3212.         cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die;
  3213.         echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" >> "${JAVA_PKG_ENV}" || die;
  3214.     fi;
  3215.     sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
  3216. }
  3217. java-pkg_doexamples ()
  3218. {
  3219.     debug-print-function ${FUNCNAME} $*;
  3220.     [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3221.     java-pkg_check-phase install;
  3222.     java-pkg_init_paths_;
  3223.     local dest=/usr/share/doc/${PF}/examples;
  3224.     if [[ ${1} == --subdir ]]; then
  3225.         local dest=${dest}/${2};
  3226.         dodir ${dest};
  3227.         shift 2;
  3228.     fi;
  3229.     if [[ ${#} = 1 && -d ${1} ]]; then
  3230.         ( insinto "${dest}";
  3231.         doins -r ${1}/* ) || die "Installing examples failed";
  3232.     else
  3233.         ( insinto "${dest}";
  3234.         doins -r "$@" ) || die "Installing examples failed";
  3235.     fi;
  3236.     dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
  3237. }
  3238. java-pkg_dohtml ()
  3239. {
  3240.     debug-print-function ${FUNCNAME} $*;
  3241.     [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}";
  3242.     docinto html;
  3243.     dodoc "$@";
  3244.     java-pkg_recordjavadoc
  3245. }
  3246. java-pkg_dojar ()
  3247. {
  3248.     debug-print-function ${FUNCNAME} $*;
  3249.     [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3250.     java-pkg_check-phase install;
  3251.     java-pkg_init_paths_;
  3252.     dodir ${JAVA_PKG_JARDEST};
  3253.     local jar;
  3254.     for jar in "${@}";
  3255.     do
  3256.         local jar_basename=$(basename "${jar}");
  3257.         java-pkg_check-versioned-jar ${jar_basename};
  3258.         if [[ -e "${jar}" ]]; then
  3259.             local dest="${ED}${JAVA_PKG_JARDEST}/${jar_basename}";
  3260.             if [[ -e "${dest}" ]]; then
  3261.                 ewarn "Overwriting ${dest}";
  3262.             fi;
  3263.             if [[ ! -L "${jar}" ]]; then
  3264.                 is-java-strict && java-pkg_verify-classes "${jar}";
  3265.                 ( insinto "${JAVA_PKG_JARDEST}";
  3266.                 doins "${jar}" ) || die "failed to install ${jar}";
  3267.                 java-pkg_append_ JAVA_PKG_CLASSPATH "${EPREFIX}/${JAVA_PKG_JARDEST}/${jar_basename}";
  3268.                 debug-print "installed ${jar} to ${ED}${JAVA_PKG_JARDEST}";
  3269.             else
  3270.                 ln -s "$(readlink "${jar}")" "${ED}${JAVA_PKG_JARDEST}/${jar_basename}";
  3271.                 debug-print "${jar} is a symlink, linking accordingly";
  3272.             fi;
  3273.         else
  3274.             die "${jar} does not exist";
  3275.         fi;
  3276.     done;
  3277.     if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  3278.         einfo "Verbose logging for \"${FUNCNAME}\" function";
  3279.         einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}";
  3280.         einfo "Jar file(s) created: ${@}";
  3281.         einfo "Complete command:";
  3282.         einfo "${FUNCNAME} ${@}";
  3283.     fi;
  3284.     java-pkg_do_write_
  3285. }
  3286. java-pkg_dojavadoc ()
  3287. {
  3288.     debug-print-function ${FUNCNAME} $*;
  3289.     local symlink;
  3290.     if [[ ${1} = --symlink ]]; then
  3291.         symlink=${2};
  3292.         shift 2;
  3293.     fi;
  3294.     local dir="$1";
  3295.     local dest=/usr/share/doc/${PF}/html;
  3296.     java-pkg_check-phase install;
  3297.     java-pkg_init_paths_;
  3298.     [[ -z "${dir}" ]] && die "Must specify a directory!";
  3299.     [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!";
  3300.     if [[ ! -e "${dir}/index.html" ]]; then
  3301.         local msg="No index.html in javadoc directory";
  3302.         ewarn "${msg}";
  3303.         is-java-strict && die "${msg}";
  3304.     fi;
  3305.     if [[ -e ${D}/${dest}/api ]]; then
  3306.         eerror "${dest} already exists. Will not overwrite.";
  3307.         die "${dest}";
  3308.     fi;
  3309.     local dir_to_install="${dir}";
  3310.     if [[ "$(basename "${dir}")" != "api" ]]; then
  3311.         dir_to_install="${T}/api";
  3312.         cp -r "${dir}" "${dir_to_install}" || die "cp failed";
  3313.     fi;
  3314.     java-pkg_dohtml -r "${dir_to_install}";
  3315.     dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die;
  3316.     if [[ -n ${symlink} ]]; then
  3317.         debug-print "symlinking ${dest}/{api,${symlink}}";
  3318.         dosym ${dest}/{api,${symlink}} || die;
  3319.     fi;
  3320.     if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  3321.         einfo "Verbose logging for \"${FUNCNAME}\" function";
  3322.         einfo "Documentation destination: ${dest}";
  3323.         einfo "Directory to install: ${dir_to_install}";
  3324.         einfo "Complete command:";
  3325.         einfo "${FUNCNAME} ${@}";
  3326.     fi
  3327. }
  3328. java-pkg_dolauncher ()
  3329. {
  3330.     debug-print-function ${FUNCNAME} $*;
  3331.     java-pkg_check-phase install;
  3332.     java-pkg_init_paths_;
  3333.     if [[ ${#} = 0 ]]; then
  3334.         local name="${PN}";
  3335.     else
  3336.         local name="${1}";
  3337.         shift;
  3338.     fi;
  3339.     local target="${T}/${name}";
  3340.     local var_tmp="${T}/launcher_variables_tmp";
  3341.     local target_dir pre;
  3342.     while [[ -n "${1}" && -n "${2}" ]]; do
  3343.         local var="${1}" value="${2}";
  3344.         if [[ "${var:0:2}" == "--" ]]; then
  3345.             local var=${var:2};
  3346.             echo "gjl_${var}=\"${value}\"" >> "${var_tmp}";
  3347.             local gjl_${var}="${value}";
  3348.         else
  3349.             if [[ "${var}" == "-into" ]]; then
  3350.                 target_dir="${value}";
  3351.             else
  3352.                 if [[ "${var}" == "-pre" ]]; then
  3353.                     pre="${value}";
  3354.                 fi;
  3355.             fi;
  3356.         fi;
  3357.         shift 2;
  3358.     done;
  3359.     if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
  3360.         local cp="${JAVA_PKG_CLASSPATH}";
  3361.         if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
  3362.             echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}";
  3363.         else
  3364.             local msg="Not enough information to create a launcher given.";
  3365.             msg="${msg} Please give --jar or --main argument to ${FUNCNAME}.";
  3366.             die "${msg}";
  3367.         fi;
  3368.     fi;
  3369.     echo "#!/bin/bash" > "${target}";
  3370.     if [[ -n "${pre}" ]]; then
  3371.         if [[ -f "${pre}" ]]; then
  3372.             cat "${pre}" >> "${target}";
  3373.         else
  3374.             die "-pre specified file '${pre}' does not exist";
  3375.         fi;
  3376.     fi;
  3377.     echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}";
  3378.     cat "${var_tmp}" >> "${target}";
  3379.     rm -f "${var_tmp}";
  3380.     echo "source ${EPREFIX}/usr/share/java-config-2/launcher/launcher.bash" >> "${target}";
  3381.     if [[ -n "${target_dir}" ]]; then
  3382.         ( into "${target_dir}";
  3383.         dobin "${target}" );
  3384.         local ret=$?;
  3385.         return ${ret};
  3386.     else
  3387.         dobin "${target}";
  3388.     fi
  3389. }
  3390. java-pkg_doso ()
  3391. {
  3392.     debug-print-function ${FUNCNAME} $*;
  3393.     java-pkg_check-phase install;
  3394.     [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument";
  3395.     java-pkg_init_paths_;
  3396.     local lib;
  3397.     for lib in "$@";
  3398.     do
  3399.         if [[ -e "${lib}" ]]; then
  3400.             if [[ ! -L "${lib}" ]]; then
  3401.                 ( insinto "${JAVA_PKG_LIBDEST}";
  3402.                 insopts -m0755;
  3403.                 doins "${lib}" ) || die "failed to install ${lib}";
  3404.                 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}";
  3405.                 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}";
  3406.             else
  3407.                 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}";
  3408.                 debug-print "${lib} is a symlink, linking accordantly";
  3409.             fi;
  3410.         else
  3411.             die "${lib} does not exist";
  3412.         fi;
  3413.     done;
  3414.     java-pkg_do_write_
  3415. }
  3416. java-pkg_dosrc ()
  3417. {
  3418.     debug-print-function ${FUNCNAME} $*;
  3419.     [ ${#} -lt 1 ] && die "At least one argument needed";
  3420.     java-pkg_check-phase install;
  3421.     [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3422.     if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
  3423.         local msg="${FUNCNAME} called without app-arch/zip in DEPEND";
  3424.         java-pkg_announce-qa-violation ${msg};
  3425.     fi;
  3426.     java-pkg_init_paths_;
  3427.     local zip_name="${PN}-src.zip";
  3428.     local zip_path="${T}/${zip_name}";
  3429.     local dir;
  3430.     for dir in "${@}";
  3431.     do
  3432.         local dir_parent=$(dirname "${dir}");
  3433.         local dir_name=$(basename "${dir}");
  3434.         pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}";
  3435.         zip -q -r ${zip_path} ${dir_name} -i '*.java';
  3436.         local result=$?;
  3437.         if [[ ${result} != 12 && ${result} != 0 ]]; then
  3438.             die "failed to zip ${dir_name}";
  3439.         fi;
  3440.         popd > /dev/null || die;
  3441.     done;
  3442.     ( insinto "${JAVA_PKG_SOURCESPATH}";
  3443.     doins ${zip_path} ) || die "Failed to install source";
  3444.     JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}";
  3445.     if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  3446.         einfo "Verbose logging for \"${FUNCNAME}\" function";
  3447.         einfo "Zip filename created: ${zip_name}";
  3448.         einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}";
  3449.         einfo "Directories zipped: ${@}";
  3450.         einfo "Complete command:";
  3451.         einfo "${FUNCNAME} ${@}";
  3452.     fi;
  3453.     java-pkg_do_write_
  3454. }
  3455. java-pkg_dowar ()
  3456. {
  3457.     debug-print-function ${FUNCNAME} $*;
  3458.     [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3459.     java-pkg_check-phase install;
  3460.     java-pkg_init_paths_;
  3461.     local war;
  3462.     for war in $*;
  3463.     do
  3464.         local warpath;
  3465.         if [[ -L "${war}" ]]; then
  3466.             cp "${war}" "${T}";
  3467.             warpath="${T}$(basename "${war}")";
  3468.         else
  3469.             if [[ -d "${war}" ]]; then
  3470.                 echo "dowar: warning, skipping directory ${war}";
  3471.                 continue;
  3472.             else
  3473.                 warpath="${war}";
  3474.             fi;
  3475.         fi;
  3476.         ( insopts -m0644;
  3477.         insinto "${JAVA_PKG_WARDEST}";
  3478.         doins ${warpath} );
  3479.     done
  3480. }
  3481. java-pkg_ensure-dep ()
  3482. {
  3483.     debug-print-function ${FUNCNAME} $*;
  3484.     local limit_to="${1}";
  3485.     local target_pkg="${2}";
  3486.     local dev_error="";
  3487.     local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b;
  3488.     debug-print "Matching against: ${stripped_pkg}";
  3489.     if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
  3490.         dev_error="The ebuild is attempting to use ${target_pkg}, which is not ";
  3491.         dev_error+="declared with a SLOT in DEPEND.";
  3492.         eqawarn "java-pkg_ensure-dep: ${dev_error}";
  3493.     else
  3494.         if [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
  3495.             dev_error="The ebuild is attempting to use ${target_pkg}, which is not ";
  3496.             dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given.";
  3497.             eqawarn "java-pkg_ensure-dep: ${dev_error}";
  3498.         fi;
  3499.     fi
  3500. }
  3501. java-pkg_ensure-gcj ()
  3502. {
  3503.     die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
  3504. }
  3505. java-pkg_ensure-no-bundled-jars ()
  3506. {
  3507.     debug-print-function ${FUNCNAME} $*;
  3508.     local bundled_jars=$(java-pkg_find-normal-jars);
  3509.     if [[ -n ${bundled_jars} ]]; then
  3510.         echo "Bundled jars found:";
  3511.         local jar;
  3512.         for jar in ${bundled_jars};
  3513.         do
  3514.             echo $(pwd)${jar/./};
  3515.         done;
  3516.         die "Bundled jars found!";
  3517.     fi
  3518. }
  3519. java-pkg_ensure-test ()
  3520. {
  3521.     die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
  3522. }
  3523. java-pkg_ensure-vm-version-eq ()
  3524. {
  3525.     debug-print-function ${FUNCNAME} $*;
  3526.     if ! java-pkg_is-vm-version-eq $@; then
  3527.         debug-print "VM is not suffient";
  3528.         eerror "This package requires a Java VM version = $@";
  3529.         einfo "Please use java-config -S to set the correct one";
  3530.         die "Active Java VM too old";
  3531.     fi
  3532. }
  3533. java-pkg_ensure-vm-version-ge ()
  3534. {
  3535.     debug-print-function ${FUNCNAME} $*;
  3536.     if ! java-pkg_is-vm-version-ge "$@"; then
  3537.         debug-print "vm is not suffient";
  3538.         eerror "This package requires a Java VM version >= $@";
  3539.         einfo "Please use java-config -S to set the correct one";
  3540.         die "Active Java VM too old";
  3541.     fi
  3542. }
  3543. java-pkg_ensure-vm-version-sufficient ()
  3544. {
  3545.     debug-print-function ${FUNCNAME} $*;
  3546.     if ! java-pkg_is-vm-version-sufficient; then
  3547.         debug-print "VM is not suffient";
  3548.         eerror "Current Java VM cannot build this package";
  3549.         einfo "Please use java-config -S to set the correct one";
  3550.         die "Active Java VM cannot build this package";
  3551.     fi
  3552. }
  3553. java-pkg_expand_dir_ ()
  3554. {
  3555.     pushd "$(dirname "${1}")" > /dev/null 2>&1 || die;
  3556.     pwd;
  3557.     popd > /dev/null 2>&1 || die
  3558. }
  3559. java-pkg_filter-compiler ()
  3560. {
  3561.     JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
  3562. }
  3563. java-pkg_find-normal-jars ()
  3564. {
  3565.     local dir=$1;
  3566.     [[ -n "${dir}" ]] || dir="${WORKDIR}";
  3567.     local found;
  3568.     for jar in $(find "${dir}" -name "*.jar" -type f);
  3569.     do
  3570.         echo "${jar}";
  3571.         found="true";
  3572.     done;
  3573.     [[ -n "${found}" ]];
  3574.     return $?
  3575. }
  3576. java-pkg_force-compiler ()
  3577. {
  3578.     JAVA_PKG_FORCE_COMPILER="$@"
  3579. }
  3580. java-pkg_func-exists ()
  3581. {
  3582.     declare -F ${1} > /dev/null
  3583. }
  3584. java-pkg_gen-cp ()
  3585. {
  3586.     debug-print-function ${FUNCNAME} "${@}";
  3587.     local atom;
  3588.     for atom in ${CP_DEPEND};
  3589.     do
  3590.         if [[ ${atom} =~ /(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)?(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+) ]]; then
  3591.             atom=${BASH_REMATCH[2]:-${BASH_REMATCH[1]}};
  3592.             [[ ${BASH_REMATCH[6]} != 0 ]] && atom+=-${BASH_REMATCH[6]};
  3593.             local regex="(^|\s|,)${atom}($|\s|,)";
  3594.             [[ ${!1} =~ ${regex} ]] || declare -g ${1}+=${!1:+,}${atom};
  3595.         else
  3596.             die "Invalid CP_DEPEND atom ${atom}, ensure a SLOT is included";
  3597.         fi;
  3598.     done
  3599. }
  3600. java-pkg_get-bootclasspath ()
  3601. {
  3602.     local version="${1}";
  3603.     local bcp;
  3604.     case "${version}" in
  3605.         auto)
  3606.             bcp="$(java-config -g BOOTCLASSPATH)"
  3607.         ;;
  3608.         1.5)
  3609.             bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
  3610.         ;;
  3611.         *)
  3612.             eerror "unknown parameter of java-pkg_get-bootclasspath";
  3613.             die "unknown parameter of java-pkg_get-bootclasspath"
  3614.         ;;
  3615.     esac;
  3616.     echo "${bcp}"
  3617. }
  3618. java-pkg_get-current-vm ()
  3619. {
  3620.     java-config -f
  3621. }
  3622. java-pkg_get-javac ()
  3623. {
  3624.     debug-print-function ${FUNCNAME} $*;
  3625.     java-pkg_init-compiler_;
  3626.     local compiler="${GENTOO_COMPILER}";
  3627.     local compiler_executable;
  3628.     if [[ "${compiler}" = "javac" ]]; then
  3629.         compiler_executable="javac";
  3630.     else
  3631.         local compiler_env="/usr/share/java-config-2/compiler/${compiler}";
  3632.         if [[ -f ${compiler_env} ]]; then
  3633.             local old_javac=${JAVAC};
  3634.             unset JAVAC;
  3635.             compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})";
  3636.             export JAVAC=${old_javac};
  3637.             if [[ -z ${compiler_executable} ]]; then
  3638.                 die "JAVAC is empty or undefined in ${compiler_env}";
  3639.             fi;
  3640.             if [[ ! -x ${compiler_executable} ]]; then
  3641.                 die "${compiler_executable} doesn't exist, or isn't executable";
  3642.             fi;
  3643.         else
  3644.             die "Could not find environment file for ${compiler}";
  3645.         fi;
  3646.     fi;
  3647.     echo ${compiler_executable}
  3648. }
  3649. java-pkg_get-jni-cflags ()
  3650. {
  3651.     local flags="-I${JAVA_HOME}/include";
  3652.     local platform="linux";
  3653.     use elibc_FreeBSD && platform="freebsd";
  3654.     flags="${flags} -I${JAVA_HOME}/include/${platform}";
  3655.     echo ${flags}
  3656. }
  3657. java-pkg_get-source ()
  3658. {
  3659.     echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
  3660. }
  3661. java-pkg_get-target ()
  3662. {
  3663.     echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
  3664. }
  3665. java-pkg_get-vm-vendor ()
  3666. {
  3667.     debug-print-function ${FUNCNAME} $*;
  3668.     local vm="$(java-pkg_get-current-vm)";
  3669.     vm="${vm/-*/}";
  3670.     echo "${vm}"
  3671. }
  3672. java-pkg_get-vm-version ()
  3673. {
  3674.     debug-print-function ${FUNCNAME} $*;
  3675.     java-config -g PROVIDES_VERSION
  3676. }
  3677. java-pkg_getjar ()
  3678. {
  3679.     debug-print-function ${FUNCNAME} $*;
  3680.     local build_only="";
  3681.     local virtual="";
  3682.     local record_jar="";
  3683.     [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3684.     while [[ "${1}" == --* ]]; do
  3685.         if [[ "${1}" = "--build-only" ]]; then
  3686.             build_only="build";
  3687.         else
  3688.             if [[ "${1}" == "--virtual" ]]; then
  3689.                 virtual="true";
  3690.             else
  3691.                 die "java-pkg_getjar called with unknown parameter: ${1}";
  3692.             fi;
  3693.         fi;
  3694.         shift;
  3695.     done;
  3696.     [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*";
  3697.     local pkg="${1}" target_jar="${2}" jar;
  3698.     if [[ "${EAPI}" == "1" ]]; then
  3699.         pkg="${pkg//:/-}";
  3700.     fi;
  3701.     [[ -z ${pkg} ]] && die "Must specify package to get a jar from";
  3702.     [[ -z ${target_jar} ]] && die "Must specify jar to get";
  3703.     local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?";
  3704.     local classpath;
  3705.     classpath=$(java-config --classpath=${pkg});
  3706.     [[ $? != 0 ]] && die ${error_msg};
  3707.     java-pkg_ensure-dep "${build_only}" "${pkg}";
  3708.     if [[ -n "${virtual}" ]]; then
  3709.         if [[ -z "${build_only}" ]]; then
  3710.             java-pkg_record-jar_ "${pkg}";
  3711.         else
  3712.             java-pkg_record-jar_ --build-only "${pkg}";
  3713.         fi;
  3714.         record_jar="true";
  3715.     fi;
  3716.     for jar in ${classpath//:/ };
  3717.     do
  3718.         if [[ ! -f "${jar}" ]]; then
  3719.             die "Installation problem with jar ${jar} in ${pkg} - is it installed?";
  3720.         fi;
  3721.         if [[ "$(basename ${jar})" == "${target_jar}" ]]; then
  3722.             if [[ -z "${record_jar}" ]]; then
  3723.                 if [[ -z "${build_only}" ]]; then
  3724.                     java-pkg_record-jar_ "${pkg}" "${jar}";
  3725.                 else
  3726.                     java-pkg_record-jar_ --build-only "${pkg}" "${jar}";
  3727.                 fi;
  3728.             fi;
  3729.             echo "${jar}";
  3730.             return 0;
  3731.         fi;
  3732.     done;
  3733.     die "Could not find ${target_jar} in ${pkg}";
  3734.     return 1
  3735. }
  3736. java-pkg_getjars ()
  3737. {
  3738.     debug-print-function ${FUNCNAME} $*;
  3739.     local build_only="";
  3740.     local deep="";
  3741.     [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3742.     while [[ "${1}" == --* ]]; do
  3743.         if [[ "${1}" = "--build-only" ]]; then
  3744.             build_only="build";
  3745.         else
  3746.             if [[ "${1}" = "--with-dependencies" ]]; then
  3747.                 deep="--with-dependencies";
  3748.             else
  3749.                 die "java-pkg_jar-from called with unknown parameter: ${1}";
  3750.             fi;
  3751.         fi;
  3752.         shift;
  3753.     done;
  3754.     [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*";
  3755.     local pkgs="${1}";
  3756.     if [[ "${EAPI}" == "1" ]]; then
  3757.         pkgs="${pkgs//:/-}";
  3758.     fi;
  3759.     jars="$(java-config ${deep} --classpath=${pkgs})";
  3760.     [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed";
  3761.     debug-print "${pkgs}:${jars}";
  3762.     for pkg in ${pkgs//,/ };
  3763.     do
  3764.         java-pkg_ensure-dep "${build_only}" "${pkg}";
  3765.     done;
  3766.     for pkg in ${pkgs//,/ };
  3767.     do
  3768.         if [[ -z "${build_only}" ]]; then
  3769.             java-pkg_record-jar_ "${pkg}";
  3770.         else
  3771.             java-pkg_record-jar_ --build-only "${pkg}";
  3772.         fi;
  3773.     done;
  3774.     echo "${jars}"
  3775. }
  3776. java-pkg_init ()
  3777. {
  3778.     debug-print-function ${FUNCNAME} $*;
  3779.     [[ "${MERGE_TYPE}" == "binary" ]] && return;
  3780.     has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return;
  3781.     unset JAVAC;
  3782.     unset JAVA_HOME;
  3783.     java-config --help > /dev/null || {
  3784.         eerror "";
  3785.         eerror "Can't run java-config --help";
  3786.         eerror "Have you upgraded python recently but haven't";
  3787.         eerror "run python-updater yet?";
  3788.         die "Can't run java-config --help"
  3789.     };
  3790.     local silence="${SILENCE_JAVA_OPTIONS_WARNING}";
  3791.     local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}";
  3792.     if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
  3793.         ewarn "_JAVA_OPTIONS changes what java -version outputs at least for";
  3794.         ewarn "sun-jdk vms and and as such break configure scripts that";
  3795.         ewarn "use it (for example app-office/openoffice) so we filter it out.";
  3796.         ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use";
  3797.         ewarn "make.conf for example) to silence this warning or";
  3798.         ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it.";
  3799.     fi;
  3800.     if [[ -z ${accept} ]]; then
  3801.         unset _JAVA_OPTIONS;
  3802.         I_WANT_GLOBAL_JAVA_OPTIONS="true";
  3803.     fi;
  3804.     java-pkg_switch-vm;
  3805.     PATH=${JAVA_HOME}/bin:${PATH};
  3806.     java-pkg_check-jikes;
  3807.     export CLASSPATH=;
  3808.     export ANT_TASKS=;
  3809.     export ANT_OPTS=;
  3810.     export ANT_RESPECT_JAVA_HOME=
  3811. }
  3812. java-pkg_init-compiler_ ()
  3813. {
  3814.     debug-print-function ${FUNCNAME} $*;
  3815.     if [[ -n ${GENTOO_COMPILER} ]]; then
  3816.         debug-print "GENTOO_COMPILER already set";
  3817.         return;
  3818.     fi;
  3819.     local compilers;
  3820.     if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
  3821.         compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo   ${COMPILERS})";
  3822.     else
  3823.         compilers=${JAVA_PKG_FORCE_COMPILER};
  3824.     fi;
  3825.     debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}";
  3826.     local compiler;
  3827.     for compiler in ${compilers};
  3828.     do
  3829.         debug-print "Checking ${compiler}...";
  3830.         if [[ ${compiler} = "javac" ]]; then
  3831.             debug-print "Found javac... breaking";
  3832.             export GENTOO_COMPILER="javac";
  3833.             break;
  3834.         fi;
  3835.         if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
  3836.             if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
  3837.                 einfo "Filtering ${compiler}" 1>&2;
  3838.                 continue;
  3839.             fi;
  3840.         fi;
  3841.         local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}";
  3842.         if [[ -f ${compiler_env} ]]; then
  3843.             local desired_target="$(java-pkg_get-target)";
  3844.             local desired_source="$(java-pkg_get-source)";
  3845.             local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET});
  3846.             if ! has ${desired_target} ${supported_target}; then
  3847.                 ewarn "${compiler} does not support -target ${desired_target},  skipping";
  3848.                 continue;
  3849.             fi;
  3850.             local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE});
  3851.             if ! has ${desired_source} ${supported_source}; then
  3852.                 ewarn "${compiler} does not support -source ${desired_source}, skipping";
  3853.                 continue;
  3854.             fi;
  3855.             export GENTOO_COMPILER="${compiler}";
  3856.             break;
  3857.         else
  3858.             ewarn "Could not find configuration for ${compiler}, skipping";
  3859.             ewarn "Perhaps it is not installed?";
  3860.             continue;
  3861.         fi;
  3862.     done;
  3863.     if [[ -z ${GENTOO_COMPILER} ]]; then
  3864.         if [[ -n ${compilers} ]]; then
  3865.             einfo "No suitable compiler found: defaulting to JDK default for compilation" 1>&2;
  3866.         else
  3867.             :;
  3868.         fi;
  3869.         if java-config -g GENTOO_COMPILER 2> /dev/null; then
  3870.             export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER);
  3871.         else
  3872.             export GENTOO_COMPILER=javac;
  3873.         fi;
  3874.     else
  3875.         einfo "Using ${GENTOO_COMPILER} for compilation" 1>&2;
  3876.     fi
  3877. }
  3878. java-pkg_init_paths_ ()
  3879. {
  3880.     debug-print-function ${FUNCNAME} $*;
  3881.     local pkg_name;
  3882.     if [[ "${SLOT%/*}" == "0" ]]; then
  3883.         JAVA_PKG_NAME="${PN}";
  3884.     else
  3885.         JAVA_PKG_NAME="${PN}-${SLOT%/*}";
  3886.     fi;
  3887.     JAVA_PKG_SHAREPATH="/usr/share/${JAVA_PKG_NAME}";
  3888.     JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/";
  3889.     JAVA_PKG_ENV="${ED}${JAVA_PKG_SHAREPATH}/package.env";
  3890.     JAVA_PKG_VIRTUALS_PATH="/usr/share/java-config-2/virtuals";
  3891.     JAVA_PKG_VIRTUAL_PROVIDER="${ED}${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}";
  3892.     [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib";
  3893.     [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="/usr/$(get_libdir)/${JAVA_PKG_NAME}";
  3894.     [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps";
  3895.     debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}";
  3896.     debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}";
  3897.     debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}";
  3898.     debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}";
  3899.     debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
  3900. }
  3901. java-pkg_is-vm-version-eq ()
  3902. {
  3903.     debug-print-function ${FUNCNAME} $*;
  3904.     local needed_version="$@";
  3905.     [[ -z "${needed_version}" ]] && die "need an argument";
  3906.     local vm_version="$(java-pkg_get-vm-version)";
  3907.     vm_version="$(get_version_component_range 1-2 "${vm_version}")";
  3908.     needed_version="$(get_version_component_range 1-2 "${needed_version}")";
  3909.     if [[ -z "${vm_version}" ]]; then
  3910.         debug-print "Could not get JDK version from DEPEND";
  3911.         return 1;
  3912.     else
  3913.         if [[ "${vm_version}" == "${needed_version}" ]]; then
  3914.             debug-print "Detected a JDK(${vm_version}) = ${needed_version}";
  3915.             return 0;
  3916.         else
  3917.             debug-print "Detected a JDK(${vm_version}) != ${needed_version}";
  3918.             return 1;
  3919.         fi;
  3920.     fi
  3921. }
  3922. java-pkg_is-vm-version-ge ()
  3923. {
  3924.     debug-print-function ${FUNCNAME} $*;
  3925.     local needed_version=$@;
  3926.     local vm_version=$(java-pkg_get-vm-version);
  3927.     if [[ -z "${vm_version}" ]]; then
  3928.         debug-print "Could not get JDK version from DEPEND";
  3929.         return 1;
  3930.     else
  3931.         if version_is_at_least "${needed_version}" "${vm_version}"; then
  3932.             debug-print "Detected a JDK(${vm_version}) >= ${needed_version}";
  3933.             return 0;
  3934.         else
  3935.             debug-print "Detected a JDK(${vm_version}) < ${needed_version}";
  3936.             return 1;
  3937.         fi;
  3938.     fi
  3939. }
  3940. java-pkg_is-vm-version-sufficient ()
  3941. {
  3942.     debug-print-function ${FUNCNAME} $*;
  3943.     depend-java-query --is-sufficient "${DEPEND}" > /dev/null;
  3944.     return $?
  3945. }
  3946. java-pkg_jar-from ()
  3947. {
  3948.     debug-print-function ${FUNCNAME} $*;
  3949.     local build_only="";
  3950.     local destdir=".";
  3951.     local deep="";
  3952.     local virtual="";
  3953.     local record_jar="";
  3954.     [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3955.     while [[ "${1}" == --* ]]; do
  3956.         if [[ "${1}" = "--build-only" ]]; then
  3957.             build_only="build";
  3958.         else
  3959.             if [[ "${1}" = "--with-dependencies" ]]; then
  3960.                 deep="--with-dependencies";
  3961.             else
  3962.                 if [[ "${1}" = "--virtual" ]]; then
  3963.                     virtual="true";
  3964.                 else
  3965.                     if [[ "${1}" = "--into" ]]; then
  3966.                         destdir="${2}";
  3967.                         shift;
  3968.                     else
  3969.                         die "java-pkg_jar-from called with unknown parameter: ${1}";
  3970.                     fi;
  3971.                 fi;
  3972.             fi;
  3973.         fi;
  3974.         shift;
  3975.     done;
  3976.     local target_pkg="${1}" target_jar="${2}" destjar="${3}";
  3977.     [[ -z ${target_pkg} ]] && die "Must specify a package";
  3978.     if [[ "${EAPI}" == "1" ]]; then
  3979.         target_pkg="${target_pkg//:/-}";
  3980.     fi;
  3981.     [[ -z "${destjar}" ]] && destjar="${target_jar}";
  3982.     local error_msg="There was a problem getting the classpath for ${target_pkg}.";
  3983.     local classpath;
  3984.     classpath="$(java-config ${deep} --classpath=${target_pkg})";
  3985.     [[ $? != 0 ]] && die ${error_msg};
  3986.     if [[ ${target_pkg} = *,* ]]; then
  3987.         for pkg in ${target_pkg//,/ };
  3988.         do
  3989.             java-pkg_ensure-dep "${build_only}" "${pkg}";
  3990.             [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}";
  3991.         done;
  3992.         record_jar="true";
  3993.     else
  3994.         java-pkg_ensure-dep "${build_only}" "${target_pkg}";
  3995.     fi;
  3996.     if [[ -z "${build_only}" && -n "${virtual}" ]]; then
  3997.         java-pkg_record-jar_ "${target_pkg}";
  3998.         record_jar="true";
  3999.     fi;
  4000.     pushd ${destdir} > /dev/null || die "failed to change directory to ${destdir}";
  4001.     local jar;
  4002.     for jar in ${classpath//:/ };
  4003.     do
  4004.         local jar_name=$(basename "${jar}");
  4005.         if [[ ! -f "${jar}" ]]; then
  4006.             debug-print "${jar} from ${target_pkg} does not exist";
  4007.             die "Installation problems with jars in ${target_pkg} - is it installed?";
  4008.         fi;
  4009.         if [[ -z "${target_jar}" ]]; then
  4010.             [[ -f "${target_jar}" ]] && rm "${target_jar}";
  4011.             ln -snf "${jar}" || die "Failed to make symlink from ${jar} to ${jar_name}";
  4012.             if [[ -z "${record_jar}" ]]; then
  4013.                 if [[ -z "${build_only}" ]]; then
  4014.                     java-pkg_record-jar_ "${target_pkg}" "${jar}";
  4015.                 else
  4016.                     java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}";
  4017.                 fi;
  4018.             fi;
  4019.         else
  4020.             if [[ "${jar_name}" == "${target_jar}" ]]; then
  4021.                 [[ -f "${destjar}" ]] && rm "${destjar}";
  4022.                 ln -snf "${jar}" "${destjar}" || die "Failed to make symlink from ${jar} to ${destjar}";
  4023.                 if [[ -z "${record_jar}" ]]; then
  4024.                     if [[ -z "${build_only}" ]]; then
  4025.                         java-pkg_record-jar_ "${target_pkg}" "${jar}";
  4026.                     else
  4027.                         java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}";
  4028.                     fi;
  4029.                 fi;
  4030.                 popd > /dev/null || die;
  4031.                 return 0;
  4032.             fi;
  4033.         fi;
  4034.     done;
  4035.     popd > /dev/null || die;
  4036.     if [[ -z "${target_jar}" ]]; then
  4037.         return 0;
  4038.     else
  4039.         die "Failed to find ${target_jar:-jar} in ${target_pkg}";
  4040.     fi
  4041. }
  4042. java-pkg_jar-list ()
  4043. {
  4044.     if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
  4045.         einfo "Linked Jars";
  4046.         find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  4047.         einfo "Jars";
  4048.         find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  4049.         einfo "Classes";
  4050.         find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  4051.     fi
  4052. }
  4053. java-pkg_jarfrom ()
  4054. {
  4055.     java-pkg_jar-from "$@"
  4056. }
  4057. java-pkg_jarinto ()
  4058. {
  4059.     debug-print-function ${FUNCNAME} $*;
  4060.     JAVA_PKG_JARDEST="${1}"
  4061. }
  4062. java-pkg_javac-args ()
  4063. {
  4064.     debug-print-function ${FUNCNAME} $*;
  4065.     local want_source="$(java-pkg_get-source)";
  4066.     local want_target="$(java-pkg_get-target)";
  4067.     local source_str="-source ${want_source}";
  4068.     local target_str="-target ${want_target}";
  4069.     debug-print "want source: ${want_source}";
  4070.     debug-print "want target: ${want_target}";
  4071.     if [[ -z "${want_source}" || -z "${want_target}" ]]; then
  4072.         die "Could not find valid -source/-target values for javac";
  4073.     else
  4074.         echo "${source_str} ${target_str}";
  4075.     fi
  4076. }
  4077. java-pkg_needs-vm ()
  4078. {
  4079.     debug-print-function ${FUNCNAME} $*;
  4080.     if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
  4081.         return 0;
  4082.     fi;
  4083.     [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0;
  4084.     return 1
  4085. }
  4086. java-pkg_newjar ()
  4087. {
  4088.     debug-print-function ${FUNCNAME} $*;
  4089.     local original_jar="${1}";
  4090.     local new_jar="${2:-${PN}.jar}";
  4091.     local new_jar_dest="${T}/${new_jar}";
  4092.     [[ -z ${original_jar} ]] && die "Must specify a jar to install";
  4093.     [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist or is not a file!";
  4094.     rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}";
  4095.     cp "${original_jar}" "${new_jar_dest}" || die "Failed to copy ${original_jar} to ${new_jar_dest}";
  4096.     java-pkg_dojar "${new_jar_dest}"
  4097. }
  4098. java-pkg_record-jar_ ()
  4099. {
  4100.     debug-print-function ${FUNCNAME} $*;
  4101.     local depend_file="${JAVA_PKG_DEPEND_FILE}";
  4102.     case "${1}" in
  4103.         "--optional")
  4104.             depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}";
  4105.             shift
  4106.         ;;
  4107.         "--build-only")
  4108.             depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}";
  4109.             shift
  4110.         ;;
  4111.     esac;
  4112.     local pkg=${1} jar=${2} append;
  4113.     if [[ -z "${jar}" ]]; then
  4114.         append="${pkg}";
  4115.     else
  4116.         append="$(basename ${jar})@${pkg}";
  4117.     fi;
  4118.     echo "${append}" >> "${depend_file}"
  4119. }
  4120. java-pkg_recordjavadoc ()
  4121. {
  4122.     debug-print-function ${FUNCNAME} $*;
  4123.     JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')";
  4124.     JAVADOC_PATH="${JAVADOC_PATH//${D}}";
  4125.     if [[ -n "${JAVADOC_PATH}" ]]; then
  4126.         debug-print "javadocs found in ${JAVADOC_PATH%:}";
  4127.         java-pkg_do_write_;
  4128.     else
  4129.         debug-print "No javadocs found";
  4130.     fi
  4131. }
  4132. java-pkg_register-ant-task ()
  4133. {
  4134.     local TASKS_DIR="tasks";
  4135.     while [[ -n "${1}" && -n "${2}" ]]; do
  4136.         local var="${1#--}";
  4137.         local val="${2}";
  4138.         if [[ "${var}" == "version" ]]; then
  4139.             TASKS_DIR="tasks-${val}";
  4140.         else
  4141.             die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}";
  4142.         fi;
  4143.         shift 2;
  4144.     done;
  4145.     local TASK_NAME="${1:-${JAVA_PKG_NAME}}";
  4146.     dodir /usr/share/ant/${TASKS_DIR};
  4147.     touch "${ED}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
  4148. }
  4149. java-pkg_register-dependency ()
  4150. {
  4151.     debug-print-function ${FUNCNAME} $*;
  4152.     java-pkg_check-phase install;
  4153.     [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments";
  4154.     local pkgs="${1}";
  4155.     local jar="${2}";
  4156.     [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified";
  4157.     if [[ "${EAPI}" == "1" ]]; then
  4158.         pkgs="${pkgs//:/-}";
  4159.     fi;
  4160.     if [[ -z "${jar}" ]]; then
  4161.         for pkg in ${pkgs//,/ };
  4162.         do
  4163.             java-pkg_ensure-dep runtime "${pkg}";
  4164.             java-pkg_record-jar_ "${pkg}";
  4165.         done;
  4166.     else
  4167.         [[ ${pkgs} == *,* ]] && die "${FUNCNAME} called with both package list and jar name";
  4168.         java-pkg_ensure-dep runtime "${pkgs}";
  4169.         java-pkg_record-jar_ "${pkgs}" "${jar}";
  4170.     fi;
  4171.     java-pkg_do_write_
  4172. }
  4173. java-pkg_register-environment-variable ()
  4174. {
  4175.     debug-print-function ${FUNCNAME} $*;
  4176.     java-pkg_check-phase install;
  4177.     [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments";
  4178.     echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV};
  4179.     JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}";
  4180.     java-pkg_do_write_
  4181. }
  4182. java-pkg_register-optional-dependency ()
  4183. {
  4184.     debug-print-function ${FUNCNAME} $*;
  4185.     java-pkg_check-phase install;
  4186.     [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments";
  4187.     local pkgs="${1}";
  4188.     local jar="${2}";
  4189.     [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified";
  4190.     if [[ "${EAPI}" == "1" ]]; then
  4191.         pkgs="${pkgs//:/-}";
  4192.     fi;
  4193.     if [[ -z "${jar}" ]]; then
  4194.         for pkg in ${pkgs//,/ };
  4195.         do
  4196.             java-pkg_record-jar_ --optional "${pkg}";
  4197.         done;
  4198.     else
  4199.         [[ ${pkgs} == *,* ]] && die "${FUNCNAME} called with both package list and jar name";
  4200.         java-pkg_record-jar_ --optional "${pkgs}" "${jar}";
  4201.     fi;
  4202.     java-pkg_do_write_
  4203. }
  4204. java-pkg_regjar ()
  4205. {
  4206.     debug-print-function ${FUNCNAME} $*;
  4207.     java-pkg_check-phase install;
  4208.     [[ ${#} -lt 1 ]] && die "at least one argument needed";
  4209.     java-pkg_init_paths_;
  4210.     local jar jar_dir jar_file;
  4211.     for jar in "${@}";
  4212.     do
  4213.         if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
  4214.             [[ -d "${jar}" || -d "${D}${jar}" ]] && die "Called ${FUNCNAME} on a    directory $*";
  4215.             is-java-strict && java-pkg_verify-classes "${jar}";
  4216.             java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}";
  4217.         else
  4218.             if [[ ${jar} = *\** ]]; then
  4219.                 eerror "The argument ${jar} to ${FUNCNAME}";
  4220.                 eerror "has * in it. If you want it to glob in";
  4221.                 eerror '${D} add ${D} to the argument.';
  4222.             fi;
  4223.             debug-print "${jar} or ${D}${jar} not found";
  4224.             die "${jar} does not exist";
  4225.         fi;
  4226.     done;
  4227.     java-pkg_do_write_
  4228. }
  4229. java-pkg_regso ()
  4230. {
  4231.     debug-print-function ${FUNCNAME} $*;
  4232.     java-pkg_check-phase install;
  4233.     [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument";
  4234.     java-pkg_init_paths_;
  4235.     local lib target_dir;
  4236.     for lib in "$@";
  4237.     do
  4238.         if [[ -e "${lib}" ]]; then
  4239.             target_dir="$(java-pkg_expand_dir_ ${lib})";
  4240.             java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}";
  4241.         else
  4242.             if [[ -e "${D}${lib}" ]]; then
  4243.                 target_dir="$(java-pkg_expand_dir_ ${D}${lib})";
  4244.                 java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}";
  4245.             else
  4246.                 die "${lib} does not exist";
  4247.             fi;
  4248.         fi;
  4249.     done;
  4250.     java-pkg_do_write_
  4251. }
  4252. java-pkg_rm_files ()
  4253. {
  4254.     debug-print-function ${FUNCNAME} $*;
  4255.     local IFS="\n";
  4256.     for filename in "$@";
  4257.     do
  4258.         [[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting.";
  4259.         einfo "Removing unneeded file ${filename}";
  4260.         rm -f "${S}/${filename}" || die "cannot remove ${filename}";
  4261.         eend $?;
  4262.     done
  4263. }
  4264. java-pkg_set-current-vm ()
  4265. {
  4266.     export GENTOO_VM=${1}
  4267. }
  4268. java-pkg_setup-vm ()
  4269. {
  4270.     debug-print-function ${FUNCNAME} $*;
  4271.     local vendor="$(java-pkg_get-vm-vendor)";
  4272.     if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5"; then
  4273.         addpredict "/dev/random";
  4274.     else
  4275.         if [[ "${vendor}" == "ibm" ]]; then
  4276.             addpredict "/proc/self/maps";
  4277.             addpredict "/proc/cpuinfo";
  4278.             addpredict "/proc/self/coredump_filter";
  4279.         else
  4280.             if [[ "${vendor}" == "oracle" ]]; then
  4281.                 addpredict "/dev/random";
  4282.                 addpredict "/proc/self/coredump_filter";
  4283.             else
  4284.                 if [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7"; then
  4285.                     addpredict "/dev/random";
  4286.                     addpredict "/proc/self/coredump_filter";
  4287.                 else
  4288.                     if [[ "${vendor}" == "jrockit" ]]; then
  4289.                         addpredict "/proc/cpuinfo";
  4290.                     fi;
  4291.                 fi;
  4292.             fi;
  4293.         fi;
  4294.     fi
  4295. }
  4296. java-pkg_sointo ()
  4297. {
  4298.     debug-print-function ${FUNCNAME} $*;
  4299.     JAVA_PKG_LIBDEST="${1}"
  4300. }
  4301. java-pkg_switch-vm ()
  4302. {
  4303.     debug-print-function ${FUNCNAME} $*;
  4304.     if java-pkg_needs-vm; then
  4305.         if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
  4306.             debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}";
  4307.             export GENTOO_VM="${JAVA_PKG_FORCE_VM}";
  4308.         else
  4309.             if [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
  4310.                 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
  4311.                     debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}";
  4312.                     GENTOO_VM=$(java-pkg_build-vm-from-handle);
  4313.                     if [[ $? != 0 ]]; then
  4314.                         eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}";
  4315.                         die "${FUNCNAME}: Failed to determine VM for building";
  4316.                     fi;
  4317.                     if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
  4318.                         eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE";
  4319.                         die "Specify JAVA_PKG_WANT_SOURCE";
  4320.                     fi;
  4321.                     if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
  4322.                         eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET";
  4323.                         die "Specify JAVA_PKG_WANT_TARGET";
  4324.                     fi;
  4325.                 else
  4326.                     debug-print "depend-java-query:  NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}";
  4327.                     GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")";
  4328.                     if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
  4329.                         eerror "Unable to determine VM for building from dependencies:";
  4330.                         echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}";
  4331.                         die "Failed to determine VM for building.";
  4332.                     fi;
  4333.                 fi;
  4334.                 export GENTOO_VM;
  4335.             else
  4336.                 java-pkg_ensure-vm-version-sufficient;
  4337.             fi;
  4338.         fi;
  4339.         debug-print "Using: $(java-config -f)";
  4340.         java-pkg_setup-vm;
  4341.         export JAVA=$(java-config --java);
  4342.         export JAVAC=$(java-config --javac);
  4343.         JAVACFLAGS="$(java-pkg_javac-args)";
  4344.         [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}";
  4345.         export JAVACFLAGS;
  4346.         export JAVA_HOME="$(java-config -g JAVA_HOME)";
  4347.         export JDK_HOME=${JAVA_HOME};
  4348.         java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)";
  4349.         local tann="${T}/announced-vm";
  4350.         if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]]; then
  4351.             einfo "Using: $(java-config -f)";
  4352.             [[ ! -f "${tann}" ]] && touch "${tann}";
  4353.         fi;
  4354.     else
  4355.         [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!";
  4356.     fi
  4357. }
  4358. java-pkg_verify-classes ()
  4359. {
  4360.     local version_verify="/usr/bin/class-version-verify.py";
  4361.     if [[ ! -x "${version_verify}" ]]; then
  4362.         version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py";
  4363.     fi;
  4364.     if [[ ! -x "${version_verify}" ]]; then
  4365.         ewarn "Unable to perform class version checks as";
  4366.         ewarn "class-version-verify.py is unavailable";
  4367.         ewarn "Please install dev-java/javatoolkit.";
  4368.         return;
  4369.     fi;
  4370.     local target=$(java-pkg_get-target);
  4371.     local result;
  4372.     local log="${T}/class-version-verify.log";
  4373.     if [[ -n "${1}" ]]; then
  4374.         ${version_verify} -v -t ${target} "${1}" > "${log}";
  4375.         result=$?;
  4376.     else
  4377.         ebegin "Verifying java class versions (target: ${target})";
  4378.         ${version_verify} -v -t ${target} -r "${D}" > "${log}";
  4379.         result=$?;
  4380.         eend ${result};
  4381.     fi;
  4382.     [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}";
  4383.     if [[ ${result} != 0 ]]; then
  4384.         eerror "Incorrect bytecode version found";
  4385.         [[ -n "${1}" ]] && eerror "in file: ${1}";
  4386.         eerror "See ${log} for more details.";
  4387.         die "Incorrect bytecode found";
  4388.     fi
  4389. }
  4390. java-utils-2_pkg_preinst ()
  4391. {
  4392.     if is-java-strict; then
  4393.         if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
  4394.             return;
  4395.         fi;
  4396.         if has_version dev-java/java-dep-check; then
  4397.             local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}");
  4398.             [[ -n ${output} ]] && ewarn "${output}";
  4399.         else
  4400.             eerror "Install dev-java/java-dep-check for dependency checking";
  4401.         fi;
  4402.     fi
  4403. }
  4404. java-utils-2_src_prepare ()
  4405. {
  4406.     case ${EAPI:-0} in
  4407.         [0-5])
  4408.             java-pkg_func-exists java_prepare && java_prepare
  4409.         ;;
  4410.         *)
  4411.             java-pkg_func-exists java_prepare && eqawarn "java_prepare is no longer called, define src_prepare instead.";
  4412.             eapply_user
  4413.         ;;
  4414.     esac;
  4415.     if [[ -n ${JAVA_RM_FILES[@]} ]]; then
  4416.         debug-print "$FUNCNAME: removing unneeded files";
  4417.         java-pkg_rm_files "${JAVA_RM_FILES[@]}";
  4418.     fi;
  4419.     if is-java-strict; then
  4420.         echo "Searching for bundled jars:";
  4421.         java-pkg_find-normal-jars || echo "None found.";
  4422.         echo "Searching for bundled classes (no output if none found):";
  4423.         find "${WORKDIR}" -name "*.class";
  4424.         echo "Search done.";
  4425.     fi
  4426. }
  4427. libtool_elt_patch_dir ()
  4428. {
  4429.     echo "${EPREFIX}/usr/share/elt-patches"
  4430. }
  4431. make_desktop_entry ()
  4432. {
  4433.     [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  4434.     local exec=${1};
  4435.     local name=${2:-${PN}};
  4436.     local icon=${3:-${PN}};
  4437.     local type=${4};
  4438.     local fields=${5};
  4439.     if [[ -z ${type} ]]; then
  4440.         local catmaj=${CATEGORY%%-*};
  4441.         local catmin=${CATEGORY##*-};
  4442.         case ${catmaj} in
  4443.             app)
  4444.                 case ${catmin} in
  4445.                     accessibility)
  4446.                         type="Utility;Accessibility"
  4447.                     ;;
  4448.                     admin)
  4449.                         type=System
  4450.                     ;;
  4451.                     antivirus)
  4452.                         type=System
  4453.                     ;;
  4454.                     arch)
  4455.                         type="Utility;Archiving"
  4456.                     ;;
  4457.                     backup)
  4458.                         type="Utility;Archiving"
  4459.                     ;;
  4460.                     cdr)
  4461.                         type="AudioVideo;DiscBurning"
  4462.                     ;;
  4463.                     dicts)
  4464.                         type="Office;Dictionary"
  4465.                     ;;
  4466.                     doc)
  4467.                         type=Documentation
  4468.                     ;;
  4469.                     editors)
  4470.                         type="Utility;TextEditor"
  4471.                     ;;
  4472.                     emacs)
  4473.                         type="Development;TextEditor"
  4474.                     ;;
  4475.                     emulation)
  4476.                         type="System;Emulator"
  4477.                     ;;
  4478.                     laptop)
  4479.                         type="Settings;HardwareSettings"
  4480.                     ;;
  4481.                     office)
  4482.                         type=Office
  4483.                     ;;
  4484.                     pda)
  4485.                         type="Office;PDA"
  4486.                     ;;
  4487.                     vim)
  4488.                         type="Development;TextEditor"
  4489.                     ;;
  4490.                     xemacs)
  4491.                         type="Development;TextEditor"
  4492.                     ;;
  4493.                 esac
  4494.             ;;
  4495.             dev)
  4496.                 type="Development"
  4497.             ;;
  4498.             games)
  4499.                 case ${catmin} in
  4500.                     action | fps)
  4501.                         type=ActionGame
  4502.                     ;;
  4503.                     arcade)
  4504.                         type=ArcadeGame
  4505.                     ;;
  4506.                     board)
  4507.                         type=BoardGame
  4508.                     ;;
  4509.                     emulation)
  4510.                         type=Emulator
  4511.                     ;;
  4512.                     kids)
  4513.                         type=KidsGame
  4514.                     ;;
  4515.                     puzzle)
  4516.                         type=LogicGame
  4517.                     ;;
  4518.                     roguelike)
  4519.                         type=RolePlaying
  4520.                     ;;
  4521.                     rpg)
  4522.                         type=RolePlaying
  4523.                     ;;
  4524.                     simulation)
  4525.                         type=Simulation
  4526.                     ;;
  4527.                     sports)
  4528.                         type=SportsGame
  4529.                     ;;
  4530.                     strategy)
  4531.                         type=StrategyGame
  4532.                     ;;
  4533.                 esac;
  4534.                 type="Game;${type}"
  4535.             ;;
  4536.             gnome)
  4537.                 type="Gnome;GTK"
  4538.             ;;
  4539.             kde)
  4540.                 type="KDE;Qt"
  4541.             ;;
  4542.             mail)
  4543.                 type="Network;Email"
  4544.             ;;
  4545.             media)
  4546.                 case ${catmin} in
  4547.                     gfx)
  4548.                         type=Graphics
  4549.                     ;;
  4550.                     *)
  4551.                         case ${catmin} in
  4552.                             radio)
  4553.                                 type=Tuner
  4554.                             ;;
  4555.                             sound)
  4556.                                 type=Audio
  4557.                             ;;
  4558.                             tv)
  4559.                                 type=TV
  4560.                             ;;
  4561.                             video)
  4562.                                 type=Video
  4563.                             ;;
  4564.                         esac;
  4565.                         type="AudioVideo;${type}"
  4566.                     ;;
  4567.                 esac
  4568.             ;;
  4569.             net)
  4570.                 case ${catmin} in
  4571.                     dialup)
  4572.                         type=Dialup
  4573.                     ;;
  4574.                     ftp)
  4575.                         type=FileTransfer
  4576.                     ;;
  4577.                     im)
  4578.                         type=InstantMessaging
  4579.                     ;;
  4580.                     irc)
  4581.                         type=IRCClient
  4582.                     ;;
  4583.                     mail)
  4584.                         type=Email
  4585.                     ;;
  4586.                     news)
  4587.                         type=News
  4588.                     ;;
  4589.                     nntp)
  4590.                         type=News
  4591.                     ;;
  4592.                     p2p)
  4593.                         type=FileTransfer
  4594.                     ;;
  4595.                     voip)
  4596.                         type=Telephony
  4597.                     ;;
  4598.                 esac;
  4599.                 type="Network;${type}"
  4600.             ;;
  4601.             sci)
  4602.                 case ${catmin} in
  4603.                     astro*)
  4604.                         type=Astronomy
  4605.                     ;;
  4606.                     bio*)
  4607.                         type=Biology
  4608.                     ;;
  4609.                     calc*)
  4610.                         type=Calculator
  4611.                     ;;
  4612.                     chem*)
  4613.                         type=Chemistry
  4614.                     ;;
  4615.                     elec*)
  4616.                         type=Electronics
  4617.                     ;;
  4618.                     geo*)
  4619.                         type=Geology
  4620.                     ;;
  4621.                     math*)
  4622.                         type=Math
  4623.                     ;;
  4624.                     physics)
  4625.                         type=Physics
  4626.                     ;;
  4627.                     visual*)
  4628.                         type=DataVisualization
  4629.                     ;;
  4630.                 esac;
  4631.                 type="Education;Science;${type}"
  4632.             ;;
  4633.             sys)
  4634.                 type="System"
  4635.             ;;
  4636.             www)
  4637.                 case ${catmin} in
  4638.                     client)
  4639.                         type=WebBrowser
  4640.                     ;;
  4641.                 esac;
  4642.                 type="Network;${type}"
  4643.             ;;
  4644.             *)
  4645.                 type=
  4646.             ;;
  4647.         esac;
  4648.     fi;
  4649.     local slot=${SLOT%/*};
  4650.     if [[ ${slot} == "0" ]]; then
  4651.         local desktop_name="${PN}";
  4652.     else
  4653.         local desktop_name="${PN}-${slot}";
  4654.     fi;
  4655.     local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  4656.     type=${type%;}${type:+;};
  4657.     eshopts_push -s extglob;
  4658.     if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  4659.         ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  4660.         ewarn "allowed in .desktop files if the value is not an absolute path.";
  4661.         icon=${icon%.@(xpm|png|svg)};
  4662.     fi;
  4663.     eshopts_pop;
  4664.     cat > "${desktop}"  <<-EOF
  4665. [Desktop Entry]
  4666. Name=${name}
  4667. Type=Application
  4668. Comment=${DESCRIPTION}
  4669. Exec=${exec}
  4670. TryExec=${exec%% *}
  4671. Icon=${icon}
  4672. Categories=${type}
  4673. EOF
  4674.  
  4675.     if [[ ${fields:-=} != *=* ]]; then
  4676.         ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  4677.         fields="Path=${fields}";
  4678.     fi;
  4679.     [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  4680.     ( insinto /usr/share/applications;
  4681.     doins "${desktop}" ) || die "installing desktop file failed"
  4682. }
  4683. make_session_desktop ()
  4684. {
  4685.     [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  4686.     [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  4687.     local title=$1;
  4688.     local command=$2;
  4689.     local desktop=${T}/${wm:-${PN}}.desktop;
  4690.     shift 2;
  4691.     cat > "${desktop}"  <<-EOF
  4692. [Desktop Entry]
  4693. Name=${title}
  4694. Comment=This session logs you into ${title}
  4695. Exec=${command} $*
  4696. TryExec=${command}
  4697. Type=XSession
  4698. EOF
  4699.  
  4700.     ( insinto /usr/share/xsessions;
  4701.     doins "${desktop}" )
  4702. }
  4703. make_wrapper ()
  4704. {
  4705.     _eutils_eprefix_init;
  4706.     local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  4707.     local tmpwrapper=$(emktemp);
  4708.     ( echo '#!/bin/sh';
  4709.     [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}";
  4710.     if [[ -n ${libdir} ]]; then
  4711.         local var;
  4712.         if [[ ${CHOST} == *-darwin* ]]; then
  4713.             var=DYLD_LIBRARY_PATH;
  4714.         else
  4715.             var=LD_LIBRARY_PATH;
  4716.         fi;
  4717.         cat  <<-EOF
  4718. if [ "\${${var}+set}" = "set" ] ; then
  4719. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  4720. else
  4721. export ${var}="${EPREFIX}${libdir}"
  4722. fi
  4723. EOF
  4724.  
  4725.     fi
  4726.     printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  4727.     chmod go+rx "${tmpwrapper}";
  4728.     if [[ -n ${path} ]]; then
  4729.         ( exeinto "${path}";
  4730.         newexe "${tmpwrapper}" "${wrapper}" ) || die;
  4731.     else
  4732.         newbin "${tmpwrapper}" "${wrapper}" || die;
  4733.     fi
  4734. }
  4735. mono-env_pkg_setup ()
  4736. {
  4737.     export MONO_SHARED_DIR="${T}";
  4738.     export MONO_REGISTRY_PATH="${T}/registry";
  4739.     export XDG_DATA_HOME="${T}/data";
  4740.     export LC_ALL=C;
  4741.     export XDG_CONFIG_HOME="${T}";
  4742.     unset MONO_AOT_CACHE;
  4743.     QA_MULTILIB_PATHS="usr/lib/"
  4744. }
  4745. multibuild_copy_sources ()
  4746. {
  4747.     debug-print-function ${FUNCNAME} "${@}";
  4748.     local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  4749.     einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  4750.     local cp_args=();
  4751.     if cp --reflink=auto --version &> /dev/null; then
  4752.         cp_args+=(--reflink=auto);
  4753.     fi;
  4754.     function _multibuild_create_source_copy ()
  4755.     {
  4756.         einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  4757.         cp -p -R "${cp_args[@]}" "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  4758.     };
  4759.     multibuild_foreach_variant _multibuild_create_source_copy
  4760. }
  4761. multibuild_for_best_variant ()
  4762. {
  4763.     debug-print-function ${FUNCNAME} "${@}";
  4764.     [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  4765.     local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}");
  4766.     multibuild_foreach_variant "${@}"
  4767. }
  4768. multibuild_foreach_variant ()
  4769. {
  4770.     debug-print-function ${FUNCNAME} "${@}";
  4771.     [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  4772.     local bdir=${BUILD_DIR:-${S}};
  4773.     [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  4774.     local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  4775.     local ret=0 lret=0 v;
  4776.     debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  4777.     for v in "${MULTIBUILD_VARIANTS[@]}";
  4778.     do
  4779.         local MULTIBUILD_VARIANT=${v};
  4780.         local MULTIBUILD_ID=${prev_id}${v};
  4781.         local BUILD_DIR=${bdir%%/}-${v};
  4782.         function _multibuild_run ()
  4783.         {
  4784.             local i=1;
  4785.             while [[ ${!i} == _* ]]; do
  4786.                 (( i += 1 ));
  4787.             done;
  4788.             [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  4789.             "${@}"
  4790.         };
  4791.         _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  4792.         lret=${?};
  4793.     done;
  4794.     [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  4795.     return ${ret}
  4796. }
  4797. multibuild_merge_root ()
  4798. {
  4799.     local src=${1};
  4800.     local dest=${2};
  4801.     local ret;
  4802.     if use userland_BSD; then
  4803.         tar -C "${src}" -f - -c . | tar -x -f - -C "${dest}";
  4804.         [[ ${PIPESTATUS[*]} == '0 0' ]];
  4805.         ret=${?};
  4806.     else
  4807.         local cp_args=();
  4808.         if cp -a --version &> /dev/null; then
  4809.             cp_args+=(-a);
  4810.         else
  4811.             cp_args+=(-P -R -p);
  4812.         fi;
  4813.         if cp --reflink=auto --version &> /dev/null; then
  4814.             cp_args+=(--reflink=auto);
  4815.         fi;
  4816.         cp "${cp_args[@]}" "${src}"/. "${dest}"/;
  4817.         ret=${?};
  4818.     fi;
  4819.     if [[ ${ret} -ne 0 ]]; then
  4820.         die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
  4821.     fi;
  4822.     rm -rf "${src}"
  4823. }
  4824. multibuild_parallel_foreach_variant ()
  4825. {
  4826.     debug-print-function ${FUNCNAME} "${@}";
  4827.     [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  4828.     multibuild_foreach_variant "${@}"
  4829. }
  4830. multilib-minimal_abi_src_configure ()
  4831. {
  4832.     debug-print-function ${FUNCNAME} "$@";
  4833.     mkdir -p "${BUILD_DIR}" || die;
  4834.     pushd "${BUILD_DIR}" > /dev/null || die;
  4835.     if declare -f multilib_src_configure > /dev/null; then
  4836.         multilib_src_configure;
  4837.     else
  4838.         default_src_configure;
  4839.     fi;
  4840.     popd > /dev/null || die
  4841. }
  4842. multilib-minimal_src_compile ()
  4843. {
  4844.     debug-print-function ${FUNCNAME} "$@";
  4845.     function multilib-minimal_abi_src_compile ()
  4846.     {
  4847.         debug-print-function ${FUNCNAME} "$@";
  4848.         pushd "${BUILD_DIR}" > /dev/null || die;
  4849.         if declare -f multilib_src_compile > /dev/null; then
  4850.             multilib_src_compile;
  4851.         else
  4852.             default_src_compile;
  4853.         fi;
  4854.         popd > /dev/null || die
  4855.     };
  4856.     multilib_foreach_abi multilib-minimal_abi_src_compile
  4857. }
  4858. multilib-minimal_src_configure ()
  4859. {
  4860.     debug-print-function ${FUNCNAME} "$@";
  4861.     function multilib-minimal_abi_src_configure ()
  4862.     {
  4863.         debug-print-function ${FUNCNAME} "$@";
  4864.         mkdir -p "${BUILD_DIR}" || die;
  4865.         pushd "${BUILD_DIR}" > /dev/null || die;
  4866.         if declare -f multilib_src_configure > /dev/null; then
  4867.             multilib_src_configure;
  4868.         else
  4869.             default_src_configure;
  4870.         fi;
  4871.         popd > /dev/null || die
  4872.     };
  4873.     multilib_foreach_abi multilib-minimal_abi_src_configure
  4874. }
  4875. multilib-minimal_src_install ()
  4876. {
  4877.     debug-print-function ${FUNCNAME} "$@";
  4878.     function multilib-minimal_abi_src_install ()
  4879.     {
  4880.         debug-print-function ${FUNCNAME} "$@";
  4881.         pushd "${BUILD_DIR}" > /dev/null || die;
  4882.         if declare -f multilib_src_install > /dev/null; then
  4883.             multilib_src_install;
  4884.         else
  4885.             if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  4886.                 emake DESTDIR="${D}" install;
  4887.             fi;
  4888.         fi;
  4889.         multilib_prepare_wrappers;
  4890.         multilib_check_headers;
  4891.         popd > /dev/null || die
  4892.     };
  4893.     multilib_foreach_abi multilib-minimal_abi_src_install;
  4894.     multilib_install_wrappers;
  4895.     if declare -f multilib_src_install_all > /dev/null; then
  4896.         multilib_src_install_all;
  4897.     else
  4898.         einstalldocs;
  4899.     fi
  4900. }
  4901. multilib-minimal_src_test ()
  4902. {
  4903.     debug-print-function ${FUNCNAME} "$@";
  4904.     function multilib-minimal_abi_src_test ()
  4905.     {
  4906.         debug-print-function ${FUNCNAME} "$@";
  4907.         pushd "${BUILD_DIR}" > /dev/null || die;
  4908.         if declare -f multilib_src_test > /dev/null; then
  4909.             multilib_src_test;
  4910.         else
  4911.             default_src_test;
  4912.         fi;
  4913.         popd > /dev/null || die
  4914.     };
  4915.     multilib_foreach_abi multilib-minimal_abi_src_test
  4916. }
  4917. multilib_build_binaries ()
  4918. {
  4919.     debug-print-function ${FUNCNAME} "${@}";
  4920.     [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  4921.     eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent";
  4922.     eqawarn "multilib_is_native_abi function instead.";
  4923.     multilib_is_native_abi "${@}"
  4924. }
  4925. multilib_check_headers ()
  4926. {
  4927.     function _multilib_header_cksum ()
  4928.     {
  4929.         set -o pipefail;
  4930.         if [[ -d ${ED}usr/include ]]; then
  4931.             find "${ED}"usr/include -type f -exec cksum {} + | sort -k2;
  4932.         fi
  4933.     };
  4934.     local cksum cksum_prev;
  4935.     local cksum_file=${T}/.multilib_header_cksum;
  4936.     cksum=$(_multilib_header_cksum) || die;
  4937.     unset -f _multilib_header_cksum;
  4938.     if [[ -f ${cksum_file} ]]; then
  4939.         cksum_prev=$(< "${cksum_file}") || die;
  4940.         if [[ ${cksum} != ${cksum_prev} ]]; then
  4941.             echo "${cksum}" > "${cksum_file}.new" || die;
  4942.             eerror "Header files have changed between ABIs.";
  4943.             if type -p diff &> /dev/null; then
  4944.                 eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  4945.             else
  4946.                 eerror "Old checksums in: ${cksum_file}";
  4947.                 eerror "New checksums in: ${cksum_file}.new";
  4948.             fi;
  4949.             die "Header checksum mismatch, aborting.";
  4950.         fi;
  4951.     else
  4952.         echo "${cksum}" > "${cksum_file}" || die;
  4953.     fi
  4954. }
  4955. multilib_copy_sources ()
  4956. {
  4957.     debug-print-function ${FUNCNAME} "${@}";
  4958.     local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  4959.     multibuild_copy_sources
  4960. }
  4961. multilib_env ()
  4962. {
  4963.     local CTARGET=${1:-${CTARGET}};
  4964.     local cpu=${CTARGET%%*-};
  4965.     case ${cpu} in
  4966.         aarch64*)
  4967.             export CFLAGS_arm=${CFLAGS_arm-};
  4968.             case ${cpu} in
  4969.                 aarch64*be)
  4970.                     export CHOST_arm="armv8b-${CTARGET#*-}"
  4971.                 ;;
  4972.                 *)
  4973.                     export CHOST_arm="armv8l-${CTARGET#*-}"
  4974.                 ;;
  4975.             esac;
  4976.             CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  4977.             export CTARGET_arm=${CHOST_arm};
  4978.             export LIBDIR_arm="lib";
  4979.             export CFLAGS_arm64=${CFLAGS_arm64-};
  4980.             export CHOST_arm64=${CTARGET};
  4981.             export CTARGET_arm64=${CHOST_arm64};
  4982.             export LIBDIR_arm64="lib64";
  4983.             : ${MULTILIB_ABIS=arm64};
  4984.             : ${DEFAULT_ABI=arm64}
  4985.         ;;
  4986.         x86_64*)
  4987.             export CFLAGS_x86=${CFLAGS_x86--m32};
  4988.             export CHOST_x86=${CTARGET/x86_64/i686};
  4989.             CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  4990.             export CTARGET_x86=${CHOST_x86};
  4991.             if [[ ${SYMLINK_LIB} == "yes" ]]; then
  4992.                 export LIBDIR_x86="lib32";
  4993.             else
  4994.                 export LIBDIR_x86="lib";
  4995.             fi;
  4996.             export CFLAGS_amd64=${CFLAGS_amd64--m64};
  4997.             export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  4998.             export CTARGET_amd64=${CHOST_amd64};
  4999.             export LIBDIR_amd64="lib64";
  5000.             export CFLAGS_x32=${CFLAGS_x32--mx32};
  5001.             export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  5002.             export CTARGET_x32=${CHOST_x32};
  5003.             export LIBDIR_x32="libx32";
  5004.             case ${CTARGET} in
  5005.                 *-gnux32)
  5006.                     : ${MULTILIB_ABIS=x32 amd64 x86};
  5007.                     : ${DEFAULT_ABI=x32}
  5008.                 ;;
  5009.                 *)
  5010.                     : ${MULTILIB_ABIS=amd64 x86};
  5011.                     : ${DEFAULT_ABI=amd64}
  5012.                 ;;
  5013.             esac
  5014.         ;;
  5015.         mips64*)
  5016.             export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  5017.             export CHOST_o32=${CTARGET/mips64/mips};
  5018.             export CTARGET_o32=${CHOST_o32};
  5019.             export LIBDIR_o32="lib";
  5020.             export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  5021.             export CHOST_n32=${CTARGET};
  5022.             export CTARGET_n32=${CHOST_n32};
  5023.             export LIBDIR_n32="lib32";
  5024.             export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  5025.             export CHOST_n64=${CTARGET};
  5026.             export CTARGET_n64=${CHOST_n64};
  5027.             export LIBDIR_n64="lib64";
  5028.             : ${MULTILIB_ABIS=n64 n32 o32};
  5029.             : ${DEFAULT_ABI=n32}
  5030.         ;;
  5031.         powerpc64*)
  5032.             export CFLAGS_ppc=${CFLAGS_ppc--m32};
  5033.             export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  5034.             export CTARGET_ppc=${CHOST_ppc};
  5035.             export LIBDIR_ppc="lib";
  5036.             export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  5037.             export CHOST_ppc64=${CTARGET};
  5038.             export CTARGET_ppc64=${CHOST_ppc64};
  5039.             export LIBDIR_ppc64="lib64";
  5040.             : ${MULTILIB_ABIS=ppc64 ppc};
  5041.             : ${DEFAULT_ABI=ppc64}
  5042.         ;;
  5043.         s390x*)
  5044.             export CFLAGS_s390=${CFLAGS_s390--m31};
  5045.             export CHOST_s390=${CTARGET/s390x/s390};
  5046.             export CTARGET_s390=${CHOST_s390};
  5047.             export LIBDIR_s390="lib";
  5048.             export CFLAGS_s390x=${CFLAGS_s390x--m64};
  5049.             export CHOST_s390x=${CTARGET};
  5050.             export CTARGET_s390x=${CHOST_s390x};
  5051.             export LIBDIR_s390x="lib64";
  5052.             : ${MULTILIB_ABIS=s390x s390};
  5053.             : ${DEFAULT_ABI=s390x}
  5054.         ;;
  5055.         sparc64*)
  5056.             export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  5057.             export CHOST_sparc32=${CTARGET/sparc64/sparc};
  5058.             export CTARGET_sparc32=${CHOST_sparc32};
  5059.             export LIBDIR_sparc32="lib";
  5060.             export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  5061.             export CHOST_sparc64=${CTARGET};
  5062.             export CTARGET_sparc64=${CHOST_sparc64};
  5063.             export LIBDIR_sparc64="lib64";
  5064.             : ${MULTILIB_ABIS=sparc64 sparc32};
  5065.             : ${DEFAULT_ABI=sparc64}
  5066.         ;;
  5067.         *)
  5068.             : ${MULTILIB_ABIS=default};
  5069.             : ${DEFAULT_ABI=default}
  5070.         ;;
  5071.     esac;
  5072.     export MULTILIB_ABIS DEFAULT_ABI
  5073. }
  5074. multilib_for_best_abi ()
  5075. {
  5076.     debug-print-function ${FUNCNAME} "${@}";
  5077.     [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  5078.     eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should";
  5079.     eqawarn "not be used. The multilib_is_native_abi() check may be used instead.";
  5080.     local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  5081.     multibuild_for_best_variant _multilib_multibuild_wrapper "${@}"
  5082. }
  5083. multilib_foreach_abi ()
  5084. {
  5085.     debug-print-function ${FUNCNAME} "${@}";
  5086.     local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  5087.     multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  5088. }
  5089. multilib_get_enabled_abi_pairs ()
  5090. {
  5091.     debug-print-function ${FUNCNAME} "${@}";
  5092.     local abis=($(get_all_abis));
  5093.     local abi i found;
  5094.     for abi in "${abis[@]}";
  5095.     do
  5096.         for i in "${_MULTILIB_FLAGS[@]}";
  5097.         do
  5098.             local m_abis=${i#*:} m_abi;
  5099.             local m_flag=${i%:*};
  5100.             for m_abi in ${m_abis//,/ };
  5101.             do
  5102.                 if [[ ${m_abi} == ${abi} ]] && {
  5103.                     [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  5104.                 } && use "${m_flag}"; then
  5105.                     echo "${m_flag}.${abi}";
  5106.                     found=1;
  5107.                     break 2;
  5108.                 fi;
  5109.             done;
  5110.         done;
  5111.     done;
  5112.     if [[ ! -n ${found} ]]; then
  5113.         local abi=${ABI:-${DEFAULT_ABI}};
  5114.         debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  5115.         debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  5116.         echo ".${abi}";
  5117.     fi
  5118. }
  5119. multilib_get_enabled_abis ()
  5120. {
  5121.     debug-print-function ${FUNCNAME} "${@}";
  5122.     local pairs=($(multilib_get_enabled_abi_pairs));
  5123.     echo "${pairs[@]#*.}"
  5124. }
  5125. multilib_install_wrappers ()
  5126. {
  5127.     debug-print-function ${FUNCNAME} "${@}";
  5128.     [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  5129.     [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  5130.     local root=${1:-${ED}};
  5131.     if [[ -d "${ED}"/tmp/multilib-include ]]; then
  5132.         multibuild_merge_root "${ED}"/tmp/multilib-include "${root}"/usr/include;
  5133.         rmdir "${ED}"/tmp &> /dev/null;
  5134.     fi
  5135. }
  5136. multilib_is_native_abi ()
  5137. {
  5138.     debug-print-function ${FUNCNAME} "${@}";
  5139.     [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  5140.     [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  5141. }
  5142. multilib_native_enable ()
  5143. {
  5144.     if multilib_is_native_abi; then
  5145.         echo "--enable-${1}${2+=${2}}";
  5146.     else
  5147.         echo "--disable-${1}";
  5148.     fi
  5149. }
  5150. multilib_native_use_enable ()
  5151. {
  5152.     if multilib_is_native_abi; then
  5153.         use_enable "${@}";
  5154.     else
  5155.         echo "--disable-${2:-${1}}";
  5156.     fi
  5157. }
  5158. multilib_native_use_with ()
  5159. {
  5160.     if multilib_is_native_abi; then
  5161.         use_with "${@}";
  5162.     else
  5163.         echo "--without-${2:-${1}}";
  5164.     fi
  5165. }
  5166. multilib_native_usex ()
  5167. {
  5168.     if multilib_is_native_abi; then
  5169.         usex "${@}";
  5170.     else
  5171.         echo "${3-no}${5}";
  5172.     fi
  5173. }
  5174. multilib_native_with ()
  5175. {
  5176.     if multilib_is_native_abi; then
  5177.         echo "--with-${1}${2+=${2}}";
  5178.     else
  5179.         echo "--without-${1}";
  5180.     fi
  5181. }
  5182. multilib_parallel_foreach_abi ()
  5183. {
  5184.     debug-print-function ${FUNCNAME} "${@}";
  5185.     local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  5186.     multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  5187. }
  5188. multilib_prepare_wrappers ()
  5189. {
  5190.     debug-print-function ${FUNCNAME} "${@}";
  5191.     [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  5192.     local root=${1:-${ED}};
  5193.     local f;
  5194.     if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  5195.         for f in "${MULTILIB_CHOST_TOOLS[@]}";
  5196.         do
  5197.             f=${f#/};
  5198.             local dir=${f%/*};
  5199.             local fn=${f##*/};
  5200.             ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  5201.         done;
  5202.         return;
  5203.     fi;
  5204.     for f in "${MULTILIB_CHOST_TOOLS[@]}";
  5205.     do
  5206.         f=${f#/};
  5207.         local dir=${f%/*};
  5208.         local fn=${f##*/};
  5209.         if [[ -L ${root}/${f} ]]; then
  5210.             local target;
  5211.             target=$(readlink "${root}/${f}") || die;
  5212.             local target_dir target_fn=${target##*/};
  5213.             [[ ${target} == */* ]] && target_dir=${target%/*};
  5214.             ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  5215.         fi;
  5216.         mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  5217.         if multilib_is_native_abi; then
  5218.             ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  5219.         fi;
  5220.     done;
  5221.     if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  5222.         if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  5223.             for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  5224.             do
  5225.                 f=${f#/};
  5226.                 if [[ ${f} != usr/include/* ]]; then
  5227.                     die "Wrapping headers outside of /usr/include is not supported at the moment.";
  5228.                 fi;
  5229.                 f=${f#usr/include};
  5230.                 local dir=${f%/*};
  5231.                 if [[ -f ${root}/usr/include${f} ]]; then
  5232.                     local wrapper=${ED}/tmp/multilib-include${f};
  5233.                     if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
  5234.                         dodir "/tmp/multilib-include${dir}";
  5235.                         cat > "${wrapper}"  <<_EOF_ ||
  5236. /* This file is auto-generated by multilib-build.eclass
  5237.  * as a multilib-friendly wrapper. For the original content,
  5238.  * please see the files that are #included below.
  5239.  */
  5240.  
  5241. #if defined(__x86_64__) /* amd64 */
  5242. #   if defined(__ILP32__) /* x32 ABI */
  5243. #       error "abi_x86_x32 not supported by the package."
  5244. #   else /* 64-bit ABI */
  5245. #       error "abi_x86_64 not supported by the package."
  5246. #   endif
  5247. #elif defined(__i386__) /* plain x86 */
  5248. #   error "abi_x86_32 not supported by the package."
  5249. #elif defined(__mips__)
  5250. #   if(_MIPS_SIM == _ABIN32) /* n32 */
  5251. #       error "abi_mips_n32 not supported by the package."
  5252. #   elif(_MIPS_SIM == _ABI64) /* n64 */
  5253. #       error "abi_mips_n64 not supported by the package."
  5254. #   elif(_MIPS_SIM == _ABIO32) /* o32 */
  5255. #       error "abi_mips_o32 not supported by the package."
  5256. #   endif
  5257. #elif defined(__sparc__)
  5258. #   if defined(__arch64__)
  5259. #       error "abi_sparc_64 not supported by the package."
  5260. #   else
  5261. #       error "abi_sparc_32 not supported by the package."
  5262. #   endif
  5263. #elif defined(__s390__)
  5264. #   if defined(__s390x__)
  5265. #       error "abi_s390_64 not supported by the package."
  5266. #   else
  5267. #       error "abi_s390_32 not supported by the package."
  5268. #   endif
  5269. #elif defined(__powerpc__)
  5270. #   if defined(__powerpc64__)
  5271. #       error "abi_ppc_64 not supported by the package."
  5272. #   else
  5273. #       error "abi_ppc_32 not supported by the package."
  5274. #   endif
  5275. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  5276. #   error "Native ABI not supported by the package."
  5277. #else
  5278. #   error "No ABI matched, please report a bug to bugs.gentoo.org"
  5279. #endif
  5280. _EOF_
  5281.  die;
  5282.                     fi
  5283.                     if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  5284.                         die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  5285.                     fi;
  5286.                     dodir "/tmp/multilib-include/${CHOST}${dir}";
  5287.                     mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die;
  5288.                     sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  5289.                     if multilib_is_native_abi; then
  5290.                         sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  5291.                     fi;
  5292.                 fi;
  5293.             done;
  5294.         fi;
  5295.     fi
  5296. }
  5297. multilib_src_compile ()
  5298. {
  5299.     local _java_makeopts;
  5300.     use java && _java_makeopts="-j1";
  5301.     emake V=1 ${_java_makeopts}
  5302. }
  5303. multilib_src_configure ()
  5304. {
  5305.     if multilib_is_native_abi; then
  5306.         if use java; then
  5307.             export JAVACFLAGS="$(java-pkg_javac-args)";
  5308.             export JAVA_CFLAGS="$(java-pkg_get-jni-cflags)";
  5309.         fi;
  5310.         use mono && export CSC="$(type -P gmcs)";
  5311.         export VARTEXFONTS="${T}/fonts";
  5312.         use ruby && use ruby_targets_${USE_RUBY} && export RUBY=$(ruby_implementation_command ${USE_RUBY});
  5313.     fi;
  5314.     ECONF_SOURCE="${S}" econf $(use_enable static-libs static) $(use_enable slang) $(use_enable ncurses) $(use_enable X x11) $(use_with X x) --x-libraries=/usr/$(get_libdir) $(use_enable opengl gl) $(use_enable cxx) $(use_enable imlib imlib2) $(use_enable test cppunit) $(multilib_native_use_enable java) $(multilib_native_use_enable ruby) $(multilib_native_use_enable python) $(multilib_native_use_enable mono csharp) $(multilib_native_use_enable doc)
  5315. }
  5316. multilib_src_install ()
  5317. {
  5318.     emake V=1 DESTDIR="${D}" install;
  5319.     if multilib_is_native_abi && use java; then
  5320.         java-pkg_newjar java/libjava.jar;
  5321.     fi
  5322. }
  5323. multilib_src_install_all ()
  5324. {
  5325.     einstalldocs;
  5326.     rm -rf "${D}"/usr/share/java;
  5327.     prune_libtool_files --modules
  5328. }
  5329. multilib_src_test ()
  5330. {
  5331.     emake V=1 -j1 check
  5332. }
  5333. multilib_toolchain_setup ()
  5334. {
  5335.     local v vv;
  5336.     export ABI=$1;
  5337.     if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  5338.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  5339.         do
  5340.             vv="_abi_saved_${v}";
  5341.             [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  5342.             unset ${vv};
  5343.         done;
  5344.         unset _DEFAULT_ABI_SAVED;
  5345.     fi;
  5346.     if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  5347.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  5348.         do
  5349.             vv="_abi_saved_${v}";
  5350.             [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  5351.         done;
  5352.         export _DEFAULT_ABI_SAVED="true";
  5353.         export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  5354.         export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  5355.         export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  5356.         export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  5357.         export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  5358.         export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  5359.         export CHOST=$(get_abi_CHOST $1);
  5360.         export CBUILD=$(get_abi_CHOST $1);
  5361.         export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  5362.         export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  5363.     fi
  5364. }
  5365. newicon ()
  5366. {
  5367.     _iconins ${FUNCNAME} "$@"
  5368. }
  5369. newmenu ()
  5370. {
  5371.     ( insinto /usr/share/applications;
  5372.     newins "$@" )
  5373. }
  5374. no-as-needed ()
  5375. {
  5376.     case $($(tc-getLD) -v 2>&1 </dev/null) in
  5377.         *GNU*)
  5378.             echo "-Wl,--no-as-needed"
  5379.         ;;
  5380.     esac
  5381. }
  5382. number_abis ()
  5383. {
  5384.     set -- `get_install_abis`;
  5385.     echo $#
  5386. }
  5387. optfeature ()
  5388. {
  5389.     debug-print-function ${FUNCNAME} "$@";
  5390.     local i j msg;
  5391.     local desc=$1;
  5392.     local flag=0;
  5393.     shift;
  5394.     for i in "$@";
  5395.     do
  5396.         for j in ${i};
  5397.         do
  5398.             if has_version "${j}"; then
  5399.                 flag=1;
  5400.             else
  5401.                 flag=0;
  5402.                 break;
  5403.             fi;
  5404.         done;
  5405.         if [[ ${flag} -eq 1 ]]; then
  5406.             break;
  5407.         fi;
  5408.     done;
  5409.     if [[ ${flag} -eq 0 ]]; then
  5410.         for i in "$@";
  5411.         do
  5412.             msg=" ";
  5413.             for j in ${i};
  5414.             do
  5415.                 msg+=" ${j} and";
  5416.             done;
  5417.             msg="${msg:0: -4} for ${desc}";
  5418.             elog "${msg}";
  5419.         done;
  5420.     fi
  5421. }
  5422. path_exists ()
  5423. {
  5424.     local opt=$1;
  5425.     [[ ${opt} == -[ao] ]] && shift || opt="-a";
  5426.     [[ $# -eq 0 ]] && return 1;
  5427.     local p r=0;
  5428.     for p in "$@";
  5429.     do
  5430.         [[ -e ${p} ]];
  5431.         : $(( r += $? ));
  5432.     done;
  5433.     case ${opt} in
  5434.         -a)
  5435.             return $(( r != 0 ))
  5436.         ;;
  5437.         -o)
  5438.             return $(( r == $# ))
  5439.         ;;
  5440.     esac
  5441. }
  5442. pkg_nofetch ()
  5443. {
  5444.     default
  5445. }
  5446. pkg_preinst ()
  5447. {
  5448.     java-pkg-opt-2_pkg_preinst "$@"
  5449. }
  5450. pkg_setup ()
  5451. {
  5452.     use python && python-single-r1_pkg_setup;
  5453.     java-pkg-opt-2_pkg_setup;
  5454.     use mono && mono-env_pkg_setup
  5455. }
  5456. preserve_old_lib ()
  5457. {
  5458.     _eutils_eprefix_init;
  5459.     if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  5460.         eerror "preserve_old_lib() must be called from pkg_preinst() only";
  5461.         die "Invalid preserve_old_lib() usage";
  5462.     fi;
  5463.     [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  5464.     has preserve-libs ${FEATURES} && return 0;
  5465.     local lib dir;
  5466.     for lib in "$@";
  5467.     do
  5468.         [[ -e ${EROOT}/${lib} ]] || continue;
  5469.         dir=${lib%/*};
  5470.         dodir ${dir} || die "dodir ${dir} failed";
  5471.         cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  5472.         touch "${ED}"/${lib};
  5473.     done
  5474. }
  5475. preserve_old_lib_notify ()
  5476. {
  5477.     if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  5478.         eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  5479.         die "Invalid preserve_old_lib_notify() usage";
  5480.     fi;
  5481.     has preserve-libs ${FEATURES} && return 0;
  5482.     _eutils_eprefix_init;
  5483.     local lib notice=0;
  5484.     for lib in "$@";
  5485.     do
  5486.         [[ -e ${EROOT}/${lib} ]] || continue;
  5487.         if [[ ${notice} -eq 0 ]]; then
  5488.             notice=1;
  5489.             ewarn "Old versions of installed libraries were detected on your system.";
  5490.             ewarn "In order to avoid breaking packages that depend on these old libs,";
  5491.             ewarn "the libraries are not being removed.  You need to run revdep-rebuild";
  5492.             ewarn "in order to remove these old dependencies.  If you do not have this";
  5493.             ewarn "helper program, simply emerge the 'gentoolkit' package.";
  5494.             ewarn;
  5495.         fi;
  5496.         ewarn "  # revdep-rebuild --library '${lib}' && rm '${lib}'";
  5497.     done
  5498. }
  5499. prune_libtool_files ()
  5500. {
  5501.     debug-print-function ${FUNCNAME} "$@";
  5502.     local removing_all removing_modules opt;
  5503.     for opt in "$@";
  5504.     do
  5505.         case "${opt}" in
  5506.             --all)
  5507.                 removing_all=1;
  5508.                 removing_modules=1
  5509.             ;;
  5510.             --modules)
  5511.                 removing_modules=1
  5512.             ;;
  5513.             *)
  5514.                 die "Invalid argument to ${FUNCNAME}(): ${opt}"
  5515.             ;;
  5516.         esac;
  5517.     done;
  5518.     local f;
  5519.     local queue=();
  5520.     while IFS= read -r -d '' f; do
  5521.         local archivefile=${f/%.la/.a};
  5522.         if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  5523.             continue;
  5524.         fi;
  5525.         [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  5526.         local reason= pkgconfig_scanned=;
  5527.         local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  5528.         if [[ ${snotlink} == yes ]]; then
  5529.             if [[ -f ${archivefile} ]]; then
  5530.                 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  5531.                 queue+=("${archivefile}");
  5532.             fi;
  5533.             if [[ -n ${removing_modules} ]]; then
  5534.                 reason='module';
  5535.             fi;
  5536.         else
  5537.             if [[ -n ${removing_all} ]]; then
  5538.                 reason='requested';
  5539.             else
  5540.                 if [[ ! -f ${archivefile} ]]; then
  5541.                     reason='no static archive';
  5542.                 else
  5543.                     if [[ ! -n $(sed -nre                   "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p"                  "${f}") ]]; then
  5544.                         reason='no libs & flags';
  5545.                     else
  5546.                         if [[ ! -n ${pkgconfig_scanned} ]]; then
  5547.                             local pc_libs=();
  5548.                             if [[ ! -n ${removing_all} ]]; then
  5549.                                 local pc;
  5550.                                 local tf=${T}/prune-lt-files.pc;
  5551.                                 local pkgconf=$(tc-getPKG_CONFIG);
  5552.                                 while IFS= read -r -d '' pc; do
  5553.                                     local arg libs;
  5554.                                     if ${pkgconf} --exists "${pc}" &> /dev/null; then
  5555.                                         sed -e '/^Requires:/d' "${pc}" > "${tf}";
  5556.                                         libs=$(${pkgconf} --libs "${tf}");
  5557.                                     else
  5558.                                         libs=$(sed -ne 's/^Libs://p' "${pc}");
  5559.                                     fi;
  5560.                                     for arg in ${libs};
  5561.                                     do
  5562.                                         if [[ ${arg} == -l* ]]; then
  5563.                                             if [[ ${arg} == '*$*' ]]; then
  5564.                                                 eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  5565.                                                 eerror "(arg: ${arg})";
  5566.                                                 eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  5567.                                                 die "${FUNCNAME}: unsubstituted variable found in .pc";
  5568.                                             fi;
  5569.                                             pc_libs+=(lib${arg#-l}.la);
  5570.                                         fi;
  5571.                                     done;
  5572.                                 done < <(find "${D}" -type f -name '*.pc' -print0);
  5573.                                 rm -f "${tf}";
  5574.                             fi;
  5575.                             pkgconfig_scanned=1;
  5576.                         fi;
  5577.                         has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  5578.                     fi;
  5579.                 fi;
  5580.             fi;
  5581.         fi;
  5582.         if [[ -n ${reason} ]]; then
  5583.             einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  5584.             queue+=("${f}");
  5585.         fi;
  5586.     done < <(find "${D}" -xtype f -name '*.la' -print0);
  5587.     if [[ -n ${queue[@]} ]]; then
  5588.         rm -f "${queue[@]}";
  5589.     fi
  5590. }
  5591. python-single-r1_pkg_setup ()
  5592. {
  5593.     debug-print-function ${FUNCNAME} "${@}";
  5594.     [[ ${MERGE_TYPE} != binary ]] && python_setup
  5595. }
  5596. python_abi_depend ()
  5597. {
  5598.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5599. }
  5600. python_byte-compile_modules ()
  5601. {
  5602.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5603. }
  5604. python_clean_byte-compiled_modules ()
  5605. {
  5606.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5607. }
  5608. python_clean_installation_image ()
  5609. {
  5610.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5611. }
  5612. python_clean_py-compile_files ()
  5613. {
  5614.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5615. }
  5616. python_convert_shebangs ()
  5617. {
  5618.     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"
  5619. }
  5620. python_disable_pyc ()
  5621. {
  5622.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5623. }
  5624. python_doexe ()
  5625. {
  5626.     debug-print-function ${FUNCNAME} "${@}";
  5627.     local f;
  5628.     for f in "$@";
  5629.     do
  5630.         python_newexe "${f}" "${f##*/}";
  5631.     done
  5632. }
  5633. python_doheader ()
  5634. {
  5635.     debug-print-function ${FUNCNAME} "${@}";
  5636.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5637.     if [[ ${EAPI:-0} == [0123] ]]; then
  5638.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  5639.     fi;
  5640.     local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  5641.     [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  5642.     d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  5643.     ( insinto "${d}";
  5644.     doins -r "${@}" || return ${?} )
  5645. }
  5646. python_domodule ()
  5647. {
  5648.     debug-print-function ${FUNCNAME} "${@}";
  5649.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5650.     if [[ ${EAPI:-0} == [0123] ]]; then
  5651.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  5652.     fi;
  5653.     local d;
  5654.     if [[ ${python_moduleroot} == /* ]]; then
  5655.         d=${python_moduleroot};
  5656.     else
  5657.         local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  5658.         [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  5659.         d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  5660.     fi;
  5661.     ( insinto "${d}";
  5662.     doins -r "${@}" || return ${?} );
  5663.     python_optimize "${ED}/${d}"
  5664. }
  5665. python_doscript ()
  5666. {
  5667.     debug-print-function ${FUNCNAME} "${@}";
  5668.     local _PYTHON_REWRITE_SHEBANG=1;
  5669.     python_doexe "${@}"
  5670. }
  5671. python_enable_pyc ()
  5672. {
  5673.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5674. }
  5675. python_execute_function ()
  5676. {
  5677.     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"
  5678. }
  5679. python_execute_nosetests ()
  5680. {
  5681.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5682. }
  5683. python_execute_py.test ()
  5684. {
  5685.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5686. }
  5687. python_execute_trial ()
  5688. {
  5689.     die "${FUNCNAME}() is invalid for python-r1 suite"
  5690. }
  5691. python_export ()
  5692. {
  5693.     debug-print-function ${FUNCNAME} "${@}";
  5694.     local impl var;
  5695.     case "${1}" in
  5696.         python* | jython*)
  5697.             impl=${1/_/.};
  5698.             shift
  5699.         ;;
  5700.         pypy | pypy3)
  5701.             impl=${1};
  5702.             shift
  5703.         ;;
  5704.         *)
  5705.             impl=${EPYTHON};
  5706.             if [[ -z ${impl} ]]; then
  5707.                 die "python_export called without a python implementation and EPYTHON is unset";
  5708.             fi
  5709.         ;;
  5710.     esac;
  5711.     debug-print "${FUNCNAME}: implementation: ${impl}";
  5712.     for var in "$@";
  5713.     do
  5714.         case "${var}" in
  5715.             EPYTHON)
  5716.                 export EPYTHON=${impl};
  5717.                 debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  5718.             ;;
  5719.             PYTHON)
  5720.                 export PYTHON=${EPREFIX}/usr/bin/${impl};
  5721.                 debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  5722.             ;;
  5723.             PYTHON_SITEDIR)
  5724.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5725.                 PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  5726.                 export PYTHON_SITEDIR;
  5727.                 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  5728.             ;;
  5729.             PYTHON_INCLUDEDIR)
  5730.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5731.                 PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  5732.                 export PYTHON_INCLUDEDIR;
  5733.                 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  5734.                 if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  5735.                     die "${impl} does not install any header files!";
  5736.                 fi
  5737.             ;;
  5738.             PYTHON_LIBPATH)
  5739.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5740.                 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;
  5741.                 export PYTHON_LIBPATH;
  5742.                 debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  5743.                 if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  5744.                     die "${impl} lacks a (usable) dynamic library";
  5745.                 fi
  5746.             ;;
  5747.             PYTHON_CFLAGS)
  5748.                 local val;
  5749.                 case "${impl}" in
  5750.                     python*)
  5751.                         val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  5752.                     ;;
  5753.                     *)
  5754.                         die "${impl}: obtaining ${var} not supported"
  5755.                     ;;
  5756.                 esac;
  5757.                 export PYTHON_CFLAGS=${val};
  5758.                 debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  5759.             ;;
  5760.             PYTHON_LIBS)
  5761.                 local val;
  5762.                 case "${impl}" in
  5763.                     python*)
  5764.                         val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  5765.                     ;;
  5766.                     *)
  5767.                         die "${impl}: obtaining ${var} not supported"
  5768.                     ;;
  5769.                 esac;
  5770.                 export PYTHON_LIBS=${val};
  5771.                 debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  5772.             ;;
  5773.             PYTHON_CONFIG)
  5774.                 local flags val;
  5775.                 case "${impl}" in
  5776.                     python*)
  5777.                         [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5778.                         flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  5779.                         val=${PYTHON}${flags}-config
  5780.                     ;;
  5781.                     *)
  5782.                         die "${impl}: obtaining ${var} not supported"
  5783.                     ;;
  5784.                 esac;
  5785.                 export PYTHON_CONFIG=${val};
  5786.                 debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  5787.             ;;
  5788.             PYTHON_PKG_DEP)
  5789.                 local d;
  5790.                 case ${impl} in
  5791.                     python2.7)
  5792.                         PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  5793.                     ;;
  5794.                     python3.3)
  5795.                         PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  5796.                     ;;
  5797.                     python*)
  5798.                         PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  5799.                     ;;
  5800.                     pypy)
  5801.                         PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  5802.                     ;;
  5803.                     pypy3)
  5804.                         PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  5805.                     ;;
  5806.                     jython2.7)
  5807.                         PYTHON_PKG_DEP='dev-java/jython:2.7'
  5808.                     ;;
  5809.                     *)
  5810.                         die "Invalid implementation: ${impl}"
  5811.                     ;;
  5812.                 esac;
  5813.                 if [[ -n ${PYTHON_REQ_USE} ]]; then
  5814.                     PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  5815.                 fi;
  5816.                 export PYTHON_PKG_DEP;
  5817.                 debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  5818.             ;;
  5819.             PYTHON_SCRIPTDIR)
  5820.                 local dir;
  5821.                 export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  5822.                 debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  5823.             ;;
  5824.             *)
  5825.                 die "python_export: unknown variable ${var}"
  5826.             ;;
  5827.         esac;
  5828.     done
  5829. }
  5830. python_export_utf8_locale ()
  5831. {
  5832.     debug-print-function ${FUNCNAME} "${@}";
  5833.     type locale > /dev/null || return 0;
  5834.     if [[ $(locale charmap) != UTF-8 ]]; then
  5835.         local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  5836.         for lang in ${locales};
  5837.         do
  5838.             if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  5839.                 if _python_check_locale_sanity "${lang}"; then
  5840.                     export LC_CTYPE=${lang};
  5841.                     if [[ -n ${LC_ALL} ]]; then
  5842.                         export LC_NUMERIC=${LC_ALL};
  5843.                         export LC_TIME=${LC_ALL};
  5844.                         export LC_COLLATE=${LC_ALL};
  5845.                         export LC_MONETARY=${LC_ALL};
  5846.                         export LC_MESSAGES=${LC_ALL};
  5847.                         export LC_PAPER=${LC_ALL};
  5848.                         export LC_NAME=${LC_ALL};
  5849.                         export LC_ADDRESS=${LC_ALL};
  5850.                         export LC_TELEPHONE=${LC_ALL};
  5851.                         export LC_MEASUREMENT=${LC_ALL};
  5852.                         export LC_IDENTIFICATION=${LC_ALL};
  5853.                         export LC_ALL=;
  5854.                     fi;
  5855.                     return 0;
  5856.                 fi;
  5857.             fi;
  5858.         done;
  5859.         ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  5860.         ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  5861.         ewarn "/etc/locale.gen and run locale-gen.";
  5862.         return 1;
  5863.     fi;
  5864.     return 0
  5865. }
  5866. python_fix_shebang ()
  5867. {
  5868.     debug-print-function ${FUNCNAME} "${@}";
  5869.     [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  5870.     local force quiet;
  5871.     while [[ -n ${@} ]]; do
  5872.         case "${1}" in
  5873.             -f | --force)
  5874.                 force=1;
  5875.                 shift
  5876.             ;;
  5877.             -q | --quiet)
  5878.                 quiet=1;
  5879.                 shift
  5880.             ;;
  5881.             --)
  5882.                 shift;
  5883.                 break
  5884.             ;;
  5885.             *)
  5886.                 break
  5887.             ;;
  5888.         esac;
  5889.     done;
  5890.     [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  5891.     local path f;
  5892.     for path in "$@";
  5893.     do
  5894.         local any_correct any_fixed is_recursive;
  5895.         [[ -d ${path} ]] && is_recursive=1;
  5896.         while IFS= read -r -d '' f; do
  5897.             local shebang i;
  5898.             local error= from=;
  5899.             IFS= read -r shebang < "${f}";
  5900.             if [[ ${shebang} == '#!'* ]]; then
  5901.                 local split_shebang=();
  5902.                 read -r -a split_shebang <<< ${shebang} || die;
  5903.                 for i in "${split_shebang[@]}";
  5904.                 do
  5905.                     case "${i}" in
  5906.                         *"${EPYTHON}")
  5907.                             debug-print "${FUNCNAME}: in file ${f#${D}}";
  5908.                             debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  5909.                             any_correct=1;
  5910.                             from=${EPYTHON};
  5911.                             break
  5912.                         ;;
  5913.                         *python | *python[23])
  5914.                             debug-print "${FUNCNAME}: in file ${f#${D}}";
  5915.                             debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  5916.                             if [[ ${i} == *python2 ]]; then
  5917.                                 from=python2;
  5918.                                 if [[ ! -n ${force} ]]; then
  5919.                                     python_is_python3 "${EPYTHON}" && error=1;
  5920.                                 fi;
  5921.                             else
  5922.                                 if [[ ${i} == *python3 ]]; then
  5923.                                     from=python3;
  5924.                                     if [[ ! -n ${force} ]]; then
  5925.                                         python_is_python3 "${EPYTHON}" || error=1;
  5926.                                     fi;
  5927.                                 else
  5928.                                     from=python;
  5929.                                 fi;
  5930.                             fi;
  5931.                             break
  5932.                         ;;
  5933.                         *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  5934.                             if [[ ! -n ${force} ]]; then
  5935.                                 error=1;
  5936.                             else
  5937.                                 case "${i}" in
  5938.                                     *python[23].[0123456789])
  5939.                                         from="python[23].[0123456789]"
  5940.                                     ;;
  5941.                                     *pypy)
  5942.                                         from="pypy"
  5943.                                     ;;
  5944.                                     *pypy3)
  5945.                                         from="pypy3"
  5946.                                     ;;
  5947.                                     *jython[23].[0123456789])
  5948.                                         from="jython[23].[0123456789]"
  5949.                                     ;;
  5950.                                     *)
  5951.                                         die "${FUNCNAME}: internal error in 2nd pattern match"
  5952.                                     ;;
  5953.                                 esac;
  5954.                             fi;
  5955.                             break
  5956.                         ;;
  5957.                     esac;
  5958.                 done;
  5959.             fi;
  5960.             if [[ ! -n ${error} && ! -n ${from} ]]; then
  5961.                 [[ -n ${is_recursive} ]] && continue;
  5962.                 error=1;
  5963.             fi;
  5964.             if [[ ! -n ${quiet} ]]; then
  5965.                 einfo "Fixing shebang in ${f#${D}}.";
  5966.             fi;
  5967.             if [[ ! -n ${error} ]]; then
  5968.                 if [[ ${shebang} == *${from}" "* ]]; then
  5969.                     sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  5970.                 else
  5971.                     sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  5972.                 fi;
  5973.                 any_fixed=1;
  5974.             else
  5975.                 eerror "The file has incompatible shebang:";
  5976.                 eerror "  file: ${f#${D}}";
  5977.                 eerror "  current shebang: ${shebang}";
  5978.                 eerror "  requested impl: ${EPYTHON}";
  5979.                 die "${FUNCNAME}: conversion of incompatible shebang requested";
  5980.             fi;
  5981.         done < <(find -H "${path}" -type f -print0 || die);
  5982.         if [[ ! -n ${any_fixed} ]]; then
  5983.             local cmd=eerror;
  5984.             [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  5985.             "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D}} did not match any fixable files.";
  5986.             if [[ -n ${any_correct} ]]; then
  5987.                 "${cmd}" "All files have ${EPYTHON} shebang already.";
  5988.             else
  5989.                 "${cmd}" "There are no Python files in specified directory.";
  5990.             fi;
  5991.             [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  5992.         fi;
  5993.     done
  5994. }
  5995. python_gen_cond_dep ()
  5996. {
  5997.     debug-print-function ${FUNCNAME} "${@}";
  5998.     local flag_prefix impl matches=();
  5999.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  6000.         flag_prefix=python_targets;
  6001.     else
  6002.         flag_prefix=python_single_target;
  6003.     fi;
  6004.     local dep=${1};
  6005.     shift;
  6006.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6007.     do
  6008.         if _python_impl_matches "${impl}" "${@}"; then
  6009.             if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  6010.                 local usedep=$(python_gen_usedep "${@}");
  6011.                 dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  6012.             fi;
  6013.             matches+=("${flag_prefix}_${impl}? ( ${dep} )");
  6014.         fi;
  6015.     done;
  6016.     echo "${matches[@]}"
  6017. }
  6018. python_gen_impl_dep ()
  6019. {
  6020.     debug-print-function ${FUNCNAME} "${@}";
  6021.     local impl pattern;
  6022.     local matches=();
  6023.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  6024.         flag_prefix=python_targets;
  6025.     else
  6026.         flag_prefix=python_single_target;
  6027.     fi;
  6028.     local PYTHON_REQ_USE=${1};
  6029.     shift;
  6030.     local patterns=("${@-*}");
  6031.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6032.     do
  6033.         if _python_impl_matches "${impl}" "${patterns[@]}"; then
  6034.             local PYTHON_PKG_DEP;
  6035.             python_export "${impl}" PYTHON_PKG_DEP;
  6036.             matches+=("${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )");
  6037.         fi;
  6038.     done;
  6039.     echo "${matches[@]}"
  6040. }
  6041. python_gen_usedep ()
  6042. {
  6043.     debug-print-function ${FUNCNAME} "${@}";
  6044.     local impl matches=();
  6045.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6046.     do
  6047.         if _python_impl_matches "${impl}" "${@}"; then
  6048.             matches+=("python_targets_${impl}(-)?" "python_single_target_${impl}(+)?");
  6049.         fi;
  6050.     done;
  6051.     [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  6052.     local out=${matches[@]};
  6053.     echo "${out// /,}"
  6054. }
  6055. python_gen_useflags ()
  6056. {
  6057.     debug-print-function ${FUNCNAME} "${@}";
  6058.     local flag_prefix impl matches=();
  6059.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  6060.         flag_prefix=python_targets;
  6061.     else
  6062.         flag_prefix=python_single_target;
  6063.     fi;
  6064.     for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6065.     do
  6066.         if _python_impl_matches "${impl}" "${@}"; then
  6067.             matches+=("${flag_prefix}_${impl}");
  6068.         fi;
  6069.     done;
  6070.     echo "${matches[@]}"
  6071. }
  6072. python_generate_cffi_modules ()
  6073. {
  6074.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6075. }
  6076. python_generate_wrapper_scripts ()
  6077. {
  6078.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6079. }
  6080. python_get_CFLAGS ()
  6081. {
  6082.     debug-print-function ${FUNCNAME} "${@}";
  6083.     python_export "${@}" PYTHON_CFLAGS;
  6084.     echo "${PYTHON_CFLAGS}"
  6085. }
  6086. python_get_LIBS ()
  6087. {
  6088.     debug-print-function ${FUNCNAME} "${@}";
  6089.     python_export "${@}" PYTHON_LIBS;
  6090.     echo "${PYTHON_LIBS}"
  6091. }
  6092. python_get_PYTHON_CONFIG ()
  6093. {
  6094.     debug-print-function ${FUNCNAME} "${@}";
  6095.     python_export "${@}" PYTHON_CONFIG;
  6096.     echo "${PYTHON_CONFIG}"
  6097. }
  6098. python_get_extension_module_suffix ()
  6099. {
  6100.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6101. }
  6102. python_get_implementation ()
  6103. {
  6104.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6105. }
  6106. python_get_implementation_and_version ()
  6107. {
  6108.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6109. }
  6110. python_get_implementational_package ()
  6111. {
  6112.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6113. }
  6114. python_get_includedir ()
  6115. {
  6116.     debug-print-function ${FUNCNAME} "${@}";
  6117.     python_export "${@}" PYTHON_INCLUDEDIR;
  6118.     echo "${PYTHON_INCLUDEDIR}"
  6119. }
  6120. python_get_libdir ()
  6121. {
  6122.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6123. }
  6124. python_get_library ()
  6125. {
  6126.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6127. }
  6128. python_get_library_path ()
  6129. {
  6130.     debug-print-function ${FUNCNAME} "${@}";
  6131.     python_export "${@}" PYTHON_LIBPATH;
  6132.     echo "${PYTHON_LIBPATH}"
  6133. }
  6134. python_get_scriptdir ()
  6135. {
  6136.     debug-print-function ${FUNCNAME} "${@}";
  6137.     python_export "${@}" PYTHON_SCRIPTDIR;
  6138.     echo "${PYTHON_SCRIPTDIR}"
  6139. }
  6140. python_get_sitedir ()
  6141. {
  6142.     debug-print-function ${FUNCNAME} "${@}";
  6143.     python_export "${@}" PYTHON_SITEDIR;
  6144.     echo "${PYTHON_SITEDIR}"
  6145. }
  6146. python_get_version ()
  6147. {
  6148.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6149. }
  6150. python_install_executables ()
  6151. {
  6152.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6153. }
  6154. python_is_installed ()
  6155. {
  6156.     local impl=${1:-${EPYTHON}};
  6157.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  6158.     local -x ROOT=/;
  6159.     case "${impl}" in
  6160.         pypy | pypy3)
  6161.             local append=;
  6162.             if [[ -n ${PYTHON_REQ_USE} ]]; then
  6163.                 append=[${PYTHON_REQ_USE}];
  6164.             fi;
  6165.             has_version "dev-python/${impl}${append}" || has_version "dev-python/${impl}-bin${append}"
  6166.         ;;
  6167.         *)
  6168.             local PYTHON_PKG_DEP;
  6169.             python_export "${impl}" PYTHON_PKG_DEP;
  6170.             has_version "${PYTHON_PKG_DEP}"
  6171.         ;;
  6172.     esac
  6173. }
  6174. python_is_python3 ()
  6175. {
  6176.     local impl=${1:-${EPYTHON}};
  6177.     [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  6178.     [[ ${impl} == python3* || ${impl} == pypy3 ]]
  6179. }
  6180. python_merge_intermediate_installation_images ()
  6181. {
  6182.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6183. }
  6184. python_mod_cleanup ()
  6185. {
  6186.     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"
  6187. }
  6188. python_mod_optimize ()
  6189. {
  6190.     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"
  6191. }
  6192. python_moduleinto ()
  6193. {
  6194.     debug-print-function ${FUNCNAME} "${@}";
  6195.     python_moduleroot=${1}
  6196. }
  6197. python_need_rebuild ()
  6198. {
  6199.     die "${FUNCNAME}() is invalid for python-r1 suite"
  6200. }
  6201. python_newexe ()
  6202. {
  6203.     debug-print-function ${FUNCNAME} "${@}";
  6204.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  6205.     [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  6206.     if [[ ${EAPI:-0} == [0123] ]]; then
  6207.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  6208.     fi;
  6209.     local wrapd=${python_scriptroot:-/usr/bin};
  6210.     local f=${1};
  6211.     local newfn=${2};
  6212.     local PYTHON_SCRIPTDIR d;
  6213.     python_export PYTHON_SCRIPTDIR;
  6214.     d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  6215.     ( dodir "${wrapd}";
  6216.     exeinto "${d}";
  6217.     newexe "${f}" "${newfn}" || return ${?} );
  6218.     _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  6219.     if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  6220.         python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  6221.     fi
  6222. }
  6223. python_newscript ()
  6224. {
  6225.     debug-print-function ${FUNCNAME} "${@}";
  6226.     local _PYTHON_REWRITE_SHEBANG=1;
  6227.     python_newexe "${@}"
  6228. }
  6229. python_optimize ()
  6230. {
  6231.     debug-print-function ${FUNCNAME} "${@}";
  6232.     if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  6233.         eerror "The new Python eclasses expect the compiled Python files to";
  6234.         eerror "be controlled by the Package Manager. For this reason,";
  6235.         eerror "the python_optimize function can be used only during src_* phases";
  6236.         eerror "(src_install most commonly) and not during pkg_* phases.";
  6237.         echo;
  6238.         die "python_optimize is not to be used in pre/post* phases";
  6239.     fi;
  6240.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  6241.     local PYTHON=${PYTHON};
  6242.     [[ -n ${PYTHON} ]] || python_export PYTHON;
  6243.     if [[ ${#} -eq 0 ]]; then
  6244.         local f;
  6245.         while IFS= read -r -d '' f; do
  6246.             if [[ ${f} == /* && -d ${D}${f} ]]; then
  6247.                 set -- "${D}${f}" "${@}";
  6248.             fi;
  6249.         done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  6250.         debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  6251.     fi;
  6252.     local d;
  6253.     for d in "$@";
  6254.     do
  6255.         local instpath=${d#${D}};
  6256.         instpath=/${instpath##/};
  6257.         case "${EPYTHON}" in
  6258.             python2.7 | python3.[34])
  6259.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  6260.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  6261.             ;;
  6262.             python* | pypy3)
  6263.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  6264.                 "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  6265.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  6266.             ;;
  6267.             *)
  6268.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  6269.             ;;
  6270.         esac;
  6271.     done
  6272. }
  6273. python_pkg_setup ()
  6274. {
  6275.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  6276. }
  6277. python_scriptinto ()
  6278. {
  6279.     debug-print-function ${FUNCNAME} "${@}";
  6280.     python_scriptroot=${1}
  6281. }
  6282. python_set_active_version ()
  6283. {
  6284.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  6285. }
  6286. python_setup ()
  6287. {
  6288.     debug-print-function ${FUNCNAME} "${@}";
  6289.     unset EPYTHON;
  6290.     if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  6291.         local impls=(${PYTHON_COMPAT_OVERRIDE});
  6292.         [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1";
  6293.         ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  6294.         ewarn "implementation will be used:";
  6295.         ewarn;
  6296.         ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  6297.         ewarn;
  6298.         ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored.";
  6299.         python_export "${impls[0]}" EPYTHON PYTHON;
  6300.         python_wrapper_setup;
  6301.         return;
  6302.     fi;
  6303.     if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  6304.         if use "python_targets_${_PYTHON_SUPPORTED_IMPLS[0]}"; then
  6305.             python_export "${_PYTHON_SUPPORTED_IMPLS[0]}" EPYTHON PYTHON;
  6306.             python_wrapper_setup;
  6307.         fi;
  6308.     else
  6309.         local impl;
  6310.         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6311.         do
  6312.             if use "python_single_target_${impl}"; then
  6313.                 if [[ -n ${EPYTHON} ]]; then
  6314.                     eerror "Your PYTHON_SINGLE_TARGET setting lists more than a single Python";
  6315.                     eerror "implementation. Please set it to just one value. If you need";
  6316.                     eerror "to override the value for a single package, please use package.env";
  6317.                     eerror "or an equivalent solution (man 5 portage).";
  6318.                     echo;
  6319.                     die "More than one implementation in PYTHON_SINGLE_TARGET.";
  6320.                 fi;
  6321.                 if ! use "python_targets_${impl}"; then
  6322.                     eerror "The implementation chosen as PYTHON_SINGLE_TARGET must be added";
  6323.                     eerror "to PYTHON_TARGETS as well. This is in order to ensure that";
  6324.                     eerror "dependencies are satisfied correctly. We're sorry";
  6325.                     eerror "for the inconvenience.";
  6326.                     echo;
  6327.                     die "Build target (${impl}) not in PYTHON_TARGETS.";
  6328.                 fi;
  6329.                 python_export "${impl}" EPYTHON PYTHON;
  6330.                 python_wrapper_setup;
  6331.             fi;
  6332.         done;
  6333.     fi;
  6334.     if [[ ! -n ${EPYTHON} ]]; then
  6335.         eerror "No Python implementation selected for the build. Please set";
  6336.         if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  6337.             eerror "the PYTHON_TARGETS variable in your make.conf to include one";
  6338.         else
  6339.             eerror "the PYTHON_SINGLE_TARGET variable in your make.conf to one";
  6340.         fi;
  6341.         eerror "of the following values:";
  6342.         eerror;
  6343.         eerror "${_PYTHON_SUPPORTED_IMPLS[@]}";
  6344.         echo;
  6345.         die "No supported Python implementation in PYTHON_SINGLE_TARGET/PYTHON_TARGETS.";
  6346.     fi
  6347. }
  6348. python_wrapper_setup ()
  6349. {
  6350.     debug-print-function ${FUNCNAME} "${@}";
  6351.     local workdir=${1:-${T}/${EPYTHON}};
  6352.     local impl=${2:-${EPYTHON}};
  6353.     [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  6354.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  6355.     if [[ ! -x ${workdir}/bin/python ]]; then
  6356.         _python_check_dead_variables;
  6357.         mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  6358.         rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  6359.         rm -f "${workdir}"/bin/2to3 || die;
  6360.         rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  6361.         local EPYTHON PYTHON;
  6362.         python_export "${impl}" EPYTHON PYTHON;
  6363.         local pyver pyother;
  6364.         if python_is_python3; then
  6365.             pyver=3;
  6366.             pyother=2;
  6367.         else
  6368.             pyver=2;
  6369.             pyother=3;
  6370.         fi;
  6371.         cat > "${workdir}/bin/python"  <<-_EOF_ ||
  6372. #!/bin/sh
  6373. exec "${PYTHON}" "\${@}"
  6374. _EOF_
  6375.  die
  6376.         cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  6377.         chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  6378.         local nonsupp=("python${pyother}" "python${pyother}-config");
  6379.         if [[ ${EPYTHON} == python* ]]; then
  6380.             cat > "${workdir}/bin/python-config"  <<-_EOF_ ||
  6381. #!/bin/sh
  6382. exec "${PYTHON}-config" "\${@}"
  6383. _EOF_
  6384.  die
  6385.             cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  6386.             chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  6387.             ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  6388.             ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  6389.             ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  6390.         else
  6391.             nonsupp+=(2to3 python-config "python${pyver}-config");
  6392.         fi;
  6393.         local x;
  6394.         for x in "${nonsupp[@]}";
  6395.         do
  6396.             cat > "${workdir}"/bin/${x}  <<-_EOF_ ||
  6397. #!/bin/sh
  6398. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  6399. exit 127
  6400. _EOF_
  6401.  die
  6402.             chmod +x "${workdir}"/bin/${x} || die;
  6403.         done;
  6404.     fi;
  6405.     if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  6406.         PATH=${workdir}/bin${PATH:+:${PATH}};
  6407.     fi;
  6408.     if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  6409.         PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  6410.     fi;
  6411.     export PATH PKG_CONFIG_PATH
  6412. }
  6413. raw-ldflags ()
  6414. {
  6415.     local x input="$@";
  6416.     [[ -z ${input} ]] && input=${LDFLAGS};
  6417.     set --;
  6418.     for x in ${input};
  6419.     do
  6420.         case ${x} in
  6421.             -Wl,*)
  6422.                 x=${x#-Wl,};
  6423.                 set -- "$@" ${x//,/ }
  6424.             ;;
  6425.             *)
  6426.  
  6427.             ;;
  6428.         esac;
  6429.     done;
  6430.     echo "$@"
  6431. }
  6432. replace-cpu-flags ()
  6433. {
  6434.     local newcpu="$#";
  6435.     newcpu="${!newcpu}";
  6436.     while [ $# -gt 1 ]; do
  6437.         replace-flags "-march=${1}" "-march=${newcpu}";
  6438.         replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  6439.         replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  6440.         shift;
  6441.     done;
  6442.     return 0
  6443. }
  6444. replace-flags ()
  6445. {
  6446.     [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  6447.     local f var new;
  6448.     for var in $(all-flag-vars);
  6449.     do
  6450.         new=();
  6451.         for f in ${!var};
  6452.         do
  6453.             [[ ${f} == ${1} ]] && f=${2};
  6454.             new+=("${f}");
  6455.         done;
  6456.         eval export ${var}=\""${new[*]}"\";
  6457.     done;
  6458.     return 0
  6459. }
  6460. replace-sparc64-flags ()
  6461. {
  6462.     local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  6463.     if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  6464.         for x in ${SPARC64_CPUS};
  6465.         do
  6466.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  6467.         done;
  6468.     else
  6469.         for x in ${SPARC64_CPUS};
  6470.         do
  6471.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  6472.         done;
  6473.     fi;
  6474.     if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  6475.         for x in ${SPARC64_CPUS};
  6476.         do
  6477.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  6478.         done;
  6479.     else
  6480.         for x in ${SPARC64_CPUS};
  6481.         do
  6482.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  6483.         done;
  6484.     fi;
  6485.     export CFLAGS CXXFLAGS
  6486. }
  6487. replace_all_version_separators ()
  6488. {
  6489.     local c=($(get_all_version_components "${2:-${PV}}"));
  6490.     c=${c[@]//[-._]/$1};
  6491.     echo ${c// }
  6492. }
  6493. replace_version_separator ()
  6494. {
  6495.     eshopts_push -s extglob;
  6496.     local w c v="${3:-${PV}}";
  6497.     declare -i i found=0;
  6498.     w=${1:-1};
  6499.     c=($(get_all_version_components ${v}));
  6500.     if [[ ${w} != *[[:digit:]]* ]]; then
  6501.         for ((i = 0; i < ${#c[@]}; i++))
  6502.         do
  6503.             if [[ ${c[i]} == ${w} ]]; then
  6504.                 c[i]=${2};
  6505.                 break;
  6506.             fi;
  6507.         done;
  6508.     else
  6509.         for ((i = 0; i < ${#c[@]}; i++))
  6510.         do
  6511.             if [[ -n "${c[i]//[^-._]}" ]]; then
  6512.                 found+=1;
  6513.                 if ((found == w)); then
  6514.                     c[i]=${2};
  6515.                     break;
  6516.                 fi;
  6517.             fi;
  6518.         done;
  6519.     fi;
  6520.     c=${c[*]};
  6521.     echo ${c// };
  6522.     eshopts_pop
  6523. }
  6524. ruby-ng_cucumber ()
  6525. {
  6526.     if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
  6527.         ewarn "Missing dev-util/cucumber in \${DEPEND}";
  6528.     fi;
  6529.     local cucumber_params=;
  6530.     case ${NOCOLOR} in
  6531.         1 | yes | true)
  6532.             cucumber_params+=" --no-color"
  6533.         ;;
  6534.         *)
  6535.             cucumber_params+=" --color"
  6536.         ;;
  6537.     esac;
  6538.     case ${TEST_VERBOSE} in
  6539.         1 | yes | true)
  6540.             cucumber_params+=" --format pretty"
  6541.         ;;
  6542.         *)
  6543.             cucumber_params+=" --format progress"
  6544.         ;;
  6545.     esac;
  6546.     if [[ ${RUBY} == *jruby ]]; then
  6547.         ewarn "Skipping cucumber tests on JRuby (unsupported).";
  6548.         return 0;
  6549.     fi;
  6550.     ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed"
  6551. }
  6552. ruby-ng_pkg_setup ()
  6553. {
  6554.     _ruby_each_implementation;
  6555.     has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
  6556. }
  6557. ruby-ng_rspec ()
  6558. {
  6559.     local version=${RSPEC_VERSION-2};
  6560.     local files="$@";
  6561.     if [ ${#@} -eq 0 ]; then
  6562.         files="spec";
  6563.     fi;
  6564.     if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
  6565.         ewarn "Missing dev-ruby/rspec in \${DEPEND}";
  6566.     fi;
  6567.     local rspec_params=;
  6568.     case ${NOCOLOR} in
  6569.         1 | yes | true)
  6570.             rspec_params+=" --no-color"
  6571.         ;;
  6572.         *)
  6573.             rspec_params+=" --color"
  6574.         ;;
  6575.     esac;
  6576.     case ${TEST_VERBOSE} in
  6577.         1 | yes | true)
  6578.             rspec_params+=" --format documentation"
  6579.         ;;
  6580.         *)
  6581.             rspec_params+=" --format progress"
  6582.         ;;
  6583.     esac;
  6584.     ${RUBY} -S rspec-${version} ${rspec_params} ${files} || die "rspec failed"
  6585. }
  6586. ruby-ng_src_compile ()
  6587. {
  6588.     if type each_ruby_compile &> /dev/null; then
  6589.         _ruby_each_implementation each_ruby_compile;
  6590.     fi;
  6591.     type all_ruby_compile &> /dev/null && _ruby_invoke_environment all all_ruby_compile
  6592. }
  6593. ruby-ng_src_configure ()
  6594. {
  6595.     if type each_ruby_configure &> /dev/null; then
  6596.         _ruby_each_implementation each_ruby_configure;
  6597.     fi;
  6598.     type all_ruby_configure &> /dev/null && _ruby_invoke_environment all all_ruby_configure
  6599. }
  6600. ruby-ng_src_install ()
  6601. {
  6602.     if type each_ruby_install &> /dev/null; then
  6603.         _ruby_each_implementation each_ruby_install;
  6604.     fi;
  6605.     type all_ruby_install &> /dev/null && _ruby_invoke_environment all all_ruby_install;
  6606.     _PHASE="check install" _ruby_each_implementation _each_ruby_check_install
  6607. }
  6608. ruby-ng_src_prepare ()
  6609. {
  6610.     find . -name '._*' -delete;
  6611.     case ${EAPI} in
  6612.         6)
  6613.             _ruby_invoke_environment all default
  6614.         ;;
  6615.     esac;
  6616.     _ruby_invoke_environment all _ruby_apply_patches;
  6617.     _PHASE="source copy" _ruby_each_implementation _ruby_source_copy;
  6618.     if type each_ruby_prepare &> /dev/null; then
  6619.         _ruby_each_implementation each_ruby_prepare;
  6620.     fi
  6621. }
  6622. ruby-ng_src_test ()
  6623. {
  6624.     if type each_ruby_test &> /dev/null; then
  6625.         _ruby_each_implementation each_ruby_test;
  6626.     fi;
  6627.     type all_ruby_test &> /dev/null && _ruby_invoke_environment all all_ruby_test
  6628. }
  6629. ruby-ng_src_unpack ()
  6630. {
  6631.     mkdir "${WORKDIR}"/all;
  6632.     pushd "${WORKDIR}"/all &> /dev/null || die;
  6633.     if type all_ruby_unpack &> /dev/null; then
  6634.         _ruby_invoke_environment all all_ruby_unpack;
  6635.     else
  6636.         [[ -n ${A} ]] && unpack ${A};
  6637.     fi;
  6638.     popd &> /dev/null || die
  6639. }
  6640. ruby-ng_testrb-2 ()
  6641. {
  6642.     if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
  6643.         ewarn "Missing dev-ruby/test-unit in \${DEPEND}";
  6644.     fi;
  6645.     local testrb_params=;
  6646.     case ${NOCOLOR} in
  6647.         1 | yes | true)
  6648.             testrb_params+=" --no-use-color"
  6649.         ;;
  6650.         *)
  6651.             testrb_params+=" --use-color=auto"
  6652.         ;;
  6653.     esac;
  6654.     case ${TEST_VERBOSE} in
  6655.         1 | yes | true)
  6656.             testrb_params+=" --verbose=verbose"
  6657.         ;;
  6658.         *)
  6659.             testrb_params+=" --verbose=normal"
  6660.         ;;
  6661.     esac;
  6662.     ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed"
  6663. }
  6664. ruby_add_bdepend ()
  6665. {
  6666.     case $# in
  6667.         1)
  6668.  
  6669.         ;;
  6670.         2)
  6671.             [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF";
  6672.             ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")";
  6673.             return
  6674.         ;;
  6675.         *)
  6676.             die "bad number of arguments to $0"
  6677.         ;;
  6678.     esac;
  6679.     local dependency=$(_ruby_atoms_samelib "$1");
  6680.     DEPEND="${DEPEND} $dependency";
  6681.     RDEPEND="${RDEPEND}"
  6682. }
  6683. ruby_add_rdepend ()
  6684. {
  6685.     case $# in
  6686.         1)
  6687.  
  6688.         ;;
  6689.         2)
  6690.             [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF";
  6691.             ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")";
  6692.             return
  6693.         ;;
  6694.         *)
  6695.             die "bad number of arguments to $0"
  6696.         ;;
  6697.     esac;
  6698.     local dependency=$(_ruby_atoms_samelib "$1");
  6699.     RDEPEND="${RDEPEND} $dependency";
  6700.     DEPEND="${DEPEND} test? ( ${dependency} )";
  6701.     has test "$IUSE" || IUSE="${IUSE} test"
  6702. }
  6703. ruby_get_hdrdir ()
  6704. {
  6705.     local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir');
  6706.     if [[ "${rubyhdrdir}" = "nil" ]]; then
  6707.         rubyhdrdir=$(ruby_rbconfig_value 'archdir');
  6708.     fi;
  6709.     echo "${rubyhdrdir}"
  6710. }
  6711. ruby_get_implementation ()
  6712. {
  6713.     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)};
  6714.     case $(${ruby} --version) in
  6715.         *jruby*)
  6716.             echo "jruby"
  6717.         ;;
  6718.         *rubinius*)
  6719.             echo "rbx"
  6720.         ;;
  6721.         *)
  6722.             echo "mri"
  6723.         ;;
  6724.     esac
  6725. }
  6726. ruby_get_libruby ()
  6727. {
  6728.     ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
  6729. }
  6730. ruby_get_use_implementations ()
  6731. {
  6732.     local i implementation;
  6733.     for implementation in $(_ruby_get_all_impls);
  6734.     do
  6735.         use ruby_targets_${implementation} && i+=" ${implementation}";
  6736.     done;
  6737.     echo $i
  6738. }
  6739. ruby_get_use_targets ()
  6740. {
  6741.     local t implementation;
  6742.     for implementation in $(_ruby_get_all_impls);
  6743.     do
  6744.         t+=" ruby_targets_${implementation}";
  6745.     done;
  6746.     echo $t
  6747. }
  6748. ruby_get_version ()
  6749. {
  6750.     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)};
  6751.     echo $(${ruby} -e 'puts RUBY_VERSION')
  6752. }
  6753. ruby_implementation_command ()
  6754. {
  6755.     local _ruby_name=$1;
  6756.     echo $(type -p ${_ruby_name} 2>/dev/null)
  6757. }
  6758. ruby_implementation_depend ()
  6759. {
  6760.     _ruby_implementation_depend $1
  6761. }
  6762. ruby_implementations_depend ()
  6763. {
  6764.     local depend;
  6765.     for _ruby_implementation in $(_ruby_get_all_impls);
  6766.     do
  6767.         depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )";
  6768.     done;
  6769.     echo "${depend}"
  6770. }
  6771. ruby_rbconfig_value ()
  6772. {
  6773.     echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
  6774. }
  6775. ruby_samelib ()
  6776. {
  6777.     local res=;
  6778.     for _ruby_implementation in $(_ruby_get_all_impls);
  6779.     do
  6780.         has -${_ruby_implementation} $@ || res="${res}ruby_targets_${_ruby_implementation}?,";
  6781.     done;
  6782.     echo "[${res%,}]"
  6783. }
  6784. run_in_build_dir ()
  6785. {
  6786.     debug-print-function ${FUNCNAME} "${@}";
  6787.     local ret;
  6788.     [[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified.";
  6789.     [[ -n ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set.";
  6790.     mkdir -p "${BUILD_DIR}" || die;
  6791.     pushd "${BUILD_DIR}" > /dev/null || die;
  6792.     "${@}";
  6793.     ret=${?};
  6794.     popd > /dev/null || die;
  6795.     return ${ret}
  6796. }
  6797. setup-allowed-flags ()
  6798. {
  6799.     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+ -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*');
  6800.     ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  6801.     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)
  6802. }
  6803. src_compile ()
  6804. {
  6805.     multilib-minimal_src_compile "$@"
  6806. }
  6807. src_configure ()
  6808. {
  6809.     multilib-minimal_src_configure "$@"
  6810. }
  6811. src_install ()
  6812. {
  6813.     multilib-minimal_src_install "$@"
  6814. }
  6815. src_prepare ()
  6816. {
  6817.     sed -i -e '/doxygen_tests = check-doxygen/d' test/Makefile.am || die;
  6818.     sed -i -e 's:-g -O2 -fno-strength-reduce -fomit-frame-pointer::' -e 's:AM_CONFIG_HEADER:AC_CONFIG_HEADERS:' configure.ac || die;
  6819.     sed -i -e 's:$(JAVAC):$(JAVAC) $(JAVACFLAGS):' -e 's:libcaca_java_la_CPPFLAGS =:libcaca_java_la_CPPFLAGS = -I$(top_srcdir)/caca:' java/Makefile.am || die;
  6820.     if ! use truetype; then
  6821.         sed -i -e '/PKG_CHECK_MODULES/s:ftgl:dIsAbLe&:' configure.ac || die;
  6822.     fi;
  6823.     if use imlib && ! use X; then
  6824.         append-cflags -DX_DISPLAY_MISSING;
  6825.     fi;
  6826.     epatch "${FILESDIR}"/${PN}-0.99_beta18-latex_hacks.patch;
  6827.     epatch "${FILESDIR}"/${PN}-0.99_beta18-fix-tests.patch;
  6828.     eautoreconf;
  6829.     java-pkg-opt-2_src_prepare
  6830. }
  6831. src_test ()
  6832. {
  6833.     multilib-minimal_src_test "$@"
  6834. }
  6835. src_unpack ()
  6836. {
  6837.     default
  6838. }
  6839. strip-flags ()
  6840. {
  6841.     local x y var;
  6842.     local ALLOWED_FLAGS;
  6843.     setup-allowed-flags;
  6844.     set -f;
  6845.     for var in $(all-flag-vars);
  6846.     do
  6847.         local new=();
  6848.         for x in ${!var};
  6849.         do
  6850.             local flag=${x%%=*};
  6851.             for y in "${ALLOWED_FLAGS[@]}";
  6852.             do
  6853.                 if [[ -z ${flag%%${y}} ]]; then
  6854.                     new+=("${x}");
  6855.                     break;
  6856.                 fi;
  6857.             done;
  6858.         done;
  6859.         if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  6860.             new+=(-O2);
  6861.         fi;
  6862.         if [[ ${!var} != "${new[*]}" ]]; then
  6863.             einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  6864.         fi;
  6865.         eval export ${var}=\""${new[*]}"\";
  6866.     done;
  6867.     set +f;
  6868.     return 0
  6869. }
  6870. strip-linguas ()
  6871. {
  6872.     local ls newls nols;
  6873.     if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  6874.         local op=$1;
  6875.         shift;
  6876.         ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  6877.         shift;
  6878.         local d f;
  6879.         for d in "$@";
  6880.         do
  6881.             if [[ ${op} == "-u" ]]; then
  6882.                 newls=${ls};
  6883.             else
  6884.                 newls="";
  6885.             fi;
  6886.             for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  6887.             do
  6888.                 if [[ ${op} == "-i" ]]; then
  6889.                     has ${f} ${ls} && newls="${newls} ${f}";
  6890.                 else
  6891.                     has ${f} ${ls} || newls="${newls} ${f}";
  6892.                 fi;
  6893.             done;
  6894.             ls=${newls};
  6895.         done;
  6896.     else
  6897.         ls="$@";
  6898.     fi;
  6899.     nols="";
  6900.     newls="";
  6901.     for f in ${LINGUAS};
  6902.     do
  6903.         if has ${f} ${ls}; then
  6904.             newls="${newls} ${f}";
  6905.         else
  6906.             nols="${nols} ${f}";
  6907.         fi;
  6908.     done;
  6909.     [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  6910.     export LINGUAS=${newls:1}
  6911. }
  6912. strip-unsupported-flags ()
  6913. {
  6914.     export CFLAGS=$(test-flags-CC ${CFLAGS});
  6915.     export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  6916.     export FFLAGS=$(test-flags-F77 ${FFLAGS});
  6917.     export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  6918. }
  6919. tc-arch ()
  6920. {
  6921.     tc-ninja_magic_to_arch portage "$@"
  6922. }
  6923. tc-arch-kernel ()
  6924. {
  6925.     tc-ninja_magic_to_arch kern "$@"
  6926. }
  6927. tc-check-openmp ()
  6928. {
  6929.     if ! tc-has-openmp; then
  6930.         eerror "Your current compiler does not support OpenMP!";
  6931.         if tc-is-gcc; then
  6932.             eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  6933.         else
  6934.             if tc-is-clang; then
  6935.                 eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  6936.             fi;
  6937.         fi;
  6938.         die "Active compiler does not have required support for OpenMP";
  6939.     fi
  6940. }
  6941. tc-endian ()
  6942. {
  6943.     local host=$1;
  6944.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  6945.     host=${host%%-*};
  6946.     case ${host} in
  6947.         aarch64*be)
  6948.             echo big
  6949.         ;;
  6950.         aarch64)
  6951.             echo little
  6952.         ;;
  6953.         alpha*)
  6954.             echo big
  6955.         ;;
  6956.         arm*b*)
  6957.             echo big
  6958.         ;;
  6959.         arm*)
  6960.             echo little
  6961.         ;;
  6962.         cris*)
  6963.             echo little
  6964.         ;;
  6965.         hppa*)
  6966.             echo big
  6967.         ;;
  6968.         i?86*)
  6969.             echo little
  6970.         ;;
  6971.         ia64*)
  6972.             echo little
  6973.         ;;
  6974.         m68*)
  6975.             echo big
  6976.         ;;
  6977.         mips*l*)
  6978.             echo little
  6979.         ;;
  6980.         mips*)
  6981.             echo big
  6982.         ;;
  6983.         powerpc*le)
  6984.             echo little
  6985.         ;;
  6986.         powerpc*)
  6987.             echo big
  6988.         ;;
  6989.         s390*)
  6990.             echo big
  6991.         ;;
  6992.         sh*b*)
  6993.             echo big
  6994.         ;;
  6995.         sh*)
  6996.             echo little
  6997.         ;;
  6998.         sparc*)
  6999.             echo big
  7000.         ;;
  7001.         x86_64*)
  7002.             echo little
  7003.         ;;
  7004.         *)
  7005.             echo wtf
  7006.         ;;
  7007.     esac
  7008. }
  7009. tc-env_build ()
  7010. {
  7011.     tc-export_build_env;
  7012.     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) "$@"
  7013. }
  7014. tc-export ()
  7015. {
  7016.     local var;
  7017.     for var in "$@";
  7018.     do
  7019.         [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  7020.         eval tc-get${var} > /dev/null;
  7021.     done
  7022. }
  7023. tc-export_build_env ()
  7024. {
  7025.     tc-export "$@";
  7026.     : ${BUILD_CFLAGS:=-O1 -pipe};
  7027.     : ${BUILD_CXXFLAGS:=-O1 -pipe};
  7028.     : ${BUILD_CPPFLAGS:= };
  7029.     : ${BUILD_LDFLAGS:= };
  7030.     export BUILD_{C,CXX,CPP,LD}FLAGS;
  7031.     local v;
  7032.     for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  7033.     do
  7034.         export ${v#BUILD_}_FOR_BUILD="${!v}";
  7035.     done
  7036. }
  7037. tc-get-compiler-type ()
  7038. {
  7039.     local code='
  7040. #if defined(__PATHSCALE__)
  7041.     HAVE_PATHCC
  7042. #elif defined(__clang__)
  7043.     HAVE_CLANG
  7044. #elif defined(__GNUC__)
  7045.     HAVE_GCC
  7046. #endif
  7047. ';
  7048.     local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  7049.     case ${res} in
  7050.         *HAVE_PATHCC*)
  7051.             echo pathcc
  7052.         ;;
  7053.         *HAVE_CLANG*)
  7054.             echo clang
  7055.         ;;
  7056.         *HAVE_GCC*)
  7057.             echo gcc
  7058.         ;;
  7059.         *)
  7060.             echo unknown
  7061.         ;;
  7062.     esac
  7063. }
  7064. tc-getAR ()
  7065. {
  7066.     tc-getPROG AR ar "$@"
  7067. }
  7068. tc-getAS ()
  7069. {
  7070.     tc-getPROG AS as "$@"
  7071. }
  7072. tc-getBUILD_AR ()
  7073. {
  7074.     tc-getBUILD_PROG AR ar "$@"
  7075. }
  7076. tc-getBUILD_AS ()
  7077. {
  7078.     tc-getBUILD_PROG AS as "$@"
  7079. }
  7080. tc-getBUILD_CC ()
  7081. {
  7082.     tc-getBUILD_PROG CC gcc "$@"
  7083. }
  7084. tc-getBUILD_CPP ()
  7085. {
  7086.     tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  7087. }
  7088. tc-getBUILD_CXX ()
  7089. {
  7090.     tc-getBUILD_PROG CXX g++ "$@"
  7091. }
  7092. tc-getBUILD_LD ()
  7093. {
  7094.     tc-getBUILD_PROG LD ld "$@"
  7095. }
  7096. tc-getBUILD_NM ()
  7097. {
  7098.     tc-getBUILD_PROG NM nm "$@"
  7099. }
  7100. tc-getBUILD_OBJCOPY ()
  7101. {
  7102.     tc-getBUILD_PROG OBJCOPY objcopy "$@"
  7103. }
  7104. tc-getBUILD_PKG_CONFIG ()
  7105. {
  7106.     tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  7107. }
  7108. tc-getBUILD_PROG ()
  7109. {
  7110.     _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  7111. }
  7112. tc-getBUILD_RANLIB ()
  7113. {
  7114.     tc-getBUILD_PROG RANLIB ranlib "$@"
  7115. }
  7116. tc-getBUILD_STRIP ()
  7117. {
  7118.     tc-getBUILD_PROG STRIP strip "$@"
  7119. }
  7120. tc-getCC ()
  7121. {
  7122.     tc-getPROG CC gcc "$@"
  7123. }
  7124. tc-getCPP ()
  7125. {
  7126.     tc-getPROG CPP "${CC:-gcc} -E" "$@"
  7127. }
  7128. tc-getCXX ()
  7129. {
  7130.     tc-getPROG CXX g++ "$@"
  7131. }
  7132. tc-getDLLWRAP ()
  7133. {
  7134.     tc-getPROG DLLWRAP dllwrap "$@"
  7135. }
  7136. tc-getF77 ()
  7137. {
  7138.     tc-getPROG F77 gfortran "$@"
  7139. }
  7140. tc-getFC ()
  7141. {
  7142.     tc-getPROG FC gfortran "$@"
  7143. }
  7144. tc-getGCJ ()
  7145. {
  7146.     tc-getPROG GCJ gcj "$@"
  7147. }
  7148. tc-getGO ()
  7149. {
  7150.     tc-getPROG GO gccgo "$@"
  7151. }
  7152. tc-getLD ()
  7153. {
  7154.     tc-getPROG LD ld "$@"
  7155. }
  7156. tc-getNM ()
  7157. {
  7158.     tc-getPROG NM nm "$@"
  7159. }
  7160. tc-getOBJCOPY ()
  7161. {
  7162.     tc-getPROG OBJCOPY objcopy "$@"
  7163. }
  7164. tc-getOBJDUMP ()
  7165. {
  7166.     tc-getPROG OBJDUMP objdump "$@"
  7167. }
  7168. tc-getPKG_CONFIG ()
  7169. {
  7170.     tc-getPROG PKG_CONFIG pkg-config "$@"
  7171. }
  7172. tc-getPROG ()
  7173. {
  7174.     _tc-getPROG CHOST "$@"
  7175. }
  7176. tc-getRANLIB ()
  7177. {
  7178.     tc-getPROG RANLIB ranlib "$@"
  7179. }
  7180. tc-getRC ()
  7181. {
  7182.     tc-getPROG RC windres "$@"
  7183. }
  7184. tc-getSTRIP ()
  7185. {
  7186.     tc-getPROG STRIP strip "$@"
  7187. }
  7188. tc-has-openmp ()
  7189. {
  7190.     local base="${T}/test-tc-openmp";
  7191.     cat > "${base}.c"  <<-EOF
  7192. #include <omp.h>
  7193. int main() {
  7194. int nthreads, tid, ret = 0;
  7195. #pragma omp parallel private(nthreads, tid)
  7196. {
  7197. tid = omp_get_thread_num();
  7198. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  7199. }
  7200. return ret;
  7201. }
  7202. EOF
  7203.  
  7204.     $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  7205.     local ret=$?;
  7206.     rm -f "${base}"*;
  7207.     return ${ret}
  7208. }
  7209. tc-has-tls ()
  7210. {
  7211.     local base="${T}/test-tc-tls";
  7212.     cat > "${base}.c"  <<-EOF
  7213. int foo(int *i) {
  7214. static __thread int j = 0;
  7215. return *i ? j : *i;
  7216. }
  7217. EOF
  7218.  
  7219.     local flags;
  7220.     case $1 in
  7221.         -s)
  7222.             flags="-S"
  7223.         ;;
  7224.         -c)
  7225.             flags="-c"
  7226.         ;;
  7227.         -l)
  7228.  
  7229.         ;;
  7230.         -*)
  7231.             die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  7232.         ;;
  7233.     esac;
  7234.     : ${flags:=-fPIC -shared -Wl,-z,defs};
  7235.     [[ $1 == -* ]] && shift;
  7236.     $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  7237.     local ret=$?;
  7238.     rm -f "${base}"*;
  7239.     return ${ret}
  7240. }
  7241. tc-is-clang ()
  7242. {
  7243.     [[ $(tc-get-compiler-type) == clang ]]
  7244. }
  7245. tc-is-cross-compiler ()
  7246. {
  7247.     [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  7248. }
  7249. tc-is-gcc ()
  7250. {
  7251.     [[ $(tc-get-compiler-type) == gcc ]]
  7252. }
  7253. tc-is-softfloat ()
  7254. {
  7255.     local CTARGET=${CTARGET:-${CHOST}};
  7256.     case ${CTARGET} in
  7257.         bfin* | h8300*)
  7258.             echo "only"
  7259.         ;;
  7260.         *)
  7261.             if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  7262.                 echo "yes";
  7263.             else
  7264.                 if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  7265.                     echo "softfp";
  7266.                 else
  7267.                     echo "no";
  7268.                 fi;
  7269.             fi
  7270.         ;;
  7271.     esac
  7272. }
  7273. tc-is-static-only ()
  7274. {
  7275.     local host=${CTARGET:-${CHOST}};
  7276.     [[ ${host} == *-mint* ]]
  7277. }
  7278. tc-ld-disable-gold ()
  7279. {
  7280.     if ! tc-ld-is-gold "$@"; then
  7281.         return;
  7282.     fi;
  7283.     ewarn "Forcing usage of the BFD linker instead of GOLD";
  7284.     local ld=$(tc-getLD "$@");
  7285.     local bfd_ld="${ld%% *}.bfd";
  7286.     local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  7287.     [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  7288.     local major=$(gcc-major-version "$@");
  7289.     local minor=$(gcc-minor-version "$@");
  7290.     if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]]; then
  7291.         if [[ -e ${path_ld} ]]; then
  7292.             local d="${T}/bfd-linker";
  7293.             mkdir -p "${d}";
  7294.             ln -sf "${path_ld}" "${d}"/ld;
  7295.             export LDFLAGS="${LDFLAGS} -B${d}";
  7296.         else
  7297.             die "unable to locate a BFD linker to bypass gold";
  7298.         fi;
  7299.     else
  7300.         export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  7301.     fi
  7302. }
  7303. tc-ld-is-gold ()
  7304. {
  7305.     local out;
  7306.     out=$($(tc-getLD "$@") --version 2>&1);
  7307.     if [[ ${out} == *"GNU gold"* ]]; then
  7308.         return 0;
  7309.     fi;
  7310.     local base="${T}/test-tc-gold";
  7311.     cat > "${base}.c"  <<-EOF
  7312. int main() { return 0; }
  7313. EOF
  7314.  
  7315.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  7316.     rm -f "${base}"*;
  7317.     if [[ ${out} == *"GNU gold"* ]]; then
  7318.         return 0;
  7319.     fi;
  7320.     return 1
  7321. }
  7322. tc-ninja_magic_to_arch ()
  7323. {
  7324.     function ninj ()
  7325.     {
  7326.         [[ ${type} == "kern" ]] && echo $1 || echo $2
  7327.     };
  7328.     local type=$1;
  7329.     local host=$2;
  7330.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  7331.     case ${host} in
  7332.         aarch64*)
  7333.             echo arm64
  7334.         ;;
  7335.         alpha*)
  7336.             echo alpha
  7337.         ;;
  7338.         arm*)
  7339.             echo arm
  7340.         ;;
  7341.         avr*)
  7342.             ninj avr32 avr
  7343.         ;;
  7344.         bfin*)
  7345.             ninj blackfin bfin
  7346.         ;;
  7347.         c6x*)
  7348.             echo c6x
  7349.         ;;
  7350.         cris*)
  7351.             echo cris
  7352.         ;;
  7353.         frv*)
  7354.             echo frv
  7355.         ;;
  7356.         hexagon*)
  7357.             echo hexagon
  7358.         ;;
  7359.         hppa*)
  7360.             ninj parisc hppa
  7361.         ;;
  7362.         i?86*)
  7363.             if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  7364.                 echo i386;
  7365.             else
  7366.                 echo x86;
  7367.             fi
  7368.         ;;
  7369.         ia64*)
  7370.             echo ia64
  7371.         ;;
  7372.         m68*)
  7373.             echo m68k
  7374.         ;;
  7375.         metag*)
  7376.             echo metag
  7377.         ;;
  7378.         microblaze*)
  7379.             echo microblaze
  7380.         ;;
  7381.         mips*)
  7382.             echo mips
  7383.         ;;
  7384.         nios2*)
  7385.             echo nios2
  7386.         ;;
  7387.         nios*)
  7388.             echo nios
  7389.         ;;
  7390.         or1k | or32*)
  7391.             echo openrisc
  7392.         ;;
  7393.         powerpc*)
  7394.             if [[ ${type} == "kern" ]]; then
  7395.                 echo powerpc;
  7396.             else
  7397.                 if [[ ${host} == powerpc64* ]]; then
  7398.                     echo ppc64;
  7399.                 else
  7400.                     echo ppc;
  7401.                 fi;
  7402.             fi
  7403.         ;;
  7404.         riscv*)
  7405.             echo riscv
  7406.         ;;
  7407.         s390*)
  7408.             echo s390
  7409.         ;;
  7410.         score*)
  7411.             echo score
  7412.         ;;
  7413.         sh64*)
  7414.             ninj sh64 sh
  7415.         ;;
  7416.         sh*)
  7417.             echo sh
  7418.         ;;
  7419.         sparc64*)
  7420.             ninj sparc64 sparc
  7421.         ;;
  7422.         sparc*)
  7423.             [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  7424.         ;;
  7425.         tile*)
  7426.             echo tile
  7427.         ;;
  7428.         vax*)
  7429.             echo vax
  7430.         ;;
  7431.         x86_64*freebsd*)
  7432.             echo amd64
  7433.         ;;
  7434.         x86_64*)
  7435.             if [[ ${type} == "kern" ]]; then
  7436.                 echo x86;
  7437.             else
  7438.                 echo amd64;
  7439.             fi
  7440.         ;;
  7441.         xtensa*)
  7442.             echo xtensa
  7443.         ;;
  7444.         *)
  7445.             echo unknown
  7446.         ;;
  7447.     esac
  7448. }
  7449. tc-stack-grows-down ()
  7450. {
  7451.     case ${ARCH} in
  7452.         hppa | metag)
  7453.             return 1
  7454.         ;;
  7455.     esac;
  7456.     return 0
  7457. }
  7458. test-flag-CC ()
  7459. {
  7460.     test-flag-PROG "CC" c "$1"
  7461. }
  7462. test-flag-CXX ()
  7463. {
  7464.     test-flag-PROG "CXX" c++ "$1"
  7465. }
  7466. test-flag-F77 ()
  7467. {
  7468.     test-flag-PROG "F77" f77 "$1"
  7469. }
  7470. test-flag-FC ()
  7471. {
  7472.     test-flag-PROG "FC" f95 "$1"
  7473. }
  7474. test-flag-PROG ()
  7475. {
  7476.     local comp=$1;
  7477.     local lang=$2;
  7478.     local flag=$3;
  7479.     [[ -z ${comp} || -z ${flag} ]] && return 1;
  7480.     local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  7481.     if "${cmdline[@]}" -x${lang} - < /dev/null > /dev/null 2>&1; then
  7482.         "${cmdline[@]}" "${flag}" -x${lang} - < /dev/null > /dev/null 2>&1;
  7483.     else
  7484.         "${cmdline[@]}" "${flag}" -c -o /dev/null /dev/null > /dev/null 2>&1;
  7485.     fi
  7486. }
  7487. test-flags ()
  7488. {
  7489.     test-flags-CC "$@"
  7490. }
  7491. test-flags-CC ()
  7492. {
  7493.     test-flags-PROG "CC" "$@"
  7494. }
  7495. test-flags-CXX ()
  7496. {
  7497.     test-flags-PROG "CXX" "$@"
  7498. }
  7499. test-flags-F77 ()
  7500. {
  7501.     test-flags-PROG "F77" "$@"
  7502. }
  7503. test-flags-FC ()
  7504. {
  7505.     test-flags-PROG "FC" "$@"
  7506. }
  7507. test-flags-PROG ()
  7508. {
  7509.     local comp=$1;
  7510.     local flags=();
  7511.     local x;
  7512.     shift;
  7513.     [[ -z ${comp} ]] && return 1;
  7514.     for x in "$@";
  7515.     do
  7516.         test-flag-${comp} "${x}" && flags+=("${x}");
  7517.     done;
  7518.     echo "${flags[*]}";
  7519.     [[ ${#flags[@]} -gt 0 ]]
  7520. }
  7521. test_version_info ()
  7522. {
  7523.     if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  7524.         return 0;
  7525.     else
  7526.         return 1;
  7527.     fi
  7528. }
  7529. uclibctoolize ()
  7530. {
  7531.     die "Use elibtoolize"
  7532. }
  7533. use_doc ()
  7534. {
  7535.     use doc && echo ${@:-javadoc}
  7536. }
  7537. use_if_iuse ()
  7538. {
  7539.     in_iuse $1 || return 1;
  7540.     use $1
  7541. }
  7542. validate_desktop_entries ()
  7543. {
  7544.     eqawarn "validate_desktop_entries is deprecated and should be not be used.";
  7545.     eqawarn ".desktop file validation is done implicitly by Portage now.";
  7546.     _eutils_eprefix_init;
  7547.     if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]]; then
  7548.         einfo "Checking desktop entry validity";
  7549.         local directories="";
  7550.         for d in /usr/share/applications $@;
  7551.         do
  7552.             [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}";
  7553.         done;
  7554.         if [[ -n ${directories} ]]; then
  7555.             for FILE in $(find ${directories} -name "*\.desktop"                            -not -path '*.hidden*' | sort -u 2>/dev/null);
  7556.             do
  7557.                 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" |                               sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  7558.                 [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:};
  7559.             done;
  7560.         fi;
  7561.         echo "";
  7562.     else
  7563.         einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  7564.     fi
  7565. }
  7566. version_compare ()
  7567. {
  7568.     eshopts_push -s extglob;
  7569.     local ver_a=${1} ver_b=${2} parts_a parts_b;
  7570.     local cur_tok_a cur_tok_b num_part_a num_part_b;
  7571.     local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  7572.     parts_a=($(get_all_version_components "${ver_a}" ));
  7573.     parts_b=($(get_all_version_components "${ver_b}" ));
  7574.     local -i inf_loop=0;
  7575.     while true; do
  7576.         inf_loop+=1;
  7577.         ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  7578.         prev_idx_a=cur_idx_a;
  7579.         prev_idx_b=cur_idx_b;
  7580.         cur_tok_a=${parts_a[cur_idx_a]};
  7581.         cur_tok_b=${parts_b[cur_idx_b]};
  7582.         if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  7583.             cur_idx_a+=1;
  7584.             [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  7585.         else
  7586.             cur_tok_a=;
  7587.         fi;
  7588.         if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  7589.             cur_idx_b+=1;
  7590.             [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  7591.         else
  7592.             cur_tok_b=;
  7593.         fi;
  7594.         [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  7595.         [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  7596.         [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  7597.         if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  7598.             cur_tok_a=${cur_tok_a%%+(0)};
  7599.             cur_tok_b=${cur_tok_b%%+(0)};
  7600.             [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  7601.             [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  7602.         else
  7603.             cur_tok_a=${cur_tok_a##+(0)};
  7604.             cur_tok_b=${cur_tok_b##+(0)};
  7605.             : ${cur_tok_a:=0};
  7606.             : ${cur_tok_b:=0};
  7607.             ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  7608.             ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  7609.         fi;
  7610.     done;
  7611.     local letter_a=;
  7612.     letter_a=${parts_a[cur_idx_a]};
  7613.     if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  7614.         cur_idx_a+=1;
  7615.     else
  7616.         letter_a=@;
  7617.     fi;
  7618.     local letter_b=;
  7619.     letter_b=${parts_b[cur_idx_b]};
  7620.     if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  7621.         cur_idx_b+=1;
  7622.     else
  7623.         letter_b=@;
  7624.     fi;
  7625.     [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  7626.     [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  7627.     inf_loop=0;
  7628.     while true; do
  7629.         inf_loop+=1;
  7630.         ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  7631.         [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  7632.         [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  7633.         cur_tok_a=${parts_a[cur_idx_a]};
  7634.         cur_tok_b=${parts_b[cur_idx_b]};
  7635.         num_part_a=0;
  7636.         num_part_b=0;
  7637.         if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  7638.             cur_idx_a+=1;
  7639.             num_part_a=${cur_tok_a##+([a-z])};
  7640.             num_part_a=${num_part_a##+(0)};
  7641.             : ${num_part_a:=0};
  7642.             cur_tok_a=${cur_tok_a%%+([0-9])};
  7643.         else
  7644.             cur_tok_a=;
  7645.         fi;
  7646.         if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  7647.             cur_idx_b+=1;
  7648.             num_part_b=${cur_tok_b##+([a-z])};
  7649.             num_part_b=${num_part_b##+(0)};
  7650.             : ${num_part_b:=0};
  7651.             cur_tok_b=${cur_tok_b%%+([0-9])};
  7652.         else
  7653.             cur_tok_b=;
  7654.         fi;
  7655.         if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  7656.             local suffix;
  7657.             for suffix in alpha beta pre rc "" p;
  7658.             do
  7659.                 [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  7660.                 [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  7661.             done;
  7662.         else
  7663.             if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  7664.                 break;
  7665.             else
  7666.                 ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  7667.                 ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  7668.             fi;
  7669.         fi;
  7670.     done;
  7671.     [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  7672.     [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  7673.     if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  7674.         die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  7675.     fi;
  7676.     num_part_a=${parts_a[cur_idx_a]#r};
  7677.     num_part_a=${num_part_a##+(0)};
  7678.     : ${num_part_a:=0};
  7679.     num_part_b=${parts_b[cur_idx_b]#r};
  7680.     num_part_b=${num_part_b##+(0)};
  7681.     : ${num_part_b:=0};
  7682.     ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  7683.     ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  7684.     eshopts_pop;
  7685.     return 2
  7686. }
  7687. version_format_string ()
  7688. {
  7689.     local fstr=$1;
  7690.     shift;
  7691.     set -- $(get_version_components "$@");
  7692.     eval echo "${fstr}"
  7693. }
  7694. version_is_at_least ()
  7695. {
  7696.     local want_s="$1" have_s="${2:-${PVR}}" r;
  7697.     version_compare "${want_s}" "${have_s}";
  7698.     r=$?;
  7699.     case $r in
  7700.         1 | 2)
  7701.             return 0
  7702.         ;;
  7703.         3)
  7704.             return 1
  7705.         ;;
  7706.         *)
  7707.             die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  7708.         ;;
  7709.     esac
  7710. }
  7711. version_sort ()
  7712. {
  7713.     eshopts_push -s extglob;
  7714.     local items=;
  7715.     local -i left=0;
  7716.     items=("$@");
  7717.     while ((left < ${#items[@]})); do
  7718.         local -i lowest_idx=left;
  7719.         local -i idx=lowest_idx+1;
  7720.         while ((idx < ${#items[@]})); do
  7721.             version_compare "${items[lowest_idx]}" "${items[idx]}";
  7722.             [[ $? -eq 3 ]] && lowest_idx=idx;
  7723.             idx+=1;
  7724.         done;
  7725.         local tmp=${items[lowest_idx]};
  7726.         items[lowest_idx]=${items[left]};
  7727.         items[left]=${tmp};
  7728.         left+=1;
  7729.     done;
  7730.     echo ${items[@]};
  7731.     eshopts_pop
  7732. }
RAW Paste Data