Advertisement
NISMO1968

environment

Mar 21st, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 137.75 KB | None | 0 0
  1. declare -x ABI="alpha"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_S390=""
  4. declare -x ABI_X86=""
  5. declare -x ADA_TARGET=""
  6. declare -x ALSA_CARDS=""
  7. declare -x AMDGPU_TARGETS=""
  8. declare -x APACHE2_MODULES=""
  9. declare -x APACHE2_MPMS=""
  10. declare -x ARCH="alpha"
  11. declare BDEPEND=">=dev-build/b2-4.9.2 "
  12. declare -x BINPKG_FORMAT="gpkg"
  13. declare -x BINPKG_GPG_SIGNING_BASE_COMMAND="/usr/bin/flock /run/lock/portage-binpkg-gpg.lock /usr/bin/gpg --sign --armor [PORTAGE_CONFIG]"
  14. declare -x BINPKG_GPG_SIGNING_DIGEST="SHA512"
  15. declare -x BINPKG_GPG_VERIFY_BASE_COMMAND="/usr/bin/gpg --verify --batch --no-tty --no-auto-check-trustdb --status-fd 2 [PORTAGE_CONFIG] [SIGNATURE]"
  16. declare -x BINPKG_GPG_VERIFY_GPG_HOME="/etc/portage/gnupg"
  17. declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr xml python_targets_python3_11 python_single_target_python3_11"
  18. declare -x CALLIGRA_FEATURES=""
  19. declare -x CAMERAS=""
  20. declare -x CBUILD="alpha-unknown-linux-gnu"
  21. declare -x CFLAGS="-mieee -pipe -O2 -mcpu=ev67"
  22. declare -x CFLAGS_default
  23. declare -x CHOST="alpha-unknown-linux-gnu"
  24. declare -x CHOST_alpha="alpha-unknown-linux-gnu"
  25. declare -x CHOST_default="alpha-unknown-linux-gnu"
  26. declare -x COLLECTD_PLUGINS=""
  27. declare -x COMMON_FLAGS="-mieee -pipe -O2 -mcpu=ev67"
  28. declare -x CPPFLAGS=" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
  29. declare -x CPU_FLAGS_ARM=""
  30. declare -x CPU_FLAGS_PPC=""
  31. declare -x CPU_FLAGS_X86=""
  32. declare -x CTARGET_default="alpha-unknown-linux-gnu"
  33. declare -x CURL_SSL=""
  34. declare -x CXXFLAGS="-mieee -pipe -O2 -mcpu=ev67 -std=c++17"
  35. declare -x DEFAULT_ABI="alpha"
  36. declare -x DEFINED_PHASES=" compile configure install postinst preinst prepare setup test"
  37. declare DEPEND=$'\n\tbzip2? ( app-arch/bzip2:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\ticu? ( dev-libs/icu:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\t!icu? ( virtual/libiconv[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tlzma? ( app-arch/xz-utils:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tmpi? ( virtual/mpi[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?,cxx,threads] )\n\tpython? (\n\t\tpython_targets_python3_10? ( dev-lang/python:3.10 ) python_targets_python3_11? ( dev-lang/python:3.11 ) python_targets_python3_12? ( dev-lang/python:3.12 ) \n\t\tnumpy? ( dev-python/numpy[python_targets_python3_10(-)?,python_targets_python3_11(-)?,python_targets_python3_12(-)?] )\n\t)\n\tzlib? ( sys-libs/zlib:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tzstd? ( app-arch/zstd:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] ) '
  38. declare DESCRIPTION="Boost Libraries for C++"
  39. declare -x DIROPTIONS="-m0755"
  40. declare -x EAPI="8"
  41. declare -x ELIBC="glibc"
  42. declare -x ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
  43. declare -- EPOCHREALTIME="1711023972.617862"
  44. declare -- EPOCHSECONDS="1711023972"
  45. declare -x EXEOPTIONS="-m0755"
  46. declare -x FCFLAGS="-mieee -pipe -O2 -mcpu=ev67"
  47. 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}\""
  48. declare -x FFLAGS="-mieee -pipe -O2 -mcpu=ev67"
  49. declare -x FFTOOLS=""
  50. declare -x GCC_SPECS=""
  51. declare -x GNUMAKEFLAGS="--load-average 1 --output-sync=line"
  52. declare -x GPG_VERIFY_GROUP_DROP="nogroup"
  53. declare -x GPG_VERIFY_USER_DROP="nobody"
  54. declare -x GPSD_PROTOCOLS=""
  55. declare -x GRUB_PLATFORMS=""
  56. declare HOMEPAGE="https://www.boost.org/"
  57. declare -x HUSHLOGIN="FALSE"
  58. declare IDEPEND=""
  59. declare -x INHERITED=" toolchain-funcs multilib flag-o-matic multiprocessing out-of-source-utils multibuild python-utils-r1 python-r1 multilib-build multilib-minimal"
  60. declare -x INPUT_DEVICES=""
  61. declare -x INSOPTIONS="-m0644"
  62. declare IUSE="bzip2 +context debug doc icu lzma +nls mpi numpy python +stacktrace tools zlib zstd python_targets_python3_10 python_targets_python3_11 python_targets_python3_12 abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_s390_32 abi_s390_64"
  63. declare -x IUSE_EFFECTIVE="abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-linux arm arm64 arm64-macos bzip2 context debug doc elibc_Darwin elibc_SunOS elibc_bionic elibc_glibc elibc_mingw elibc_musl hppa ia64 icu kernel_Darwin kernel_SunOS kernel_linux loong lzma m68k mips mpi nls numpy ppc ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack python python_targets_python3_10 python_targets_python3_11 python_targets_python3_12 riscv s390 sparc stacktrace tools x64-macos x64-solaris x86 x86-linux zlib zstd"
  64. declare -x IUSE_IMPLICIT="prefix prefix-guest prefix-stack"
  65. declare -x KERNEL="linux"
  66. declare -x KERNEL_ABI="alpha"
  67. declare -x KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
  68. declare -x L10N=""
  69. declare -x LANG="C.UTF8"
  70. declare -x LCD_DEVICES=""
  71. declare -x LC_COLLATE="C"
  72. declare -x LC_MESSAGES="C.utf8"
  73. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  74. declare -x LDFLAGS_default
  75. declare -x LEX="flex"
  76. declare -x LIBDIR_alpha="lib"
  77. declare -x LIBDIR_default="lib"
  78. declare -x LIBOPTIONS="-m0644"
  79. declare -x LIBREOFFICE_EXTENSIONS=""
  80. declare -x LICENSE="Boost-1.0"
  81. declare -x LLVM_SLOT=""
  82. declare -x LLVM_TARGETS=""
  83. declare -x LUA_SINGLE_TARGET=""
  84. declare -x LUA_TARGETS=""
  85. declare -x MAIL="/var/mail/root"
  86. declare -x MAKEOPTS="-j1"
  87. declare -x MANPAGER="manpager"
  88. declare -x MONKEYD_PLUGINS=""
  89. declare -x MOTD_SHOWN="pam"
  90. declare -x MULTILIB_ABIS="alpha"
  91. declare -- MULTILIB_USEDEP="abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?"
  92. declare -- MY_PV="1_84_0"
  93. declare -x NGINX_MODULES_HTTP=""
  94. declare -x NGINX_MODULES_MAIL=""
  95. declare -x NGINX_MODULES_STREAM=""
  96. declare -x OFFICE_IMPLEMENTATION=""
  97. declare -x OPENMPI_FABRICS=""
  98. declare -x OPENMPI_OFED_FEATURES=""
  99. declare -x OPENMPI_RM=""
  100. declare -a OPTIONS=([0]="gentoorelease" [1]="-j1" [2]="-q" [3]="-d+2" [4]="pch=off" [5]="--without-mpi" [6]="--without-context" [7]="--without-coroutine" [8]="--without-fiber" [9]="--boost-build=/usr/share/b2/src" [10]="--layout=system" [11]="threading=multi" [12]="link=shared" [13]="-sNO_BZIP2=0" [14]="-sNO_LZMA=1" [15]="-sNO_ZLIB=0" [16]="-sNO_ZSTD=1")
  101. declare -a PATCHES=([0]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.81.0-disable_icu_rpath.patch" [1]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.79.0-build-auto_index-tool.patch" [2]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.83.0-math-gcc14.patch" [3]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.79.0-context-x32.patch" [4]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.84.0-signals2-patch1.patch" [5]="/var/tmp/portage/dev-libs/boost-1.84.0-r3/files/boost-1.84.0-signals2-patch2.patch")
  102. declare -x PATH="/usr/lib/portage/python3.11/ebuild-helpers/xattr:/usr/lib/portage/python3.11/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  103. declare PDEPEND=""
  104. declare -x PHP_TARGETS=""
  105. declare -x PORTAGE_COMPRESSION_COMMAND="zstd -T1"
  106. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  107. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  108. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/boost-1.84.0-r3/html")
  109. declare -a PORTAGE_DOSTRIP=([0]="/")
  110. declare -a PORTAGE_DOSTRIP_SKIP=()
  111. declare -x POSTGRES_TARGETS=""
  112. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL"
  113. declare -- PROPERTIES=""
  114. declare -x PYTHONDONTWRITEBYTECODE="1"
  115. declare -a PYTHON_COMPAT=([0]="python3_10" [1]="python3_11" [2]="python3_12")
  116. declare -- PYTHON_DEPS="python_targets_python3_10? ( dev-lang/python:3.10 ) python_targets_python3_11? ( dev-lang/python:3.11 ) python_targets_python3_12? ( dev-lang/python:3.12 ) "
  117. declare -- PYTHON_REQUIRED_USE="|| ( python_targets_python3_10 python_targets_python3_11 python_targets_python3_12 )"
  118. declare -x PYTHON_SINGLE_TARGET=""
  119. declare -x PYTHON_TARGETS="python3_11"
  120. declare -- PYTHON_USEDEP="python_targets_python3_10(-)?,python_targets_python3_11(-)?,python_targets_python3_12(-)?"
  121. declare -x QEMU_SOFTMMU_TARGETS=""
  122. declare -x QEMU_USER_TARGETS=""
  123. declare RDEPEND=$'\n\tbzip2? ( app-arch/bzip2:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\ticu? ( dev-libs/icu:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\t!icu? ( virtual/libiconv[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tlzma? ( app-arch/xz-utils:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tmpi? ( virtual/mpi[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?,cxx,threads] )\n\tpython? (\n\t\tpython_targets_python3_10? ( dev-lang/python:3.10 ) python_targets_python3_11? ( dev-lang/python:3.11 ) python_targets_python3_12? ( dev-lang/python:3.12 ) \n\t\tnumpy? ( dev-python/numpy[python_targets_python3_10(-)?,python_targets_python3_11(-)?,python_targets_python3_12(-)?] )\n\t)\n\tzlib? ( sys-libs/zlib:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tzstd? ( app-arch/zstd:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] ) '
  124. declare REPOSITORY
  125. declare REQUIRED_USE="python? ( || ( python_targets_python3_10 python_targets_python3_11 python_targets_python3_12 ) ) "
  126. declare RESTRICT="test"
  127. 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}\""
  128. declare -x RUBY_TARGETS=""
  129. declare -x S="/var/tmp/portage/dev-libs/boost-1.84.0-r3/work/boost_1_84_0"
  130. declare -x SANDBOX_DEBUG="0"
  131. declare -x SANDBOX_DENY=""
  132. declare -x SANDBOX_METHOD="any"
  133. declare -x SANDBOX_PREDICT="/var/tmp/portage/dev-libs/boost-1.84.0-r3/homedir:/dev/crypto:/var/cache/man:/var/cache/fontconfig"
  134. declare -x SANDBOX_READ="/:/var/tmp/portage"
  135. declare -x SANDBOX_VERBOSE="1"
  136. 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/:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp/:/var/tmp/portage:/var/tmp/portage/dev-libs/boost-1.84.0-r3/homedir/.bash_history"
  137. declare -x SANE_BACKENDS=""
  138. declare -x SHELL="/bin/bash"
  139. declare -x SLOT="0/1.84.0"
  140. declare -i SRANDOM="3062890256"
  141. declare SRC_URI="https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2"
  142. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  143. declare -x USE="alpha bzip2 elibc_glibc icu kernel_linux nls python_targets_python3_11 stacktrace zlib"
  144. declare -x USERLAND="GNU"
  145. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL"
  146. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  147. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-linux arm arm64 arm64-macos hppa ia64 loong m68k mips ppc ppc64 ppc64-linux ppc-macos riscv s390 sparc x64-macos x64-solaris x86 x86-linux"
  148. declare -x USE_EXPAND_VALUES_ELIBC="bionic Darwin glibc mingw musl SunOS"
  149. declare -x USE_EXPAND_VALUES_KERNEL="Darwin linux SunOS"
  150. declare -x UWSGI_PLUGINS=""
  151. declare -x VIDEO_CARDS=""
  152. declare -x VOICEMAIL_STORAGE=""
  153. declare -x XTABLES_ADDONS=""
  154. declare -- _FLAG_O_MATIC_ECLASS="1"
  155. declare -- _MULTIBUILD_ECLASS="1"
  156. declare -- _MULTILIB_BUILD_ECLASS="1"
  157. declare -- _MULTILIB_ECLASS="1"
  158. 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_s390_32:s390" [7]="abi_s390_64:s390x")
  159. declare -- _MULTILIB_MINIMAL_ECLASS="1"
  160. declare -- _MULTIPROCESSING_ECLASS="1"
  161. declare -- _OUT_OF_SOURCE_UTILS_ECLASS="1"
  162. declare -a _PYTHON_ALL_IMPLS=([0]="pypy3" [1]="python3_10" [2]="python3_11" [3]="python3_12")
  163. declare -a _PYTHON_HISTORICAL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy1_8" [3]="pypy1_9" [4]="pypy2_0" [5]="python2_5" [6]="python2_6" [7]="python2_7" [8]="python3_1" [9]="python3_2" [10]="python3_3" [11]="python3_4" [12]="python3_5" [13]="python3_6" [14]="python3_7" [15]="python3_8" [16]="python3_9")
  164. declare -- _PYTHON_R1_ECLASS="1"
  165. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python3_10" [1]="python3_11" [2]="python3_12")
  166. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="pypy3")
  167. declare -- _PYTHON_UTILS_R1_ECLASS="1"
  168. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  169. declare -x __E_DESTTREE="/usr"
  170. declare -x __E_DOCDESTTREE=""
  171. declare -x __E_EXEDESTTREE=""
  172. declare -x __E_INSDESTTREE=""
  173. declare -x ac_cv_c_undeclared_builtin_options="none needed"
  174. declare -x enable_year2038="no"
  175. declare -x gl_cv_compiler_check_decl_option="-Werror=implicit-function-declaration"
  176. declare -x gl_cv_func_getcwd_path_max="yes"
  177. __eapi6_src_install ()
  178. {
  179. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  180. emake DESTDIR="${D}" install;
  181. fi;
  182. einstalldocs
  183. }
  184. __eapi6_src_prepare ()
  185. {
  186. if ___is_indexed_array_var PATCHES; then
  187. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  188. else
  189. if [[ -n ${PATCHES} ]]; then
  190. eapply ${PATCHES};
  191. fi;
  192. fi;
  193. eapply_user
  194. }
  195. __eapi7_ver_compare ()
  196. {
  197. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  198. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  199. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  200. an=${BASH_REMATCH[1]};
  201. al=${BASH_REMATCH[3]};
  202. as=${BASH_REMATCH[4]};
  203. ar=${BASH_REMATCH[7]};
  204. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  205. bn=${BASH_REMATCH[1]};
  206. bl=${BASH_REMATCH[3]};
  207. bs=${BASH_REMATCH[4]};
  208. br=${BASH_REMATCH[7]};
  209. __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  210. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  211. an=${an#*.};
  212. bn=${bn#*.};
  213. a=${an%%.*};
  214. b=${bn%%.*};
  215. if [[ ${a} == 0* || ${b} == 0* ]]; then
  216. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  217. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  218. [[ ${a} > ${b} ]] && return 3;
  219. [[ ${a} < ${b} ]] && return 1;
  220. else
  221. __eapi7_ver_compare_int "${a}" "${b}" || return;
  222. fi;
  223. done;
  224. [[ ${an} == *.* ]] && return 3;
  225. [[ ${bn} == *.* ]] && return 1;
  226. [[ ${al} > ${bl} ]] && return 3;
  227. [[ ${al} < ${bl} ]] && return 1;
  228. as=${as#_}${as:+_};
  229. bs=${bs#_}${bs:+_};
  230. while [[ -n ${as} && -n ${bs} ]]; do
  231. a=${as%%_*};
  232. b=${bs%%_*};
  233. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  234. __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  235. else
  236. [[ ${a%%[0-9]*} == p ]] && return 3;
  237. [[ ${b%%[0-9]*} == p ]] && return 1;
  238. [[ ${a} > ${b} ]] && return 3 || return 1;
  239. fi;
  240. as=${as#*_};
  241. bs=${bs#*_};
  242. done;
  243. if [[ -n ${as} ]]; then
  244. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  245. else
  246. if [[ -n ${bs} ]]; then
  247. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  248. fi;
  249. fi;
  250. __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  251. return 2
  252. }
  253. __eapi7_ver_compare_int ()
  254. {
  255. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  256. if [[ ${d} -gt 0 ]]; then
  257. printf -v b "%0${d}d%s" 0 "${b}";
  258. else
  259. if [[ ${d} -lt 0 ]]; then
  260. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  261. fi;
  262. fi;
  263. [[ ${a} > ${b} ]] && return 3;
  264. [[ ${a} == "${b}" ]]
  265. }
  266. __eapi7_ver_parse_range ()
  267. {
  268. local range=${1};
  269. local max=${2};
  270. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  271. start=${range%-*};
  272. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  273. if [[ -n ${end} ]]; then
  274. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  275. [[ ${end} -le ${max} ]] || end=${max};
  276. else
  277. end=${max};
  278. fi
  279. }
  280. __eapi7_ver_split ()
  281. {
  282. local v=${1} LC_ALL=C;
  283. comp=();
  284. local s c;
  285. while [[ -n ${v} ]]; do
  286. s=${v%%[a-zA-Z0-9]*};
  287. v=${v:${#s}};
  288. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  289. v=${v:${#c}};
  290. comp+=("${s}" "${c}");
  291. done
  292. }
  293. __eapi8_src_prepare ()
  294. {
  295. local f;
  296. if ___is_indexed_array_var PATCHES; then
  297. [[ ${#PATCHES[@]} -gt 0 ]] && eapply -- "${PATCHES[@]}";
  298. else
  299. if [[ -n ${PATCHES} ]]; then
  300. eapply -- ${PATCHES};
  301. fi;
  302. fi;
  303. eapply_user
  304. }
  305. _clang_fullversion ()
  306. {
  307. local ver="$1";
  308. shift;
  309. set -- $($(tc-getCPP "$@") -E -P - <<< "__clang_major__ __clang_minor__ __clang_patchlevel__");
  310. eval echo "${ver}"
  311. }
  312. _eapply_patch ()
  313. {
  314. local f=${1};
  315. local prefix=${2};
  316. ebegin "${prefix:-Applying }${f##*/}";
  317. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  318. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  319. all_opts+=(-s -F0);
  320. fi;
  321. ${patch_cmd} "${all_opts[@]}" < "${f}";
  322. failed=${?};
  323. if ! eend "${failed}"; then
  324. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  325. fi
  326. }
  327. _filter-hardened ()
  328. {
  329. local f;
  330. for f in "$@";
  331. do
  332. case "${f}" in
  333. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  334. if ! gcc-specs-pie && ! tc-enables-pie; then
  335. continue;
  336. fi;
  337. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  338. if test-flags -nopie > /dev/null; then
  339. append-flags -nopie;
  340. else
  341. append-flags -no-pie;
  342. fi;
  343. fi
  344. ;;
  345. -fstack-protector | -fstack-protector-strong)
  346. if ! gcc-specs-ssp && ! tc-enables-ssp && ! tc-enables-ssp-strong; then
  347. continue;
  348. fi;
  349. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  350. ;;
  351. -fstack-protector-all)
  352. if ! gcc-specs-ssp-to-all && ! tc-enables-ssp-all; then
  353. continue;
  354. fi;
  355. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  356. ;;
  357. -fno-strict-overflow)
  358. gcc-specs-nostrict || continue;
  359. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  360. ;;
  361. -D_GLIBCXX_ASSERTIONS | -D_LIBCPP_ENABLE_ASSERTIONS | -D_LIBCPP_ENABLE_HARDENED_MODE)
  362. tc-enables-cxx-assertions || continue;
  363. append-cppflags -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -U_LIBCPP_ENABLE_HARDENED_MODE
  364. ;;
  365. -D_FORTIFY_SOURCE=*)
  366. tc-enables-fortify-source || continue;
  367. append-cppflags -U_FORTIFY_SOURCE
  368. ;;
  369. esac;
  370. done
  371. }
  372. _filter-var ()
  373. {
  374. local f x var=$1 new=();
  375. shift;
  376. for f in ${!var};
  377. do
  378. for x in "$@";
  379. do
  380. [[ ${f} == ${x} ]] && continue 2;
  381. done;
  382. new+=("${f}");
  383. done;
  384. export ${var}="${new[*]}"
  385. }
  386. _gcc-install-dir ()
  387. {
  388. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  389. }
  390. _gcc-specs-directive_raw ()
  391. {
  392. local cc=$(tc-getCC);
  393. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  394. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  395. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  396. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  397. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  398. { spec=spec $0 }
  399. END { print spec }';
  400. return 0
  401. }
  402. _gcc-specs-exists ()
  403. {
  404. [[ -f $(_gcc-install-dir)/$1 ]]
  405. }
  406. _gcc_fullversion ()
  407. {
  408. local ver="$1";
  409. shift;
  410. set -- $($(tc-getCPP "$@") -E -P - <<< "__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  411. eval echo "${ver}"
  412. }
  413. _get_all_makeopts ()
  414. {
  415. echo "${MAKEOPTS} ${GNUMAKEFLAGS} ${MAKEFLAGS}"
  416. }
  417. _is_flagq ()
  418. {
  419. local x var="$1[*]";
  420. for x in ${!var};
  421. do
  422. [[ ${x} == $2 ]] && return 0;
  423. done;
  424. return 1
  425. }
  426. _multibuild_create_source_copy ()
  427. {
  428. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  429. cp -p -R "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  430. }
  431. _multibuild_run ()
  432. {
  433. local i=1;
  434. while [[ ${!i} == _* ]]; do
  435. (( i += 1 ));
  436. done;
  437. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  438. "${@}"
  439. }
  440. _multilib_multibuild_wrapper ()
  441. {
  442. debug-print-function ${FUNCNAME} "$@";
  443. local ABI=${MULTIBUILD_VARIANT#*.};
  444. local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  445. multilib_toolchain_setup "${ABI}";
  446. readonly ABI;
  447. "${@}"
  448. }
  449. _python_check_EPYTHON ()
  450. {
  451. if [[ -z ${EPYTHON} ]]; then
  452. die "EPYTHON unset, invalid call context";
  453. fi
  454. }
  455. _python_check_locale_sanity ()
  456. {
  457. local -x LC_ALL=${1};
  458. local IFS=;
  459. local lc=({a..z});
  460. local uc=({A..Z});
  461. local input="${lc[*]}${uc[*]}";
  462. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<< "${input}");
  463. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  464. }
  465. _python_check_occluded_packages ()
  466. {
  467. debug-print-function ${FUNCNAME} "${@}";
  468. [[ -z ${BUILD_DIR} || ! -d ${BUILD_DIR}/install ]] && return;
  469. local sitedir="${BUILD_DIR}/install$(python_get_sitedir)";
  470. [[ ${sitedir} -ef . ]] && return;
  471. local f fn diff l;
  472. for f in "${sitedir}"/*/;
  473. do
  474. f=${f%/};
  475. fn=${f##*/};
  476. [[ ${fn} == *.dist-info || ${fn} == *.egg-info ]] && continue;
  477. if [[ -d ${fn} ]]; then
  478. diff=$(comm -1 -3 <(find "${fn}" -type f -not -path '*/__pycache__/*' | sort
  479. assert) <(cd "${sitedir}" && find "${fn}" -type f -not -path '*/__pycache__/*' | sort
  480. assert));
  481. if [[ -n ${diff} ]]; then
  482. eqawarn "The directory ${fn} occludes package installed for ${EPYTHON}.";
  483. eqawarn "The installed package includes additional files:";
  484. eqawarn;
  485. while IFS= read -r l; do
  486. eqawarn " ${l}";
  487. done <<< "${diff}";
  488. eqawarn;
  489. if [[ ! -n ${_PYTHON_WARNED_OCCLUDED_PACKAGES} ]]; then
  490. eqawarn "For more information on occluded packages, please see:";
  491. eqawarn "https://projects.gentoo.org/python/guide/test.html#importerrors-for-c-extensions";
  492. _PYTHON_WARNED_OCCLUDED_PACKAGES=1;
  493. fi;
  494. fi;
  495. fi;
  496. done
  497. }
  498. _python_export ()
  499. {
  500. debug-print-function ${FUNCNAME} "${@}";
  501. local impl var;
  502. case "${1}" in
  503. python* | jython*)
  504. impl=${1/_/.};
  505. shift
  506. ;;
  507. pypy | pypy3)
  508. impl=${1};
  509. shift
  510. ;;
  511. *)
  512. impl=${EPYTHON};
  513. if [[ -z ${impl} ]]; then
  514. die "_python_export called without a python implementation and EPYTHON is unset";
  515. fi
  516. ;;
  517. esac;
  518. debug-print "${FUNCNAME}: implementation: ${impl}";
  519. for var in "$@";
  520. do
  521. case "${var}" in
  522. EPYTHON)
  523. export EPYTHON=${impl};
  524. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  525. ;;
  526. PYTHON)
  527. export PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl};
  528. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  529. ;;
  530. PYTHON_SITEDIR)
  531. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  532. PYTHON_SITEDIR=$("${PYTHON}" - "${EPREFIX}/usr" <<-EOF ||
  533. import sys, sysconfig
  534. print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
  535. EOF
  536. die);
  537. export PYTHON_SITEDIR;
  538. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  539. ;;
  540. PYTHON_INCLUDEDIR)
  541. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  542. PYTHON_INCLUDEDIR=$("${PYTHON}" - "${ESYSROOT}/usr" <<-EOF ||
  543. import sys, sysconfig
  544. print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
  545. EOF
  546. die);
  547. export PYTHON_INCLUDEDIR;
  548. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  549. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  550. die "${impl} does not install any header files!";
  551. fi
  552. ;;
  553. PYTHON_LIBPATH)
  554. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  555. PYTHON_LIBPATH=$("${PYTHON}" - <<-EOF ||
  556. import os.path, sysconfig
  557. print(
  558. os.path.join(
  559. sysconfig.get_config_var("LIBDIR"),
  560. sysconfig.get_config_var("LDLIBRARY"))
  561. if sysconfig.get_config_var("LDLIBRARY")
  562. else "")
  563. EOF
  564. die);
  565. export PYTHON_LIBPATH;
  566. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  567. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  568. die "${impl} lacks a (usable) dynamic library";
  569. fi
  570. ;;
  571. PYTHON_CFLAGS)
  572. local val;
  573. case "${impl}" in
  574. python*)
  575. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  576. ;;
  577. *)
  578. die "${impl}: obtaining ${var} not supported"
  579. ;;
  580. esac;
  581. export PYTHON_CFLAGS=${val};
  582. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  583. ;;
  584. PYTHON_LIBS)
  585. local val;
  586. case "${impl}" in
  587. python*)
  588. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}-embed) || die
  589. ;;
  590. *)
  591. die "${impl}: obtaining ${var} not supported"
  592. ;;
  593. esac;
  594. export PYTHON_LIBS=${val};
  595. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  596. ;;
  597. PYTHON_CONFIG)
  598. local flags val;
  599. case "${impl}" in
  600. python*)
  601. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  602. flags=$("${PYTHON}" - <<-EOF ||
  603. import sysconfig
  604. print(sysconfig.get_config_var("ABIFLAGS")
  605. or "")
  606. EOF
  607. die);
  608. val=${PYTHON}${flags}-config
  609. ;;
  610. *)
  611. die "${impl}: obtaining ${var} not supported"
  612. ;;
  613. esac;
  614. export PYTHON_CONFIG=${val};
  615. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  616. ;;
  617. PYTHON_PKG_DEP)
  618. local d;
  619. case ${impl} in
  620. python*)
  621. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  622. ;;
  623. pypy3)
  624. PYTHON_PKG_DEP="dev-python/${impl}:="
  625. ;;
  626. *)
  627. die "Invalid implementation: ${impl}"
  628. ;;
  629. esac;
  630. if [[ -n ${PYTHON_REQ_USE} ]]; then
  631. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  632. fi;
  633. export PYTHON_PKG_DEP;
  634. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  635. ;;
  636. PYTHON_SCRIPTDIR)
  637. local dir;
  638. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  639. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  640. ;;
  641. *)
  642. die "_python_export: unknown variable ${var}"
  643. ;;
  644. esac;
  645. done
  646. }
  647. _python_gen_usedep ()
  648. {
  649. debug-print-function ${FUNCNAME} "${@}";
  650. local impl matches=();
  651. _python_verify_patterns "${@}";
  652. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  653. do
  654. if _python_impl_matches "${impl}" "${@}"; then
  655. matches+=("python_targets_${impl}(-)?");
  656. fi;
  657. done;
  658. [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  659. local out=${matches[@]};
  660. echo "${out// /,}"
  661. }
  662. _python_impl_matches ()
  663. {
  664. [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter";
  665. [[ ${#} -eq 1 ]] && return 0;
  666. local impl=${1/./_} pattern;
  667. shift;
  668. for pattern in "$@";
  669. do
  670. case ${pattern} in
  671. -2 | python2* | pypy)
  672. if [[ ${EAPI} != 7 ]]; then
  673. eerror;
  674. eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  675. eerror "${FUNCNAME[1]} calls.";
  676. die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  677. fi
  678. ;;
  679. -3)
  680. if [[ ${EAPI} != 7 ]]; then
  681. eerror;
  682. eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  683. eerror "${FUNCNAME[1]} calls.";
  684. die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  685. fi;
  686. return 0
  687. ;;
  688. 3.10)
  689. [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] && return 0
  690. ;;
  691. 3.8 | 3.9 | 3.1[1-2])
  692. [[ ${impl} == python${pattern/./_} ]] && return 0
  693. ;;
  694. *)
  695. [[ ${impl} == ${pattern/./_} ]] && return 0
  696. ;;
  697. esac;
  698. done;
  699. return 1
  700. }
  701. _python_multibuild_wrapper ()
  702. {
  703. debug-print-function ${FUNCNAME} "${@}";
  704. local -x EPYTHON PYTHON;
  705. local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH};
  706. _python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON;
  707. _python_wrapper_setup;
  708. "${@}"
  709. }
  710. _python_obtain_impls ()
  711. {
  712. _python_validate_useflags;
  713. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  714. MULTIBUILD_VARIANTS=(${PYTHON_COMPAT_OVERRIDE});
  715. return;
  716. fi;
  717. MULTIBUILD_VARIANTS=();
  718. local impl;
  719. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  720. do
  721. has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}" && MULTIBUILD_VARIANTS+=("${impl}");
  722. done
  723. }
  724. _python_run_check_deps ()
  725. {
  726. debug-print-function ${FUNCNAME} "${@}";
  727. local impl=${1};
  728. einfo "Checking whether ${impl} is suitable ...";
  729. local PYTHON_PKG_DEP;
  730. _python_export "${impl}" PYTHON_PKG_DEP;
  731. ebegin " ${PYTHON_PKG_DEP}";
  732. has_version -b "${PYTHON_PKG_DEP}";
  733. eend ${?} || return 1;
  734. declare -f python_check_deps > /dev/null || return 0;
  735. local PYTHON_USEDEP="python_targets_${impl}(-)";
  736. local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)";
  737. ebegin " python_check_deps";
  738. python_check_deps;
  739. eend ${?}
  740. }
  741. _python_set_impls ()
  742. {
  743. local i;
  744. if [[ ${BASH_VERSINFO[0]} -ge 5 ]]; then
  745. [[ ${PYTHON_COMPAT@a} == *a* ]];
  746. else
  747. [[ $(declare -p PYTHON_COMPAT) == "declare -a"* ]];
  748. fi;
  749. if [[ ${?} -ne 0 ]]; then
  750. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  751. die 'PYTHON_COMPAT not declared.';
  752. else
  753. die 'PYTHON_COMPAT must be an array.';
  754. fi;
  755. fi;
  756. local obsolete=();
  757. if [[ ! -n ${PYTHON_COMPAT_NO_STRICT} ]]; then
  758. for i in "${PYTHON_COMPAT[@]}";
  759. do
  760. case ${i} in
  761. pypy3 | python3_9 | python3_1[0-2])
  762.  
  763. ;;
  764. jython2_7 | pypy | pypy1_[89] | pypy2_0 | python2_[5-7] | python3_[1-9])
  765. obsolete+=("${i}")
  766. ;;
  767. *)
  768. if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}"; then
  769. die "Mis-synced patterns in _python_set_impls: missing ${i}";
  770. else
  771. die "Invalid implementation in PYTHON_COMPAT: ${i}";
  772. fi
  773. ;;
  774. esac;
  775. done;
  776. fi;
  777. local supp=() unsupp=();
  778. for i in "${_PYTHON_ALL_IMPLS[@]}";
  779. do
  780. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  781. supp+=("${i}");
  782. else
  783. unsupp+=("${i}");
  784. fi;
  785. done;
  786. if [[ ! -n ${supp[@]} ]]; then
  787. die "No supported implementation in PYTHON_COMPAT.";
  788. fi;
  789. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  790. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  791. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  792. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  793. eerror "Now : ${supp[*]}";
  794. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  795. fi;
  796. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  797. eerror "Unsupported impls changed between inherits!";
  798. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  799. eerror "Now : ${unsupp[*]}";
  800. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  801. fi;
  802. else
  803. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  804. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  805. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  806. fi
  807. }
  808. _python_validate_useflags ()
  809. {
  810. debug-print-function ${FUNCNAME} "${@}";
  811. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  812. if [[ ! -n ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
  813. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  814. ewarn "implementations will be enabled:";
  815. ewarn;
  816. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  817. ewarn;
  818. ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored.";
  819. _PYTHON_COMPAT_OVERRIDE_WARNED=1;
  820. fi;
  821. return;
  822. fi;
  823. local i;
  824. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  825. do
  826. use "python_targets_${i}" && return 0;
  827. done;
  828. eerror "No Python implementation selected for the build. Please add one";
  829. eerror "of the following values to your PYTHON_TARGETS (in make.conf):";
  830. eerror;
  831. eerror "${PYTHON_COMPAT[@]}";
  832. echo;
  833. die "No supported Python implementation in PYTHON_TARGETS."
  834. }
  835. _python_verify_patterns ()
  836. {
  837. debug-print-function ${FUNCNAME} "${@}";
  838. local impl pattern;
  839. for pattern in "$@";
  840. do
  841. case ${pattern} in
  842. -[23] | 3.[89] | 3.1[012])
  843. continue
  844. ;;
  845. esac;
  846. for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}";
  847. do
  848. [[ ${impl} == ${pattern/./_} ]] && continue 2;
  849. done;
  850. die "Invalid implementation pattern: ${pattern}";
  851. done
  852. }
  853. _python_wrapper_setup ()
  854. {
  855. debug-print-function ${FUNCNAME} "${@}";
  856. local workdir=${1:-${T}/${EPYTHON}};
  857. local impl=${2:-${EPYTHON}};
  858. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  859. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  860. if [[ ! -x ${workdir}/bin/python ]]; then
  861. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  862. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  863. rm -f "${workdir}"/bin/2to3 || die;
  864. rm -f "${workdir}"/pkgconfig/python{2,3}{,-embed}.pc || die;
  865. local EPYTHON PYTHON;
  866. _python_export "${impl}" EPYTHON PYTHON;
  867. cat > "${workdir}/bin/python" <<-_EOF_ ||
  868. #!/bin/sh
  869. exec "${PYTHON}" "\${@}"
  870. _EOF_
  871. die
  872. cp "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  873. chmod +x "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  874. local nonsupp=(python2 python2-config);
  875. if [[ ${EPYTHON} == python* ]]; then
  876. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  877. #!/bin/sh
  878. exec "${PYTHON}-config" "\${@}"
  879. _EOF_
  880. die
  881. cp "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  882. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  883. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  884. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python3.pc || die;
  885. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}-embed.pc "${workdir}"/pkgconfig/python3-embed.pc || die;
  886. else
  887. nonsupp+=(2to3 python-config python3-config);
  888. fi;
  889. local x;
  890. for x in "${nonsupp[@]}";
  891. do
  892. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  893. #!/bin/sh
  894. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  895. exit 127
  896. _EOF_
  897. die
  898. chmod +x "${workdir}"/bin/${x} || die;
  899. done;
  900. fi;
  901. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  902. PATH=${workdir}/bin${PATH:+:${PATH}};
  903. fi;
  904. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  905. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  906. fi;
  907. export PATH PKG_CONFIG_PATH
  908. }
  909. _setup-allowed-flags ()
  910. {
  911. ALLOWED_FLAGS=(-pipe -O '-O[123szg]' '-mcpu=*' '-march=*' '-mtune=*' '-mfpmath=*' -flto '-flto=*' -fno-lto '-fstack-protector*' -fstack-clash-protection '-fcf-protection=*' -fbounds-check -fbounds-checking -fno-PIE -fno-pie -nopie -no-pie -fharden-compares -fharden-conditional-branches -fharden-control-flow-redundancy -fno-harden-control-flow-redundancy -fhardcfr-skip-leaf -fhardcfr-check-exceptions -fhardcfr-check-returning-calls '-fhardcfr-check-noreturn-calls=*' '-mindirect-branch=*' -mindirect-branch-register '-mfunction-return=*' -mretpoline '-mharden-sls=*' '-mbranch-protection=*' -fno-unit-at-a-time -fno-strict-overflow '-fsanitize*' '-fno-sanitize*' -g '-g[0-9]' -ggdb '-ggdb[0-9]' -gdwarf '-gdwarf-*' -gstabs -gstabs+ -gz -glldb '-fdebug-default-version=*' -fno-diagnostics-color '-fmessage-length=*' -fno-ident -fpermissive -frecord-gcc-switches -frecord-command-line '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld=*');
  912. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*' -mno-omit-leaf-frame-pointer);
  913. 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=*' '-mtls-dialect=*' -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 -mfix-r10000 -mno-fix-r10000 '-mr10k-cache-barrier=*' -mthumb -marm -ffixed-x18 -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);
  914. ALLOWED_FLAGS+=(-mstackrealign '-mpreferred-stack-boundary=*' '-mincoming-stack-boundary=*');
  915. ALLOWED_FLAGS+=('--unwindlib=*' '--rtlib=*' '--stdlib=*')
  916. }
  917. _tc-getPROG ()
  918. {
  919. local tuple=$1;
  920. local v var vars=$2;
  921. local prog=($3);
  922. var=${vars%% *};
  923. for v in ${vars};
  924. do
  925. if [[ -n ${!v} ]]; then
  926. export ${var}="${!v}";
  927. echo "${!v}";
  928. return 0;
  929. fi;
  930. done;
  931. local search=;
  932. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  933. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  934. [[ -n ${search} ]] && prog[0]=${search##*/};
  935. export ${var}="${prog[*]}";
  936. echo "${!var}"
  937. }
  938. _tc-has-openmp ()
  939. {
  940. local base="${T}/test-tc-openmp";
  941. cat <<-EOF > "${base}.c"
  942. #include <omp.h>
  943. int main(void) {
  944. int nthreads, tid, ret = 0;
  945. #pragma omp parallel private(nthreads, tid)
  946. {
  947. tid = omp_get_thread_num();
  948. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  949. }
  950. return ret;
  951. }
  952. EOF
  953.  
  954. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null;
  955. local ret=$?;
  956. rm -f "${base}"*;
  957. return ${ret}
  958. }
  959. _test-flag-PROG ()
  960. {
  961. local comp=$1;
  962. local lang=$2;
  963. shift 2;
  964. if [[ -z ${comp} ]]; then
  965. return 1;
  966. fi;
  967. if [[ -z $1 ]]; then
  968. return 1;
  969. fi;
  970. comp=($(tc-get${comp}));
  971. if ! type -p ${comp[0]} > /dev/null; then
  972. return 1;
  973. fi;
  974. local in_src in_ext cmdline_extra=();
  975. case "${lang}" in
  976. c)
  977. in_ext='c';
  978. in_src='int main(void) { return 0; }';
  979. cmdline_extra+=(-xc -c)
  980. ;;
  981. c++)
  982. in_ext='cc';
  983. in_src='int main(void) { return 0; }';
  984. cmdline_extra+=(-xc++ -c)
  985. ;;
  986. f77)
  987. in_ext='f';
  988. in_src=' end';
  989. cmdline_extra+=(-xf77 -c)
  990. ;;
  991. f95)
  992. in_ext='f90';
  993. in_src='end';
  994. cmdline_extra+=(-xf95 -c)
  995. ;;
  996. c+ld)
  997. in_ext='c';
  998. in_src='int main(void) { return 0; }';
  999. if is-ldflagq -fuse-ld=*; then
  1000. fuse_ld_value=$(get-flag -fuse-ld=*);
  1001. cmdline_extra+=(${fuse_ld_value});
  1002. fi;
  1003. cmdline_extra+=(-xc)
  1004. ;;
  1005. esac;
  1006. local test_in=${T}/test-flag.${in_ext};
  1007. local test_out=${T}/test-flag.exe;
  1008. printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'";
  1009. local cmdline=("${comp[@]}" -Werror "$@" "${cmdline_extra[@]}" "${test_in}" -o "${test_out}");
  1010. "${cmdline[@]}" &> /dev/null
  1011. }
  1012. _test-flags-PROG ()
  1013. {
  1014. local comp=$1;
  1015. local flags=();
  1016. local x;
  1017. shift;
  1018. [[ -z ${comp} ]] && return 1;
  1019. while (( $# )); do
  1020. case "$1" in
  1021. --param | -B)
  1022. if test-flag-${comp} "$1" "$2"; then
  1023. flags+=("$1" "$2");
  1024. fi;
  1025. shift 2
  1026. ;;
  1027. *)
  1028. if test-flag-${comp} "$1"; then
  1029. flags+=("$1");
  1030. fi;
  1031. shift 1
  1032. ;;
  1033. esac;
  1034. done;
  1035. echo "${flags[*]}";
  1036. [[ ${#flags[@]} -gt 0 ]]
  1037. }
  1038. all-flag-vars ()
  1039. {
  1040. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  1041. }
  1042. append-atomic-flags ()
  1043. {
  1044. local code;
  1045. read -r -d '' code <<-EOF
  1046. int main(void)
  1047. {
  1048. return 0;
  1049. }
  1050. EOF
  1051.  
  1052. test-compile "c+ld" "${code}" || return;
  1053. local bytesizes;
  1054. [[ "${#}" == "0" ]] && bytesizes=("1" "2" "4" "8") || bytesizes="${@}";
  1055. for bytesize in ${bytesizes[@]};
  1056. do
  1057. read -r -d '' code <<-EOF
  1058. #include <stdint.h>
  1059. int main(void)
  1060. {
  1061. uint$((${bytesize} * 8))_t a = 0;
  1062. __atomic_add_fetch(&a, 3, __ATOMIC_RELAXED);
  1063. __atomic_compare_exchange_n(&a, &a, 2, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  1064. return 0;
  1065. }
  1066. EOF
  1067.  
  1068. test-compile "c+ld" "${code}" && continue
  1069. test-flags-CCLD "-latomic" &> /dev/null || die "-latomic is required but not supported by $(tc-getCC)";
  1070. append-libs "-latomic";
  1071. test-compile "c+ld" "${code}" || die "libatomic does not include an implementation of ${bytesize}-byte atomics for this toolchain";
  1072. return;
  1073. done
  1074. }
  1075. append-cflags ()
  1076. {
  1077. [[ $# -eq 0 ]] && return 0;
  1078. export CFLAGS+=" $*";
  1079. return 0
  1080. }
  1081. append-cppflags ()
  1082. {
  1083. [[ $# -eq 0 ]] && return 0;
  1084. export CPPFLAGS+=" $*";
  1085. return 0
  1086. }
  1087. append-cxxflags ()
  1088. {
  1089. [[ $# -eq 0 ]] && return 0;
  1090. export CXXFLAGS+=" $*";
  1091. return 0
  1092. }
  1093. append-fflags ()
  1094. {
  1095. [[ $# -eq 0 ]] && return 0;
  1096. export FFLAGS+=" $*";
  1097. export FCFLAGS+=" $*";
  1098. return 0
  1099. }
  1100. append-flags ()
  1101. {
  1102. [[ $# -eq 0 ]] && return 0;
  1103. case " $* " in
  1104. *' '-[DIU]*)
  1105. eqawarn 'Please use append-cppflags for preprocessor flags'
  1106. ;;
  1107. *' '-L* | *' '-Wl,*)
  1108. eqawarn 'Please use append-ldflags for linker flags'
  1109. ;;
  1110. esac;
  1111. append-cflags "$@";
  1112. append-cxxflags "$@";
  1113. append-fflags "$@";
  1114. return 0
  1115. }
  1116. append-ldflags ()
  1117. {
  1118. [[ $# -eq 0 ]] && return 0;
  1119. local flag;
  1120. for flag in "$@";
  1121. do
  1122. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1123. done;
  1124. export LDFLAGS="${LDFLAGS} $*";
  1125. return 0
  1126. }
  1127. append-lfs-flags ()
  1128. {
  1129. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1130. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1131. }
  1132. append-libs ()
  1133. {
  1134. [[ $# -eq 0 ]] && return 0;
  1135. local flag;
  1136. for flag in "$@";
  1137. do
  1138. if [[ -z "${flag// }" ]]; then
  1139. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1140. continue;
  1141. fi;
  1142. case $flag in
  1143. -[lL]*)
  1144. export LIBS="${LIBS} ${flag}"
  1145. ;;
  1146. -*)
  1147. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1148. export LIBS="${LIBS} ${flag}"
  1149. ;;
  1150. *)
  1151. export LIBS="${LIBS} -l${flag}"
  1152. ;;
  1153. esac;
  1154. done;
  1155. return 0
  1156. }
  1157. build_sphinx ()
  1158. {
  1159. debug-print-function ${FUNCNAME} "${@}";
  1160. [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes 1 arg: <directory>";
  1161. local dir=${1};
  1162. sed -i -e 's:^intersphinx_mapping:disabled_&:' "${dir}"/conf.py || die;
  1163. local command=("${EPYTHON}" -m sphinx.cmd.build);
  1164. if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2> /dev/null; then
  1165. command=(sphinx-build);
  1166. fi;
  1167. command+=(-b html -d "${dir}"/_build/doctrees "${dir}" "${dir}"/_build/html);
  1168. echo "${command[@]}" 1>&2;
  1169. "${command[@]}" || die;
  1170. HTML_DOCS+=("${dir}/_build/html/.")
  1171. }
  1172. clang-fullversion ()
  1173. {
  1174. _clang_fullversion '$1.$2.$3' "$@"
  1175. }
  1176. clang-major-version ()
  1177. {
  1178. _clang_fullversion '$1' "$@"
  1179. }
  1180. clang-micro-version ()
  1181. {
  1182. _clang_fullversion '$3' "$@"
  1183. }
  1184. clang-minor-version ()
  1185. {
  1186. _clang_fullversion '$2' "$@"
  1187. }
  1188. clang-version ()
  1189. {
  1190. _clang_fullversion '$1.$2' "$@"
  1191. }
  1192. create_user-config.jam ()
  1193. {
  1194. local user_config_jam="${BUILD_DIR}"/user-config.jam;
  1195. if [[ -s ${user_config_jam} ]]; then
  1196. einfo "${user_config_jam} already exists, skipping configuration";
  1197. return;
  1198. else
  1199. einfo "Creating configuration in ${user_config_jam}";
  1200. fi;
  1201. local compiler compiler_version compiler_executable="$(tc-getCXX)";
  1202. compiler="gcc";
  1203. compiler_version="$(gcc-version)";
  1204. if use mpi; then
  1205. local mpi_configuration="using mpi ;";
  1206. fi;
  1207. cat > "${user_config_jam}" <<-__EOF__ ||
  1208. using ${compiler} : ${compiler_version} : ${compiler_executable} : <cflags>"${CPPFLAGS} ${CFLAGS}" <cxxflags>"${CPPFLAGS} ${CXXFLAGS}" <linkflags>"${LDFLAGS}" <archiver>"$(tc-getAR)" <ranlib>"$(tc-getRANLIB)" ;
  1209. ${mpi_configuration}
  1210. __EOF__
  1211. die
  1212. if multilib_native_use python; then
  1213. function append_to_user_config ()
  1214. {
  1215. local py_config;
  1216. if tc-is-cross-compiler; then
  1217. py_config="using python : ${EPYTHON#python} : : ${ESYSROOT}/usr/include/${EPYTHON} : ${ESYSROOT}/usr/$(get_libdir) ;";
  1218. else
  1219. py_config="using python : ${EPYTHON#python} : ${PYTHON} : $(python_get_includedir) ;";
  1220. fi;
  1221. echo "${py_config}" >> "${user_config_jam}" || die
  1222. };
  1223. python_foreach_impl append_to_user_config;
  1224. fi;
  1225. if multilib_native_use python && use numpy; then
  1226. einfo "Enabling support for NumPy extensions in Boost.Python";
  1227. else
  1228. einfo "Disabling support for NumPy extensions in Boost.Python";
  1229. sed -e 's/\[ unless \[ python\.numpy \] : <build>no \]/<build>no/g' -i "${BUILD_DIR}"/libs/python/build/Jamfile || die;
  1230. fi
  1231. }
  1232. eapply ()
  1233. {
  1234. local failed patch_cmd=patch;
  1235. local -x LC_COLLATE=POSIX;
  1236. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1237. function _eapply_patch ()
  1238. {
  1239. local f=${1};
  1240. local prefix=${2};
  1241. ebegin "${prefix:-Applying }${f##*/}";
  1242. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  1243. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  1244. all_opts+=(-s -F0);
  1245. fi;
  1246. ${patch_cmd} "${all_opts[@]}" < "${f}";
  1247. failed=${?};
  1248. if ! eend "${failed}"; then
  1249. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1250. fi
  1251. };
  1252. local patch_options=() files=();
  1253. local i found_doublehyphen;
  1254. for ((i = 1; i <= ${#@}; ++i ))
  1255. do
  1256. if [[ ${@:i:1} == -- ]]; then
  1257. patch_options=("${@:1:i-1}");
  1258. files=("${@:i+1}");
  1259. found_doublehyphen=1;
  1260. break;
  1261. fi;
  1262. done;
  1263. if [[ -z ${found_doublehyphen} ]]; then
  1264. for ((i = 1; i <= ${#@}; ++i ))
  1265. do
  1266. if [[ ${@:i:1} != -* ]]; then
  1267. patch_options=("${@:1:i-1}");
  1268. files=("${@:i}");
  1269. break;
  1270. fi;
  1271. done;
  1272. for i in "${files[@]}";
  1273. do
  1274. if [[ ${i} == -* ]]; then
  1275. die "eapply: all options must be passed before non-options";
  1276. fi;
  1277. done;
  1278. fi;
  1279. if [[ ${#files[@]} -eq 0 ]]; then
  1280. die "eapply: no files specified";
  1281. fi;
  1282. local f;
  1283. for f in "${files[@]}";
  1284. do
  1285. if [[ -d ${f} ]]; then
  1286. function _eapply_get_files ()
  1287. {
  1288. local LC_ALL=POSIX;
  1289. local prev_shopt=$(shopt -p nullglob);
  1290. shopt -s nullglob;
  1291. local f;
  1292. for f in "${1}"/*;
  1293. do
  1294. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1295. files+=("${f}");
  1296. fi;
  1297. done;
  1298. ${prev_shopt}
  1299. };
  1300. local files=();
  1301. _eapply_get_files "${f}";
  1302. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1303. einfo "Applying patches from ${f} ...";
  1304. local f2;
  1305. for f2 in "${files[@]}";
  1306. do
  1307. _eapply_patch "${f2}" ' ';
  1308. [[ ${failed} -ne 0 ]] && return "${failed}";
  1309. done;
  1310. else
  1311. _eapply_patch "${f}";
  1312. [[ ${failed} -ne 0 ]] && return "${failed}";
  1313. fi;
  1314. done;
  1315. return 0
  1316. }
  1317. eapply_user ()
  1318. {
  1319. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1320. local tagfile=${T}/.portage_user_patches_applied;
  1321. [[ -f ${tagfile} ]] && return;
  1322. >> "${tagfile}";
  1323. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1324. local columns=${COLUMNS:-0};
  1325. [[ ${columns} == 0 ]] && columns=$(set -- $( ( stty size < /dev/tty ) 2> /dev/null || echo 24 80); echo $2);
  1326. (( columns > 0 )) || (( columns = 80 ));
  1327. local applied d f;
  1328. local -A _eapply_user_patches;
  1329. local prev_shopt=$(shopt -p nullglob);
  1330. shopt -s nullglob;
  1331. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1332. do
  1333. for f in "${d}"/*;
  1334. do
  1335. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1336. _eapply_user_patches[${f##*/}]=${f};
  1337. fi;
  1338. done;
  1339. done;
  1340. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1341. while read -r -d '' f; do
  1342. f=${_eapply_user_patches[${f}]};
  1343. if [[ -s ${f} ]]; then
  1344. if [[ -z ${applied} ]]; then
  1345. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++))
  1346. do
  1347. echo -n =;
  1348. done)${PORTAGE_COLOR_NORMAL}";
  1349. einfo "Applying user patches from ${basedir} ...";
  1350. fi;
  1351. eapply "${f}";
  1352. applied=1;
  1353. fi;
  1354. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" | LC_ALL=C sort -z);
  1355. fi;
  1356. ${prev_shopt};
  1357. if [[ -n ${applied} ]]; then
  1358. einfo "User patches applied.";
  1359. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++))
  1360. do
  1361. echo -n =;
  1362. done)${PORTAGE_COLOR_NORMAL}";
  1363. fi
  1364. }
  1365. econf_build ()
  1366. {
  1367. local CBUILD=${CBUILD:-${CHOST}};
  1368. function econf_env ()
  1369. {
  1370. CHOST=${CBUILD} econf "$@"
  1371. };
  1372. tc-env_build econf_env "$@"
  1373. }
  1374. einstalldocs ()
  1375. {
  1376. ( if [[ $(declare -p DOCS 2> /dev/null) != *=* ]]; then
  1377. local d;
  1378. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1379. do
  1380. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1381. done;
  1382. else
  1383. if ___is_indexed_array_var DOCS; then
  1384. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1385. else
  1386. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1387. fi;
  1388. fi );
  1389. ( if ___is_indexed_array_var HTML_DOCS; then
  1390. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1391. else
  1392. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1393. fi )
  1394. }
  1395. ejam ()
  1396. {
  1397. create_user-config.jam;
  1398. local b2_opts=("--user-config=${BUILD_DIR}/user-config.jam");
  1399. if multilib_native_use python; then
  1400. function append_to_b2_opts ()
  1401. {
  1402. b2_opts+=(python="${EPYTHON#python}")
  1403. };
  1404. python_foreach_impl append_to_b2_opts;
  1405. else
  1406. b2_opts+=(--without-python);
  1407. fi;
  1408. b2_opts+=("$@");
  1409. echo b2 "${b2_opts[@]}" 1>&2;
  1410. b2 "${b2_opts[@]}"
  1411. }
  1412. epytest ()
  1413. {
  1414. debug-print-function ${FUNCNAME} "${@}";
  1415. _python_check_EPYTHON;
  1416. _python_check_occluded_packages;
  1417. local color=yes;
  1418. [[ -n ${NO_COLOR} ]] && color=no;
  1419. local args=(-vv -ra -l -Wdefault "--color=${color}" -o console_output_style=count -o tmp_path_retention_count=0 -o tmp_path_retention_policy=failed);
  1420. if [[ ! -n ${PYTEST_DISABLE_PLUGIN_AUTOLOAD} ]]; then
  1421. args+=(-p no:cov -p no:flake8 -p no:flakes -p no:pylint -p no:markdown -p no:sugar -p no:xvfb -p no:pytest-describe -p no:plus -p no:tavern -p no:salt-factories);
  1422. fi;
  1423. if [[ -n ${EPYTEST_TIMEOUT} ]]; then
  1424. if [[ ${PYTEST_PLUGINS} != *pytest_timeout* ]]; then
  1425. args+=(-p timeout);
  1426. fi;
  1427. args+=("--timeout=${EPYTEST_TIMEOUT}");
  1428. fi;
  1429. if [[ -n ${EPYTEST_XDIST} ]]; then
  1430. local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)};
  1431. if [[ ${jobs} -gt 1 ]]; then
  1432. if [[ ${PYTEST_PLUGINS} != *xdist.plugin* ]]; then
  1433. args+=(-p xdist);
  1434. fi;
  1435. args+=(-n "${jobs}" --dist=worksteal);
  1436. fi;
  1437. fi;
  1438. local x;
  1439. for x in "${EPYTEST_DESELECT[@]}";
  1440. do
  1441. args+=(--deselect "${x}");
  1442. done;
  1443. for x in "${EPYTEST_IGNORE[@]}";
  1444. do
  1445. args+=(--ignore "${x}");
  1446. done;
  1447. set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}";
  1448. echo "${@}" 1>&2;
  1449. "${@}" || die -n "pytest failed with ${EPYTHON}";
  1450. local ret=${?};
  1451. rm -rf .hypothesis .pytest_cache || die;
  1452. if [[ -n ${BUILD_DIR} && -d ${BUILD_DIR} ]]; then
  1453. find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die;
  1454. fi;
  1455. return ${ret}
  1456. }
  1457. eunittest ()
  1458. {
  1459. debug-print-function ${FUNCNAME} "${@}";
  1460. _python_check_EPYTHON;
  1461. _python_check_occluded_packages;
  1462. local runner=unittest;
  1463. if _python_impl_matches "${EPYTHON}" 3.{9..11}; then
  1464. runner=unittest_or_fail;
  1465. fi;
  1466. set -- "${EPYTHON}" -m "${runner}" discover -v "${@}";
  1467. echo "${@}" 1>&2;
  1468. "${@}" || die -n "Tests failed with ${EPYTHON}";
  1469. return ${?}
  1470. }
  1471. filter-flags ()
  1472. {
  1473. _filter-hardened "$@";
  1474. local v;
  1475. for v in $(all-flag-vars);
  1476. do
  1477. _filter-var ${v} "$@";
  1478. done;
  1479. return 0
  1480. }
  1481. filter-ldflags ()
  1482. {
  1483. _filter-var LDFLAGS "$@";
  1484. return 0
  1485. }
  1486. filter-lfs-flags ()
  1487. {
  1488. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1489. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64
  1490. }
  1491. filter-lto ()
  1492. {
  1493. [[ $# -ne 0 ]] && die "filter-lto takes no arguments";
  1494. filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*'
  1495. }
  1496. filter-mfpmath ()
  1497. {
  1498. local orig_mfpmath new_math prune_math;
  1499. orig_mfpmath=$(get-flag -mfpmath);
  1500. new_math=$(get-flag mfpmath);
  1501. new_math=${new_math/both/387,sse};
  1502. new_math=" ${new_math//[,+]/ } ";
  1503. prune_math="";
  1504. for prune_math in "$@";
  1505. do
  1506. new_math=${new_math/ ${prune_math} / };
  1507. done;
  1508. new_math=$(echo ${new_math});
  1509. new_math=${new_math// /,};
  1510. if [[ -z ${new_math} ]]; then
  1511. filter-flags ${orig_mfpmath};
  1512. else
  1513. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1514. fi;
  1515. return 0
  1516. }
  1517. gcc-fullversion ()
  1518. {
  1519. _gcc_fullversion '$1.$2.$3' "$@"
  1520. }
  1521. gcc-major-version ()
  1522. {
  1523. _gcc_fullversion '$1' "$@"
  1524. }
  1525. gcc-micro-version ()
  1526. {
  1527. _gcc_fullversion '$3' "$@"
  1528. }
  1529. gcc-minor-version ()
  1530. {
  1531. _gcc_fullversion '$2' "$@"
  1532. }
  1533. gcc-specs-directive ()
  1534. {
  1535. local directive subdname subdirective;
  1536. directive="$(_gcc-specs-directive_raw $1)";
  1537. while [[ ${directive} == *%\(*\)* ]]; do
  1538. subdname=${directive/*%\(};
  1539. subdname=${subdname/\)*};
  1540. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1541. directive="${directive//\%(${subdname})/${subdirective}}";
  1542. done;
  1543. echo "${directive}";
  1544. return 0
  1545. }
  1546. gcc-specs-nostrict ()
  1547. {
  1548. local directive;
  1549. directive=$(gcc-specs-directive cc1);
  1550. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1551. }
  1552. gcc-specs-now ()
  1553. {
  1554. local directive;
  1555. directive=$(gcc-specs-directive link_command);
  1556. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1557. }
  1558. gcc-specs-pie ()
  1559. {
  1560. local directive;
  1561. directive=$(gcc-specs-directive cc1);
  1562. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1563. }
  1564. gcc-specs-relro ()
  1565. {
  1566. local directive;
  1567. directive=$(gcc-specs-directive link_command);
  1568. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1569. }
  1570. gcc-specs-ssp ()
  1571. {
  1572. local directive;
  1573. directive=$(gcc-specs-directive cc1);
  1574. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1575. }
  1576. gcc-specs-ssp-to-all ()
  1577. {
  1578. local directive;
  1579. directive=$(gcc-specs-directive cc1);
  1580. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1581. }
  1582. gcc-specs-stack-check ()
  1583. {
  1584. local directive;
  1585. directive=$(gcc-specs-directive cc1);
  1586. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1587. }
  1588. gcc-version ()
  1589. {
  1590. _gcc_fullversion '$1.$2' "$@"
  1591. }
  1592. gen_usr_ldscript ()
  1593. {
  1594. ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  1595. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1596. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1597. tc-is-static-only && return;
  1598. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1599. multilib_is_native_abi || return 0;
  1600. fi;
  1601. case ${CTARGET:-${CHOST}} in
  1602. *-darwin*)
  1603.  
  1604. ;;
  1605. *-android*)
  1606. return 0
  1607. ;;
  1608. *linux*)
  1609. use prefix && return 0
  1610. ;;
  1611. *)
  1612. return 0
  1613. ;;
  1614. esac;
  1615. dodir /usr/${libdir};
  1616. if [[ $1 == "-a" ]]; then
  1617. auto=true;
  1618. shift;
  1619. dodir /${libdir};
  1620. fi;
  1621. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1622. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1623. local d="${T}/bfd-linker";
  1624. mkdir -p "${d}";
  1625. ln -sf $(type -P ${CHOST}-ld.bfd) "${d}"/ld;
  1626. flags+=(-B"${d}");
  1627. fi;
  1628. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1629. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1630. for lib in "$@";
  1631. do
  1632. local tlib;
  1633. if ${auto}; then
  1634. lib="lib${lib}${suffix}";
  1635. else
  1636. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1637. fi;
  1638. case ${CTARGET:-${CHOST}} in
  1639. *-darwin*)
  1640. if ${auto}; then
  1641. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1642. else
  1643. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1644. fi;
  1645. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1646. tlib=${tlib##*/};
  1647. if ${auto}; then
  1648. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1649. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1650. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1651. fi;
  1652. rm -f "${ED}"/${libdir}/${lib};
  1653. fi;
  1654. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1655. chmod u+w "${ED}${libdir}/${tlib}";
  1656. local nowrite=yes;
  1657. fi;
  1658. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1659. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1660. pushd "${ED}/usr/${libdir}" > /dev/null;
  1661. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1662. popd > /dev/null
  1663. ;;
  1664. *)
  1665. if ${auto}; then
  1666. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1667. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1668. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1669. if [[ ${tlib} != ${lib}* ]]; then
  1670. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1671. fi;
  1672. rm -f "${ED}"/${libdir}/${lib};
  1673. else
  1674. tlib=${lib};
  1675. fi;
  1676. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1677. /* GNU ld script
  1678. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1679. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1680. run into linking problems. This "fake" dynamic lib is a linker script that
  1681. redirects the linker to the real lib. And yes, this works in the cross-
  1682. compiling scenario as the sysroot-ed linker will prepend the real path.
  1683.  
  1684. See bug https://bugs.gentoo.org/4411 for more info.
  1685. */
  1686. ${output_format}
  1687. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1688. END_LDSCRIPT
  1689.  
  1690. ;;
  1691. esac
  1692. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1693. done
  1694. }
  1695. get-flag ()
  1696. {
  1697. [[ $# -ne 1 ]] && die "usage: <flag>";
  1698. local f var findflag="$1";
  1699. for var in $(all-flag-vars);
  1700. do
  1701. for f in ${!var};
  1702. do
  1703. if [ "${f/${findflag}}" != "${f}" ]; then
  1704. printf "%s\n" "${f/-${findflag}=}";
  1705. return 0;
  1706. fi;
  1707. done;
  1708. done;
  1709. return 1
  1710. }
  1711. get_abi_CFLAGS ()
  1712. {
  1713. get_abi_var CFLAGS "$@"
  1714. }
  1715. get_abi_CHOST ()
  1716. {
  1717. get_abi_var CHOST "$@"
  1718. }
  1719. get_abi_CTARGET ()
  1720. {
  1721. get_abi_var CTARGET "$@"
  1722. }
  1723. get_abi_FAKE_TARGETS ()
  1724. {
  1725. get_abi_var FAKE_TARGETS "$@"
  1726. }
  1727. get_abi_LDFLAGS ()
  1728. {
  1729. get_abi_var LDFLAGS "$@"
  1730. }
  1731. get_abi_LIBDIR ()
  1732. {
  1733. get_abi_var LIBDIR "$@"
  1734. }
  1735. get_abi_var ()
  1736. {
  1737. local flag=$1;
  1738. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1739. local var="${flag}_${abi}";
  1740. echo ${!var}
  1741. }
  1742. get_all_abis ()
  1743. {
  1744. local x order="" mvar dvar;
  1745. mvar="MULTILIB_ABIS";
  1746. dvar="DEFAULT_ABI";
  1747. if [[ -n $1 ]]; then
  1748. mvar="$1_${mvar}";
  1749. dvar="$1_${dvar}";
  1750. fi;
  1751. if [[ -z ${!mvar} ]]; then
  1752. echo "default";
  1753. return 0;
  1754. fi;
  1755. for x in ${!mvar};
  1756. do
  1757. if [[ ${x} != ${!dvar} ]]; then
  1758. order="${order:+${order} }${x}";
  1759. fi;
  1760. done;
  1761. order="${order:+${order} }${!dvar}";
  1762. echo ${order};
  1763. return 0
  1764. }
  1765. get_all_libdirs ()
  1766. {
  1767. local libdirs abi;
  1768. for abi in ${MULTILIB_ABIS};
  1769. do
  1770. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1771. done;
  1772. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1773. echo "${libdirs}"
  1774. }
  1775. get_exeext ()
  1776. {
  1777. case ${CHOST} in
  1778. mingw* | *-mingw*)
  1779. echo ".exe"
  1780. ;;
  1781. esac
  1782. }
  1783. get_install_abis ()
  1784. {
  1785. local x order="";
  1786. if [[ -z ${MULTILIB_ABIS} ]]; then
  1787. echo "default";
  1788. return 0;
  1789. fi;
  1790. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1791. for x in ${MULTILIB_ABIS};
  1792. do
  1793. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1794. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1795. fi;
  1796. done;
  1797. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1798. if [[ -n ${ABI_ALLOW} ]]; then
  1799. local ordera="";
  1800. for x in ${order};
  1801. do
  1802. if has ${x} ${ABI_ALLOW}; then
  1803. ordera="${ordera} ${x}";
  1804. fi;
  1805. done;
  1806. order=${ordera};
  1807. fi;
  1808. else
  1809. order=${DEFAULT_ABI};
  1810. fi;
  1811. if [[ -z ${order} ]]; then
  1812. 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.";
  1813. fi;
  1814. echo ${order};
  1815. return 0
  1816. }
  1817. get_libdir ()
  1818. {
  1819. local libdir_var="LIBDIR_${ABI}";
  1820. local libdir="lib";
  1821. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1822. echo "${libdir}"
  1823. }
  1824. get_libname ()
  1825. {
  1826. local libname;
  1827. local ver=$1;
  1828. case ${CHOST} in
  1829. mingw* | *-mingw*)
  1830. libname="dll"
  1831. ;;
  1832. *-darwin*)
  1833. libname="dylib"
  1834. ;;
  1835. *)
  1836. libname="so"
  1837. ;;
  1838. esac;
  1839. if [[ -z $* ]]; then
  1840. echo ".${libname}";
  1841. else
  1842. for ver in "$@";
  1843. do
  1844. case ${CHOST} in
  1845. *-darwin*)
  1846. echo ".${ver}.${libname}"
  1847. ;;
  1848. *)
  1849. echo ".${libname}.${ver}"
  1850. ;;
  1851. esac;
  1852. done;
  1853. fi
  1854. }
  1855. get_makeopts_jobs ()
  1856. {
  1857. makeopts_jobs "$(_get_all_makeopts)" "${1:-1}"
  1858. }
  1859. get_makeopts_loadavg ()
  1860. {
  1861. makeopts_loadavg "$(_get_all_makeopts)" "${1:-999}"
  1862. }
  1863. get_modname ()
  1864. {
  1865. local modname;
  1866. local ver=$1;
  1867. case ${CHOST} in
  1868. *-darwin*)
  1869. modname="bundle"
  1870. ;;
  1871. *)
  1872. modname="so"
  1873. ;;
  1874. esac;
  1875. echo ".${modname}"
  1876. }
  1877. get_nproc ()
  1878. {
  1879. local nproc;
  1880. if type -P nproc &> /dev/null; then
  1881. nproc=$(nproc);
  1882. fi;
  1883. if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  1884. nproc=$(sysctl -n hw.ncpu 2> /dev/null);
  1885. fi;
  1886. if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  1887. nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2> /dev/null);
  1888. fi;
  1889. if [[ -n ${nproc} ]]; then
  1890. echo "${nproc}";
  1891. else
  1892. echo "${1:-1}";
  1893. fi
  1894. }
  1895. has_multilib_profile ()
  1896. {
  1897. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1898. }
  1899. in_iuse ()
  1900. {
  1901. local use=${1};
  1902. if [[ -z "${use}" ]]; then
  1903. echo "!!! in_iuse() called without a parameter." 1>&2;
  1904. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1905. die "in_iuse() called without a parameter";
  1906. fi;
  1907. local liuse=(${IUSE_EFFECTIVE});
  1908. has "${use}" "${liuse[@]#[+-]}"
  1909. }
  1910. is-flag ()
  1911. {
  1912. is-flagq "$@" && echo true
  1913. }
  1914. is-flagq ()
  1915. {
  1916. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1917. local var;
  1918. for var in $(all-flag-vars);
  1919. do
  1920. _is_flagq ${var} "$1" && return 0;
  1921. done;
  1922. return 1
  1923. }
  1924. is-ldflag ()
  1925. {
  1926. is-ldflagq "$@" && echo true
  1927. }
  1928. is-ldflagq ()
  1929. {
  1930. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1931. _is_flagq LDFLAGS $1
  1932. }
  1933. is_final_abi ()
  1934. {
  1935. has_multilib_profile || return 0;
  1936. set -- $(get_install_abis);
  1937. local LAST_ABI=$#;
  1938. [[ ${!LAST_ABI} == ${ABI} ]]
  1939. }
  1940. makeopts_jobs ()
  1941. {
  1942. [[ $# -eq 0 ]] && set -- "$(_get_all_makeopts)";
  1943. local jobs=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p");
  1944. echo ${jobs:-1}
  1945. }
  1946. makeopts_loadavg ()
  1947. {
  1948. [[ $# -eq 0 ]] && set -- "$(_get_all_makeopts)";
  1949. local lavg=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+(\.[0-9]+)?)[[:space:]].*:\3:p' -e "s:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:${2:-999}:p");
  1950. echo ${lavg:-${2:-999}}
  1951. }
  1952. multibuild_copy_sources ()
  1953. {
  1954. debug-print-function ${FUNCNAME} "${@}";
  1955. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  1956. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  1957. function _multibuild_create_source_copy ()
  1958. {
  1959. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  1960. cp -p -R "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  1961. };
  1962. multibuild_foreach_variant _multibuild_create_source_copy
  1963. }
  1964. multibuild_for_best_variant ()
  1965. {
  1966. debug-print-function ${FUNCNAME} "${@}";
  1967. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1968. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[-1]}");
  1969. multibuild_foreach_variant "${@}"
  1970. }
  1971. multibuild_foreach_variant ()
  1972. {
  1973. debug-print-function ${FUNCNAME} "${@}";
  1974. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1975. local bdir=${BUILD_DIR:-${S}};
  1976. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  1977. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  1978. local ret=0 lret=0 v;
  1979. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  1980. for v in "${MULTIBUILD_VARIANTS[@]}";
  1981. do
  1982. local MULTIBUILD_VARIANT=${v};
  1983. local MULTIBUILD_ID=${prev_id}${v};
  1984. local BUILD_DIR=${bdir%%/}-${v};
  1985. function _multibuild_run ()
  1986. {
  1987. local i=1;
  1988. while [[ ${!i} == _* ]]; do
  1989. (( i += 1 ));
  1990. done;
  1991. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  1992. "${@}"
  1993. };
  1994. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  1995. lret=${?};
  1996. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  1997. done;
  1998. return ${ret}
  1999. }
  2000. multibuild_merge_root ()
  2001. {
  2002. debug-print-function ${FUNCNAME} "${@}";
  2003. local src=${1};
  2004. local dest=${2};
  2005. cp -a "${src}"/. "${dest}"/ || die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed";
  2006. rm -rf "${src}" || die
  2007. }
  2008. multilib-minimal_src_compile ()
  2009. {
  2010. debug-print-function ${FUNCNAME} "$@";
  2011. function multilib-minimal_abi_src_compile ()
  2012. {
  2013. debug-print-function ${FUNCNAME} "$@";
  2014. pushd "${BUILD_DIR}" > /dev/null || die;
  2015. if declare -f multilib_src_compile > /dev/null; then
  2016. multilib_src_compile;
  2017. else
  2018. default_src_compile;
  2019. fi;
  2020. popd > /dev/null || die
  2021. };
  2022. multilib_foreach_abi multilib-minimal_abi_src_compile
  2023. }
  2024. multilib-minimal_src_configure ()
  2025. {
  2026. debug-print-function ${FUNCNAME} "$@";
  2027. function multilib-minimal_abi_src_configure ()
  2028. {
  2029. debug-print-function ${FUNCNAME} "$@";
  2030. mkdir -p "${BUILD_DIR}" || die;
  2031. pushd "${BUILD_DIR}" > /dev/null || die;
  2032. if declare -f multilib_src_configure > /dev/null; then
  2033. multilib_src_configure;
  2034. else
  2035. default_src_configure;
  2036. fi;
  2037. popd > /dev/null || die
  2038. };
  2039. multilib_foreach_abi multilib-minimal_abi_src_configure
  2040. }
  2041. multilib-minimal_src_install ()
  2042. {
  2043. debug-print-function ${FUNCNAME} "$@";
  2044. function multilib-minimal_abi_src_install ()
  2045. {
  2046. debug-print-function ${FUNCNAME} "$@";
  2047. pushd "${BUILD_DIR}" > /dev/null || die;
  2048. if declare -f multilib_src_install > /dev/null; then
  2049. multilib_src_install;
  2050. else
  2051. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  2052. emake DESTDIR="${D}" install;
  2053. fi;
  2054. fi;
  2055. multilib_prepare_wrappers;
  2056. multilib_check_headers;
  2057. popd > /dev/null || die
  2058. };
  2059. multilib_foreach_abi multilib-minimal_abi_src_install;
  2060. multilib_install_wrappers;
  2061. if declare -f multilib_src_install_all > /dev/null; then
  2062. multilib_src_install_all;
  2063. else
  2064. einstalldocs;
  2065. fi
  2066. }
  2067. multilib-minimal_src_test ()
  2068. {
  2069. debug-print-function ${FUNCNAME} "$@";
  2070. function multilib-minimal_abi_src_test ()
  2071. {
  2072. debug-print-function ${FUNCNAME} "$@";
  2073. pushd "${BUILD_DIR}" > /dev/null || die;
  2074. if declare -f multilib_src_test > /dev/null; then
  2075. multilib_src_test;
  2076. else
  2077. default_src_test;
  2078. fi;
  2079. popd > /dev/null || die
  2080. };
  2081. multilib_foreach_abi multilib-minimal_abi_src_test
  2082. }
  2083. multilib_check_headers ()
  2084. {
  2085. function _multilib_header_cksum ()
  2086. {
  2087. set -o pipefail;
  2088. if [[ -d ${ED%/}/usr/include ]]; then
  2089. find "${ED%/}"/usr/include -type f -exec cksum {} + | sort -k2;
  2090. fi
  2091. };
  2092. local cksum cksum_prev;
  2093. local cksum_file=${T}/.multilib_header_cksum;
  2094. cksum=$(_multilib_header_cksum) || die;
  2095. unset -f _multilib_header_cksum;
  2096. if [[ -f ${cksum_file} ]]; then
  2097. cksum_prev=$(< "${cksum_file}") || die;
  2098. if [[ ${cksum} != ${cksum_prev} ]]; then
  2099. echo "${cksum}" > "${cksum_file}.new" || die;
  2100. eerror "Header files have changed between ABIs.";
  2101. if type -p diff &> /dev/null; then
  2102. eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  2103. else
  2104. eerror "Old checksums in: ${cksum_file}";
  2105. eerror "New checksums in: ${cksum_file}.new";
  2106. fi;
  2107. die "Header checksum mismatch, aborting.";
  2108. fi;
  2109. else
  2110. echo "${cksum}" > "${cksum_file}" || die;
  2111. fi
  2112. }
  2113. multilib_copy_sources ()
  2114. {
  2115. debug-print-function ${FUNCNAME} "$@";
  2116. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2117. multibuild_copy_sources
  2118. }
  2119. multilib_env ()
  2120. {
  2121. local CTARGET=${1:-${CTARGET}};
  2122. local cpu=${CTARGET%%*-};
  2123. if [[ ${CTARGET} = *-musl* ]]; then
  2124. : "${MULTILIB_ABIS=default}";
  2125. : "${DEFAULT_ABI=default}";
  2126. export MULTILIB_ABIS DEFAULT_ABI;
  2127. return;
  2128. fi;
  2129. case ${cpu} in
  2130. aarch64*)
  2131. export CFLAGS_arm=${CFLAGS_arm-};
  2132. case ${cpu} in
  2133. aarch64*be)
  2134. export CHOST_arm="armv8b-${CTARGET#*-}"
  2135. ;;
  2136. *)
  2137. export CHOST_arm="armv8l-${CTARGET#*-}"
  2138. ;;
  2139. esac;
  2140. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2141. export CTARGET_arm=${CHOST_arm};
  2142. export LIBDIR_arm="lib";
  2143. export CFLAGS_arm64=${CFLAGS_arm64-};
  2144. export CHOST_arm64=${CTARGET};
  2145. export CTARGET_arm64=${CHOST_arm64};
  2146. export LIBDIR_arm64="lib64";
  2147. : "${MULTILIB_ABIS=arm64}";
  2148. : "${DEFAULT_ABI=arm64}"
  2149. ;;
  2150. x86_64*)
  2151. export CFLAGS_x86=${CFLAGS_x86--m32};
  2152. export CHOST_x86=${CTARGET/x86_64/i686};
  2153. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2154. export CTARGET_x86=${CHOST_x86};
  2155. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2156. export LIBDIR_x86="lib32";
  2157. else
  2158. export LIBDIR_x86="lib";
  2159. fi;
  2160. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2161. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2162. export CTARGET_amd64=${CHOST_amd64};
  2163. export LIBDIR_amd64="lib64";
  2164. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2165. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2166. export CTARGET_x32=${CHOST_x32};
  2167. export LIBDIR_x32="libx32";
  2168. case ${CTARGET} in
  2169. *-gnux32)
  2170. : "${MULTILIB_ABIS=x32 amd64 x86}";
  2171. : "${DEFAULT_ABI=x32}"
  2172. ;;
  2173. *)
  2174. : "${MULTILIB_ABIS=amd64 x86}";
  2175. : "${DEFAULT_ABI=amd64}"
  2176. ;;
  2177. esac
  2178. ;;
  2179. loongarch64*)
  2180. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  2181. export CHOST_lp64d=${CTARGET};
  2182. export CTARGET_lp64d=${CTARGET};
  2183. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64};
  2184. : "${MULTILIB_ABIS=lp64d}";
  2185. : "${DEFAULT_ABI=lp64d}"
  2186. ;;
  2187. mips64* | mipsisa64*)
  2188. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2189. export CHOST_o32=${CTARGET/mips64/mips};
  2190. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2191. export CTARGET_o32=${CHOST_o32};
  2192. export LIBDIR_o32="lib";
  2193. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2194. export CHOST_n32=${CTARGET};
  2195. export CTARGET_n32=${CHOST_n32};
  2196. export LIBDIR_n32="lib32";
  2197. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2198. export CHOST_n64=${CTARGET};
  2199. export CTARGET_n64=${CHOST_n64};
  2200. export LIBDIR_n64="lib64";
  2201. : "${MULTILIB_ABIS=n64 n32 o32}";
  2202. : "${DEFAULT_ABI=n32}"
  2203. ;;
  2204. powerpc64*)
  2205. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2206. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2207. export CTARGET_ppc=${CHOST_ppc};
  2208. export LIBDIR_ppc="lib";
  2209. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2210. export CHOST_ppc64=${CTARGET};
  2211. export CTARGET_ppc64=${CHOST_ppc64};
  2212. export LIBDIR_ppc64="lib64";
  2213. : "${MULTILIB_ABIS=ppc64 ppc}";
  2214. : "${DEFAULT_ABI=ppc64}"
  2215. ;;
  2216. riscv64*)
  2217. : "${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32}";
  2218. : "${DEFAULT_ABI=lp64d}";
  2219. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  2220. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  2221. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib64};
  2222. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64gc};
  2223. export CHOST_lp64d=${CTARGET};
  2224. export CTARGET_lp64d=${CTARGET};
  2225. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64/lp64d};
  2226. export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac};
  2227. export CHOST_lp64=${CTARGET};
  2228. export CTARGET_lp64=${CTARGET};
  2229. export LIBDIR_lp64=${LIBDIR_lp64-lib64/lp64};
  2230. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  2231. export CHOST_ilp32d=${CTARGET/riscv64/riscv32};
  2232. export CTARGET_ilp32d=${CTARGET/riscv64/riscv32};
  2233. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  2234. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  2235. export CHOST_ilp32=${CTARGET/riscv64/riscv32};
  2236. export CTARGET_ilp32=${CTARGET/riscv64/riscv32};
  2237. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  2238. ;;
  2239. riscv32*)
  2240. : "${MULTILIB_ABIS=ilp32d ilp32}";
  2241. : "${DEFAULT_ABI=ilp32d}";
  2242. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  2243. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  2244. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib};
  2245. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  2246. export CHOST_ilp32d=${CTARGET};
  2247. export CTARGET_ilp32d=${CTARGET};
  2248. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  2249. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  2250. export CHOST_ilp32=${CTARGET};
  2251. export CTARGET_ilp32=${CTARGET};
  2252. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  2253. ;;
  2254. s390x*)
  2255. export CFLAGS_s390=${CFLAGS_s390--m31};
  2256. export CHOST_s390=${CTARGET/s390x/s390};
  2257. export CTARGET_s390=${CHOST_s390};
  2258. export LIBDIR_s390="lib";
  2259. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2260. export CHOST_s390x=${CTARGET};
  2261. export CTARGET_s390x=${CHOST_s390x};
  2262. export LIBDIR_s390x="lib64";
  2263. : "${MULTILIB_ABIS=s390x s390}";
  2264. : "${DEFAULT_ABI=s390x}"
  2265. ;;
  2266. sparc64*)
  2267. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2268. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2269. export CTARGET_sparc32=${CHOST_sparc32};
  2270. export LIBDIR_sparc32="lib";
  2271. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2272. export CHOST_sparc64=${CTARGET};
  2273. export CTARGET_sparc64=${CHOST_sparc64};
  2274. export LIBDIR_sparc64="lib64";
  2275. : "${MULTILIB_ABIS=sparc64 sparc32}";
  2276. : "${DEFAULT_ABI=sparc64}"
  2277. ;;
  2278. *)
  2279. : "${MULTILIB_ABIS=default}";
  2280. : "${DEFAULT_ABI=default}"
  2281. ;;
  2282. esac;
  2283. export MULTILIB_ABIS DEFAULT_ABI
  2284. }
  2285. multilib_foreach_abi ()
  2286. {
  2287. debug-print-function ${FUNCNAME} "$@";
  2288. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2289. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2290. }
  2291. multilib_get_enabled_abi_pairs ()
  2292. {
  2293. debug-print-function ${FUNCNAME} "$@";
  2294. local abis=($(get_all_abis));
  2295. local abi i found;
  2296. for abi in "${abis[@]}";
  2297. do
  2298. for i in "${_MULTILIB_FLAGS[@]}";
  2299. do
  2300. local m_abis=${i#*:} m_abi;
  2301. local m_flag=${i%:*};
  2302. for m_abi in ${m_abis//,/ };
  2303. do
  2304. if [[ ${m_abi} == ${abi} ]] && {
  2305. [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  2306. } && use "${m_flag}"; then
  2307. echo "${m_flag}.${abi}";
  2308. found=1;
  2309. break 2;
  2310. fi;
  2311. done;
  2312. done;
  2313. done;
  2314. if [[ ! -n ${found} ]]; then
  2315. local abi=${ABI:-${DEFAULT_ABI}};
  2316. debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  2317. debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  2318. echo ".${abi}";
  2319. fi
  2320. }
  2321. multilib_get_enabled_abis ()
  2322. {
  2323. debug-print-function ${FUNCNAME} "$@";
  2324. local pairs=($(multilib_get_enabled_abi_pairs));
  2325. echo "${pairs[@]#*.}"
  2326. }
  2327. multilib_install_wrappers ()
  2328. {
  2329. debug-print-function ${FUNCNAME} "$@";
  2330. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2331. [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  2332. local root=${1:-${ED}};
  2333. if [[ -d ${ED%/}/tmp/multilib-include ]]; then
  2334. multibuild_merge_root "${ED%/}"/tmp/multilib-include "${root}"/usr/include;
  2335. rmdir "${ED%/}"/tmp &> /dev/null;
  2336. fi
  2337. }
  2338. multilib_is_native_abi ()
  2339. {
  2340. debug-print-function ${FUNCNAME} "$@";
  2341. [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  2342. [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  2343. }
  2344. multilib_native_enable ()
  2345. {
  2346. if multilib_is_native_abi; then
  2347. echo "--enable-${1}${2+=${2}}";
  2348. else
  2349. echo "--disable-${1}";
  2350. fi
  2351. }
  2352. multilib_native_use ()
  2353. {
  2354. multilib_is_native_abi && use "$@"
  2355. }
  2356. multilib_native_use_enable ()
  2357. {
  2358. if multilib_is_native_abi; then
  2359. use_enable "${@}";
  2360. else
  2361. echo "--disable-${2:-${1}}";
  2362. fi
  2363. }
  2364. multilib_native_use_with ()
  2365. {
  2366. if multilib_is_native_abi; then
  2367. use_with "${@}";
  2368. else
  2369. echo "--without-${2:-${1}}";
  2370. fi
  2371. }
  2372. multilib_native_usev ()
  2373. {
  2374. multilib_is_native_abi && usev "$@"
  2375. }
  2376. multilib_native_usex ()
  2377. {
  2378. if multilib_is_native_abi; then
  2379. usex "${@}";
  2380. else
  2381. echo "${3-no}${5}";
  2382. fi
  2383. }
  2384. multilib_native_with ()
  2385. {
  2386. if multilib_is_native_abi; then
  2387. echo "--with-${1}${2+=${2}}";
  2388. else
  2389. echo "--without-${1}";
  2390. fi
  2391. }
  2392. multilib_parallel_foreach_abi ()
  2393. {
  2394. debug-print-function ${FUNCNAME} "$@";
  2395. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2396. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2397. }
  2398. multilib_prepare_wrappers ()
  2399. {
  2400. debug-print-function ${FUNCNAME} "$@";
  2401. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2402. local root=${1:-${ED%/}};
  2403. local f;
  2404. if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  2405. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2406. do
  2407. f=${f#/};
  2408. local dir=${f%/*};
  2409. local fn=${f##*/};
  2410. ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2411. done;
  2412. return;
  2413. fi;
  2414. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2415. do
  2416. f=${f#/};
  2417. local dir=${f%/*};
  2418. local fn=${f##*/};
  2419. if [[ -L ${root}/${f} ]]; then
  2420. local target;
  2421. target=$(readlink "${root}/${f}") || die;
  2422. local target_dir target_fn=${target##*/};
  2423. [[ ${target} == */* ]] && target_dir=${target%/*};
  2424. ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  2425. fi;
  2426. mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2427. if multilib_is_native_abi; then
  2428. ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  2429. fi;
  2430. done;
  2431. if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  2432. if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  2433. for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  2434. do
  2435. f=${f#/};
  2436. if [[ ${f} != usr/include/* ]]; then
  2437. die "Wrapping headers outside of /usr/include is not supported at the moment.";
  2438. fi;
  2439. f=${f#usr/include};
  2440. local dir=${f%/*};
  2441. if [[ -f ${root}/usr/include${f} ]]; then
  2442. local wrapper=${ED%/}/tmp/multilib-include${f};
  2443. if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then
  2444. dodir "/tmp/multilib-include${dir}";
  2445. cat > "${wrapper}" <<_EOF_ ||
  2446. /* This file is auto-generated by multilib-build.eclass
  2447. * as a multilib-friendly wrapper. For the original content,
  2448. * please see the files that are #included below.
  2449. */
  2450.  
  2451. #if defined(__x86_64__) /* amd64 */
  2452. # if defined(__ILP32__) /* x32 ABI */
  2453. # error "abi_x86_x32 not supported by the package."
  2454. # else /* 64-bit ABI */
  2455. # error "abi_x86_64 not supported by the package."
  2456. # endif
  2457. #elif defined(__i386__) /* plain x86 */
  2458. # error "abi_x86_32 not supported by the package."
  2459. #elif defined(__mips__)
  2460. # if(_MIPS_SIM == _ABIN32) /* n32 */
  2461. # error "abi_mips_n32 not supported by the package."
  2462. # elif(_MIPS_SIM == _ABI64) /* n64 */
  2463. # error "abi_mips_n64 not supported by the package."
  2464. # elif(_MIPS_SIM == _ABIO32) /* o32 */
  2465. # error "abi_mips_o32 not supported by the package."
  2466. # endif
  2467. #elif defined(__sparc__)
  2468. # if defined(__arch64__)
  2469. # error "abi_sparc_64 not supported by the package."
  2470. # else
  2471. # error "abi_sparc_32 not supported by the package."
  2472. # endif
  2473. #elif defined(__s390__)
  2474. # if defined(__s390x__)
  2475. # error "abi_s390_64 not supported by the package."
  2476. # else
  2477. # error "abi_s390_32 not supported by the package."
  2478. # endif
  2479. #elif defined(__powerpc__) || defined(__ppc__)
  2480. # if defined(__powerpc64__) || defined(__ppc64__)
  2481. # error "abi_ppc_64 not supported by the package."
  2482. # else
  2483. # error "abi_ppc_32 not supported by the package."
  2484. # endif
  2485. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  2486. # error "Native ABI not supported by the package."
  2487. #else
  2488. # error "No ABI matched, please report a bug to bugs.gentoo.org"
  2489. #endif
  2490. _EOF_
  2491. die;
  2492. fi
  2493. if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  2494. die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  2495. fi;
  2496. dodir "/tmp/multilib-include/${CHOST}${dir}";
  2497. mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die;
  2498. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2499. if multilib_is_native_abi; then
  2500. sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2501. fi;
  2502. fi;
  2503. done;
  2504. fi;
  2505. fi
  2506. }
  2507. multilib_src_compile ()
  2508. {
  2509. ejam --prefix="${EPREFIX}"/usr "${OPTIONS[@]}" || die;
  2510. if multilib_native_use tools; then
  2511. pushd tools > /dev/null || die;
  2512. ejam --prefix="${EPREFIX}"/usr "${OPTIONS[@]}" || die "Building of Boost tools failed";
  2513. popd > /dev/null || die;
  2514. fi
  2515. }
  2516. multilib_src_install ()
  2517. {
  2518. ejam --prefix="${ED}"/usr --includedir="${ED}"/usr/include --libdir="${ED}"/usr/$(get_libdir) "${OPTIONS[@]}" install || die "Installation of Boost libraries failed";
  2519. if multilib_native_use tools; then
  2520. dobin dist/bin/*;
  2521. insinto /usr/share;
  2522. doins -r dist/share/boostbook;
  2523. fi;
  2524. if [[ ${CHOST} == *-darwin* ]]; then
  2525. einfo "Working around completely broken build-system(tm)";
  2526. local d;
  2527. for d in "${ED}"/usr/lib/*.dylib;
  2528. do
  2529. if [[ -f ${d} ]]; then
  2530. ebegin " correcting install_name of ${d#${ED}}";
  2531. install_name_tool -id "/${d#${D}}" "${d}";
  2532. eend $?;
  2533. refs=$(otool -XL "${d}" | sed -e '1d' -e 's/^\t//' | grep "libboost_" | cut -f1 -d' ');
  2534. local r;
  2535. for r in ${refs};
  2536. do
  2537. local r_basename=${r##*/};
  2538. ebegin " correcting reference to ${r_basename}";
  2539. install_name_tool -change "${r}" "${EPREFIX}/usr/lib/${r_basename}" "${d}";
  2540. eend $?;
  2541. done;
  2542. fi;
  2543. done;
  2544. fi
  2545. }
  2546. multilib_src_install_all ()
  2547. {
  2548. if ! use numpy; then
  2549. rm -r "${ED}"/usr/include/boost/python/numpy* || die;
  2550. fi;
  2551. if use python; then
  2552. if use mpi; then
  2553. function move_mpi_py_into_sitedir ()
  2554. {
  2555. python_moduleinto boost;
  2556. python_domodule "${ED}"/usr/$(get_libdir)/boost-${EPYTHON}/mpi.so;
  2557. rm -r "${ED}"/usr/$(get_libdir)/boost-${EPYTHON} || die;
  2558. python_optimize
  2559. };
  2560. python_foreach_impl move_mpi_py_into_sitedir;
  2561. else
  2562. rm -r "${ED}"/usr/include/boost/mpi/python* || die;
  2563. fi;
  2564. else
  2565. rm -r "${ED}"/usr/include/boost/{python*,mpi/python*,parameter/aux_/python,parameter/python*} || die;
  2566. fi;
  2567. if ! use nls; then
  2568. rm -r "${ED}"/usr/include/boost/locale || die;
  2569. fi;
  2570. if ! use context; then
  2571. rm -r "${ED}"/usr/include/boost/context || die;
  2572. rm -r "${ED}"/usr/include/boost/coroutine{,2} || die;
  2573. rm "${ED}"/usr/include/boost/asio/spawn.hpp || die;
  2574. fi;
  2575. if use doc; then
  2576. find libs/*/* \( -iname 'test' -o -iname 'src' \) -exec rm -rf '{}' + || die;
  2577. find doc \( -name 'Jamfile.v2' -o -name 'build' -o -name '*.manifest' \) -exec rm -rf '{}' + || die;
  2578. find tools \( -name 'Jamfile.v2' -o -name 'src' -o -name '*.cpp' -o -name '*.hpp' \) -exec rm -rf '{}' + || die;
  2579. docinto html;
  2580. dodoc *.{htm,html,png,css};
  2581. dodoc -r doc libs more tools;
  2582. dodoc LICENSE_1_0.txt;
  2583. dosym ../../../../include/boost /usr/share/doc/${PF}/html/boost;
  2584. fi
  2585. }
  2586. multilib_toolchain_setup ()
  2587. {
  2588. local v vv;
  2589. export ABI=$1;
  2590. local save_restore_variables=(CBUILD CHOST AR CC CXX F77 FC LD NM OBJCOPY OBJDUMP PKG_CONFIG RANLIB READELF STRINGS STRIP PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH);
  2591. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2592. for v in "${save_restore_variables[@]}";
  2593. do
  2594. vv="_abi_saved_${v}";
  2595. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2596. unset ${vv};
  2597. done;
  2598. unset _DEFAULT_ABI_SAVED;
  2599. fi;
  2600. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2601. for v in "${save_restore_variables[@]}";
  2602. do
  2603. vv="_abi_saved_${v}";
  2604. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2605. done;
  2606. export _DEFAULT_ABI_SAVED="true";
  2607. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2608. export CBUILD=$(get_abi_CHOST $1);
  2609. fi;
  2610. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2611. export AR="$(tc-getAR)";
  2612. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2613. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2614. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2615. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2616. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2617. export NM="$(tc-getNM)";
  2618. export OBJCOPY="$(tc-getOBJCOPY)";
  2619. export OBJDUMP="$(tc-getOBJDUMP)";
  2620. export PKG_CONFIG="$(tc-getPKG_CONFIG)";
  2621. export RANLIB="$(tc-getRANLIB)";
  2622. export READELF="$(tc-getREADELF)";
  2623. export STRINGS="$(tc-getSTRINGS)";
  2624. export STRIP="$(tc-getSTRIP)";
  2625. export CHOST=$(get_abi_CHOST $1);
  2626. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2627. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2628. export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include;
  2629. export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir);
  2630. fi
  2631. }
  2632. no-as-needed ()
  2633. {
  2634. [[ $# -ne 0 ]] && die "no-as-needed takes no arguments";
  2635. case $($(tc-getLD) -v 2>&1 < /dev/null) in
  2636. *GNU*)
  2637. echo "-Wl,--no-as-needed"
  2638. ;;
  2639. esac
  2640. }
  2641. number_abis ()
  2642. {
  2643. set -- `get_install_abis`;
  2644. echo $#
  2645. }
  2646. pkg_nofetch ()
  2647. {
  2648. default
  2649. }
  2650. pkg_postinst ()
  2651. {
  2652. elog "Boost.Regex is *extremely* ABI sensitive. If you get errors such as";
  2653. elog;
  2654. elog " undefined reference to \`boost::re_detail_$(ver_cut 1)0$(ver_cut 2)00::cpp_regex_traits_implementation";
  2655. elog " <char>::transform_primary[abi:cxx11](char const*, char const*) const'";
  2656. elog;
  2657. elog "Then you need to recompile Boost and all its reverse dependencies";
  2658. elog "using the same toolchain. In general, *every* change of the C++ toolchain";
  2659. elog "requires a complete rebuild of the Boost-dependent ecosystem.";
  2660. elog;
  2661. elog "See for instance https://bugs.gentoo.org/638138"
  2662. }
  2663. pkg_preinst ()
  2664. {
  2665. local symlink;
  2666. for symlink in "${EROOT}"/usr/include/boost "${EROOT}"/usr/share/boostbook;
  2667. do
  2668. if [[ -L ${symlink} ]]; then
  2669. rm -f "${symlink}" || die;
  2670. fi;
  2671. done;
  2672. rm -rf "${EROOT}"/usr/include/boost-1_[3-5]? || die
  2673. }
  2674. pkg_setup ()
  2675. {
  2676. if [[ -f "${EROOT}"/etc/site-config.jam ]]; then
  2677. if ! grep -q 'gentoo\(debug\|release\)' "${EROOT}"/etc/site-config.jam; then
  2678. eerror "You are using custom ${EROOT}/etc/site-config.jam without defined gentoorelease/gentoodebug targets.";
  2679. eerror "Boost can not be built in such configuration.";
  2680. eerror "Please, either remove this file or add targets from ${EROOT}/usr/share/boost-build/site-config.jam to it.";
  2681. die "Unsupported target in ${EROOT}/etc/site-config.jam";
  2682. fi;
  2683. fi
  2684. }
  2685. python_copy_sources ()
  2686. {
  2687. debug-print-function ${FUNCNAME} "${@}";
  2688. local MULTIBUILD_VARIANTS;
  2689. _python_obtain_impls;
  2690. multibuild_copy_sources
  2691. }
  2692. python_doexe ()
  2693. {
  2694. debug-print-function ${FUNCNAME} "${@}";
  2695. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  2696. local f;
  2697. for f in "$@";
  2698. do
  2699. python_newexe "${f}" "${f##*/}";
  2700. done
  2701. }
  2702. python_doheader ()
  2703. {
  2704. debug-print-function ${FUNCNAME} "${@}";
  2705. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  2706. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2707. local includedir=$(python_get_includedir);
  2708. local d=${includedir#${ESYSROOT}};
  2709. ( insopts -m 0644;
  2710. insinto "${d}";
  2711. doins -r "${@}" || return ${?} )
  2712. }
  2713. python_domodule ()
  2714. {
  2715. debug-print-function ${FUNCNAME} "${@}";
  2716. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2717. local d;
  2718. if [[ ${_PYTHON_MODULEROOT} == /* ]]; then
  2719. d=${_PYTHON_MODULEROOT};
  2720. else
  2721. local sitedir=$(python_get_sitedir);
  2722. d=${sitedir#${EPREFIX}}/${_PYTHON_MODULEROOT//.//};
  2723. fi;
  2724. if [[ ${EBUILD_PHASE} == install ]]; then
  2725. ( insopts -m 0644;
  2726. insinto "${d}";
  2727. doins -r "${@}" || return ${?} );
  2728. python_optimize "${ED%/}/${d}";
  2729. else
  2730. if [[ -n ${BUILD_DIR} ]]; then
  2731. local dest=${BUILD_DIR}/install${EPREFIX}/${d};
  2732. mkdir -p "${dest}" || die;
  2733. cp -pR "${@}" "${dest}/" || die;
  2734. ( cd "${dest}" && chmod -R a+rX "${@##*/}" ) || die;
  2735. else
  2736. die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set";
  2737. fi;
  2738. fi
  2739. }
  2740. python_doscript ()
  2741. {
  2742. debug-print-function ${FUNCNAME} "${@}";
  2743. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  2744. local _PYTHON_REWRITE_SHEBANG=1;
  2745. python_doexe "${@}"
  2746. }
  2747. python_export_utf8_locale ()
  2748. {
  2749. debug-print-function ${FUNCNAME} "${@}";
  2750. type locale &> /dev/null || return 0;
  2751. if [[ $(locale charmap) != UTF-8 ]]; then
  2752. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  2753. for lang in ${locales};
  2754. do
  2755. if [[ $(LC_ALL=${lang} locale charmap 2> /dev/null) == UTF-8 ]]; then
  2756. if _python_check_locale_sanity "${lang}"; then
  2757. export LC_CTYPE=${lang};
  2758. if [[ -n ${LC_ALL} ]]; then
  2759. export LC_NUMERIC=${LC_ALL};
  2760. export LC_TIME=${LC_ALL};
  2761. export LC_COLLATE=${LC_ALL};
  2762. export LC_MONETARY=${LC_ALL};
  2763. export LC_MESSAGES=${LC_ALL};
  2764. export LC_PAPER=${LC_ALL};
  2765. export LC_NAME=${LC_ALL};
  2766. export LC_ADDRESS=${LC_ALL};
  2767. export LC_TELEPHONE=${LC_ALL};
  2768. export LC_MEASUREMENT=${LC_ALL};
  2769. export LC_IDENTIFICATION=${LC_ALL};
  2770. export LC_ALL=;
  2771. fi;
  2772. return 0;
  2773. fi;
  2774. fi;
  2775. done;
  2776. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  2777. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  2778. ewarn "/etc/locale.gen and run locale-gen.";
  2779. return 1;
  2780. fi;
  2781. return 0
  2782. }
  2783. python_fix_shebang ()
  2784. {
  2785. debug-print-function ${FUNCNAME} "${@}";
  2786. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  2787. local force quiet;
  2788. while [[ -n ${@} ]]; do
  2789. case "${1}" in
  2790. -f | --force)
  2791. force=1;
  2792. shift
  2793. ;;
  2794. -q | --quiet)
  2795. quiet=1;
  2796. shift
  2797. ;;
  2798. --)
  2799. shift;
  2800. break
  2801. ;;
  2802. *)
  2803. break
  2804. ;;
  2805. esac;
  2806. done;
  2807. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  2808. local path f;
  2809. for path in "$@";
  2810. do
  2811. local any_fixed is_recursive;
  2812. [[ -d ${path} ]] && is_recursive=1;
  2813. while IFS= read -r -d '' f; do
  2814. local shebang i;
  2815. local error= match=;
  2816. IFS= read -r shebang < "${f}";
  2817. if [[ ${shebang} == '#!'* ]]; then
  2818. local split_shebang=();
  2819. read -r -a split_shebang <<< ${shebang#"#!"} || die;
  2820. local in_path=${split_shebang[0]};
  2821. local from='^#! *[^ ]*';
  2822. if [[ ${in_path} == */env ]]; then
  2823. in_path=${split_shebang[1]};
  2824. from+=' *[^ ]*';
  2825. fi;
  2826. case ${in_path##*/} in
  2827. "${EPYTHON}")
  2828. match=1
  2829. ;;
  2830. python | python3)
  2831. match=1
  2832. ;;
  2833. python2 | python[23].[0-9] | python3.[1-9][0-9] | pypy | pypy3 | jython[23].[0-9])
  2834. match=1;
  2835. error=1
  2836. ;;
  2837. esac;
  2838. fi;
  2839. [[ -n ${force} ]] && error=;
  2840. if [[ ! -n ${match} ]]; then
  2841. [[ -n ${is_recursive} ]] && continue;
  2842. error=1;
  2843. fi;
  2844. if [[ ! -n ${quiet} ]]; then
  2845. einfo "Fixing shebang in ${f#${D%/}}.";
  2846. fi;
  2847. if [[ ! -n ${error} ]]; then
  2848. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  2849. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  2850. sed -i -e "1s@${from}@#!${EPREFIX}/usr/bin/${EPYTHON}@" "${f}" || die;
  2851. any_fixed=1;
  2852. else
  2853. eerror "The file has incompatible shebang:";
  2854. eerror " file: ${f#${D%/}}";
  2855. eerror " current shebang: ${shebang}";
  2856. eerror " requested impl: ${EPYTHON}";
  2857. die "${FUNCNAME}: conversion of incompatible shebang requested";
  2858. fi;
  2859. done < <(find -H "${path}" -type f -print0 || die);
  2860. if [[ ! -n ${any_fixed} ]]; then
  2861. eerror "QA error: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  2862. eerror "There are no Python files in specified directory.";
  2863. die "${FUNCNAME} did not match any fixable files";
  2864. fi;
  2865. done
  2866. }
  2867. python_foreach_impl ()
  2868. {
  2869. debug-print-function ${FUNCNAME} "${@}";
  2870. if [[ -n ${_DISTUTILS_R1_ECLASS} ]]; then
  2871. if has "${EBUILD_PHASE}" prepare configure compile test install && [[ ! -n ${_DISTUTILS_CALLING_FOREACH_IMPL} && ! -n ${_DISTUTILS_FOREACH_IMPL_WARNED} ]]; then
  2872. eqawarn "python_foreach_impl has been called directly while using distutils-r1.";
  2873. eqawarn "Please redefine python_*() phase functions to meet your expectations";
  2874. eqawarn "instead.";
  2875. _DISTUTILS_FOREACH_IMPL_WARNED=1;
  2876. if ! has "${EAPI}" 7 8; then
  2877. die "Calling python_foreach_impl from distutils-r1 is banned in EAPI ${EAPI}";
  2878. fi;
  2879. fi;
  2880. local _DISTUTILS_CALLING_FOREACH_IMPL=;
  2881. fi;
  2882. local MULTIBUILD_VARIANTS;
  2883. _python_obtain_impls;
  2884. multibuild_foreach_variant _python_multibuild_wrapper "${@}"
  2885. }
  2886. python_gen_any_dep ()
  2887. {
  2888. debug-print-function ${FUNCNAME} "${@}";
  2889. local depstr=${1};
  2890. shift;
  2891. local i PYTHON_PKG_DEP out=;
  2892. _python_verify_patterns "${@}";
  2893. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2894. do
  2895. if _python_impl_matches "${i}" "${@}"; then
  2896. local PYTHON_USEDEP="python_targets_${i}(-)";
  2897. local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)";
  2898. _python_export "${i}" PYTHON_PKG_DEP;
  2899. local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  2900. i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}};
  2901. out="( ${PYTHON_PKG_DEP/:=} ${i_depstr} ) ${out}";
  2902. fi;
  2903. done;
  2904. echo "|| ( ${out})"
  2905. }
  2906. python_gen_cond_dep ()
  2907. {
  2908. debug-print-function ${FUNCNAME} "${@}";
  2909. local impl matches=();
  2910. local dep=${1};
  2911. shift;
  2912. _python_verify_patterns "${@}";
  2913. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2914. do
  2915. if _python_impl_matches "${impl}" "${@}"; then
  2916. if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  2917. local usedep=$(_python_gen_usedep "${@}");
  2918. dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  2919. fi;
  2920. matches+=("python_targets_${impl}? ( ${dep} )");
  2921. fi;
  2922. done;
  2923. echo "${matches[@]}"
  2924. }
  2925. python_gen_impl_dep ()
  2926. {
  2927. debug-print-function ${FUNCNAME} "${@}";
  2928. local impl matches=();
  2929. local PYTHON_REQ_USE=${1};
  2930. shift;
  2931. _python_verify_patterns "${@}";
  2932. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2933. do
  2934. if _python_impl_matches "${impl}" "${@}"; then
  2935. local PYTHON_PKG_DEP;
  2936. _python_export "${impl}" PYTHON_PKG_DEP;
  2937. matches+=("python_targets_${impl}? ( ${PYTHON_PKG_DEP} )");
  2938. fi;
  2939. done;
  2940. echo "${matches[@]}"
  2941. }
  2942. python_gen_useflags ()
  2943. {
  2944. debug-print-function ${FUNCNAME} "${@}";
  2945. local impl matches=();
  2946. _python_verify_patterns "${@}";
  2947. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2948. do
  2949. if _python_impl_matches "${impl}" "${@}"; then
  2950. matches+=("python_targets_${impl}");
  2951. fi;
  2952. done;
  2953. echo "${matches[@]}"
  2954. }
  2955. python_get_CFLAGS ()
  2956. {
  2957. debug-print-function ${FUNCNAME} "${@}";
  2958. _python_export "${@}" PYTHON_CFLAGS;
  2959. echo "${PYTHON_CFLAGS}"
  2960. }
  2961. python_get_LIBS ()
  2962. {
  2963. debug-print-function ${FUNCNAME} "${@}";
  2964. _python_export "${@}" PYTHON_LIBS;
  2965. echo "${PYTHON_LIBS}"
  2966. }
  2967. python_get_PYTHON_CONFIG ()
  2968. {
  2969. debug-print-function ${FUNCNAME} "${@}";
  2970. _python_export "${@}" PYTHON_CONFIG;
  2971. echo "${PYTHON_CONFIG}"
  2972. }
  2973. python_get_includedir ()
  2974. {
  2975. debug-print-function ${FUNCNAME} "${@}";
  2976. _python_export "${@}" PYTHON_INCLUDEDIR;
  2977. echo "${PYTHON_INCLUDEDIR}"
  2978. }
  2979. python_get_library_path ()
  2980. {
  2981. debug-print-function ${FUNCNAME} "${@}";
  2982. _python_export "${@}" PYTHON_LIBPATH;
  2983. echo "${PYTHON_LIBPATH}"
  2984. }
  2985. python_get_scriptdir ()
  2986. {
  2987. debug-print-function ${FUNCNAME} "${@}";
  2988. _python_export "${@}" PYTHON_SCRIPTDIR;
  2989. echo "${PYTHON_SCRIPTDIR}"
  2990. }
  2991. python_get_sitedir ()
  2992. {
  2993. debug-print-function ${FUNCNAME} "${@}";
  2994. _python_export "${@}" PYTHON_SITEDIR;
  2995. echo "${PYTHON_SITEDIR}"
  2996. }
  2997. python_has_version ()
  2998. {
  2999. debug-print-function ${FUNCNAME} "${@}";
  3000. local root_arg=(-b);
  3001. case ${1} in
  3002. -b | -d | -r)
  3003. root_arg=("${1}");
  3004. shift
  3005. ;;
  3006. esac;
  3007. local pkg;
  3008. for pkg in "$@";
  3009. do
  3010. ebegin " ${pkg}";
  3011. has_version "${root_arg[@]}" "${pkg}";
  3012. eend ${?} || return;
  3013. done;
  3014. return 0
  3015. }
  3016. python_moduleinto ()
  3017. {
  3018. debug-print-function ${FUNCNAME} "${@}";
  3019. _PYTHON_MODULEROOT=${1}
  3020. }
  3021. python_newexe ()
  3022. {
  3023. debug-print-function ${FUNCNAME} "${@}";
  3024. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3025. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3026. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3027. local wrapd=${_PYTHON_SCRIPTROOT:-/usr/bin};
  3028. local f=${1};
  3029. local newfn=${2};
  3030. local scriptdir=$(python_get_scriptdir);
  3031. local d=${scriptdir#${EPREFIX}};
  3032. ( dodir "${wrapd}";
  3033. exeopts -m 0755;
  3034. exeinto "${d}";
  3035. newexe "${f}" "${newfn}" || return ${?} );
  3036. local dosym=dosym;
  3037. [[ ${EAPI} == 7 ]] && dosym=dosym8;
  3038. "${dosym}" -r /usr/lib/python-exec/python-exec2 "${wrapd}/${newfn}";
  3039. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3040. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3041. fi
  3042. }
  3043. python_newscript ()
  3044. {
  3045. debug-print-function ${FUNCNAME} "${@}";
  3046. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3047. local _PYTHON_REWRITE_SHEBANG=1;
  3048. python_newexe "${@}"
  3049. }
  3050. python_optimize ()
  3051. {
  3052. debug-print-function ${FUNCNAME} "${@}";
  3053. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3054. local PYTHON=${PYTHON};
  3055. [[ -n ${PYTHON} ]] || _python_export PYTHON;
  3056. [[ -x ${PYTHON} ]] || die "PYTHON (${PYTHON}) is not executable";
  3057. if [[ ${#} -eq 0 ]]; then
  3058. local f;
  3059. while IFS= read -r -d '' f; do
  3060. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  3061. set -- "${D%/}${f}" "${@}";
  3062. fi;
  3063. done < <("${PYTHON}" - <<-EOF ||
  3064. import sys
  3065. print("".join(x + "\0" for x in sys.path))
  3066. EOF
  3067. die);
  3068. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  3069. fi;
  3070. local jobs=$(makeopts_jobs);
  3071. local d;
  3072. for d in "$@";
  3073. do
  3074. local instpath=${d#${D%/}};
  3075. instpath=/${instpath##/};
  3076. einfo "Optimize Python modules for ${instpath}";
  3077. case "${EPYTHON}" in
  3078. python3.8)
  3079. "${PYTHON}" -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  3080. "${PYTHON}" -O -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  3081. "${PYTHON}" -OO -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
  3082. ;;
  3083. python* | pypy3)
  3084. "${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}"
  3085. ;;
  3086. pypy | jython2.7)
  3087. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  3088. ;;
  3089. *)
  3090. die "${FUNCNAME}: unexpected EPYTHON=${EPYTHON}"
  3091. ;;
  3092. esac;
  3093. done
  3094. }
  3095. python_replicate_script ()
  3096. {
  3097. debug-print-function ${FUNCNAME} "${@}";
  3098. function _python_replicate_script ()
  3099. {
  3100. local _PYTHON_FIX_SHEBANG_QUIET=1;
  3101. local PYTHON_SCRIPTDIR;
  3102. _python_export PYTHON_SCRIPTDIR;
  3103. ( exeopts -m 0755;
  3104. exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}";
  3105. doexe "${files[@]}" );
  3106. python_fix_shebang -q "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
  3107. };
  3108. local files=("${@}");
  3109. python_foreach_impl _python_replicate_script;
  3110. unset -f _python_replicate_script;
  3111. local f;
  3112. for f in "$@";
  3113. do
  3114. local dosym=dosym;
  3115. [[ ${EAPI} == 7 ]] && dosym=dosym8;
  3116. "${dosym}" -r /usr/lib/python-exec/python-exec2 "${f#${ED}}";
  3117. done
  3118. }
  3119. python_scriptinto ()
  3120. {
  3121. debug-print-function ${FUNCNAME} "${@}";
  3122. _PYTHON_SCRIPTROOT=${1}
  3123. }
  3124. python_setup ()
  3125. {
  3126. debug-print-function ${FUNCNAME} "${@}";
  3127. local has_check_deps;
  3128. declare -f python_check_deps > /dev/null && has_check_deps=1;
  3129. if [[ ! -n ${has_check_deps} ]]; then
  3130. _python_validate_useflags;
  3131. fi;
  3132. local pycompat=("${PYTHON_COMPAT[@]}");
  3133. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  3134. pycompat=(${PYTHON_COMPAT_OVERRIDE});
  3135. fi;
  3136. local found i;
  3137. _python_verify_patterns "${@}";
  3138. for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  3139. do
  3140. local impl=${_PYTHON_SUPPORTED_IMPLS[i]};
  3141. has "${impl}" "${pycompat[@]}" || continue;
  3142. if [[ ! -n ${PYTHON_COMPAT_OVERRIDE} && ! -n ${has_check_deps} ]]; then
  3143. use "python_targets_${impl}" || continue;
  3144. fi;
  3145. _python_impl_matches "${impl}" "${@}" || continue;
  3146. _python_export "${impl}" EPYTHON PYTHON;
  3147. if [[ -n ${has_check_deps} ]]; then
  3148. _python_run_check_deps "${impl}" || continue;
  3149. fi;
  3150. found=1;
  3151. break;
  3152. done;
  3153. if [[ ! -n ${found} ]]; then
  3154. eerror "${FUNCNAME}: none of the enabled implementation matched the patterns.";
  3155. eerror " patterns: ${@-'(*)'}";
  3156. eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing.";
  3157. eerror " suggested: || ( \$(python_gen_useflags ${@}) )";
  3158. eerror "(remember to quote all the patterns with '')";
  3159. die "${FUNCNAME}: no enabled implementation satisfy requirements";
  3160. fi;
  3161. _python_wrapper_setup;
  3162. einfo "Using ${EPYTHON} in global scope"
  3163. }
  3164. raw-ldflags ()
  3165. {
  3166. local x input="$@";
  3167. [[ -z ${input} ]] && input=${LDFLAGS};
  3168. set --;
  3169. for x in ${input};
  3170. do
  3171. case ${x} in
  3172. -Wl,*)
  3173. x=${x#-Wl,};
  3174. set -- "$@" ${x//,/ }
  3175. ;;
  3176. *)
  3177.  
  3178. ;;
  3179. esac;
  3180. done;
  3181. echo "$@"
  3182. }
  3183. replace-cpu-flags ()
  3184. {
  3185. local newcpu="$#";
  3186. newcpu="${!newcpu}";
  3187. while [ $# -gt 1 ]; do
  3188. replace-flags "-march=${1}" "-march=${newcpu}";
  3189. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3190. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3191. shift;
  3192. done;
  3193. return 0
  3194. }
  3195. replace-flags ()
  3196. {
  3197. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3198. local f var new;
  3199. for var in $(all-flag-vars);
  3200. do
  3201. new=();
  3202. for f in ${!var};
  3203. do
  3204. [[ ${f} == ${1} ]] && f=${2};
  3205. new+=("${f}");
  3206. done;
  3207. export ${var}="${new[*]}";
  3208. done;
  3209. return 0
  3210. }
  3211. replace-sparc64-flags ()
  3212. {
  3213. [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments";
  3214. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3215. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3216. for x in ${SPARC64_CPUS};
  3217. do
  3218. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3219. done;
  3220. else
  3221. for x in ${SPARC64_CPUS};
  3222. do
  3223. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3224. done;
  3225. fi;
  3226. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3227. for x in ${SPARC64_CPUS};
  3228. do
  3229. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3230. done;
  3231. else
  3232. for x in ${SPARC64_CPUS};
  3233. do
  3234. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3235. done;
  3236. fi;
  3237. export CFLAGS CXXFLAGS
  3238. }
  3239. run_in_build_dir ()
  3240. {
  3241. debug-print-function ${FUNCNAME} "${@}";
  3242. local ret;
  3243. [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified.";
  3244. [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set.";
  3245. mkdir -p "${BUILD_DIR}" || die;
  3246. pushd "${BUILD_DIR}" > /dev/null || die;
  3247. "${@}";
  3248. ret=${?};
  3249. popd > /dev/null || die;
  3250. return ${ret}
  3251. }
  3252. setup-allowed-flags ()
  3253. {
  3254. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  3255. _setup-allowed-flags "$@"
  3256. }
  3257. src_compile ()
  3258. {
  3259. multilib-minimal_src_compile "$@"
  3260. }
  3261. src_configure ()
  3262. {
  3263. [[ "$(makeopts_jobs)" -gt 64 ]] && MAKEOPTS="${MAKEOPTS} -j64";
  3264. [[ -n ${ESYSROOT} ]] && local icuarg="-sICU_PATH=${ESYSROOT}/usr";
  3265. OPTIONS=($(usex debug gentoodebug gentoorelease) "-j$(makeopts_jobs)" -q -d+2 pch=off $(usex icu "${icuarg}" '--disable-icu boost.locale.icu=off') $(usev !mpi --without-mpi) $(usev !nls --without-locale) $(usev !context '--without-context --without-coroutine --without-fiber') $(usev !stacktrace --without-stacktrace) --boost-build="${BROOT}"/usr/share/b2/src --layout=system threading=multi link=shared -sNO_BZIP2=$(usex bzip2 0 1) -sNO_LZMA=$(usex lzma 0 1) -sNO_ZLIB=$(usex zlib 0 1) -sNO_ZSTD=$(usex zstd 0 1));
  3266. if [[ ${CHOST} == *-darwin* ]]; then
  3267. append-ldflags -Wl,-headerpad_max_install_names;
  3268. fi;
  3269. append-cxxflags -std=c++17;
  3270. if [[ ${CHOST} != *-darwin* ]]; then
  3271. append-lfs-flags;
  3272. fi
  3273. }
  3274. src_install ()
  3275. {
  3276. multilib-minimal_src_install "$@"
  3277. }
  3278. src_prepare ()
  3279. {
  3280. default;
  3281. multilib_copy_sources
  3282. }
  3283. src_test ()
  3284. {
  3285. multilib-minimal_src_test "$@"
  3286. }
  3287. src_unpack ()
  3288. {
  3289. default
  3290. }
  3291. strip-flags ()
  3292. {
  3293. [[ $# -ne 0 ]] && die "strip-flags takes no arguments";
  3294. local x y var;
  3295. local ALLOWED_FLAGS;
  3296. _setup-allowed-flags;
  3297. set -f;
  3298. for var in $(all-flag-vars);
  3299. do
  3300. local new=();
  3301. for x in ${!var};
  3302. do
  3303. for y in "${ALLOWED_FLAGS[@]}";
  3304. do
  3305. if [[ ${x} == ${y} ]]; then
  3306. new+=("${x}");
  3307. break;
  3308. fi;
  3309. done;
  3310. done;
  3311. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  3312. new+=(-O2);
  3313. fi;
  3314. if [[ ${!var} != "${new[*]}" ]]; then
  3315. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  3316. fi;
  3317. export ${var}="${new[*]}";
  3318. done;
  3319. set +f;
  3320. return 0
  3321. }
  3322. strip-unsupported-flags ()
  3323. {
  3324. [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments";
  3325. export CFLAGS=$(test-flags-CC ${CFLAGS});
  3326. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3327. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3328. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  3329. export LDFLAGS=$(test-flags-CCLD ${LDFLAGS})
  3330. }
  3331. tc-arch ()
  3332. {
  3333. tc-ninja_magic_to_arch portage "$@"
  3334. }
  3335. tc-arch-kernel ()
  3336. {
  3337. tc-ninja_magic_to_arch kern "$@"
  3338. }
  3339. tc-check-openmp ()
  3340. {
  3341. if ! _tc-has-openmp; then
  3342. eerror "Your current compiler does not support OpenMP!";
  3343. if tc-is-gcc; then
  3344. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  3345. else
  3346. if tc-is-clang; then
  3347. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  3348. fi;
  3349. fi;
  3350. die "Active compiler does not have required support for OpenMP";
  3351. fi
  3352. }
  3353. tc-cpp-is-true ()
  3354. {
  3355. local CONDITION=${1};
  3356. shift;
  3357. $(tc-getTARGET_CPP) "${@}" -P - <<-EOF > /dev/null 2>&1
  3358. #if ${CONDITION}
  3359. true
  3360. #else
  3361. #error false
  3362. #endif
  3363. EOF
  3364.  
  3365. }
  3366. tc-detect-is-softfloat ()
  3367. {
  3368. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  3369. case ${CTARGET:-${CHOST}} in
  3370. *-newlib | *-elf | *-eabi)
  3371. return 1
  3372. ;;
  3373. arm*)
  3374. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  3375. echo "no";
  3376. else
  3377. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  3378. echo "yes";
  3379. else
  3380. echo "softfp";
  3381. fi;
  3382. fi;
  3383. return 0
  3384. ;;
  3385. *)
  3386. return 1
  3387. ;;
  3388. esac
  3389. }
  3390. tc-enables-cxx-assertions ()
  3391. {
  3392. tc-cpp-is-true "defined(_GLIBCXX_ASSERTIONS) || defined(_LIBCPP_ENABLE_ASSERTIONS) || defined(_LIBCPP_ENABLE_HARDENED_MODE)" ${CPPFLAGS} ${CXXFLAGS}
  3393. }
  3394. tc-enables-fortify-source ()
  3395. {
  3396. tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3397. }
  3398. tc-enables-pie ()
  3399. {
  3400. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3401. }
  3402. tc-enables-ssp ()
  3403. {
  3404. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3405. }
  3406. tc-enables-ssp-all ()
  3407. {
  3408. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3409. }
  3410. tc-enables-ssp-strong ()
  3411. {
  3412. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3413. }
  3414. tc-endian ()
  3415. {
  3416. local host=$1;
  3417. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3418. host=${host%%-*};
  3419. case ${host} in
  3420. aarch64*be)
  3421. echo big
  3422. ;;
  3423. aarch64)
  3424. echo little
  3425. ;;
  3426. alpha*)
  3427. echo little
  3428. ;;
  3429. arc*b*)
  3430. echo big
  3431. ;;
  3432. arc*)
  3433. echo little
  3434. ;;
  3435. arm*b*)
  3436. echo big
  3437. ;;
  3438. arm*)
  3439. echo little
  3440. ;;
  3441. cris*)
  3442. echo little
  3443. ;;
  3444. hppa*)
  3445. echo big
  3446. ;;
  3447. i?86*)
  3448. echo little
  3449. ;;
  3450. ia64*)
  3451. echo little
  3452. ;;
  3453. loongarch*)
  3454. echo little
  3455. ;;
  3456. m68*)
  3457. echo big
  3458. ;;
  3459. mips*l*)
  3460. echo little
  3461. ;;
  3462. mips*)
  3463. echo big
  3464. ;;
  3465. powerpc*le)
  3466. echo little
  3467. ;;
  3468. powerpc*)
  3469. echo big
  3470. ;;
  3471. riscv*)
  3472. echo little
  3473. ;;
  3474. s390*)
  3475. echo big
  3476. ;;
  3477. sh*b*)
  3478. echo big
  3479. ;;
  3480. sh*)
  3481. echo little
  3482. ;;
  3483. sparc*)
  3484. echo big
  3485. ;;
  3486. x86_64*)
  3487. echo little
  3488. ;;
  3489. *)
  3490. echo wtf
  3491. ;;
  3492. esac
  3493. }
  3494. tc-env_build ()
  3495. {
  3496. tc-export_build_env;
  3497. 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) READELF=$(tc-getBUILD_READELF) "$@"
  3498. }
  3499. tc-export ()
  3500. {
  3501. local var;
  3502. for var in "$@";
  3503. do
  3504. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3505. "tc-get${var}" > /dev/null;
  3506. done
  3507. }
  3508. tc-export_build_env ()
  3509. {
  3510. tc-export "$@";
  3511. if tc-is-cross-compiler; then
  3512. : "${BUILD_CFLAGS:=-O1 -pipe}";
  3513. : "${BUILD_CXXFLAGS:=-O1 -pipe}";
  3514. : "${BUILD_CPPFLAGS:= }";
  3515. : "${BUILD_LDFLAGS:= }";
  3516. else
  3517. : "${BUILD_CFLAGS:=${CFLAGS}}";
  3518. : "${BUILD_CXXFLAGS:=${CXXFLAGS}}";
  3519. : "${BUILD_CPPFLAGS:=${CPPFLAGS}}";
  3520. : "${BUILD_LDFLAGS:=${LDFLAGS}}";
  3521. fi;
  3522. export BUILD_{C,CXX,CPP,LD}FLAGS;
  3523. local v;
  3524. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  3525. do
  3526. export ${v#BUILD_}_FOR_BUILD="${!v}";
  3527. done
  3528. }
  3529. tc-get-build-ptr-size ()
  3530. {
  3531. $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CBUILD pointer size"
  3532. }
  3533. tc-get-c-rtlib ()
  3534. {
  3535. local res=$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name 2> /dev/null);
  3536. case ${res} in
  3537. *libclang_rt*)
  3538. echo compiler-rt
  3539. ;;
  3540. *libgcc*)
  3541. echo libgcc
  3542. ;;
  3543. *)
  3544. return 1
  3545. ;;
  3546. esac;
  3547. return 0
  3548. }
  3549. tc-get-compiler-type ()
  3550. {
  3551. local code='
  3552. #if defined(__PATHSCALE__)
  3553. HAVE_PATHCC
  3554. #elif defined(__clang__)
  3555. HAVE_CLANG
  3556. #elif defined(__GNUC__)
  3557. HAVE_GCC
  3558. #endif
  3559. ';
  3560. local res=$($(tc-getCPP "$@") -E -P - <<< "${code}");
  3561. case ${res} in
  3562. *HAVE_PATHCC*)
  3563. echo pathcc
  3564. ;;
  3565. *HAVE_CLANG*)
  3566. echo clang
  3567. ;;
  3568. *HAVE_GCC*)
  3569. echo gcc
  3570. ;;
  3571. *)
  3572. echo unknown
  3573. ;;
  3574. esac
  3575. }
  3576. tc-get-cxx-stdlib ()
  3577. {
  3578. local code='#include <ciso646>
  3579.  
  3580. #if defined(_LIBCPP_VERSION)
  3581. HAVE_LIBCXX
  3582. #elif defined(__GLIBCXX__)
  3583. HAVE_LIBSTDCPP
  3584. #endif
  3585. ';
  3586. local res=$($(tc-getCXX) ${CPPFLAGS} ${CXXFLAGS} -x c++ -E -P - <<< "${code}" 2> /dev/null);
  3587. case ${res} in
  3588. *HAVE_LIBCXX*)
  3589. echo libc++
  3590. ;;
  3591. *HAVE_LIBSTDCPP*)
  3592. echo libstdc++
  3593. ;;
  3594. *)
  3595. return 1
  3596. ;;
  3597. esac;
  3598. return 0
  3599. }
  3600. tc-get-ptr-size ()
  3601. {
  3602. $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CHOST pointer size"
  3603. }
  3604. tc-getAR ()
  3605. {
  3606. tc-getPROG AR ar "$@"
  3607. }
  3608. tc-getAS ()
  3609. {
  3610. tc-getPROG AS as "$@"
  3611. }
  3612. tc-getBUILD_AR ()
  3613. {
  3614. tc-getBUILD_PROG AR ar "$@"
  3615. }
  3616. tc-getBUILD_AS ()
  3617. {
  3618. tc-getBUILD_PROG AS as "$@"
  3619. }
  3620. tc-getBUILD_CC ()
  3621. {
  3622. tc-getBUILD_PROG CC gcc "$@"
  3623. }
  3624. tc-getBUILD_CPP ()
  3625. {
  3626. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  3627. }
  3628. tc-getBUILD_CXX ()
  3629. {
  3630. tc-getBUILD_PROG CXX g++ "$@"
  3631. }
  3632. tc-getBUILD_LD ()
  3633. {
  3634. tc-getBUILD_PROG LD ld "$@"
  3635. }
  3636. tc-getBUILD_NM ()
  3637. {
  3638. tc-getBUILD_PROG NM nm "$@"
  3639. }
  3640. tc-getBUILD_OBJCOPY ()
  3641. {
  3642. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3643. }
  3644. tc-getBUILD_PKG_CONFIG ()
  3645. {
  3646. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3647. }
  3648. tc-getBUILD_PROG ()
  3649. {
  3650. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  3651. tc-is-cross-compiler || vars+=" $1";
  3652. _tc-getPROG CBUILD "${vars}" "${@:2}"
  3653. }
  3654. tc-getBUILD_RANLIB ()
  3655. {
  3656. tc-getBUILD_PROG RANLIB ranlib "$@"
  3657. }
  3658. tc-getBUILD_READELF ()
  3659. {
  3660. tc-getBUILD_PROG READELF readelf "$@"
  3661. }
  3662. tc-getBUILD_STRINGS ()
  3663. {
  3664. tc-getBUILD_PROG STRINGS strings "$@"
  3665. }
  3666. tc-getBUILD_STRIP ()
  3667. {
  3668. tc-getBUILD_PROG STRIP strip "$@"
  3669. }
  3670. tc-getCC ()
  3671. {
  3672. tc-getPROG CC gcc "$@"
  3673. }
  3674. tc-getCPP ()
  3675. {
  3676. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  3677. }
  3678. tc-getCXX ()
  3679. {
  3680. tc-getPROG CXX g++ "$@"
  3681. }
  3682. tc-getDLLWRAP ()
  3683. {
  3684. tc-getPROG DLLWRAP dllwrap "$@"
  3685. }
  3686. tc-getF77 ()
  3687. {
  3688. tc-getPROG F77 gfortran "$@"
  3689. }
  3690. tc-getFC ()
  3691. {
  3692. tc-getPROG FC gfortran "$@"
  3693. }
  3694. tc-getGCJ ()
  3695. {
  3696. tc-getPROG GCJ gcj "$@"
  3697. }
  3698. tc-getGO ()
  3699. {
  3700. tc-getPROG GO gccgo "$@"
  3701. }
  3702. tc-getLD ()
  3703. {
  3704. tc-getPROG LD ld "$@"
  3705. }
  3706. tc-getNM ()
  3707. {
  3708. tc-getPROG NM nm "$@"
  3709. }
  3710. tc-getOBJCOPY ()
  3711. {
  3712. tc-getPROG OBJCOPY objcopy "$@"
  3713. }
  3714. tc-getOBJDUMP ()
  3715. {
  3716. tc-getPROG OBJDUMP objdump "$@"
  3717. }
  3718. tc-getPKG_CONFIG ()
  3719. {
  3720. tc-getPROG PKG_CONFIG pkg-config "$@"
  3721. }
  3722. tc-getPROG ()
  3723. {
  3724. _tc-getPROG CHOST "$@"
  3725. }
  3726. tc-getRANLIB ()
  3727. {
  3728. tc-getPROG RANLIB ranlib "$@"
  3729. }
  3730. tc-getRC ()
  3731. {
  3732. tc-getPROG RC windres "$@"
  3733. }
  3734. tc-getREADELF ()
  3735. {
  3736. tc-getPROG READELF readelf "$@"
  3737. }
  3738. tc-getSTRINGS ()
  3739. {
  3740. tc-getPROG STRINGS strings "$@"
  3741. }
  3742. tc-getSTRIP ()
  3743. {
  3744. tc-getPROG STRIP strip "$@"
  3745. }
  3746. tc-getTARGET_CPP ()
  3747. {
  3748. if [[ -n ${CTARGET} ]]; then
  3749. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  3750. else
  3751. tc-getCPP "$@";
  3752. fi
  3753. }
  3754. tc-has-tls ()
  3755. {
  3756. local base="${T}/test-tc-tls";
  3757. cat <<-EOF > "${base}.c"
  3758. int foo(int *i) {
  3759. static __thread int j = 0;
  3760. return *i ? j : *i;
  3761. }
  3762. EOF
  3763.  
  3764. local flags;
  3765. case $1 in
  3766. -s)
  3767. flags="-S"
  3768. ;;
  3769. -c)
  3770. flags="-c"
  3771. ;;
  3772. -l)
  3773.  
  3774. ;;
  3775. -*)
  3776. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3777. ;;
  3778. esac;
  3779. : "${flags:=-fPIC -shared -Wl,-z,defs}";
  3780. [[ $1 == -* ]] && shift;
  3781. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null;
  3782. local ret=$?;
  3783. rm -f "${base}"*;
  3784. return ${ret}
  3785. }
  3786. tc-is-clang ()
  3787. {
  3788. [[ $(tc-get-compiler-type) == clang ]]
  3789. }
  3790. tc-is-cross-compiler ()
  3791. {
  3792. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  3793. }
  3794. tc-is-gcc ()
  3795. {
  3796. [[ $(tc-get-compiler-type) == gcc ]]
  3797. }
  3798. tc-is-lto ()
  3799. {
  3800. local f="${T}/test-lto.o";
  3801. case $(tc-get-compiler-type) in
  3802. clang)
  3803. $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  3804. llvm-bcanalyzer "${f}" &> /dev/null && return 0
  3805. ;;
  3806. gcc)
  3807. $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  3808. [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0
  3809. ;;
  3810. esac;
  3811. return 1
  3812. }
  3813. tc-is-softfloat ()
  3814. {
  3815. tc-detect-is-softfloat || tc-tuple-is-softfloat
  3816. }
  3817. tc-is-static-only ()
  3818. {
  3819. local host=${CTARGET:-${CHOST}};
  3820. [[ ${host} == *-mint* ]]
  3821. }
  3822. tc-ld-disable-gold ()
  3823. {
  3824. tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
  3825. }
  3826. tc-ld-force-bfd ()
  3827. {
  3828. if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@"; then
  3829. return;
  3830. fi;
  3831. ewarn "Forcing usage of the BFD linker";
  3832. local ld=$(unset LD; tc-getLD "$@");
  3833. local bfd_ld="${ld}.bfd";
  3834. local path_ld=$(type -P "${bfd_ld}" 2> /dev/null);
  3835. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  3836. if tc-is-gcc || tc-is-clang; then
  3837. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3838. fi
  3839. }
  3840. tc-ld-is-gold ()
  3841. {
  3842. local out;
  3843. local -x LC_ALL=C;
  3844. out=$($(tc-getLD "$@") --version 2>&1);
  3845. if [[ ${out} == *"GNU gold"* ]]; then
  3846. return 0;
  3847. fi;
  3848. local base="${T}/test-tc-gold";
  3849. cat <<-EOF > "${base}.c"
  3850. int main(void) { return 0; }
  3851. EOF
  3852.  
  3853. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3854. rm -f "${base}"*;
  3855. if [[ ${out} == *"GNU gold"* ]]; then
  3856. return 0;
  3857. fi;
  3858. return 1
  3859. }
  3860. tc-ld-is-lld ()
  3861. {
  3862. local out;
  3863. local -x LC_ALL=C;
  3864. out=$($(tc-getLD "$@") --version 2>&1);
  3865. if [[ ${out} == *"LLD"* ]]; then
  3866. return 0;
  3867. fi;
  3868. local base="${T}/test-tc-lld";
  3869. cat <<-EOF > "${base}.c"
  3870. int main(void) { return 0; }
  3871. EOF
  3872.  
  3873. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3874. rm -f "${base}"*;
  3875. if [[ ${out} == *"LLD"* ]]; then
  3876. return 0;
  3877. fi;
  3878. return 1
  3879. }
  3880. tc-ninja_magic_to_arch ()
  3881. {
  3882. function _tc_echo_kernel_alias ()
  3883. {
  3884. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3885. };
  3886. local type=$1;
  3887. local host=$2;
  3888. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3889. case ${host} in
  3890. aarch64*)
  3891. echo arm64
  3892. ;;
  3893. alpha*)
  3894. echo alpha
  3895. ;;
  3896. arc*)
  3897. echo arc
  3898. ;;
  3899. arm*)
  3900. echo arm
  3901. ;;
  3902. avr*)
  3903. _tc_echo_kernel_alias avr32 avr
  3904. ;;
  3905. bfin*)
  3906. _tc_echo_kernel_alias blackfin bfin
  3907. ;;
  3908. c6x*)
  3909. echo c6x
  3910. ;;
  3911. cris*)
  3912. echo cris
  3913. ;;
  3914. frv*)
  3915. echo frv
  3916. ;;
  3917. hexagon*)
  3918. echo hexagon
  3919. ;;
  3920. hppa*)
  3921. _tc_echo_kernel_alias parisc hppa
  3922. ;;
  3923. i?86*)
  3924. echo x86
  3925. ;;
  3926. ia64*)
  3927. echo ia64
  3928. ;;
  3929. loongarch*)
  3930. _tc_echo_kernel_alias loongarch loong
  3931. ;;
  3932. m68*)
  3933. echo m68k
  3934. ;;
  3935. metag*)
  3936. echo metag
  3937. ;;
  3938. microblaze*)
  3939. echo microblaze
  3940. ;;
  3941. mips*)
  3942. echo mips
  3943. ;;
  3944. nios2*)
  3945. echo nios2
  3946. ;;
  3947. nios*)
  3948. echo nios
  3949. ;;
  3950. or1k* | or32*)
  3951. echo openrisc
  3952. ;;
  3953. powerpc*)
  3954. if [[ ${type} == "kern" ]]; then
  3955. echo powerpc;
  3956. else
  3957. if [[ ${host} == powerpc64* ]]; then
  3958. echo ppc64;
  3959. else
  3960. echo ppc;
  3961. fi;
  3962. fi
  3963. ;;
  3964. riscv*)
  3965. echo riscv
  3966. ;;
  3967. s390*)
  3968. echo s390
  3969. ;;
  3970. score*)
  3971. echo score
  3972. ;;
  3973. sh64*)
  3974. _tc_echo_kernel_alias sh64 sh
  3975. ;;
  3976. sh*)
  3977. echo sh
  3978. ;;
  3979. sparc64*)
  3980. _tc_echo_kernel_alias sparc64 sparc
  3981. ;;
  3982. sparc*)
  3983. [[ ${PROFILE_ARCH} == "sparc64" ]] && _tc_echo_kernel_alias sparc64 sparc || echo sparc
  3984. ;;
  3985. tile*)
  3986. echo tile
  3987. ;;
  3988. vax*)
  3989. echo vax
  3990. ;;
  3991. x86_64*)
  3992. if [[ ${type} == "kern" ]]; then
  3993. echo x86;
  3994. else
  3995. echo amd64;
  3996. fi
  3997. ;;
  3998. xtensa*)
  3999. echo xtensa
  4000. ;;
  4001. *)
  4002. echo unknown
  4003. ;;
  4004. esac
  4005. }
  4006. tc-stack-grows-down ()
  4007. {
  4008. case ${ARCH} in
  4009. hppa | metag)
  4010. return 1
  4011. ;;
  4012. esac;
  4013. return 0
  4014. }
  4015. tc-tuple-is-softfloat ()
  4016. {
  4017. local CTARGET=${CTARGET:-${CHOST}};
  4018. case ${CTARGET//_/-} in
  4019. bfin* | h8300*)
  4020. echo "only"
  4021. ;;
  4022. *-softfloat-*)
  4023. echo "yes"
  4024. ;;
  4025. *-softfp-*)
  4026. echo "softfp"
  4027. ;;
  4028. arm*-hardfloat-* | arm*eabihf)
  4029. echo "no"
  4030. ;;
  4031. *-newlib | *-elf | *-eabi)
  4032. echo "no"
  4033. ;;
  4034. arm*)
  4035. echo "yes"
  4036. ;;
  4037. *)
  4038. echo "no"
  4039. ;;
  4040. esac
  4041. }
  4042. test-compile ()
  4043. {
  4044. local lang=$1;
  4045. local code=$2;
  4046. shift 2;
  4047. [[ -z "${lang}" ]] && return 1;
  4048. [[ -z "${code}" ]] && return 1;
  4049. local compiler filename_in filename_out args=() libs=();
  4050. case "${lang}" in
  4051. c)
  4052. compiler="$(tc-getCC)";
  4053. filename_in="${T}/test.c";
  4054. filename_out="${T}/test.o";
  4055. args+=(${CFLAGS[@]} -xc -c)
  4056. ;;
  4057. c++)
  4058. compiler="$(tc-getCXX)";
  4059. filename_in="${T}/test.cc";
  4060. filename_out="${T}/test.o";
  4061. args+=(${CXXFLAGS[@]} -xc++ -c)
  4062. ;;
  4063. f77)
  4064. compiler="$(tc-getF77)";
  4065. filename_in="${T}/test.f";
  4066. filename_out="${T}/test.o";
  4067. args+=(${FFFLAGS[@]} -xf77 -c)
  4068. ;;
  4069. f95)
  4070. compiler="$(tc-getFC)";
  4071. filename_in="${T}/test.f90";
  4072. filename_out="${T}/test.o";
  4073. args+=(${FCFLAGS[@]} -xf95 -c)
  4074. ;;
  4075. c+ld)
  4076. compiler="$(tc-getCC)";
  4077. filename_in="${T}/test.c";
  4078. filename_out="${T}/test.exe";
  4079. args+=(${CFLAGS[@]} ${LDFLAGS[@]} -xc);
  4080. libs+=(${LIBS[@]})
  4081. ;;
  4082. c+++ld)
  4083. compiler="$(tc-getCXX)";
  4084. filename_in="${T}/test.cc";
  4085. filename_out="${T}/test.exe";
  4086. args+=(${CXXFLAGS[@]} ${LDFLAGS[@]} -xc++);
  4087. libs+=(${LIBS[@]})
  4088. ;;
  4089. f77+ld)
  4090. compiler="$(tc-getF77)";
  4091. filename_in="${T}/test.f";
  4092. filename_out="${T}/test.exe";
  4093. args+=(${FFLAGS[@]} ${LDFLAGS[@]} -xf77);
  4094. libs+=(${LIBS[@]})
  4095. ;;
  4096. f95+ld)
  4097. compiler="$(tc-getFC)";
  4098. filename_in="${T}/test.f90";
  4099. filename_out="${T}/test.exe";
  4100. args+=(${FCFLAGS[@]} ${LDFLAGS[@]} -xf95);
  4101. libs+=(${LIBS[@]})
  4102. ;;
  4103. *)
  4104. die "Unknown compiled language ${lang}"
  4105. ;;
  4106. esac;
  4107. printf "%s\n" "${code}" > "${filename_in}" || die "Failed to create '${test_in}'";
  4108. "${compiler}" ${args[@]} "${filename_in}" -o "${filename_out}" ${libs[@]} &> /dev/null
  4109. }
  4110. test-flag-CC ()
  4111. {
  4112. _test-flag-PROG CC c "$@"
  4113. }
  4114. test-flag-CCLD ()
  4115. {
  4116. _test-flag-PROG CC c+ld "$@"
  4117. }
  4118. test-flag-CXX ()
  4119. {
  4120. _test-flag-PROG CXX c++ "$@"
  4121. }
  4122. test-flag-F77 ()
  4123. {
  4124. _test-flag-PROG F77 f77 "$@"
  4125. }
  4126. test-flag-FC ()
  4127. {
  4128. _test-flag-PROG FC f95 "$@"
  4129. }
  4130. test-flag-PROG ()
  4131. {
  4132. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  4133. _test-flag-PROG "$@"
  4134. }
  4135. test-flags ()
  4136. {
  4137. test-flags-CC "$@"
  4138. }
  4139. test-flags-CC ()
  4140. {
  4141. _test-flags-PROG CC "$@"
  4142. }
  4143. test-flags-CCLD ()
  4144. {
  4145. _test-flags-PROG CCLD "$@"
  4146. }
  4147. test-flags-CXX ()
  4148. {
  4149. _test-flags-PROG CXX "$@"
  4150. }
  4151. test-flags-F77 ()
  4152. {
  4153. _test-flags-PROG F77 "$@"
  4154. }
  4155. test-flags-FC ()
  4156. {
  4157. _test-flags-PROG FC "$@"
  4158. }
  4159. test-flags-PROG ()
  4160. {
  4161. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  4162. _test-flags-PROG "$@"
  4163. }
  4164. test_version_info ()
  4165. {
  4166. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  4167. return 0;
  4168. else
  4169. return 1;
  4170. fi
  4171. }
  4172. ver_cut ()
  4173. {
  4174. local range=${1};
  4175. local v=${2:-${PV}};
  4176. local start end;
  4177. local -a comp;
  4178. __eapi7_ver_split "${v}";
  4179. local max=$((${#comp[@]}/2));
  4180. __eapi7_ver_parse_range "${range}" "${max}";
  4181. local IFS=;
  4182. if [[ ${start} -gt 0 ]]; then
  4183. start=$(( start*2 - 1 ));
  4184. fi;
  4185. echo "${comp[*]:start:end*2-start}"
  4186. }
  4187. ver_rs ()
  4188. {
  4189. local v;
  4190. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  4191. local start end i;
  4192. local -a comp;
  4193. __eapi7_ver_split "${v}";
  4194. local max=$((${#comp[@]}/2 - 1));
  4195. while [[ ${#} -ge 2 ]]; do
  4196. __eapi7_ver_parse_range "${1}" "${max}";
  4197. for ((i = start*2; i <= end*2; i+=2 ))
  4198. do
  4199. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  4200. comp[i]=${2};
  4201. done;
  4202. shift 2;
  4203. done;
  4204. local IFS=;
  4205. echo "${comp[*]}"
  4206. }
  4207. ver_test ()
  4208. {
  4209. local va op vb;
  4210. if [[ $# -eq 3 ]]; then
  4211. va=${1};
  4212. shift;
  4213. else
  4214. va=${PVR};
  4215. fi;
  4216. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  4217. op=${1};
  4218. vb=${2};
  4219. case ${op} in
  4220. -eq | -ne | -lt | -le | -gt | -ge)
  4221.  
  4222. ;;
  4223. *)
  4224. die "${FUNCNAME}: invalid operator: ${op}"
  4225. ;;
  4226. esac;
  4227. __eapi7_ver_compare "${va}" "${vb}";
  4228. test $? "${op}" 2
  4229. }
  4230.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement