spacepaste

  1.  
  2. declare -x ABI="arm"
  3. declare -x ABI_MIPS=""
  4. declare -x ABI_PPC=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86=""
  7. declare -x ALSA_CARDS=""
  8. declare -x APACHE2_MODULES=""
  9. declare -x APACHE2_MPMS=""
  10. declare -x ARCH="arm"
  11. declare BDEPEND="python_targets_pypy? ( >=virtual/pypy-5:0= ) python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_4? ( dev-lang/python:3.4 ) python_targets_python3_5? ( dev-lang/python:3.5 ) python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 ) >=dev-lang/python-exec-2:=[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)]"
  12. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7"
  13. declare -x BUILD_CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
  14. declare -x BUILD_CPPFLAGS=""
  15. declare -x BUILD_CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
  16. declare -x BUILD_LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  17. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  18. declare -x CALLIGRA_FEATURES=""
  19. declare -x CAMERAS=""
  20. declare -x CBUILD="x86_64-pc-linux-gnu"
  21. declare -x CFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv6j -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard"
  22. declare -x CFLAGS_default
  23. declare -x CHOST="armv6j-unknown-linux-gnueabihf"
  24. declare -x CHOST_arm="armv6j-unknown-linux-gnueabihf"
  25. declare -x CHOST_default="armv6j-unknown-linux-gnueabihf"
  26. declare -x COLLECTD_PLUGINS=""
  27. declare -x CPU_FLAGS_ARM=""
  28. declare -x CPU_FLAGS_X86=""
  29. declare -x CTARGET_default="armv6j-unknown-linux-gnueabihf"
  30. declare -x CURL_SSL=""
  31. declare -x CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv6j -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard"
  32. declare -x DCC_EMAILLOG_WHOM_TO_BLAME=""
  33. declare -x DEFAULT_ABI="arm"
  34. declare -x DEFINED_PHASES=" compile configure install prepare test"
  35. declare DEPEND="sys-apps/attr
  36. dev-python/setuptools[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)]
  37. doc? ( >=dev-python/sphinx-1.3.1[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  38. test? ( dev-python/nose[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] ) "
  39. declare DESCRIPTION="Python interface to xattr"
  40. declare -x DIROPTIONS="-m0755"
  41. declare -x EAPI="7"
  42. declare -x ELIBC="glibc"
  43. declare -x ENLIGHTENMENT_MODULES=""
  44. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  45. declare -x EXEOPTIONS="-m0755"
  46. declare -x FCFLAGS="-O2 -pipe -march=armv6j"
  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="-O2 -pipe -march=armv6j"
  49. declare -x FFTOOLS=""
  50. declare -x GCC_SPECS=""
  51. declare -x GPSD_PROTOCOLS=""
  52. declare -x GRUB_PLATFORMS=""
  53. declare HDEPEND=""
  54. declare HOMEPAGE="https://pyxattr.k1024.org/"
  55. declare -x HOSTCC="x86_64-pc-linux-gnu-gcc"
  56. declare -x INHERITED=" multiprocessing toolchain-funcs multilib multibuild python-utils-r1 python-r1 distutils-r1 eutils"
  57. declare -x INPUT_DEVICES=""
  58. declare -x INSOPTIONS="-m0644"
  59. declare IUSE="doc test python_targets_pypy python_targets_python2_7 python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7"
  60. declare -x IUSE_EFFECTIVE="alpha amd64 amd64-fbsd amd64-linux arm arm64 doc elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mips ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest python_targets_pypy python_targets_python2_7 python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 s390 sh sparc sparc-solaris sparc64-solaris test userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  61. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  62. declare -x KERNEL="linux"
  63. declare -x KERNEL_ABI="arm"
  64. declare -x KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
  65. declare -x L10N=""
  66. declare -x LANG="en_US.utf8"
  67. declare -x LCD_DEVICES=""
  68. declare -x LC_ADDRESS="en_US.utf8"
  69. declare -x LC_COLLATE="C"
  70. declare -x LC_CTYPE="en_US.utf8"
  71. declare -x LC_IDENTIFICATION="en_US.utf8"
  72. declare -x LC_MEASUREMENT="en_US.utf8"
  73. declare -x LC_MESSAGES="en_US.utf8"
  74. declare -x LC_MONETARY="en_US.utf8"
  75. declare -x LC_NAME="en_US.utf8"
  76. declare -x LC_NUMERIC="en_US.utf8"
  77. declare -x LC_PAPER="en_US.utf8"
  78. declare -x LC_TELEPHONE="en_US.utf8"
  79. declare -x LC_TIME="en_US.utf8"
  80. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  81. declare -x LDFLAGS_default
  82. declare -x LIBDIR_arm="lib"
  83. declare -x LIBDIR_default="lib"
  84. declare -x LIBOPTIONS="-m0644"
  85. declare -x LIBREOFFICE_EXTENSIONS=""
  86. declare -x LICENSE="LGPL-2.1"
  87. declare -x LIRC_DEVICES=""
  88. declare -x LLVM_TARGETS=""
  89. declare -x MAIL="/var/mail/necktwi"
  90. declare -x MAKEOPTS="-j5 -l4"
  91. declare -x MANPAGER="manpager"
  92. declare -x MONKEYD_PLUGINS=""
  93. declare -x MULTILIB_ABIS="arm"
  94. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  95. declare -x NETBEANS_MODULES=""
  96. declare -x NGINX_MODULES_HTTP=""
  97. declare -x NGINX_MODULES_MAIL=""
  98. declare -x NGINX_MODULES_STREAM=""
  99. declare -x OFED_DRIVERS=""
  100. declare -x OFFICE_IMPLEMENTATION=""
  101. declare -x OPENGL_PROFILE="xorg-x11"
  102. declare -x OPENMPI_FABRICS=""
  103. declare -x OPENMPI_OFED_FEATURES=""
  104. declare -x OPENMPI_RM=""
  105. declare -x PATH="/usr/lib/ccache/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  106. declare PDEPEND=""
  107. declare -x PHP_TARGETS=""
  108. declare -x PKG_CONFIG_PATH="/usr/armv6j-unknown-linux-gnueabihf/usr/lib/pkgconfig/"
  109. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  110. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  111. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  112. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/pyxattr-0.6.1/html")
  113. declare -a PORTAGE_DOSTRIP=([0]="/")
  114. declare -a PORTAGE_DOSTRIP_SKIP=()
  115. declare -x POSTGRES_TARGETS=""
  116. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  117. declare -x PROPERTIES=""
  118. declare -x PYTHONDONTWRITEBYTECODE="1"
  119. declare -a PYTHON_COMPAT=([0]="python2_7" [1]="python3_4" [2]="python3_5" [3]="python3_6" [4]="python3_7" [5]="pypy")
  120. declare -- PYTHON_DEPS="python_targets_pypy? ( >=virtual/pypy-5:0= ) python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_4? ( dev-lang/python:3.4 ) python_targets_python3_5? ( dev-lang/python:3.5 ) python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 ) >=dev-lang/python-exec-2:=[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)]"
  121. declare -- PYTHON_REQUIRED_USE="|| ( python_targets_pypy python_targets_python2_7 python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 )"
  122. declare -x PYTHON_SINGLE_TARGET=""
  123. declare -x PYTHON_TARGETS="python2_7 python3_6"
  124. declare -- PYTHON_USEDEP="python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)"
  125. declare -x QEMU_SOFTMMU_TARGETS=""
  126. declare -x QEMU_USER_TARGETS=""
  127. declare RDEPEND="sys-apps/attr python_targets_pypy? ( >=virtual/pypy-5:0= ) python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_4? ( dev-lang/python:3.4 ) python_targets_python3_5? ( dev-lang/python:3.5 ) python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 ) >=dev-lang/python-exec-2:=[python_targets_pypy(-)?,python_targets_python2_7(-)?,python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_pypy(-),-python_single_target_python2_7(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)]"
  128. declare REPOSITORY
  129. declare REQUIRED_USE="|| ( python_targets_pypy python_targets_python2_7 python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 )"
  130. declare -x RESTRICT=""
  131. 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}\""
  132. declare -x ROS_MESSAGES=""
  133. declare -x RUBY_TARGETS=""
  134. declare -x S="/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/dev-python/pyxattr-0.6.1/work/pyxattr-0.6.1"
  135. declare -x SANDBOX_DEBUG="0"
  136. declare -x SANDBOX_DENY=""
  137. declare -x SANDBOX_PREDICT="/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/dev-python/pyxattr-0.6.1/homedir"
  138. declare -x SANDBOX_READ="/:/usr/armv6j-unknown-linux-gnueabihf/tmp:/var/CCache"
  139. declare -x SANDBOX_VERBOSE="1"
  140. 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/armv6j-unknown-linux-gnueabihf/tmp:/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/dev-python/pyxattr-0.6.1/homedir/.bash_history:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/CCache:/var/tmp/"
  141. declare -x SANE_BACKENDS=""
  142. declare -x SHELL="/bin/bash"
  143. declare -x SLOT="0"
  144. declare SRC_URI="mirror://pypi/p/pyxattr/pyxattr-0.6.1.tar.gz
  145. https://pyxattr.k1024.org/downloads/pyxattr-0.6.1.tar.gz"
  146. declare -x SSH_CLIENT="192.168.19.1 53444 22"
  147. declare -x SSH_CONNECTION="192.168.19.1 53444 192.168.19.128 22"
  148. declare -x SSH_TTY="/dev/pts/0"
  149. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  150. declare -x UNCACHED_ERR_FD=""
  151. declare -x USE="arm elibc_glibc kernel_linux python_targets_python2_7 python_targets_python3_6 userland_GNU"
  152. declare -x USERLAND="GNU"
  153. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  154. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  155. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  156. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  157. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  158. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  159. declare -x UWSGI_PLUGINS=""
  160. declare -x VIDEO_CARDS=""
  161. declare -x VISUAL="emacs"
  162. declare -x VOICEMAIL_STORAGE=""
  163. declare -x XFCE_PLUGINS=""
  164. declare -x XTABLES_ADDONS=""
  165. declare -- _DISTUTILS_R1="1"
  166. declare -- _EUTILS_ECLASS="1"
  167. declare -x _E_DESTTREE_="/usr"
  168. declare -x _E_DOCDESTTREE_=""
  169. declare -x _E_EXEDESTTREE_=""
  170. declare -x _E_INSDESTTREE_=""
  171. declare -- _MULTIBUILD="1"
  172. declare -- _MULTILIB_ECLASS="1"
  173. declare -- _MULTIPROCESSING_ECLASS="1"
  174. declare -a _PYTHON_ALL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_4" [5]="python3_5" [6]="python3_6" [7]="python3_7")
  175. declare -- _PYTHON_R1="1"
  176. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="pypy" [1]="python2_7" [2]="python3_4" [3]="python3_5" [4]="python3_6" [5]="python3_7")
  177. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy3")
  178. declare -- _PYTHON_UTILS_R1="1"
  179. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  180. declare -- phase_func
  181. PYTHON ()
  182. {
  183. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#.24.28PYTHON.29.2C_.24.7BEPYTHON.7D"
  184. }
  185. __eapi6_src_install ()
  186. {
  187. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  188. emake DESTDIR="${D}" install;
  189. fi;
  190. einstalldocs
  191. }
  192. __eapi6_src_prepare ()
  193. {
  194. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  195. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  196. else
  197. if [[ -n ${PATCHES} ]]; then
  198. eapply ${PATCHES};
  199. fi;
  200. fi;
  201. eapply_user
  202. }
  203. __eapi7_ver_compare ()
  204. {
  205. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  206. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  207. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  208. an=${BASH_REMATCH[1]};
  209. al=${BASH_REMATCH[3]};
  210. as=${BASH_REMATCH[4]};
  211. ar=${BASH_REMATCH[7]};
  212. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  213. bn=${BASH_REMATCH[1]};
  214. bl=${BASH_REMATCH[3]};
  215. bs=${BASH_REMATCH[4]};
  216. br=${BASH_REMATCH[7]};
  217. __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  218. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  219. an=${an#*.};
  220. bn=${bn#*.};
  221. a=${an%%.*};
  222. b=${bn%%.*};
  223. if [[ ${a} == 0* || ${b} == 0* ]]; then
  224. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  225. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  226. [[ ${a} > ${b} ]] && return 3;
  227. [[ ${a} < ${b} ]] && return 1;
  228. else
  229. __eapi7_ver_compare_int "${a}" "${b}" || return;
  230. fi;
  231. done;
  232. [[ ${an} == *.* ]] && return 3;
  233. [[ ${bn} == *.* ]] && return 1;
  234. [[ ${al} > ${bl} ]] && return 3;
  235. [[ ${al} < ${bl} ]] && return 1;
  236. as=${as#_}${as:+_};
  237. bs=${bs#_}${bs:+_};
  238. while [[ -n ${as} && -n ${bs} ]]; do
  239. a=${as%%_*};
  240. b=${bs%%_*};
  241. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  242. __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  243. else
  244. [[ ${a%%[0-9]*} == p ]] && return 3;
  245. [[ ${b%%[0-9]*} == p ]] && return 1;
  246. [[ ${a} > ${b} ]] && return 3 || return 1;
  247. fi;
  248. as=${as#*_};
  249. bs=${bs#*_};
  250. done;
  251. if [[ -n ${as} ]]; then
  252. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  253. else
  254. if [[ -n ${bs} ]]; then
  255. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  256. fi;
  257. fi;
  258. __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  259. return 2
  260. }
  261. __eapi7_ver_compare_int ()
  262. {
  263. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  264. if [[ ${d} -gt 0 ]]; then
  265. printf -v b "%0${d}d%s" 0 "${b}";
  266. else
  267. if [[ ${d} -lt 0 ]]; then
  268. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  269. fi;
  270. fi;
  271. [[ ${a} > ${b} ]] && return 3;
  272. [[ ${a} == "${b}" ]]
  273. }
  274. __eapi7_ver_parse_range ()
  275. {
  276. local range=${1};
  277. local max=${2};
  278. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  279. start=${range%-*};
  280. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  281. if [[ -n ${end} ]]; then
  282. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  283. [[ ${end} -le ${max} ]] || end=${max};
  284. else
  285. end=${max};
  286. fi
  287. }
  288. __eapi7_ver_split ()
  289. {
  290. local v=${1} LC_ALL=C;
  291. comp=();
  292. local s c;
  293. while [[ -n ${v} ]]; do
  294. s=${v%%[a-zA-Z0-9]*};
  295. v=${v:${#s}};
  296. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  297. v=${v:${#c}};
  298. comp+=("${s}" "${c}");
  299. done
  300. }
  301. _clang_fullversion ()
  302. {
  303. local ver="$1";
  304. shift;
  305. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  306. eval echo "$ver"
  307. }
  308. _distutils-r1_check_namespace_pth ()
  309. {
  310. local f pth=();
  311. while IFS= read -r -d '' f; do
  312. pth+=("${f}");
  313. done < <(find "${ED%/}" -name '*-nspkg.pth' -print0);
  314. if [[ -n ${pth[@]} ]]; then
  315. ewarn "The following *-nspkg.pth files were found installed:";
  316. ewarn;
  317. for f in "${pth[@]}";
  318. do
  319. ewarn " ${f#${ED%/}}";
  320. done;
  321. ewarn;
  322. ewarn "The presence of those files may break namespaces in Python 3.5+. Please";
  323. ewarn "read our documentation on reliable handling of namespaces and update";
  324. ewarn "the ebuild accordingly:";
  325. ewarn;
  326. ewarn " https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages";
  327. fi
  328. }
  329. _distutils-r1_clean_egg_info ()
  330. {
  331. rm -rf "${BUILD_DIR}"/lib/*.egg-info || die
  332. }
  333. _distutils-r1_copy_egg_info ()
  334. {
  335. mkdir -p "${BUILD_DIR}" || die;
  336. find -name '*.egg-info' -type d -exec cp -R -p {} "${BUILD_DIR}"/ ';' || die
  337. }
  338. _distutils-r1_create_setup_cfg ()
  339. {
  340. cat > "${HOME}"/.pydistutils.cfg <<-_EOF_ ||
  341. [build]
  342. build-base = ${BUILD_DIR}
  343. # using a single directory for them helps us export
  344. # ${PYTHONPATH} and ebuilds find the sources independently
  345. # of whether the package installs extensions or not
  346. #
  347. # note: due to some packages (wxpython) relying on separate
  348. # platlib & purelib dirs, we do not set --build-lib (which
  349. # can not be overridden with --build-*lib)
  350. build-platlib = %(build-base)s/lib
  351. build-purelib = %(build-base)s/lib
  352. # make the ebuild writer lives easier
  353. build-scripts = %(build-base)s/scripts
  354. # this is needed by distutils_install_for_testing since
  355. # setuptools like to create .egg files for install --home.
  356. [bdist_egg]
  357. dist-dir = ${BUILD_DIR}/dist
  358. _EOF_
  359. die
  360. if [[ ${EBUILD_PHASE} == install ]]; then
  361. cat >> "${HOME}"/.pydistutils.cfg <<-_EOF_ ||
  362. # installation paths -- allow calling extra install targets
  363. # without the default 'install'
  364. [install]
  365. compile = True
  366. optimize = 2
  367. root = ${D%/}
  368. _EOF_
  369. die
  370. if [[ ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  371. cat >> "${HOME}"/.pydistutils.cfg <<-_EOF_ ||
  372. install-scripts = $(python_get_scriptdir)
  373. _EOF_
  374. die;
  375. fi;
  376. fi
  377. }
  378. _distutils-r1_disable_ez_setup ()
  379. {
  380. local stub="def use_setuptools(*args, **kwargs): pass";
  381. if [[ -f ez_setup.py ]]; then
  382. echo "${stub}" > ez_setup.py || die;
  383. fi;
  384. if [[ -f distribute_setup.py ]]; then
  385. echo "${stub}" > distribute_setup.py || die;
  386. fi
  387. }
  388. _distutils-r1_run_common_phase ()
  389. {
  390. local DISTUTILS_ORIG_BUILD_DIR=${BUILD_DIR};
  391. if [[ -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  392. _distutils-r1_run_foreach_impl "${@}";
  393. else
  394. local -x EPYTHON PYTHON;
  395. local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH};
  396. python_setup "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]}";
  397. local MULTIBUILD_VARIANTS=("${EPYTHON/./_}");
  398. local _DISTUTILS_INITIAL_CWD=${PWD};
  399. multibuild_foreach_variant distutils-r1_run_phase "${@}";
  400. fi
  401. }
  402. _distutils-r1_run_foreach_impl ()
  403. {
  404. debug-print-function ${FUNCNAME} "${@}";
  405. local _DISTUTILS_INITIAL_CWD=${PWD};
  406. set -- distutils-r1_run_phase "${@}";
  407. if [[ ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  408. python_foreach_impl "${@}";
  409. else
  410. if [[ ! -n ${EPYTHON} ]]; then
  411. die "EPYTHON unset, python-single-r1_pkg_setup not called?!";
  412. fi;
  413. local BUILD_DIR=${BUILD_DIR:-${S}};
  414. BUILD_DIR=${BUILD_DIR%%/}_${EPYTHON};
  415. "${@}";
  416. fi
  417. }
  418. _distutils-r1_wrap_scripts ()
  419. {
  420. debug-print-function ${FUNCNAME} "${@}";
  421. [[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} <path> <bindir>";
  422. local path=${1};
  423. local bindir=${2};
  424. local PYTHON_SCRIPTDIR;
  425. python_export PYTHON_SCRIPTDIR;
  426. local f python_files=() non_python_files=();
  427. if [[ -d ${path}${PYTHON_SCRIPTDIR} ]]; then
  428. for f in "${path}${PYTHON_SCRIPTDIR}"/*;
  429. do
  430. [[ -d ${f} ]] && die "Unexpected directory: ${f}";
  431. debug-print "${FUNCNAME}: found executable at ${f#${path}/}";
  432. local shebang;
  433. read -r shebang < "${f}";
  434. if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
  435. debug-print "${FUNCNAME}: matching shebang: ${shebang}";
  436. python_files+=("${f}");
  437. else
  438. debug-print "${FUNCNAME}: non-matching shebang: ${shebang}";
  439. non_python_files+=("${f}");
  440. fi;
  441. mkdir -p "${path}${bindir}" || die;
  442. done;
  443. for f in "${python_files[@]}";
  444. do
  445. local basename=${f##*/};
  446. debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}";
  447. _python_ln_rel "${path}${EPREFIX}"/usr/lib/python-exec/python-exec2 "${path}${bindir}/${basename}" || die;
  448. done;
  449. for f in "${non_python_files[@]}";
  450. do
  451. local basename=${f##*/};
  452. debug-print "${FUNCNAME}: moving ${f#${path}/} to ${bindir}/${basename}";
  453. mv "${f}" "${path}${bindir}/${basename}" || die;
  454. done;
  455. fi
  456. }
  457. _gcc-install-dir ()
  458. {
  459. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  460. }
  461. _gcc-specs-directive_raw ()
  462. {
  463. local cc=$(tc-getCC);
  464. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  465. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  466. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  467. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  468. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  469. { spec=spec $0 }
  470. END { print spec }';
  471. return 0
  472. }
  473. _gcc-specs-exists ()
  474. {
  475. [[ -f $(_gcc-install-dir)/$1 ]]
  476. }
  477. _gcc_fullversion ()
  478. {
  479. local ver="$1";
  480. shift;
  481. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  482. eval echo "$ver"
  483. }
  484. _python_check_dead_variables ()
  485. {
  486. local v;
  487. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  488. do
  489. if [[ -n ${!v} ]]; then
  490. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  491. fi;
  492. done;
  493. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  494. do
  495. if [[ -n ${!v} ]]; then
  496. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  497. fi;
  498. done;
  499. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  500. do
  501. if [[ -n ${!v} ]]; then
  502. die "${v} is invalid for python-r1 suite";
  503. fi;
  504. done;
  505. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  506. do
  507. if [[ -n ${!v} ]]; then
  508. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  509. fi;
  510. done;
  511. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  512. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  513. fi;
  514. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  515. do
  516. if [[ -n ${!v} ]]; then
  517. die "${v} is invalid for python-r1 suite";
  518. fi;
  519. done
  520. }
  521. _python_check_locale_sanity ()
  522. {
  523. local -x LC_ALL=${1};
  524. local IFS=;
  525. local lc=({a..z});
  526. local uc=({A..Z});
  527. local input="${lc[*]}${uc[*]}";
  528. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  529. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  530. }
  531. _python_impl_matches ()
  532. {
  533. [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  534. local impl=${1} pattern;
  535. shift;
  536. for pattern in "$@";
  537. do
  538. if [[ ${pattern} == -2 ]]; then
  539. ! python_is_python3 "${impl}";
  540. return;
  541. else
  542. if [[ ${pattern} == -3 ]]; then
  543. python_is_python3 "${impl}";
  544. return;
  545. else
  546. if [[ ${impl/./_} == ${pattern/./_} ]]; then
  547. return 0;
  548. fi;
  549. fi;
  550. fi;
  551. done;
  552. return 1
  553. }
  554. _python_impl_supported ()
  555. {
  556. debug-print-function ${FUNCNAME} "${@}";
  557. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  558. local impl=${1};
  559. case "${impl}" in
  560. python2_7 | python3_[4567] | jython2_7)
  561. return 0
  562. ;;
  563. pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  564. return 1
  565. ;;
  566. pypy | pypy3)
  567. if [[ ${EAPI:-0} == [01234] ]]; then
  568. die "PyPy is supported in EAPI 5 and newer only.";
  569. fi
  570. ;;
  571. *)
  572. [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  573. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  574. ;;
  575. esac
  576. }
  577. _python_ln_rel ()
  578. {
  579. debug-print-function ${FUNCNAME} "${@}";
  580. local target=${1};
  581. local symname=${2};
  582. local tgpath=${target%/*}/;
  583. local sympath=${symname%/*}/;
  584. local rel_target=;
  585. while [[ -n ${sympath} ]]; do
  586. local tgseg= symseg=;
  587. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  588. tgseg=${tgpath%%/*};
  589. tgpath=${tgpath#${tgseg}/};
  590. done;
  591. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  592. symseg=${sympath%%/*};
  593. sympath=${sympath#${symseg}/};
  594. done;
  595. if [[ ${tgseg} != ${symseg} ]]; then
  596. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  597. fi;
  598. done;
  599. rel_target+=${tgpath}${target##*/};
  600. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  601. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  602. ln -fs "${rel_target}" "${symname}"
  603. }
  604. _python_multibuild_wrapper ()
  605. {
  606. debug-print-function ${FUNCNAME} "${@}";
  607. local -x EPYTHON PYTHON;
  608. local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH};
  609. python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON;
  610. python_wrapper_setup;
  611. "${@}"
  612. }
  613. _python_obtain_impls ()
  614. {
  615. _python_validate_useflags;
  616. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  617. MULTIBUILD_VARIANTS=(${PYTHON_COMPAT_OVERRIDE});
  618. return;
  619. fi;
  620. MULTIBUILD_VARIANTS=();
  621. local impl;
  622. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  623. do
  624. has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}" && MULTIBUILD_VARIANTS+=("${impl}");
  625. done
  626. }
  627. _python_set_impls ()
  628. {
  629. local i;
  630. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  631. die 'PYTHON_COMPAT not declared.';
  632. fi;
  633. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  634. die 'PYTHON_COMPAT must be an array.';
  635. fi;
  636. for i in "${PYTHON_COMPAT[@]}";
  637. do
  638. _python_impl_supported "${i}";
  639. done;
  640. local supp=() unsupp=();
  641. for i in "${_PYTHON_ALL_IMPLS[@]}";
  642. do
  643. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  644. supp+=("${i}");
  645. else
  646. unsupp+=("${i}");
  647. fi;
  648. done;
  649. if [[ ! -n ${supp[@]} ]]; then
  650. die "No supported implementation in PYTHON_COMPAT.";
  651. fi;
  652. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  653. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  654. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  655. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  656. eerror "Now : ${supp[*]}";
  657. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  658. fi;
  659. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  660. eerror "Unsupported impls changed between inherits!";
  661. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  662. eerror "Now : ${unsupp[*]}";
  663. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  664. fi;
  665. else
  666. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  667. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  668. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  669. fi
  670. }
  671. _python_validate_useflags ()
  672. {
  673. debug-print-function ${FUNCNAME} "${@}";
  674. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  675. if [[ ! -n ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
  676. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  677. ewarn "implementations will be enabled:";
  678. ewarn;
  679. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  680. ewarn;
  681. ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored.";
  682. _PYTHON_COMPAT_OVERRIDE_WARNED=1;
  683. fi;
  684. return;
  685. fi;
  686. local i;
  687. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  688. do
  689. use "python_targets_${i}" && return 0;
  690. done;
  691. eerror "No Python implementation selected for the build. Please add one";
  692. eerror "of the following values to your PYTHON_TARGETS (in make.conf):";
  693. eerror;
  694. eerror "${PYTHON_COMPAT[@]}";
  695. echo;
  696. die "No supported Python implementation in PYTHON_TARGETS."
  697. }
  698. _tc-getPROG ()
  699. {
  700. local tuple=$1;
  701. local v var vars=$2;
  702. local prog=($3);
  703. var=${vars%% *};
  704. for v in ${vars};
  705. do
  706. if [[ -n ${!v} ]]; then
  707. export ${var}="${!v}";
  708. echo "${!v}";
  709. return 0;
  710. fi;
  711. done;
  712. local search=;
  713. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  714. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  715. [[ -n ${search} ]] && prog[0]=${search##*/};
  716. export ${var}="${prog[*]}";
  717. echo "${!var}"
  718. }
  719. clang-fullversion ()
  720. {
  721. _clang_fullversion '$1.$2.$3' "$@"
  722. }
  723. clang-major-version ()
  724. {
  725. _clang_fullversion '$1' "$@"
  726. }
  727. clang-micro-version ()
  728. {
  729. _clang_fullversion '$3' "$@"
  730. }
  731. clang-minor-version ()
  732. {
  733. _clang_fullversion '$2' "$@"
  734. }
  735. clang-version ()
  736. {
  737. _clang_fullversion '$1.$2' "$@"
  738. }
  739. distutils-r1_python_compile ()
  740. {
  741. debug-print-function ${FUNCNAME} "${@}";
  742. _distutils-r1_copy_egg_info;
  743. local build_args=();
  744. if python_is_python3 && [[ ${EPYTHON} != python3.4 ]]; then
  745. if [[ ${EAPI} != [56] || ${EPYTHON} != python3.[56] ]]; then
  746. local jobs=$(makeopts_jobs "${MAKEOPTS}" INF);
  747. if [[ ${jobs} == INF ]]; then
  748. local nproc=$(get_nproc);
  749. jobs=$(( nproc + 1 ));
  750. fi;
  751. build_args+=(-j "${jobs}");
  752. fi;
  753. fi;
  754. esetup.py build "${build_args[@]}" "${@}"
  755. }
  756. distutils-r1_python_configure ()
  757. {
  758. debug-print-function ${FUNCNAME} "${@}";
  759. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI 6 (it was a no-op)"
  760. }
  761. distutils-r1_python_install ()
  762. {
  763. debug-print-function ${FUNCNAME} "${@}";
  764. local args=("${@}");
  765. local -x PYTHONDONTWRITEBYTECODE=;
  766. addpredict "${EPREFIX}/usr/$(get_libdir)/${EPYTHON}";
  767. addpredict /usr/lib/portage/pym;
  768. addpredict /usr/local;
  769. if [[ ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  770. local mydistutilsargs=("${mydistutilsargs[@]}");
  771. local scriptdir=${EPREFIX}/usr/bin;
  772. local arg arg_vars;
  773. [[ -n ${mydistutilsargs[@]} ]] && eval arg_vars+=('mydistutilsargs['{0..$(( ${#mydistutilsargs[@]} - 1 ))}']');
  774. [[ -n ${args[@]} ]] && eval arg_vars+=('args['{0..$(( ${#args[@]} - 1 ))}']');
  775. set -- "${arg_vars[@]}";
  776. while [[ -n ${@} ]]; do
  777. local arg_var=${1};
  778. shift;
  779. local a=${!arg_var};
  780. case "${a}" in
  781. --install-scripts=*)
  782. scriptdir=${a#--install-scripts=};
  783. unset "${arg_var}"
  784. ;;
  785. --install-scripts)
  786. scriptdir=${!1};
  787. unset "${arg_var}" "${1}";
  788. shift
  789. ;;
  790. esac;
  791. done;
  792. fi;
  793. local root=${D%/}/_${EPYTHON};
  794. [[ -n ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/};
  795. esetup.py install --root="${root}" "${args[@]}";
  796. local forbidden_package_names=(examples test tests);
  797. local p;
  798. for p in "${forbidden_package_names[@]}";
  799. do
  800. if [[ -d ${root}$(python_get_sitedir)/${p} ]]; then
  801. die "Package installs '${p}' package which is forbidden and likely a bug in the build system.";
  802. fi;
  803. done;
  804. if [[ -d ${root}/usr/$(get_libdir)/pypy/share ]]; then
  805. local cmd=die;
  806. [[ ${EAPI} == [45] ]] && cmd=eqawarn;
  807. "${cmd}" "Package installs 'share' in PyPy prefix, see bug #465546.";
  808. fi;
  809. if [[ ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  810. _distutils-r1_wrap_scripts "${root}" "${scriptdir}";
  811. multibuild_merge_root "${root}" "${D%/}";
  812. fi
  813. }
  814. distutils-r1_python_install_all ()
  815. {
  816. debug-print-function ${FUNCNAME} "${@}";
  817. einstalldocs;
  818. if declare -p EXAMPLES &> /dev/null; then
  819. [[ ${EAPI} != [45] ]] && die "EXAMPLES are banned in EAPI ${EAPI}";
  820. ( docinto examples;
  821. dodoc -r "${EXAMPLES[@]}" );
  822. docompress -x "/usr/share/doc/${PF}/examples";
  823. fi;
  824. _DISTUTILS_DEFAULT_CALLED=1
  825. }
  826. distutils-r1_python_prepare ()
  827. {
  828. debug-print-function ${FUNCNAME} "${@}";
  829. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI 6 (it was a no-op)"
  830. }
  831. distutils-r1_python_prepare_all ()
  832. {
  833. debug-print-function ${FUNCNAME} "${@}";
  834. if [[ ! -n ${DISTUTILS_OPTIONAL} ]]; then
  835. if [[ ${EAPI} != [45] ]]; then
  836. default;
  837. else
  838. [[ -n ${PATCHES} ]] && epatch "${PATCHES[@]}";
  839. epatch_user;
  840. fi;
  841. fi;
  842. if [[ ! -n ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
  843. if declare -f python_prepare > /dev/null; then
  844. DISTUTILS_IN_SOURCE_BUILD=1;
  845. fi;
  846. fi;
  847. _distutils-r1_disable_ez_setup;
  848. if [[ -n ${DISTUTILS_IN_SOURCE_BUILD} && ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  849. python_copy_sources;
  850. fi;
  851. _DISTUTILS_DEFAULT_CALLED=1
  852. }
  853. distutils-r1_run_phase ()
  854. {
  855. debug-print-function ${FUNCNAME} "${@}";
  856. if [[ -n ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
  857. if [[ ! -n ${DISTUTILS_SINGLE_IMPL} ]]; then
  858. cd "${BUILD_DIR}" || die;
  859. fi;
  860. local BUILD_DIR=${BUILD_DIR}/build;
  861. fi;
  862. local -x PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}";
  863. mkdir -p "${BUILD_DIR}/lib" || die;
  864. local -x AR=${AR} CC=${CC} CPP=${CPP} CXX=${CXX};
  865. tc-export AR CC CPP CXX;
  866. local ldopts;
  867. case "${CHOST}" in
  868. *-aix*)
  869. ldopts='-shared -Wl,-berok'
  870. ;;
  871. *-darwin*)
  872. ldopts='-bundle -undefined dynamic_lookup'
  873. ;;
  874. *)
  875. ldopts='-shared'
  876. ;;
  877. esac;
  878. local -x LDSHARED="${CC} ${ldopts}" LDCXXSHARED="${CXX} ${ldopts}";
  879. "${@}";
  880. cd "${_DISTUTILS_INITIAL_CWD}" || die
  881. }
  882. distutils-r1_src_compile ()
  883. {
  884. debug-print-function ${FUNCNAME} "${@}";
  885. if declare -f python_compile > /dev/null; then
  886. _distutils-r1_run_foreach_impl python_compile;
  887. else
  888. _distutils-r1_run_foreach_impl distutils-r1_python_compile;
  889. fi;
  890. if declare -f python_compile_all > /dev/null; then
  891. _distutils-r1_run_common_phase python_compile_all;
  892. fi
  893. }
  894. distutils-r1_src_configure ()
  895. {
  896. python_export_utf8_locale;
  897. [[ ${EAPI} == [56] ]] && xdg_environment_reset;
  898. if declare -f python_configure > /dev/null; then
  899. _distutils-r1_run_foreach_impl python_configure;
  900. fi;
  901. if declare -f python_configure_all > /dev/null; then
  902. _distutils-r1_run_common_phase python_configure_all;
  903. fi
  904. }
  905. distutils-r1_src_install ()
  906. {
  907. debug-print-function ${FUNCNAME} "${@}";
  908. if declare -f python_install > /dev/null; then
  909. _distutils-r1_run_foreach_impl python_install;
  910. else
  911. _distutils-r1_run_foreach_impl distutils-r1_python_install;
  912. fi;
  913. local _DISTUTILS_DEFAULT_CALLED;
  914. if declare -f python_install_all > /dev/null; then
  915. _distutils-r1_run_common_phase python_install_all;
  916. else
  917. _distutils-r1_run_common_phase distutils-r1_python_install_all;
  918. fi;
  919. if [[ ! -n ${_DISTUTILS_DEFAULT_CALLED} ]]; then
  920. local cmd=die;
  921. [[ ${EAPI} == [45] ]] && cmd=eqawarn;
  922. "${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all";
  923. fi;
  924. _distutils-r1_check_namespace_pth
  925. }
  926. distutils-r1_src_prepare ()
  927. {
  928. debug-print-function ${FUNCNAME} "${@}";
  929. local _DISTUTILS_DEFAULT_CALLED;
  930. if declare -f python_prepare_all > /dev/null; then
  931. python_prepare_all;
  932. else
  933. distutils-r1_python_prepare_all;
  934. fi;
  935. if [[ ! -n ${_DISTUTILS_DEFAULT_CALLED} ]]; then
  936. local cmd=die;
  937. [[ ${EAPI} == [45] ]] && cmd=eqawarn;
  938. "${cmd}" "QA: python_prepare_all() didn't call distutils-r1_python_prepare_all";
  939. fi;
  940. if declare -f python_prepare > /dev/null; then
  941. _distutils-r1_run_foreach_impl python_prepare;
  942. fi
  943. }
  944. distutils-r1_src_test ()
  945. {
  946. debug-print-function ${FUNCNAME} "${@}";
  947. if declare -f python_test > /dev/null; then
  948. _distutils-r1_run_foreach_impl python_test;
  949. _distutils-r1_run_foreach_impl _distutils-r1_clean_egg_info;
  950. fi;
  951. if declare -f python_test_all > /dev/null; then
  952. _distutils-r1_run_common_phase python_test_all;
  953. fi
  954. }
  955. distutils_get_intermediate_installation_image ()
  956. {
  957. die "${FUNCNAME}() is invalid for distutils-r1"
  958. }
  959. distutils_install_for_testing ()
  960. {
  961. debug-print-function ${FUNCNAME} "${@}";
  962. TEST_DIR=${BUILD_DIR}/test;
  963. local bindir=${TEST_DIR}/scripts;
  964. local libdir=${TEST_DIR}/lib;
  965. PYTHONPATH=${libdir}:${PYTHONPATH};
  966. local add_args=(install --home="${TEST_DIR}" --install-lib="${libdir}" --install-scripts="${bindir}");
  967. mkdir -p "${libdir}" || die;
  968. esetup.py "${add_args[@]}" "${@}"
  969. }
  970. distutils_pkg_postinst ()
  971. {
  972. die "${FUNCNAME}() is invalid for distutils-r1, and pkg_postinst is unnecessary"
  973. }
  974. distutils_pkg_postrm ()
  975. {
  976. die "${FUNCNAME}() is invalid for distutils-r1, and pkg_postrm is unnecessary"
  977. }
  978. distutils_src_compile ()
  979. {
  980. die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}"
  981. }
  982. distutils_src_install ()
  983. {
  984. die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}"
  985. }
  986. distutils_src_prepare ()
  987. {
  988. die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}"
  989. }
  990. distutils_src_test ()
  991. {
  992. die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}"
  993. }
  994. distutils_src_unpack ()
  995. {
  996. die "${FUNCNAME}() is invalid for distutils-r1, and you don't want it in EAPI ${EAPI} anyway"
  997. }
  998. eapply ()
  999. {
  1000. local failed patch_cmd=patch;
  1001. local -x LC_COLLATE=POSIX;
  1002. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1003. function _eapply_patch ()
  1004. {
  1005. local f=${1};
  1006. local prefix=${2};
  1007. started_applying=1;
  1008. ebegin "${prefix:-Applying }${f##*/}";
  1009. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1010. failed=${?};
  1011. if ! eend "${failed}"; then
  1012. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1013. fi
  1014. };
  1015. local patch_options=() files=();
  1016. local i found_doublehyphen;
  1017. for ((i = 1; i <= ${#@}; ++i ))
  1018. do
  1019. if [[ ${@:i:1} == -- ]]; then
  1020. patch_options=("${@:1:i-1}");
  1021. files=("${@:i+1}");
  1022. found_doublehyphen=1;
  1023. break;
  1024. fi;
  1025. done;
  1026. if [[ -z ${found_doublehyphen} ]]; then
  1027. for ((i = 1; i <= ${#@}; ++i ))
  1028. do
  1029. if [[ ${@:i:1} != -* ]]; then
  1030. patch_options=("${@:1:i-1}");
  1031. files=("${@:i}");
  1032. break;
  1033. fi;
  1034. done;
  1035. for i in "${files[@]}";
  1036. do
  1037. if [[ ${i} == -* ]]; then
  1038. die "eapply: all options must be passed before non-options";
  1039. fi;
  1040. done;
  1041. fi;
  1042. if [[ ${#files[@]} -eq 0 ]]; then
  1043. die "eapply: no files specified";
  1044. fi;
  1045. local f;
  1046. for f in "${files[@]}";
  1047. do
  1048. if [[ -d ${f} ]]; then
  1049. function _eapply_get_files ()
  1050. {
  1051. local LC_ALL=POSIX;
  1052. local prev_shopt=$(shopt -p nullglob);
  1053. shopt -s nullglob;
  1054. local f;
  1055. for f in "${1}"/*;
  1056. do
  1057. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1058. files+=("${f}");
  1059. fi;
  1060. done;
  1061. ${prev_shopt}
  1062. };
  1063. local files=();
  1064. _eapply_get_files "${f}";
  1065. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1066. einfo "Applying patches from ${f} ...";
  1067. local f2;
  1068. for f2 in "${files[@]}";
  1069. do
  1070. _eapply_patch "${f2}" ' ';
  1071. [[ ${failed} -ne 0 ]] && return "${failed}";
  1072. done;
  1073. else
  1074. _eapply_patch "${f}";
  1075. [[ ${failed} -ne 0 ]] && return "${failed}";
  1076. fi;
  1077. done;
  1078. return 0
  1079. }
  1080. eapply_user ()
  1081. {
  1082. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1083. local tagfile=${T}/.portage_user_patches_applied;
  1084. [[ -f ${tagfile} ]] && return;
  1085. >> "${tagfile}";
  1086. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1087. local applied d f;
  1088. local -A _eapply_user_patches;
  1089. local prev_shopt=$(shopt -p nullglob);
  1090. shopt -s nullglob;
  1091. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1092. do
  1093. for f in "${d}"/*;
  1094. do
  1095. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1096. _eapply_user_patches[${f##*/}]=${f};
  1097. fi;
  1098. done;
  1099. done;
  1100. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1101. while read -r -d '' f; do
  1102. f=${_eapply_user_patches[${f}]};
  1103. if [[ -s ${f} ]]; then
  1104. eapply "${f}";
  1105. applied=1;
  1106. fi;
  1107. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1108. LC_ALL=C sort -z);
  1109. fi;
  1110. ${prev_shopt};
  1111. [[ -n ${applied} ]] && ewarn "User patches applied."
  1112. }
  1113. ebeep ()
  1114. {
  1115. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1116. }
  1117. econf_build ()
  1118. {
  1119. local CBUILD=${CBUILD:-${CHOST}};
  1120. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1121. }
  1122. edos2unix ()
  1123. {
  1124. [[ $# -eq 0 ]] && return 0;
  1125. sed -i 's/\r$//' -- "$@" || die
  1126. }
  1127. einstalldocs ()
  1128. {
  1129. ( if ! declare -p DOCS &> /dev/null; then
  1130. local d;
  1131. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1132. do
  1133. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1134. done;
  1135. else
  1136. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1137. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1138. else
  1139. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1140. fi;
  1141. fi );
  1142. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1143. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1144. else
  1145. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1146. fi )
  1147. }
  1148. emktemp ()
  1149. {
  1150. local exe="touch";
  1151. [[ $1 == -d ]] && exe="mkdir" && shift;
  1152. local topdir=$1;
  1153. if [[ -z ${topdir} ]]; then
  1154. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1155. fi;
  1156. if ! type -P mktemp > /dev/null; then
  1157. local tmp=/;
  1158. while [[ -e ${tmp} ]]; do
  1159. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1160. done;
  1161. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1162. echo "${tmp}";
  1163. else
  1164. if [[ ${exe} == "touch" ]]; then
  1165. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1166. else
  1167. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1168. fi;
  1169. fi
  1170. }
  1171. epause ()
  1172. {
  1173. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1174. }
  1175. esetup.py ()
  1176. {
  1177. debug-print-function ${FUNCNAME} "${@}";
  1178. local die_args=();
  1179. [[ ${EAPI} != [45] ]] && die_args+=(-n);
  1180. [[ -n ${BUILD_DIR} ]] && _distutils-r1_create_setup_cfg;
  1181. set -- "${EPYTHON:-python}" setup.py "${mydistutilsargs[@]}" "${@}";
  1182. echo "${@}" 1>&2;
  1183. "${@}" || die "${die_args[@]}";
  1184. local ret=${?};
  1185. if [[ -n ${BUILD_DIR} ]]; then
  1186. rm "${HOME}"/.pydistutils.cfg || die "${die_args[@]}";
  1187. fi;
  1188. return ${ret}
  1189. }
  1190. gcc-fullversion ()
  1191. {
  1192. _gcc_fullversion '$1.$2.$3' "$@"
  1193. }
  1194. gcc-major-version ()
  1195. {
  1196. _gcc_fullversion '$1' "$@"
  1197. }
  1198. gcc-micro-version ()
  1199. {
  1200. _gcc_fullversion '$3' "$@"
  1201. }
  1202. gcc-minor-version ()
  1203. {
  1204. _gcc_fullversion '$2' "$@"
  1205. }
  1206. gcc-specs-directive ()
  1207. {
  1208. local directive subdname subdirective;
  1209. directive="$(_gcc-specs-directive_raw $1)";
  1210. while [[ ${directive} == *%\(*\)* ]]; do
  1211. subdname=${directive/*%\(};
  1212. subdname=${subdname/\)*};
  1213. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1214. directive="${directive//\%(${subdname})/${subdirective}}";
  1215. done;
  1216. echo "${directive}";
  1217. return 0
  1218. }
  1219. gcc-specs-nostrict ()
  1220. {
  1221. local directive;
  1222. directive=$(gcc-specs-directive cc1);
  1223. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1224. }
  1225. gcc-specs-now ()
  1226. {
  1227. local directive;
  1228. directive=$(gcc-specs-directive link_command);
  1229. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1230. }
  1231. gcc-specs-pie ()
  1232. {
  1233. local directive;
  1234. directive=$(gcc-specs-directive cc1);
  1235. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1236. }
  1237. gcc-specs-relro ()
  1238. {
  1239. local directive;
  1240. directive=$(gcc-specs-directive link_command);
  1241. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1242. }
  1243. gcc-specs-ssp ()
  1244. {
  1245. local directive;
  1246. directive=$(gcc-specs-directive cc1);
  1247. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1248. }
  1249. gcc-specs-ssp-to-all ()
  1250. {
  1251. local directive;
  1252. directive=$(gcc-specs-directive cc1);
  1253. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1254. }
  1255. gcc-specs-stack-check ()
  1256. {
  1257. local directive;
  1258. directive=$(gcc-specs-directive cc1);
  1259. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1260. }
  1261. gcc-version ()
  1262. {
  1263. _gcc_fullversion '$1.$2' "$@"
  1264. }
  1265. gen_usr_ldscript ()
  1266. {
  1267. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1268. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1269. tc-is-static-only && return;
  1270. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1271. multilib_is_native_abi || return 0;
  1272. fi;
  1273. case ${CTARGET:-${CHOST}} in
  1274. *-darwin*)
  1275. ;;
  1276. *-android*)
  1277. return 0
  1278. ;;
  1279. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1280. use prefix && return 0
  1281. ;;
  1282. *)
  1283. return 0
  1284. ;;
  1285. esac;
  1286. dodir /usr/${libdir};
  1287. if [[ $1 == "-a" ]]; then
  1288. auto=true;
  1289. shift;
  1290. dodir /${libdir};
  1291. fi;
  1292. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1293. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1294. local d="${T}/bfd-linker";
  1295. mkdir -p "${d}";
  1296. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1297. flags+=(-B"${d}");
  1298. fi;
  1299. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1300. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1301. for lib in "$@";
  1302. do
  1303. local tlib;
  1304. if ${auto}; then
  1305. lib="lib${lib}${suffix}";
  1306. else
  1307. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1308. fi;
  1309. case ${CTARGET:-${CHOST}} in
  1310. *-darwin*)
  1311. if ${auto}; then
  1312. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1313. else
  1314. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1315. fi;
  1316. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1317. tlib=${tlib##*/};
  1318. if ${auto}; then
  1319. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1320. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1321. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1322. fi;
  1323. rm -f "${ED}"/${libdir}/${lib};
  1324. fi;
  1325. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1326. chmod u+w "${ED}${libdir}/${tlib}";
  1327. local nowrite=yes;
  1328. fi;
  1329. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1330. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1331. pushd "${ED}/usr/${libdir}" > /dev/null;
  1332. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1333. popd > /dev/null
  1334. ;;
  1335. *)
  1336. if ${auto}; then
  1337. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1338. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1339. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1340. if [[ ${tlib} != ${lib}* ]]; then
  1341. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1342. fi;
  1343. rm -f "${ED}"/${libdir}/${lib};
  1344. else
  1345. tlib=${lib};
  1346. fi;
  1347. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1348. /* GNU ld script
  1349. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1350. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1351. run into linking problems. This "fake" dynamic lib is a linker script that
  1352. redirects the linker to the real lib. And yes, this works in the cross-
  1353. compiling scenario as the sysroot-ed linker will prepend the real path.
  1354. See bug https://bugs.gentoo.org/4411 for more info.
  1355. */
  1356. ${output_format}
  1357. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1358. END_LDSCRIPT
  1359. ;;
  1360. esac
  1361. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1362. done
  1363. }
  1364. get_abi_CFLAGS ()
  1365. {
  1366. get_abi_var CFLAGS "$@"
  1367. }
  1368. get_abi_CHOST ()
  1369. {
  1370. get_abi_var CHOST "$@"
  1371. }
  1372. get_abi_CTARGET ()
  1373. {
  1374. get_abi_var CTARGET "$@"
  1375. }
  1376. get_abi_FAKE_TARGETS ()
  1377. {
  1378. get_abi_var FAKE_TARGETS "$@"
  1379. }
  1380. get_abi_LDFLAGS ()
  1381. {
  1382. get_abi_var LDFLAGS "$@"
  1383. }
  1384. get_abi_LIBDIR ()
  1385. {
  1386. get_abi_var LIBDIR "$@"
  1387. }
  1388. get_abi_var ()
  1389. {
  1390. local flag=$1;
  1391. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1392. local var="${flag}_${abi}";
  1393. echo ${!var}
  1394. }
  1395. get_all_abis ()
  1396. {
  1397. local x order="" mvar dvar;
  1398. mvar="MULTILIB_ABIS";
  1399. dvar="DEFAULT_ABI";
  1400. if [[ -n $1 ]]; then
  1401. mvar="$1_${mvar}";
  1402. dvar="$1_${dvar}";
  1403. fi;
  1404. if [[ -z ${!mvar} ]]; then
  1405. echo "default";
  1406. return 0;
  1407. fi;
  1408. for x in ${!mvar};
  1409. do
  1410. if [[ ${x} != ${!dvar} ]]; then
  1411. order="${order:+${order} }${x}";
  1412. fi;
  1413. done;
  1414. order="${order:+${order} }${!dvar}";
  1415. echo ${order};
  1416. return 0
  1417. }
  1418. get_all_libdirs ()
  1419. {
  1420. local libdirs abi;
  1421. for abi in ${MULTILIB_ABIS};
  1422. do
  1423. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1424. done;
  1425. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1426. echo "${libdirs}"
  1427. }
  1428. get_exeext ()
  1429. {
  1430. case ${CHOST} in
  1431. *-cygwin* | mingw* | *-mingw*)
  1432. echo ".exe"
  1433. ;;
  1434. esac
  1435. }
  1436. get_install_abis ()
  1437. {
  1438. local x order="";
  1439. if [[ -z ${MULTILIB_ABIS} ]]; then
  1440. echo "default";
  1441. return 0;
  1442. fi;
  1443. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1444. for x in ${MULTILIB_ABIS};
  1445. do
  1446. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1447. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1448. fi;
  1449. done;
  1450. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1451. if [[ -n ${ABI_ALLOW} ]]; then
  1452. local ordera="";
  1453. for x in ${order};
  1454. do
  1455. if has ${x} ${ABI_ALLOW}; then
  1456. ordera="${ordera} ${x}";
  1457. fi;
  1458. done;
  1459. order=${ordera};
  1460. fi;
  1461. else
  1462. order=${DEFAULT_ABI};
  1463. fi;
  1464. if [[ -z ${order} ]]; then
  1465. 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.";
  1466. fi;
  1467. echo ${order};
  1468. return 0
  1469. }
  1470. get_libdir ()
  1471. {
  1472. local libdir_var="LIBDIR_${ABI}";
  1473. local libdir="lib";
  1474. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1475. echo "${libdir}"
  1476. }
  1477. get_libname ()
  1478. {
  1479. local libname;
  1480. local ver=$1;
  1481. case ${CHOST} in
  1482. *-cygwin*)
  1483. libname="dll.a"
  1484. ;;
  1485. mingw* | *-mingw*)
  1486. libname="dll"
  1487. ;;
  1488. *-darwin*)
  1489. libname="dylib"
  1490. ;;
  1491. *-mint*)
  1492. libname="irrelevant"
  1493. ;;
  1494. hppa*-hpux*)
  1495. libname="sl"
  1496. ;;
  1497. *)
  1498. libname="so"
  1499. ;;
  1500. esac;
  1501. if [[ -z $* ]]; then
  1502. echo ".${libname}";
  1503. else
  1504. for ver in "$@";
  1505. do
  1506. case ${CHOST} in
  1507. *-cygwin*)
  1508. echo ".${ver}.${libname}"
  1509. ;;
  1510. *-darwin*)
  1511. echo ".${ver}.${libname}"
  1512. ;;
  1513. *-mint*)
  1514. echo ".${libname}"
  1515. ;;
  1516. *)
  1517. echo ".${libname}.${ver}"
  1518. ;;
  1519. esac;
  1520. done;
  1521. fi
  1522. }
  1523. get_modname ()
  1524. {
  1525. local modname;
  1526. local ver=$1;
  1527. case ${CHOST} in
  1528. *-darwin*)
  1529. modname="bundle"
  1530. ;;
  1531. *)
  1532. modname="so"
  1533. ;;
  1534. esac;
  1535. echo ".${modname}"
  1536. }
  1537. get_nproc ()
  1538. {
  1539. local nproc;
  1540. if type -P nproc &> /dev/null; then
  1541. nproc=$(nproc);
  1542. fi;
  1543. if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  1544. nproc=$(sysctl -n hw.ncpu 2>/dev/null);
  1545. fi;
  1546. if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  1547. nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null);
  1548. fi;
  1549. if [[ -n ${nproc} ]]; then
  1550. echo "${nproc}";
  1551. else
  1552. echo "${1:-1}";
  1553. fi
  1554. }
  1555. has_multilib_profile ()
  1556. {
  1557. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1558. }
  1559. in_iuse ()
  1560. {
  1561. local use=${1};
  1562. if [[ -z "${use}" ]]; then
  1563. echo "!!! in_iuse() called without a parameter." 1>&2;
  1564. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1565. die "in_iuse() called without a parameter";
  1566. fi;
  1567. local liuse=(${IUSE_EFFECTIVE});
  1568. has "${use}" "${liuse[@]#[+-]}"
  1569. }
  1570. is_final_abi ()
  1571. {
  1572. has_multilib_profile || return 0;
  1573. set -- $(get_install_abis);
  1574. local LAST_ABI=$#;
  1575. [[ ${!LAST_ABI} == ${ABI} ]]
  1576. }
  1577. make_wrapper ()
  1578. {
  1579. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  1580. local tmpwrapper=$(emktemp);
  1581. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  1582. ( echo '#!/bin/sh';
  1583. if [[ -n ${libdir} ]]; then
  1584. local var;
  1585. if [[ ${CHOST} == *-darwin* ]]; then
  1586. var=DYLD_LIBRARY_PATH;
  1587. else
  1588. var=LD_LIBRARY_PATH;
  1589. fi;
  1590. cat <<-EOF
  1591. if [ "\${${var}+set}" = "set" ] ; then
  1592. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  1593. else
  1594. export ${var}="${EPREFIX}${libdir}"
  1595. fi
  1596. EOF
  1597. fi
  1598. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  1599. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  1600. chmod go+rx "${tmpwrapper}";
  1601. if [[ -n ${path} ]]; then
  1602. ( exeopts -m 0755;
  1603. exeinto "${path}";
  1604. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  1605. else
  1606. newbin "${tmpwrapper}" "${wrapper}" || die;
  1607. fi
  1608. }
  1609. makeopts_jobs ()
  1610. {
  1611. [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  1612. local jobs=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p");
  1613. echo ${jobs:-1}
  1614. }
  1615. makeopts_loadavg ()
  1616. {
  1617. [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  1618. 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");
  1619. echo ${lavg:-${2:-999}}
  1620. }
  1621. multibuild_copy_sources ()
  1622. {
  1623. debug-print-function ${FUNCNAME} "${@}";
  1624. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  1625. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  1626. local cp_args=();
  1627. if cp --reflink=auto --version &> /dev/null; then
  1628. cp_args+=(--reflink=auto);
  1629. fi;
  1630. function _multibuild_create_source_copy ()
  1631. {
  1632. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  1633. cp -p -R "${cp_args[@]}" "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  1634. };
  1635. multibuild_foreach_variant _multibuild_create_source_copy
  1636. }
  1637. multibuild_for_best_variant ()
  1638. {
  1639. debug-print-function ${FUNCNAME} "${@}";
  1640. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1641. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}");
  1642. multibuild_foreach_variant "${@}"
  1643. }
  1644. multibuild_foreach_variant ()
  1645. {
  1646. debug-print-function ${FUNCNAME} "${@}";
  1647. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1648. local bdir=${BUILD_DIR:-${S}};
  1649. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  1650. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  1651. local ret=0 lret=0 v;
  1652. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  1653. for v in "${MULTIBUILD_VARIANTS[@]}";
  1654. do
  1655. local MULTIBUILD_VARIANT=${v};
  1656. local MULTIBUILD_ID=${prev_id}${v};
  1657. local BUILD_DIR=${bdir%%/}-${v};
  1658. function _multibuild_run ()
  1659. {
  1660. local i=1;
  1661. while [[ ${!i} == _* ]]; do
  1662. (( i += 1 ));
  1663. done;
  1664. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  1665. "${@}"
  1666. };
  1667. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  1668. lret=${?};
  1669. done;
  1670. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  1671. return ${ret}
  1672. }
  1673. multibuild_merge_root ()
  1674. {
  1675. local src=${1};
  1676. local dest=${2};
  1677. local ret;
  1678. if use userland_BSD; then
  1679. tar -C "${src}" -f - -c . | tar -x -f - -C "${dest}";
  1680. [[ ${PIPESTATUS[*]} == '0 0' ]];
  1681. ret=${?};
  1682. else
  1683. local cp_args=();
  1684. if cp -a --version &> /dev/null; then
  1685. cp_args+=(-a);
  1686. else
  1687. cp_args+=(-P -R -p);
  1688. fi;
  1689. if cp --reflink=auto --version &> /dev/null; then
  1690. cp_args+=(--reflink=auto);
  1691. fi;
  1692. cp "${cp_args[@]}" "${src}"/. "${dest}"/;
  1693. ret=${?};
  1694. fi;
  1695. if [[ ${ret} -ne 0 ]]; then
  1696. die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
  1697. fi;
  1698. rm -rf "${src}"
  1699. }
  1700. multibuild_parallel_foreach_variant ()
  1701. {
  1702. debug-print-function ${FUNCNAME} "${@}";
  1703. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  1704. multibuild_foreach_variant "${@}"
  1705. }
  1706. multilib_env ()
  1707. {
  1708. local CTARGET=${1:-${CTARGET}};
  1709. local cpu=${CTARGET%%*-};
  1710. case ${cpu} in
  1711. aarch64*)
  1712. export CFLAGS_arm=${CFLAGS_arm-};
  1713. case ${cpu} in
  1714. aarch64*be)
  1715. export CHOST_arm="armv8b-${CTARGET#*-}"
  1716. ;;
  1717. *)
  1718. export CHOST_arm="armv8l-${CTARGET#*-}"
  1719. ;;
  1720. esac;
  1721. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1722. export CTARGET_arm=${CHOST_arm};
  1723. export LIBDIR_arm="lib";
  1724. export CFLAGS_arm64=${CFLAGS_arm64-};
  1725. export CHOST_arm64=${CTARGET};
  1726. export CTARGET_arm64=${CHOST_arm64};
  1727. export LIBDIR_arm64="lib64";
  1728. : ${MULTILIB_ABIS=arm64};
  1729. : ${DEFAULT_ABI=arm64}
  1730. ;;
  1731. x86_64*)
  1732. export CFLAGS_x86=${CFLAGS_x86--m32};
  1733. export CHOST_x86=${CTARGET/x86_64/i686};
  1734. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1735. export CTARGET_x86=${CHOST_x86};
  1736. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1737. export LIBDIR_x86="lib32";
  1738. else
  1739. export LIBDIR_x86="lib";
  1740. fi;
  1741. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1742. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1743. export CTARGET_amd64=${CHOST_amd64};
  1744. export LIBDIR_amd64="lib64";
  1745. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1746. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1747. export CTARGET_x32=${CHOST_x32};
  1748. export LIBDIR_x32="libx32";
  1749. case ${CTARGET} in
  1750. *-gnux32)
  1751. : ${MULTILIB_ABIS=x32 amd64 x86};
  1752. : ${DEFAULT_ABI=x32}
  1753. ;;
  1754. *)
  1755. : ${MULTILIB_ABIS=amd64 x86};
  1756. : ${DEFAULT_ABI=amd64}
  1757. ;;
  1758. esac
  1759. ;;
  1760. mips64* | mipsisa64*)
  1761. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1762. export CHOST_o32=${CTARGET/mips64/mips};
  1763. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  1764. export CTARGET_o32=${CHOST_o32};
  1765. export LIBDIR_o32="lib";
  1766. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1767. export CHOST_n32=${CTARGET};
  1768. export CTARGET_n32=${CHOST_n32};
  1769. export LIBDIR_n32="lib32";
  1770. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1771. export CHOST_n64=${CTARGET};
  1772. export CTARGET_n64=${CHOST_n64};
  1773. export LIBDIR_n64="lib64";
  1774. : ${MULTILIB_ABIS=n64 n32 o32};
  1775. : ${DEFAULT_ABI=n32}
  1776. ;;
  1777. powerpc64*)
  1778. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1779. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1780. export CTARGET_ppc=${CHOST_ppc};
  1781. export LIBDIR_ppc="lib";
  1782. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1783. export CHOST_ppc64=${CTARGET};
  1784. export CTARGET_ppc64=${CHOST_ppc64};
  1785. export LIBDIR_ppc64="lib64";
  1786. : ${MULTILIB_ABIS=ppc64 ppc};
  1787. : ${DEFAULT_ABI=ppc64}
  1788. ;;
  1789. s390x*)
  1790. export CFLAGS_s390=${CFLAGS_s390--m31};
  1791. export CHOST_s390=${CTARGET/s390x/s390};
  1792. export CTARGET_s390=${CHOST_s390};
  1793. export LIBDIR_s390="lib";
  1794. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1795. export CHOST_s390x=${CTARGET};
  1796. export CTARGET_s390x=${CHOST_s390x};
  1797. export LIBDIR_s390x="lib64";
  1798. : ${MULTILIB_ABIS=s390x s390};
  1799. : ${DEFAULT_ABI=s390x}
  1800. ;;
  1801. sparc64*)
  1802. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1803. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1804. export CTARGET_sparc32=${CHOST_sparc32};
  1805. export LIBDIR_sparc32="lib";
  1806. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1807. export CHOST_sparc64=${CTARGET};
  1808. export CTARGET_sparc64=${CHOST_sparc64};
  1809. export LIBDIR_sparc64="lib64";
  1810. : ${MULTILIB_ABIS=sparc64 sparc32};
  1811. : ${DEFAULT_ABI=sparc64}
  1812. ;;
  1813. *)
  1814. : ${MULTILIB_ABIS=default};
  1815. : ${DEFAULT_ABI=default}
  1816. ;;
  1817. esac;
  1818. export MULTILIB_ABIS DEFAULT_ABI
  1819. }
  1820. multilib_toolchain_setup ()
  1821. {
  1822. local v vv;
  1823. export ABI=$1;
  1824. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  1825. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1826. do
  1827. vv="_abi_saved_${v}";
  1828. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  1829. unset ${vv};
  1830. done;
  1831. unset _DEFAULT_ABI_SAVED;
  1832. fi;
  1833. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  1834. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1835. do
  1836. vv="_abi_saved_${v}";
  1837. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  1838. done;
  1839. export _DEFAULT_ABI_SAVED="true";
  1840. if [[ ${CBUILD} == "${CHOST}" ]]; then
  1841. export CBUILD=$(get_abi_CHOST $1);
  1842. fi;
  1843. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  1844. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  1845. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  1846. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  1847. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  1848. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  1849. export CHOST=$(get_abi_CHOST $1);
  1850. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  1851. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  1852. fi
  1853. }
  1854. number_abis ()
  1855. {
  1856. set -- `get_install_abis`;
  1857. echo $#
  1858. }
  1859. optfeature ()
  1860. {
  1861. debug-print-function ${FUNCNAME} "$@";
  1862. local i j msg;
  1863. local desc=$1;
  1864. local flag=0;
  1865. shift;
  1866. for i in "$@";
  1867. do
  1868. for j in ${i};
  1869. do
  1870. if has_version "${j}"; then
  1871. flag=1;
  1872. else
  1873. flag=0;
  1874. break;
  1875. fi;
  1876. done;
  1877. if [[ ${flag} -eq 1 ]]; then
  1878. break;
  1879. fi;
  1880. done;
  1881. if [[ ${flag} -eq 0 ]]; then
  1882. for i in "$@";
  1883. do
  1884. msg=" ";
  1885. for j in ${i};
  1886. do
  1887. msg+=" ${j} and";
  1888. done;
  1889. msg="${msg:0: -4} for ${desc}";
  1890. elog "${msg}";
  1891. done;
  1892. fi
  1893. }
  1894. path_exists ()
  1895. {
  1896. eerror "path_exists has been removed. Please see the following post";
  1897. eerror "for a replacement snippet:";
  1898. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  1899. die "path_exists is banned"
  1900. }
  1901. pkg_nofetch ()
  1902. {
  1903. default
  1904. }
  1905. python_abi_depend ()
  1906. {
  1907. die "${FUNCNAME}() is invalid for python-r1 suite"
  1908. }
  1909. python_byte-compile_modules ()
  1910. {
  1911. die "${FUNCNAME}() is invalid for python-r1 suite"
  1912. }
  1913. python_clean_byte-compiled_modules ()
  1914. {
  1915. die "${FUNCNAME}() is invalid for python-r1 suite"
  1916. }
  1917. python_clean_installation_image ()
  1918. {
  1919. die "${FUNCNAME}() is invalid for python-r1 suite"
  1920. }
  1921. python_clean_py-compile_files ()
  1922. {
  1923. die "${FUNCNAME}() is invalid for python-r1 suite"
  1924. }
  1925. python_compile_all ()
  1926. {
  1927. use doc && emake doc
  1928. }
  1929. python_convert_shebangs ()
  1930. {
  1931. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_convert_shebangs"
  1932. }
  1933. python_copy_sources ()
  1934. {
  1935. debug-print-function ${FUNCNAME} "${@}";
  1936. local MULTIBUILD_VARIANTS;
  1937. _python_obtain_impls;
  1938. multibuild_copy_sources
  1939. }
  1940. python_disable_pyc ()
  1941. {
  1942. die "${FUNCNAME}() is invalid for python-r1 suite"
  1943. }
  1944. python_doexe ()
  1945. {
  1946. debug-print-function ${FUNCNAME} "${@}";
  1947. local f;
  1948. for f in "$@";
  1949. do
  1950. python_newexe "${f}" "${f##*/}";
  1951. done
  1952. }
  1953. python_doheader ()
  1954. {
  1955. debug-print-function ${FUNCNAME} "${@}";
  1956. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1957. if [[ ${EAPI:-0} == [0123] ]]; then
  1958. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  1959. fi;
  1960. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  1961. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  1962. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  1963. ( insopts -m 0644;
  1964. insinto "${d}";
  1965. doins -r "${@}" || return ${?} )
  1966. }
  1967. python_domodule ()
  1968. {
  1969. debug-print-function ${FUNCNAME} "${@}";
  1970. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1971. if [[ ${EAPI:-0} == [0123] ]]; then
  1972. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  1973. fi;
  1974. local d;
  1975. if [[ ${python_moduleroot} == /* ]]; then
  1976. d=${python_moduleroot};
  1977. else
  1978. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  1979. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  1980. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  1981. fi;
  1982. ( insopts -m 0644;
  1983. insinto "${d}";
  1984. doins -r "${@}" || return ${?} );
  1985. python_optimize "${ED%/}/${d}"
  1986. }
  1987. python_doscript ()
  1988. {
  1989. debug-print-function ${FUNCNAME} "${@}";
  1990. local _PYTHON_REWRITE_SHEBANG=1;
  1991. python_doexe "${@}"
  1992. }
  1993. python_enable_pyc ()
  1994. {
  1995. die "${FUNCNAME}() is invalid for python-r1 suite"
  1996. }
  1997. python_execute_function ()
  1998. {
  1999. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_execute_function"
  2000. }
  2001. python_execute_nosetests ()
  2002. {
  2003. die "${FUNCNAME}() is invalid for python-r1 suite"
  2004. }
  2005. python_execute_py.test ()
  2006. {
  2007. die "${FUNCNAME}() is invalid for python-r1 suite"
  2008. }
  2009. python_execute_trial ()
  2010. {
  2011. die "${FUNCNAME}() is invalid for python-r1 suite"
  2012. }
  2013. python_export ()
  2014. {
  2015. debug-print-function ${FUNCNAME} "${@}";
  2016. local impl var;
  2017. case "${1}" in
  2018. python* | jython*)
  2019. impl=${1/_/.};
  2020. shift
  2021. ;;
  2022. pypy | pypy3)
  2023. impl=${1};
  2024. shift
  2025. ;;
  2026. *)
  2027. impl=${EPYTHON};
  2028. if [[ -z ${impl} ]]; then
  2029. die "python_export called without a python implementation and EPYTHON is unset";
  2030. fi
  2031. ;;
  2032. esac;
  2033. debug-print "${FUNCNAME}: implementation: ${impl}";
  2034. for var in "$@";
  2035. do
  2036. case "${var}" in
  2037. EPYTHON)
  2038. export EPYTHON=${impl};
  2039. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  2040. ;;
  2041. PYTHON)
  2042. export PYTHON=${EPREFIX}/usr/bin/${impl};
  2043. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  2044. ;;
  2045. PYTHON_SITEDIR)
  2046. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2047. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  2048. export PYTHON_SITEDIR;
  2049. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  2050. ;;
  2051. PYTHON_INCLUDEDIR)
  2052. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2053. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  2054. export PYTHON_INCLUDEDIR;
  2055. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  2056. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  2057. die "${impl} does not install any header files!";
  2058. fi
  2059. ;;
  2060. PYTHON_LIBPATH)
  2061. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2062. PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")') || die;
  2063. export PYTHON_LIBPATH;
  2064. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  2065. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  2066. die "${impl} lacks a (usable) dynamic library";
  2067. fi
  2068. ;;
  2069. PYTHON_CFLAGS)
  2070. local val;
  2071. case "${impl}" in
  2072. python*)
  2073. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  2074. ;;
  2075. *)
  2076. die "${impl}: obtaining ${var} not supported"
  2077. ;;
  2078. esac;
  2079. export PYTHON_CFLAGS=${val};
  2080. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  2081. ;;
  2082. PYTHON_LIBS)
  2083. local val;
  2084. case "${impl}" in
  2085. python*)
  2086. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  2087. ;;
  2088. *)
  2089. die "${impl}: obtaining ${var} not supported"
  2090. ;;
  2091. esac;
  2092. export PYTHON_LIBS=${val};
  2093. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  2094. ;;
  2095. PYTHON_CONFIG)
  2096. local flags val;
  2097. case "${impl}" in
  2098. python*)
  2099. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2100. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  2101. val=${PYTHON}${flags}-config
  2102. ;;
  2103. *)
  2104. die "${impl}: obtaining ${var} not supported"
  2105. ;;
  2106. esac;
  2107. export PYTHON_CONFIG=${val};
  2108. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  2109. ;;
  2110. PYTHON_PKG_DEP)
  2111. local d;
  2112. case ${impl} in
  2113. python2.7)
  2114. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  2115. ;;
  2116. python3.3)
  2117. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  2118. ;;
  2119. python*)
  2120. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  2121. ;;
  2122. pypy)
  2123. PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  2124. ;;
  2125. pypy3)
  2126. PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  2127. ;;
  2128. jython2.7)
  2129. PYTHON_PKG_DEP='dev-java/jython:2.7'
  2130. ;;
  2131. *)
  2132. die "Invalid implementation: ${impl}"
  2133. ;;
  2134. esac;
  2135. if [[ -n ${PYTHON_REQ_USE} ]]; then
  2136. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  2137. fi;
  2138. export PYTHON_PKG_DEP;
  2139. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  2140. ;;
  2141. PYTHON_SCRIPTDIR)
  2142. local dir;
  2143. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  2144. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  2145. ;;
  2146. *)
  2147. die "python_export: unknown variable ${var}"
  2148. ;;
  2149. esac;
  2150. done
  2151. }
  2152. python_export_best ()
  2153. {
  2154. debug-print-function ${FUNCNAME} "${@}";
  2155. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  2156. eqawarn "python_export_best() is deprecated. Please use python_setup instead,";
  2157. eqawarn "combined with python_export if necessary.";
  2158. [[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON;
  2159. local best MULTIBUILD_VARIANTS;
  2160. _python_obtain_impls;
  2161. function _python_set_best ()
  2162. {
  2163. best=${MULTIBUILD_VARIANT}
  2164. };
  2165. multibuild_for_best_variant _python_set_best;
  2166. unset -f _python_set_best;
  2167. debug-print "${FUNCNAME}: Best implementation is: ${best}";
  2168. python_export "${best}" "${@}";
  2169. python_wrapper_setup
  2170. }
  2171. python_export_utf8_locale ()
  2172. {
  2173. debug-print-function ${FUNCNAME} "${@}";
  2174. type locale > /dev/null || return 0;
  2175. if [[ $(locale charmap) != UTF-8 ]]; then
  2176. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  2177. for lang in ${locales};
  2178. do
  2179. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  2180. if _python_check_locale_sanity "${lang}"; then
  2181. export LC_CTYPE=${lang};
  2182. if [[ -n ${LC_ALL} ]]; then
  2183. export LC_NUMERIC=${LC_ALL};
  2184. export LC_TIME=${LC_ALL};
  2185. export LC_COLLATE=${LC_ALL};
  2186. export LC_MONETARY=${LC_ALL};
  2187. export LC_MESSAGES=${LC_ALL};
  2188. export LC_PAPER=${LC_ALL};
  2189. export LC_NAME=${LC_ALL};
  2190. export LC_ADDRESS=${LC_ALL};
  2191. export LC_TELEPHONE=${LC_ALL};
  2192. export LC_MEASUREMENT=${LC_ALL};
  2193. export LC_IDENTIFICATION=${LC_ALL};
  2194. export LC_ALL=;
  2195. fi;
  2196. return 0;
  2197. fi;
  2198. fi;
  2199. done;
  2200. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  2201. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  2202. ewarn "/etc/locale.gen and run locale-gen.";
  2203. return 1;
  2204. fi;
  2205. return 0
  2206. }
  2207. python_fix_shebang ()
  2208. {
  2209. debug-print-function ${FUNCNAME} "${@}";
  2210. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  2211. local force quiet;
  2212. while [[ -n ${@} ]]; do
  2213. case "${1}" in
  2214. -f | --force)
  2215. force=1;
  2216. shift
  2217. ;;
  2218. -q | --quiet)
  2219. quiet=1;
  2220. shift
  2221. ;;
  2222. --)
  2223. shift;
  2224. break
  2225. ;;
  2226. *)
  2227. break
  2228. ;;
  2229. esac;
  2230. done;
  2231. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  2232. local path f;
  2233. for path in "$@";
  2234. do
  2235. local any_correct any_fixed is_recursive;
  2236. [[ -d ${path} ]] && is_recursive=1;
  2237. while IFS= read -r -d '' f; do
  2238. local shebang i;
  2239. local error= from=;
  2240. IFS= read -r shebang < "${f}";
  2241. if [[ ${shebang} == '#!'* ]]; then
  2242. local split_shebang=();
  2243. read -r -a split_shebang <<< ${shebang} || die;
  2244. for i in "${split_shebang[@]}";
  2245. do
  2246. case "${i}" in
  2247. *"${EPYTHON}")
  2248. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  2249. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  2250. any_correct=1;
  2251. from=${EPYTHON};
  2252. break
  2253. ;;
  2254. *python | *python[23])
  2255. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  2256. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  2257. if [[ ${i} == *python2 ]]; then
  2258. from=python2;
  2259. if [[ ! -n ${force} ]]; then
  2260. python_is_python3 "${EPYTHON}" && error=1;
  2261. fi;
  2262. else
  2263. if [[ ${i} == *python3 ]]; then
  2264. from=python3;
  2265. if [[ ! -n ${force} ]]; then
  2266. python_is_python3 "${EPYTHON}" || error=1;
  2267. fi;
  2268. else
  2269. from=python;
  2270. fi;
  2271. fi;
  2272. break
  2273. ;;
  2274. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  2275. if [[ ! -n ${force} ]]; then
  2276. error=1;
  2277. else
  2278. case "${i}" in
  2279. *python[23].[0123456789])
  2280. from="python[23].[0123456789]"
  2281. ;;
  2282. *pypy)
  2283. from="pypy"
  2284. ;;
  2285. *pypy3)
  2286. from="pypy3"
  2287. ;;
  2288. *jython[23].[0123456789])
  2289. from="jython[23].[0123456789]"
  2290. ;;
  2291. *)
  2292. die "${FUNCNAME}: internal error in 2nd pattern match"
  2293. ;;
  2294. esac;
  2295. fi;
  2296. break
  2297. ;;
  2298. esac;
  2299. done;
  2300. fi;
  2301. if [[ ! -n ${error} && ! -n ${from} ]]; then
  2302. [[ -n ${is_recursive} ]] && continue;
  2303. error=1;
  2304. fi;
  2305. if [[ ! -n ${quiet} ]]; then
  2306. einfo "Fixing shebang in ${f#${D%/}}.";
  2307. fi;
  2308. if [[ ! -n ${error} ]]; then
  2309. if [[ ${shebang} == *${from}" "* ]]; then
  2310. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  2311. else
  2312. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  2313. fi;
  2314. any_fixed=1;
  2315. else
  2316. eerror "The file has incompatible shebang:";
  2317. eerror " file: ${f#${D%/}}";
  2318. eerror " current shebang: ${shebang}";
  2319. eerror " requested impl: ${EPYTHON}";
  2320. die "${FUNCNAME}: conversion of incompatible shebang requested";
  2321. fi;
  2322. done < <(find -H "${path}" -type f -print0 || die);
  2323. if [[ ! -n ${any_fixed} ]]; then
  2324. local cmd=eerror;
  2325. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  2326. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  2327. if [[ -n ${any_correct} ]]; then
  2328. "${cmd}" "All files have ${EPYTHON} shebang already.";
  2329. else
  2330. "${cmd}" "There are no Python files in specified directory.";
  2331. fi;
  2332. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  2333. fi;
  2334. done
  2335. }
  2336. python_foreach_impl ()
  2337. {
  2338. debug-print-function ${FUNCNAME} "${@}";
  2339. local MULTIBUILD_VARIANTS;
  2340. _python_obtain_impls;
  2341. multibuild_foreach_variant _python_multibuild_wrapper "${@}"
  2342. }
  2343. python_gen_any_dep ()
  2344. {
  2345. debug-print-function ${FUNCNAME} "${@}";
  2346. local depstr=${1};
  2347. [[ -n ${depstr} ]] || die "No dependency string provided";
  2348. shift;
  2349. local i PYTHON_PKG_DEP out=;
  2350. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2351. do
  2352. if _python_impl_matches "${i}" "${@-*}"; then
  2353. local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  2354. python_export "${i}" PYTHON_PKG_DEP;
  2355. local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  2356. out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}";
  2357. fi;
  2358. done;
  2359. echo "|| ( ${out})"
  2360. }
  2361. python_gen_cond_dep ()
  2362. {
  2363. debug-print-function ${FUNCNAME} "${@}";
  2364. local impl matches=();
  2365. local dep=${1};
  2366. shift;
  2367. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2368. do
  2369. if _python_impl_matches "${impl}" "${@}"; then
  2370. if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  2371. local usedep=$(python_gen_usedep "${@}");
  2372. dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  2373. fi;
  2374. matches+=("python_targets_${impl}? ( ${dep} )");
  2375. fi;
  2376. done;
  2377. echo "${matches[@]}"
  2378. }
  2379. python_gen_impl_dep ()
  2380. {
  2381. debug-print-function ${FUNCNAME} "${@}";
  2382. local impl matches=();
  2383. local PYTHON_REQ_USE=${1};
  2384. shift;
  2385. local patterns=("${@-*}");
  2386. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2387. do
  2388. if _python_impl_matches "${impl}" "${patterns[@]}"; then
  2389. local PYTHON_PKG_DEP;
  2390. python_export "${impl}" PYTHON_PKG_DEP;
  2391. matches+=("python_targets_${impl}? ( ${PYTHON_PKG_DEP} )");
  2392. fi;
  2393. done;
  2394. echo "${matches[@]}"
  2395. }
  2396. python_gen_usedep ()
  2397. {
  2398. debug-print-function ${FUNCNAME} "${@}";
  2399. local impl matches=();
  2400. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2401. do
  2402. if _python_impl_matches "${impl}" "${@}"; then
  2403. matches+=("python_targets_${impl}(-)?" "-python_single_target_${impl}(-)");
  2404. fi;
  2405. done;
  2406. [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  2407. local out=${matches[@]};
  2408. echo "${out// /,}"
  2409. }
  2410. python_gen_useflags ()
  2411. {
  2412. debug-print-function ${FUNCNAME} "${@}";
  2413. local impl matches=();
  2414. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2415. do
  2416. if _python_impl_matches "${impl}" "${@}"; then
  2417. matches+=("python_targets_${impl}");
  2418. fi;
  2419. done;
  2420. echo "${matches[@]}"
  2421. }
  2422. python_generate_cffi_modules ()
  2423. {
  2424. die "${FUNCNAME}() is invalid for python-r1 suite"
  2425. }
  2426. python_generate_wrapper_scripts ()
  2427. {
  2428. die "${FUNCNAME}() is invalid for python-r1 suite"
  2429. }
  2430. python_get_CFLAGS ()
  2431. {
  2432. debug-print-function ${FUNCNAME} "${@}";
  2433. python_export "${@}" PYTHON_CFLAGS;
  2434. echo "${PYTHON_CFLAGS}"
  2435. }
  2436. python_get_LIBS ()
  2437. {
  2438. debug-print-function ${FUNCNAME} "${@}";
  2439. python_export "${@}" PYTHON_LIBS;
  2440. echo "${PYTHON_LIBS}"
  2441. }
  2442. python_get_PYTHON_CONFIG ()
  2443. {
  2444. debug-print-function ${FUNCNAME} "${@}";
  2445. python_export "${@}" PYTHON_CONFIG;
  2446. echo "${PYTHON_CONFIG}"
  2447. }
  2448. python_get_extension_module_suffix ()
  2449. {
  2450. die "${FUNCNAME}() is invalid for python-r1 suite"
  2451. }
  2452. python_get_implementation ()
  2453. {
  2454. die "${FUNCNAME}() is invalid for python-r1 suite"
  2455. }
  2456. python_get_implementation_and_version ()
  2457. {
  2458. die "${FUNCNAME}() is invalid for python-r1 suite"
  2459. }
  2460. python_get_implementational_package ()
  2461. {
  2462. die "${FUNCNAME}() is invalid for python-r1 suite"
  2463. }
  2464. python_get_includedir ()
  2465. {
  2466. debug-print-function ${FUNCNAME} "${@}";
  2467. python_export "${@}" PYTHON_INCLUDEDIR;
  2468. echo "${PYTHON_INCLUDEDIR}"
  2469. }
  2470. python_get_libdir ()
  2471. {
  2472. die "${FUNCNAME}() is invalid for python-r1 suite"
  2473. }
  2474. python_get_library ()
  2475. {
  2476. die "${FUNCNAME}() is invalid for python-r1 suite"
  2477. }
  2478. python_get_library_path ()
  2479. {
  2480. debug-print-function ${FUNCNAME} "${@}";
  2481. python_export "${@}" PYTHON_LIBPATH;
  2482. echo "${PYTHON_LIBPATH}"
  2483. }
  2484. python_get_scriptdir ()
  2485. {
  2486. debug-print-function ${FUNCNAME} "${@}";
  2487. python_export "${@}" PYTHON_SCRIPTDIR;
  2488. echo "${PYTHON_SCRIPTDIR}"
  2489. }
  2490. python_get_sitedir ()
  2491. {
  2492. debug-print-function ${FUNCNAME} "${@}";
  2493. python_export "${@}" PYTHON_SITEDIR;
  2494. echo "${PYTHON_SITEDIR}"
  2495. }
  2496. python_get_version ()
  2497. {
  2498. die "${FUNCNAME}() is invalid for python-r1 suite"
  2499. }
  2500. python_install_all ()
  2501. {
  2502. use doc && local HTML_DOCS=(doc/html/.);
  2503. distutils-r1_python_install_all
  2504. }
  2505. python_install_executables ()
  2506. {
  2507. die "${FUNCNAME}() is invalid for python-r1 suite"
  2508. }
  2509. python_is_installed ()
  2510. {
  2511. local impl=${1:-${EPYTHON}};
  2512. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  2513. local hasv_args=();
  2514. case ${EAPI:-0} in
  2515. 0 | 1 | 2 | 3 | 4)
  2516. local -x ROOT=/
  2517. ;;
  2518. 5 | 6)
  2519. hasv_args+=(--host-root)
  2520. ;;
  2521. *)
  2522. hasv_args+=(-b)
  2523. ;;
  2524. esac;
  2525. case "${impl}" in
  2526. pypy | pypy3)
  2527. local append=;
  2528. if [[ -n ${PYTHON_REQ_USE} ]]; then
  2529. append=[${PYTHON_REQ_USE}];
  2530. fi;
  2531. has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  2532. ;;
  2533. *)
  2534. local PYTHON_PKG_DEP;
  2535. python_export "${impl}" PYTHON_PKG_DEP;
  2536. has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  2537. ;;
  2538. esac
  2539. }
  2540. python_is_python3 ()
  2541. {
  2542. local impl=${1:-${EPYTHON}};
  2543. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  2544. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  2545. }
  2546. python_merge_intermediate_installation_images ()
  2547. {
  2548. die "${FUNCNAME}() is invalid for python-r1 suite"
  2549. }
  2550. python_mod_cleanup ()
  2551. {
  2552. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  2553. }
  2554. python_mod_optimize ()
  2555. {
  2556. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  2557. }
  2558. python_moduleinto ()
  2559. {
  2560. debug-print-function ${FUNCNAME} "${@}";
  2561. python_moduleroot=${1}
  2562. }
  2563. python_need_rebuild ()
  2564. {
  2565. die "${FUNCNAME}() is invalid for python-r1 suite"
  2566. }
  2567. python_newexe ()
  2568. {
  2569. debug-print-function ${FUNCNAME} "${@}";
  2570. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2571. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  2572. if [[ ${EAPI:-0} == [0123] ]]; then
  2573. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2574. fi;
  2575. local wrapd=${python_scriptroot:-/usr/bin};
  2576. local f=${1};
  2577. local newfn=${2};
  2578. local PYTHON_SCRIPTDIR d;
  2579. python_export PYTHON_SCRIPTDIR;
  2580. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  2581. ( dodir "${wrapd}";
  2582. exeopts -m 0755;
  2583. exeinto "${d}";
  2584. newexe "${f}" "${newfn}" || return ${?} );
  2585. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  2586. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  2587. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  2588. fi
  2589. }
  2590. python_newscript ()
  2591. {
  2592. debug-print-function ${FUNCNAME} "${@}";
  2593. local _PYTHON_REWRITE_SHEBANG=1;
  2594. python_newexe "${@}"
  2595. }
  2596. python_optimize ()
  2597. {
  2598. debug-print-function ${FUNCNAME} "${@}";
  2599. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  2600. eerror "The new Python eclasses expect the compiled Python files to";
  2601. eerror "be controlled by the Package Manager. For this reason,";
  2602. eerror "the python_optimize function can be used only during src_* phases";
  2603. eerror "(src_install most commonly) and not during pkg_* phases.";
  2604. echo;
  2605. die "python_optimize is not to be used in pre/post* phases";
  2606. fi;
  2607. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2608. local PYTHON=${PYTHON};
  2609. [[ -n ${PYTHON} ]] || python_export PYTHON;
  2610. if [[ ${#} -eq 0 ]]; then
  2611. local f;
  2612. while IFS= read -r -d '' f; do
  2613. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  2614. set -- "${D%/}${f}" "${@}";
  2615. fi;
  2616. done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  2617. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  2618. fi;
  2619. local d;
  2620. for d in "$@";
  2621. do
  2622. local instpath=${d#${D%/}};
  2623. instpath=/${instpath##/};
  2624. case "${EPYTHON}" in
  2625. python2.7 | python3.[34])
  2626. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  2627. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  2628. ;;
  2629. python* | pypy3)
  2630. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  2631. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  2632. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  2633. ;;
  2634. *)
  2635. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  2636. ;;
  2637. esac;
  2638. done
  2639. }
  2640. python_pkg_setup ()
  2641. {
  2642. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  2643. }
  2644. python_prepare_all ()
  2645. {
  2646. sed -i -e 's:, "-Werror"::' setup.py || die;
  2647. sed -e "s:html_theme = 'default':html_theme = 'classic':" -i doc/conf.py || die;
  2648. distutils-r1_python_prepare_all
  2649. }
  2650. python_replicate_script ()
  2651. {
  2652. debug-print-function ${FUNCNAME} "${@}";
  2653. function _python_replicate_script ()
  2654. {
  2655. local _PYTHON_FIX_SHEBANG_QUIET=1;
  2656. local PYTHON_SCRIPTDIR;
  2657. python_export PYTHON_SCRIPTDIR;
  2658. ( exeopts -m 0755;
  2659. exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}";
  2660. doexe "${files[@]}" );
  2661. python_fix_shebang -q "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
  2662. };
  2663. local files=("${@}");
  2664. python_foreach_impl _python_replicate_script;
  2665. unset -f _python_replicate_script;
  2666. local f;
  2667. for f in "$@";
  2668. do
  2669. _python_ln_rel "${ED%/}/usr/lib/python-exec/python-exec2" "${f}" || die;
  2670. done
  2671. }
  2672. python_scriptinto ()
  2673. {
  2674. debug-print-function ${FUNCNAME} "${@}";
  2675. python_scriptroot=${1}
  2676. }
  2677. python_set_active_version ()
  2678. {
  2679. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  2680. }
  2681. python_setup ()
  2682. {
  2683. debug-print-function ${FUNCNAME} "${@}";
  2684. _python_validate_useflags;
  2685. local pycompat=("${PYTHON_COMPAT[@]}");
  2686. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  2687. pycompat=(${PYTHON_COMPAT_OVERRIDE});
  2688. fi;
  2689. local has_check_deps;
  2690. declare -f python_check_deps > /dev/null && has_check_deps=1;
  2691. local found;
  2692. for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  2693. do
  2694. local impl=${_PYTHON_SUPPORTED_IMPLS[i]};
  2695. has "${impl}" "${pycompat[@]}" || continue;
  2696. if [[ ! -n ${PYTHON_COMPAT_OVERRIDE} && ! -n ${has_check_deps} ]]; then
  2697. use "python_targets_${impl}" || continue;
  2698. fi;
  2699. _python_impl_matches "${impl}" "${@-*}" || continue;
  2700. python_export "${impl}" EPYTHON PYTHON;
  2701. if [[ -n ${has_check_deps} ]]; then
  2702. python_is_installed "${impl}" || continue;
  2703. local PYTHON_USEDEP="python_targets_${impl}(-),python_single_target_${impl}(+)";
  2704. python_check_deps || continue;
  2705. fi;
  2706. found=1;
  2707. break;
  2708. done;
  2709. if [[ ! -n ${found} ]]; then
  2710. eerror "${FUNCNAME}: none of the enabled implementation matched the patterns.";
  2711. eerror " patterns: ${@-'(*)'}";
  2712. eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing.";
  2713. eerror " suggested: || ( \$(python_gen_useflags ${@}) )";
  2714. eerror "(remember to quote all the patterns with '')";
  2715. die "${FUNCNAME}: no enabled implementation satisfy requirements";
  2716. fi;
  2717. python_wrapper_setup
  2718. }
  2719. python_test ()
  2720. {
  2721. nosetests -v || die "Tests fail with ${EPYTHON}"
  2722. }
  2723. python_wrapper_setup ()
  2724. {
  2725. debug-print-function ${FUNCNAME} "${@}";
  2726. local workdir=${1:-${T}/${EPYTHON}};
  2727. local impl=${2:-${EPYTHON}};
  2728. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  2729. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  2730. if [[ ! -x ${workdir}/bin/python ]]; then
  2731. _python_check_dead_variables;
  2732. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  2733. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  2734. rm -f "${workdir}"/bin/2to3 || die;
  2735. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  2736. local EPYTHON PYTHON;
  2737. python_export "${impl}" EPYTHON PYTHON;
  2738. local pyver pyother;
  2739. if python_is_python3; then
  2740. pyver=3;
  2741. pyother=2;
  2742. else
  2743. pyver=2;
  2744. pyother=3;
  2745. fi;
  2746. cat > "${workdir}/bin/python" <<-_EOF_ ||
  2747. #!/bin/sh
  2748. exec "${PYTHON}" "\${@}"
  2749. _EOF_
  2750. die
  2751. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2752. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2753. local nonsupp=("python${pyother}" "python${pyother}-config");
  2754. if [[ ${EPYTHON} == python* ]]; then
  2755. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  2756. #!/bin/sh
  2757. exec "${PYTHON}-config" "\${@}"
  2758. _EOF_
  2759. die
  2760. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2761. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2762. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  2763. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  2764. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  2765. else
  2766. nonsupp+=(2to3 python-config "python${pyver}-config");
  2767. fi;
  2768. local x;
  2769. for x in "${nonsupp[@]}";
  2770. do
  2771. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  2772. #!/bin/sh
  2773. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  2774. exit 127
  2775. _EOF_
  2776. die
  2777. chmod +x "${workdir}"/bin/${x} || die;
  2778. done;
  2779. fi;
  2780. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  2781. PATH=${workdir}/bin${PATH:+:${PATH}};
  2782. fi;
  2783. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  2784. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  2785. fi;
  2786. export PATH PKG_CONFIG_PATH
  2787. }
  2788. run_in_build_dir ()
  2789. {
  2790. debug-print-function ${FUNCNAME} "${@}";
  2791. local ret;
  2792. [[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified.";
  2793. [[ -n ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set.";
  2794. mkdir -p "${BUILD_DIR}" || die;
  2795. pushd "${BUILD_DIR}" > /dev/null || die;
  2796. "${@}";
  2797. ret=${?};
  2798. popd > /dev/null || die;
  2799. return ${ret}
  2800. }
  2801. src_compile ()
  2802. {
  2803. distutils-r1_src_compile "$@"
  2804. }
  2805. src_configure ()
  2806. {
  2807. distutils-r1_src_configure "$@"
  2808. }
  2809. src_install ()
  2810. {
  2811. distutils-r1_src_install "$@"
  2812. }
  2813. src_prepare ()
  2814. {
  2815. distutils-r1_src_prepare "$@"
  2816. }
  2817. src_test ()
  2818. {
  2819. local -x TEST_DIR="${TEST_DIR:-/var/tmp}";
  2820. local -x TEST_IGNORE_XATTRS="${TEST_IGNORE_XATTRS:-security.selinux}";
  2821. einfo "Please note that the tests fail if xattrs are not supported";
  2822. einfo "by the filesystem used for ${TEST_DIR}.";
  2823. einfo;
  2824. einfo "The location for tests can be overriden using TEST_DIR variable:";
  2825. einfo " $ export TEST_DIR=/my/test/place";
  2826. einfo;
  2827. einfo "Additionally, TEST_IGNORE_XATTRS can be set to control which";
  2828. einfo "external attributes are ignored by the tests.";
  2829. einfo "See https://bugs.gentoo.org/503946 for details.";
  2830. einfo;
  2831. distutils-r1_src_test
  2832. }
  2833. src_unpack ()
  2834. {
  2835. default
  2836. }
  2837. strip-linguas ()
  2838. {
  2839. local ls newls nols;
  2840. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2841. local op=$1;
  2842. shift;
  2843. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2844. shift;
  2845. local d f;
  2846. for d in "$@";
  2847. do
  2848. if [[ ${op} == "-u" ]]; then
  2849. newls=${ls};
  2850. else
  2851. newls="";
  2852. fi;
  2853. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2854. do
  2855. if [[ ${op} == "-i" ]]; then
  2856. has ${f} ${ls} && newls="${newls} ${f}";
  2857. else
  2858. has ${f} ${ls} || newls="${newls} ${f}";
  2859. fi;
  2860. done;
  2861. ls=${newls};
  2862. done;
  2863. else
  2864. ls="$@";
  2865. fi;
  2866. nols="";
  2867. newls="";
  2868. for f in ${LINGUAS};
  2869. do
  2870. if has ${f} ${ls}; then
  2871. newls="${newls} ${f}";
  2872. else
  2873. nols="${nols} ${f}";
  2874. fi;
  2875. done;
  2876. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2877. export LINGUAS=${newls:1}
  2878. }
  2879. tc-arch ()
  2880. {
  2881. tc-ninja_magic_to_arch portage "$@"
  2882. }
  2883. tc-arch-kernel ()
  2884. {
  2885. tc-ninja_magic_to_arch kern "$@"
  2886. }
  2887. tc-check-openmp ()
  2888. {
  2889. if ! tc-has-openmp; then
  2890. eerror "Your current compiler does not support OpenMP!";
  2891. if tc-is-gcc; then
  2892. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  2893. else
  2894. if tc-is-clang; then
  2895. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  2896. fi;
  2897. fi;
  2898. die "Active compiler does not have required support for OpenMP";
  2899. fi
  2900. }
  2901. tc-cpp-is-true ()
  2902. {
  2903. local CONDITION=${1};
  2904. shift;
  2905. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  2906. #if ${CONDITION}
  2907. true
  2908. #endif
  2909. EOF
  2910. );
  2911. [[ ${RESULT} == true ]]
  2912. }
  2913. tc-detect-is-softfloat ()
  2914. {
  2915. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  2916. case ${CTARGET:-${CHOST}} in
  2917. *-newlib | *-elf | *-eabi)
  2918. return 1
  2919. ;;
  2920. arm*)
  2921. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  2922. echo "no";
  2923. else
  2924. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  2925. echo "yes";
  2926. else
  2927. echo "softfp";
  2928. fi;
  2929. fi;
  2930. return 0
  2931. ;;
  2932. *)
  2933. return 1
  2934. ;;
  2935. esac
  2936. }
  2937. tc-enables-pie ()
  2938. {
  2939. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  2940. }
  2941. tc-enables-ssp ()
  2942. {
  2943. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2944. }
  2945. tc-enables-ssp-all ()
  2946. {
  2947. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2948. }
  2949. tc-enables-ssp-strong ()
  2950. {
  2951. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2952. }
  2953. tc-endian ()
  2954. {
  2955. local host=$1;
  2956. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2957. host=${host%%-*};
  2958. case ${host} in
  2959. aarch64*be)
  2960. echo big
  2961. ;;
  2962. aarch64)
  2963. echo little
  2964. ;;
  2965. alpha*)
  2966. echo little
  2967. ;;
  2968. arm*b*)
  2969. echo big
  2970. ;;
  2971. arm*)
  2972. echo little
  2973. ;;
  2974. cris*)
  2975. echo little
  2976. ;;
  2977. hppa*)
  2978. echo big
  2979. ;;
  2980. i?86*)
  2981. echo little
  2982. ;;
  2983. ia64*)
  2984. echo little
  2985. ;;
  2986. m68*)
  2987. echo big
  2988. ;;
  2989. mips*l*)
  2990. echo little
  2991. ;;
  2992. mips*)
  2993. echo big
  2994. ;;
  2995. powerpc*le)
  2996. echo little
  2997. ;;
  2998. powerpc*)
  2999. echo big
  3000. ;;
  3001. s390*)
  3002. echo big
  3003. ;;
  3004. sh*b*)
  3005. echo big
  3006. ;;
  3007. sh*)
  3008. echo little
  3009. ;;
  3010. sparc*)
  3011. echo big
  3012. ;;
  3013. x86_64*)
  3014. echo little
  3015. ;;
  3016. *)
  3017. echo wtf
  3018. ;;
  3019. esac
  3020. }
  3021. tc-env_build ()
  3022. {
  3023. tc-export_build_env;
  3024. 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) "$@"
  3025. }
  3026. tc-export ()
  3027. {
  3028. local var;
  3029. for var in "$@";
  3030. do
  3031. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3032. "tc-get${var}" > /dev/null;
  3033. done
  3034. }
  3035. tc-export_build_env ()
  3036. {
  3037. tc-export "$@";
  3038. if tc-is-cross-compiler; then
  3039. : ${BUILD_CFLAGS:=-O1 -pipe};
  3040. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  3041. : ${BUILD_CPPFLAGS:= };
  3042. : ${BUILD_LDFLAGS:= };
  3043. else
  3044. : ${BUILD_CFLAGS:=${CFLAGS}};
  3045. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  3046. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  3047. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  3048. fi;
  3049. export BUILD_{C,CXX,CPP,LD}FLAGS;
  3050. local v;
  3051. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  3052. do
  3053. export ${v#BUILD_}_FOR_BUILD="${!v}";
  3054. done
  3055. }
  3056. tc-get-compiler-type ()
  3057. {
  3058. local code='
  3059. #if defined(__PATHSCALE__)
  3060. HAVE_PATHCC
  3061. #elif defined(__clang__)
  3062. HAVE_CLANG
  3063. #elif defined(__GNUC__)
  3064. HAVE_GCC
  3065. #endif
  3066. ';
  3067. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  3068. case ${res} in
  3069. *HAVE_PATHCC*)
  3070. echo pathcc
  3071. ;;
  3072. *HAVE_CLANG*)
  3073. echo clang
  3074. ;;
  3075. *HAVE_GCC*)
  3076. echo gcc
  3077. ;;
  3078. *)
  3079. echo unknown
  3080. ;;
  3081. esac
  3082. }
  3083. tc-getAR ()
  3084. {
  3085. tc-getPROG AR ar "$@"
  3086. }
  3087. tc-getAS ()
  3088. {
  3089. tc-getPROG AS as "$@"
  3090. }
  3091. tc-getBUILD_AR ()
  3092. {
  3093. tc-getBUILD_PROG AR ar "$@"
  3094. }
  3095. tc-getBUILD_AS ()
  3096. {
  3097. tc-getBUILD_PROG AS as "$@"
  3098. }
  3099. tc-getBUILD_CC ()
  3100. {
  3101. tc-getBUILD_PROG CC gcc "$@"
  3102. }
  3103. tc-getBUILD_CPP ()
  3104. {
  3105. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  3106. }
  3107. tc-getBUILD_CXX ()
  3108. {
  3109. tc-getBUILD_PROG CXX g++ "$@"
  3110. }
  3111. tc-getBUILD_LD ()
  3112. {
  3113. tc-getBUILD_PROG LD ld "$@"
  3114. }
  3115. tc-getBUILD_NM ()
  3116. {
  3117. tc-getBUILD_PROG NM nm "$@"
  3118. }
  3119. tc-getBUILD_OBJCOPY ()
  3120. {
  3121. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3122. }
  3123. tc-getBUILD_PKG_CONFIG ()
  3124. {
  3125. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3126. }
  3127. tc-getBUILD_PROG ()
  3128. {
  3129. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  3130. tc-is-cross-compiler || vars+=" $1";
  3131. _tc-getPROG CBUILD "${vars}" "${@:2}"
  3132. }
  3133. tc-getBUILD_RANLIB ()
  3134. {
  3135. tc-getBUILD_PROG RANLIB ranlib "$@"
  3136. }
  3137. tc-getBUILD_STRIP ()
  3138. {
  3139. tc-getBUILD_PROG STRIP strip "$@"
  3140. }
  3141. tc-getCC ()
  3142. {
  3143. tc-getPROG CC gcc "$@"
  3144. }
  3145. tc-getCPP ()
  3146. {
  3147. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  3148. }
  3149. tc-getCXX ()
  3150. {
  3151. tc-getPROG CXX g++ "$@"
  3152. }
  3153. tc-getDLLWRAP ()
  3154. {
  3155. tc-getPROG DLLWRAP dllwrap "$@"
  3156. }
  3157. tc-getF77 ()
  3158. {
  3159. tc-getPROG F77 gfortran "$@"
  3160. }
  3161. tc-getFC ()
  3162. {
  3163. tc-getPROG FC gfortran "$@"
  3164. }
  3165. tc-getGCJ ()
  3166. {
  3167. tc-getPROG GCJ gcj "$@"
  3168. }
  3169. tc-getGO ()
  3170. {
  3171. tc-getPROG GO gccgo "$@"
  3172. }
  3173. tc-getLD ()
  3174. {
  3175. tc-getPROG LD ld "$@"
  3176. }
  3177. tc-getNM ()
  3178. {
  3179. tc-getPROG NM nm "$@"
  3180. }
  3181. tc-getOBJCOPY ()
  3182. {
  3183. tc-getPROG OBJCOPY objcopy "$@"
  3184. }
  3185. tc-getOBJDUMP ()
  3186. {
  3187. tc-getPROG OBJDUMP objdump "$@"
  3188. }
  3189. tc-getPKG_CONFIG ()
  3190. {
  3191. tc-getPROG PKG_CONFIG pkg-config "$@"
  3192. }
  3193. tc-getPROG ()
  3194. {
  3195. _tc-getPROG CHOST "$@"
  3196. }
  3197. tc-getRANLIB ()
  3198. {
  3199. tc-getPROG RANLIB ranlib "$@"
  3200. }
  3201. tc-getRC ()
  3202. {
  3203. tc-getPROG RC windres "$@"
  3204. }
  3205. tc-getSTRIP ()
  3206. {
  3207. tc-getPROG STRIP strip "$@"
  3208. }
  3209. tc-getTARGET_CPP ()
  3210. {
  3211. if [[ -n ${CTARGET} ]]; then
  3212. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  3213. else
  3214. tc-getCPP "$@";
  3215. fi
  3216. }
  3217. tc-has-openmp ()
  3218. {
  3219. local base="${T}/test-tc-openmp";
  3220. cat > "${base}.c" <<-EOF
  3221. #include <omp.h>
  3222. int main() {
  3223. int nthreads, tid, ret = 0;
  3224. #pragma omp parallel private(nthreads, tid)
  3225. {
  3226. tid = omp_get_thread_num();
  3227. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3228. }
  3229. return ret;
  3230. }
  3231. EOF
  3232. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  3233. local ret=$?;
  3234. rm -f "${base}"*;
  3235. return ${ret}
  3236. }
  3237. tc-has-tls ()
  3238. {
  3239. local base="${T}/test-tc-tls";
  3240. cat > "${base}.c" <<-EOF
  3241. int foo(int *i) {
  3242. static __thread int j = 0;
  3243. return *i ? j : *i;
  3244. }
  3245. EOF
  3246. local flags;
  3247. case $1 in
  3248. -s)
  3249. flags="-S"
  3250. ;;
  3251. -c)
  3252. flags="-c"
  3253. ;;
  3254. -l)
  3255. ;;
  3256. -*)
  3257. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3258. ;;
  3259. esac;
  3260. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3261. [[ $1 == -* ]] && shift;
  3262. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  3263. local ret=$?;
  3264. rm -f "${base}"*;
  3265. return ${ret}
  3266. }
  3267. tc-is-clang ()
  3268. {
  3269. [[ $(tc-get-compiler-type) == clang ]]
  3270. }
  3271. tc-is-cross-compiler ()
  3272. {
  3273. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  3274. }
  3275. tc-is-gcc ()
  3276. {
  3277. [[ $(tc-get-compiler-type) == gcc ]]
  3278. }
  3279. tc-is-softfloat ()
  3280. {
  3281. tc-detect-is-softfloat || tc-tuple-is-softfloat
  3282. }
  3283. tc-is-static-only ()
  3284. {
  3285. local host=${CTARGET:-${CHOST}};
  3286. [[ ${host} == *-mint* ]]
  3287. }
  3288. tc-ld-disable-gold ()
  3289. {
  3290. if ! tc-ld-is-gold "$@"; then
  3291. return;
  3292. fi;
  3293. ewarn "Forcing usage of the BFD linker instead of GOLD";
  3294. local ld=$(tc-getLD "$@");
  3295. local bfd_ld="${ld%% *}.bfd";
  3296. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  3297. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  3298. local fallback="true";
  3299. if tc-is-gcc; then
  3300. local major=$(gcc-major-version "$@");
  3301. local minor=$(gcc-minor-version "$@");
  3302. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  3303. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3304. fallback="false";
  3305. fi;
  3306. else
  3307. if tc-is-clang; then
  3308. local major=$(clang-major-version "$@");
  3309. local minor=$(clang-minor-version "$@");
  3310. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  3311. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3312. fallback="false";
  3313. fi;
  3314. fi;
  3315. fi;
  3316. if [[ ${fallback} == "true" ]]; then
  3317. if [[ -e ${path_ld} ]]; then
  3318. local d="${T}/bfd-linker";
  3319. mkdir -p "${d}";
  3320. ln -sf "${path_ld}" "${d}"/ld;
  3321. export LDFLAGS="${LDFLAGS} -B${d}";
  3322. else
  3323. die "unable to locate a BFD linker to bypass gold";
  3324. fi;
  3325. fi
  3326. }
  3327. tc-ld-is-gold ()
  3328. {
  3329. local out;
  3330. out=$($(tc-getLD "$@") --version 2>&1);
  3331. if [[ ${out} == *"GNU gold"* ]]; then
  3332. return 0;
  3333. fi;
  3334. local base="${T}/test-tc-gold";
  3335. cat > "${base}.c" <<-EOF
  3336. int main() { return 0; }
  3337. EOF
  3338. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3339. rm -f "${base}"*;
  3340. if [[ ${out} == *"GNU gold"* ]]; then
  3341. return 0;
  3342. fi;
  3343. return 1
  3344. }
  3345. tc-ninja_magic_to_arch ()
  3346. {
  3347. function ninj ()
  3348. {
  3349. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3350. };
  3351. local type=$1;
  3352. local host=$2;
  3353. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3354. case ${host} in
  3355. aarch64*)
  3356. echo arm64
  3357. ;;
  3358. alpha*)
  3359. echo alpha
  3360. ;;
  3361. arm*)
  3362. echo arm
  3363. ;;
  3364. avr*)
  3365. ninj avr32 avr
  3366. ;;
  3367. bfin*)
  3368. ninj blackfin bfin
  3369. ;;
  3370. c6x*)
  3371. echo c6x
  3372. ;;
  3373. cris*)
  3374. echo cris
  3375. ;;
  3376. frv*)
  3377. echo frv
  3378. ;;
  3379. hexagon*)
  3380. echo hexagon
  3381. ;;
  3382. hppa*)
  3383. ninj parisc hppa
  3384. ;;
  3385. i?86*)
  3386. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  3387. echo i386;
  3388. else
  3389. echo x86;
  3390. fi
  3391. ;;
  3392. ia64*)
  3393. echo ia64
  3394. ;;
  3395. m68*)
  3396. echo m68k
  3397. ;;
  3398. metag*)
  3399. echo metag
  3400. ;;
  3401. microblaze*)
  3402. echo microblaze
  3403. ;;
  3404. mips*)
  3405. echo mips
  3406. ;;
  3407. nios2*)
  3408. echo nios2
  3409. ;;
  3410. nios*)
  3411. echo nios
  3412. ;;
  3413. or1k | or32*)
  3414. echo openrisc
  3415. ;;
  3416. powerpc*)
  3417. if [[ ${type} == "kern" ]]; then
  3418. echo powerpc;
  3419. else
  3420. if [[ ${host} == powerpc64* ]]; then
  3421. echo ppc64;
  3422. else
  3423. echo ppc;
  3424. fi;
  3425. fi
  3426. ;;
  3427. riscv*)
  3428. echo riscv
  3429. ;;
  3430. s390*)
  3431. echo s390
  3432. ;;
  3433. score*)
  3434. echo score
  3435. ;;
  3436. sh64*)
  3437. ninj sh64 sh
  3438. ;;
  3439. sh*)
  3440. echo sh
  3441. ;;
  3442. sparc64*)
  3443. ninj sparc64 sparc
  3444. ;;
  3445. sparc*)
  3446. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3447. ;;
  3448. tile*)
  3449. echo tile
  3450. ;;
  3451. vax*)
  3452. echo vax
  3453. ;;
  3454. x86_64*freebsd*)
  3455. echo amd64
  3456. ;;
  3457. x86_64*)
  3458. if [[ ${type} == "kern" ]]; then
  3459. echo x86;
  3460. else
  3461. echo amd64;
  3462. fi
  3463. ;;
  3464. xtensa*)
  3465. echo xtensa
  3466. ;;
  3467. *)
  3468. echo unknown
  3469. ;;
  3470. esac
  3471. }
  3472. tc-stack-grows-down ()
  3473. {
  3474. case ${ARCH} in
  3475. hppa | metag)
  3476. return 1
  3477. ;;
  3478. esac;
  3479. return 0
  3480. }
  3481. tc-tuple-is-softfloat ()
  3482. {
  3483. local CTARGET=${CTARGET:-${CHOST}};
  3484. case ${CTARGET//_/-} in
  3485. bfin* | h8300*)
  3486. echo "only"
  3487. ;;
  3488. *-softfloat-*)
  3489. echo "yes"
  3490. ;;
  3491. *-softfp-*)
  3492. echo "softfp"
  3493. ;;
  3494. arm*-hardfloat-* | arm*eabihf)
  3495. echo "no"
  3496. ;;
  3497. *-newlib | *-elf | *-eabi)
  3498. echo "no"
  3499. ;;
  3500. arm*)
  3501. echo "yes"
  3502. ;;
  3503. *)
  3504. echo "no"
  3505. ;;
  3506. esac
  3507. }
  3508. use_if_iuse ()
  3509. {
  3510. in_iuse $1 || return 1;
  3511. use $1
  3512. }
  3513. ver_cut ()
  3514. {
  3515. local range=${1};
  3516. local v=${2:-${PV}};
  3517. local start end;
  3518. local -a comp;
  3519. __eapi7_ver_split "${v}";
  3520. local max=$((${#comp[@]}/2));
  3521. __eapi7_ver_parse_range "${range}" "${max}";
  3522. local IFS=;
  3523. if [[ ${start} -gt 0 ]]; then
  3524. start=$(( start*2 - 1 ));
  3525. fi;
  3526. echo "${comp[*]:start:end*2-start}"
  3527. }
  3528. ver_rs ()
  3529. {
  3530. local v;
  3531. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  3532. local start end i;
  3533. local -a comp;
  3534. __eapi7_ver_split "${v}";
  3535. local max=$((${#comp[@]}/2 - 1));
  3536. while [[ ${#} -ge 2 ]]; do
  3537. __eapi7_ver_parse_range "${1}" "${max}";
  3538. for ((i = start*2; i <= end*2; i+=2 ))
  3539. do
  3540. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  3541. comp[i]=${2};
  3542. done;
  3543. shift 2;
  3544. done;
  3545. local IFS=;
  3546. echo "${comp[*]}"
  3547. }
  3548. ver_test ()
  3549. {
  3550. local va op vb;
  3551. if [[ $# -eq 3 ]]; then
  3552. va=${1};
  3553. shift;
  3554. else
  3555. va=${PVR};
  3556. fi;
  3557. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  3558. op=${1};
  3559. vb=${2};
  3560. case ${op} in
  3561. -eq | -ne | -lt | -le | -gt | -ge)
  3562. ;;
  3563. *)
  3564. die "${FUNCNAME}: invalid operator: ${op}"
  3565. ;;
  3566. esac;
  3567. __eapi7_ver_compare "${va}" "${vb}";
  3568. test $? "${op}" 2
  3569. }
  3570.