spacepaste

  1.  
  2. declare -x ABI="arm64"
  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="arm64"
  11. declare BDEPEND=""
  12. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  13. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  14. declare -x CALLIGRA_FEATURES=""
  15. declare -x CAMERAS=""
  16. declare -x CBUILD="aarch64-unknown-linux-gnu"
  17. declare -x CFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error"
  18. declare -x CFLAGS_default
  19. declare -x CHOST="aarch64-unknown-linux-gnu"
  20. declare -x CHOST_arm64="aarch64-unknown-linux-gnu"
  21. declare -x CHOST_default="aarch64-unknown-linux-gnu"
  22. declare -x COLLECTD_PLUGINS=""
  23. declare -x CONF_PREFIX="/usr"
  24. declare -x CPU_FLAGS_ARM=""
  25. declare -x CPU_FLAGS_X86=""
  26. declare -x CTARGET_default="aarch64-unknown-linux-gnu"
  27. declare -x CURL_SSL=""
  28. declare -x CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error"
  29. declare -x DCC_EMAILLOG_WHOM_TO_BLAME=""
  30. declare -x DEFAULT_ABI="arm64"
  31. declare -x DEFINED_PHASES=" compile configure install prepare setup"
  32. declare DEPEND="
  33. dev-libs/lzo:2=
  34. sys-apps/util-linux:0=[static-libs(+)?]
  35. sys-libs/zlib:0=
  36. convert? (
  37. sys-fs/e2fsprogs:0=
  38. sys-libs/e2fsprogs-libs:0=
  39. reiserfs? (
  40. >=sys-fs/reiserfsprogs-3.6.27
  41. )
  42. )
  43. python? ( python_single_target_python3_4? ( dev-lang/python:3.4 ) python_single_target_python3_5? ( dev-lang/python:3.5 ) python_single_target_python3_6? ( dev-lang/python:3.6 ) >=dev-lang/python-exec-2:=[python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_7(-),python_single_target_python3_4(+)?,python_single_target_python3_5(+)?,python_single_target_python3_6(+)?] )
  44. zstd? ( app-arch/zstd:0= )
  45. convert? ( sys-apps/acl )
  46. >=app-text/asciidoc-8.6.0
  47. app-text/docbook-xml-dtd:4.5
  48. app-text/xmlto
  49. python? ( dev-python/setuptools[python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_7(-),python_single_target_python3_4(+)?,python_single_target_python3_5(+)?,python_single_target_python3_6(+)?] )
  50. static? (
  51. dev-libs/lzo:2[static-libs(+)]
  52. sys-apps/util-linux:0[static-libs(+)]
  53. sys-libs/zlib:0[static-libs(+)]
  54. convert? (
  55. sys-fs/e2fsprogs:0[static-libs(+)]
  56. sys-libs/e2fsprogs-libs:0[static-libs(+)]
  57. reiserfs? (
  58. >=sys-fs/reiserfsprogs-3.6.27[static-libs(+)]
  59. )
  60. )
  61. zstd? ( app-arch/zstd:0[static-libs(+)] )
  62. )
  63. "
  64. declare DESCRIPTION="Btrfs filesystem utilities"
  65. declare -x DESTTREE="/usr"
  66. declare -x DIROPTIONS="-m0755"
  67. declare -x EAPI="6"
  68. declare -- ECONF_SOURCE="."
  69. declare -x ELIBC="glibc"
  70. declare -x ENLIGHTENMENT_MODULES=""
  71. 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"
  72. declare -x EVCS_OFFLINE="1"
  73. declare -x EXEOPTIONS="-m0755"
  74. declare -x FCFLAGS="-O2"
  75. 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}\""
  76. declare -x FFLAGS="-O2"
  77. declare -x FFTOOLS=""
  78. declare -x GCC_SPECS=""
  79. declare -x GENTOO_WS="/home/Necktwi/workspace/Gentoo/"
  80. declare -x GPSD_PROTOCOLS=""
  81. declare -x GRUB_PLATFORMS=""
  82. declare HDEPEND=""
  83. declare HOMEPAGE="https://btrfs.wiki.kernel.org"
  84. declare -x INHERITED=" toolchain-funcs multilib bash-completion-r1 python-utils-r1 python-single-r1"
  85. declare -x INPUT_DEVICES=""
  86. declare -x INSDESTTREE=""
  87. declare -x INSOPTIONS="-m0644"
  88. declare IUSE="+convert python reiserfs static static-libs +zstd python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 python_single_target_python3_4 python_single_target_python3_5 python_single_target_python3_6"
  89. declare -x IUSE_EFFECTIVE="alpha amd64 amd64-fbsd amd64-linux arm arm64 convert 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 python_single_target_python3_4 python_single_target_python3_5 python_single_target_python3_6 python_targets_python3_4 python_targets_python3_5 python_targets_python3_6 reiserfs s390 sh sparc sparc-solaris sparc64-solaris static static-libs userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt zstd"
  90. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  91. declare -x KERNEL="linux"
  92. declare -x KERNEL_ABI="arm64"
  93. declare -x KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
  94. declare -x L10N=""
  95. declare -x LANG="en_US.utf8"
  96. declare -x LANGUAGE="en_US.utf8"
  97. declare -x LCD_DEVICES=""
  98. declare -x LC_ADDRESS="en_US.utf8"
  99. declare -x LC_COLLATE="C"
  100. declare -x LC_CTYPE="en_US.utf8"
  101. declare -x LC_IDENTIFICATION="en_US.utf8"
  102. declare -x LC_MEASUREMENT="en_US.utf8"
  103. declare -x LC_MESSAGES="en_US.utf8"
  104. declare -x LC_MONETARY="en_US.utf8"
  105. declare -x LC_NAME="en_US.utf8"
  106. declare -x LC_NUMERIC="en_US.utf8"
  107. declare -x LC_PAPER="en_US.utf8"
  108. declare -x LC_TELEPHONE="en_US.utf8"
  109. declare -x LC_TIME="en_US.utf8"
  110. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  111. declare -x LDFLAGS_default
  112. declare -x LIBDIR_arm64="lib64"
  113. declare -x LIBDIR_default="lib"
  114. declare -x LIBOPTIONS="-m0644"
  115. declare -x LIBREOFFICE_EXTENSIONS=""
  116. declare -x LICENSE="GPL-2"
  117. declare -x LIRC_DEVICES=""
  118. declare -x LLVM_TARGETS=""
  119. declare -x MAIL="/var/mail/root"
  120. declare -x MAKEOPTS="-j9 -l4"
  121. declare -x MANPAGER="manpager"
  122. declare -x MONKEYD_PLUGINS=""
  123. declare -x MULTILIB_ABIS="arm64"
  124. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  125. declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
  126. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  127. declare -- MY_PV="v4.17.1"
  128. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  129. declare -x NETBEANS_MODULES=""
  130. declare -x NGINX_MODULES_HTTP=""
  131. declare -x NGINX_MODULES_MAIL=""
  132. declare -x NGINX_MODULES_STREAM=""
  133. declare -x OFED_DRIVERS=""
  134. declare -x OFFICE_IMPLEMENTATION=""
  135. declare -x OPENMPI_FABRICS=""
  136. declare -x OPENMPI_OFED_FEATURES=""
  137. declare -x OPENMPI_RM=""
  138. declare -a PATCHES=([0]="/var/tmp/portage/sys-fs/btrfs-progs-4.17.1/files/btrfs-progs-man-no-gz.patch")
  139. declare -x PATH="/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/aarch64-RPi3B-linux-musl/gcc-bin/8.2.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  140. declare PDEPEND=""
  141. declare -x PHP_TARGETS=""
  142. declare -x PKG_CONFIG_PATH="/usr/lib/pkgconfig/"
  143. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  144. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  145. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  146. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/btrfs-progs-4.17.1/html")
  147. declare -a PORTAGE_DOSTRIP=([0]="/")
  148. declare -a PORTAGE_DOSTRIP_SKIP=()
  149. declare -x POSTGRES_TARGETS=""
  150. 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"
  151. declare -x PROPERTIES=""
  152. declare -x PYTHONDONTWRITEBYTECODE="1"
  153. declare -a PYTHON_COMPAT=([0]="python3_4" [1]="python3_5" [2]="python3_6")
  154. declare -- PYTHON_DEPS="python_single_target_python3_4? ( dev-lang/python:3.4 ) python_single_target_python3_5? ( dev-lang/python:3.5 ) python_single_target_python3_6? ( dev-lang/python:3.6 ) >=dev-lang/python-exec-2:=[python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_7(-),python_single_target_python3_4(+)?,python_single_target_python3_5(+)?,python_single_target_python3_6(+)?]"
  155. declare -- PYTHON_REQUIRED_USE="^^ ( python_single_target_python3_4 python_single_target_python3_5 python_single_target_python3_6 ) python_single_target_python3_4? ( python_targets_python3_4 ) python_single_target_python3_5? ( python_targets_python3_5 ) python_single_target_python3_6? ( python_targets_python3_6 )"
  156. declare -x PYTHON_SINGLE_TARGET="python3_6"
  157. declare -x PYTHON_TARGETS="python3_6"
  158. declare -- PYTHON_USEDEP="python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_7(-),python_single_target_python3_4(+)?,python_single_target_python3_5(+)?,python_single_target_python3_6(+)?"
  159. declare -x QEMU_SOFTMMU_TARGETS=""
  160. declare -x QEMU_USER_TARGETS=""
  161. declare RDEPEND="
  162. dev-libs/lzo:2=
  163. sys-apps/util-linux:0=[static-libs(+)?]
  164. sys-libs/zlib:0=
  165. convert? (
  166. sys-fs/e2fsprogs:0=
  167. sys-libs/e2fsprogs-libs:0=
  168. reiserfs? (
  169. >=sys-fs/reiserfsprogs-3.6.27
  170. )
  171. )
  172. python? ( python_single_target_python3_4? ( dev-lang/python:3.4 ) python_single_target_python3_5? ( dev-lang/python:3.5 ) python_single_target_python3_6? ( dev-lang/python:3.6 ) >=dev-lang/python-exec-2:=[python_targets_python3_4(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_7(-),python_single_target_python3_4(+)?,python_single_target_python3_5(+)?,python_single_target_python3_6(+)?] )
  173. zstd? ( app-arch/zstd:0= )
  174. "
  175. declare REPOSITORY
  176. declare REQUIRED_USE="python? ( ^^ ( python_single_target_python3_4 python_single_target_python3_5 python_single_target_python3_6 ) python_single_target_python3_4? ( python_targets_python3_4 ) python_single_target_python3_5? ( python_targets_python3_5 ) python_single_target_python3_6? ( python_targets_python3_6 ) ) "
  177. declare -x RESTRICT="test"
  178. 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}\""
  179. declare -x ROS_MESSAGES=""
  180. declare -x RUBY_TARGETS=""
  181. declare -x S="/var/tmp/portage/sys-fs/btrfs-progs-4.17.1/work/btrfs-progs-v4.17.1"
  182. declare -x SANDBOX_DEBUG="0"
  183. declare -x SANDBOX_DENY=""
  184. declare -x SANDBOX_PREDICT="/var/tmp/portage/sys-fs/btrfs-progs-4.17.1/homedir"
  185. declare -x SANDBOX_READ="/:/var/tmp"
  186. declare -x SANDBOX_VERBOSE="1"
  187. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/sys-fs/btrfs-progs-4.17.1/homedir/.bash_history"
  188. declare -x SANE_BACKENDS=""
  189. declare -x SHELL="/bin/bash"
  190. declare -x SLOT="0/0"
  191. declare SRC_URI="https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v4.17.1.tar.xz"
  192. declare -x SUDO_COMMAND="/usr/bin/emerge btrfs-progs"
  193. declare -x SUDO_GID="1000"
  194. declare -x SUDO_UID="1000"
  195. declare -x SUDO_USER="Necktwi"
  196. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  197. declare -x UNCACHED_ERR_FD=""
  198. declare -x USE="arm64 convert elibc_glibc kernel_linux python_single_target_python3_6 python_targets_python3_6 userland_GNU zstd"
  199. declare -x USERLAND="GNU"
  200. declare -x USERNAME="root"
  201. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  202. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  203. 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"
  204. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  205. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  206. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  207. declare -x UWSGI_PLUGINS=""
  208. declare -x VIDEO_CARDS=""
  209. declare -x VOICEMAIL_STORAGE=""
  210. declare -x XFCE_PLUGINS=""
  211. declare -x XTABLES_ADDONS=""
  212. declare -x _E_DOCDESTTREE_=""
  213. declare -x _E_EXEDESTTREE_=""
  214. declare -- _MULTILIB_ECLASS="1"
  215. 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")
  216. declare -- _PYTHON_SINGLE_R1="1"
  217. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python3_4" [1]="python3_5" [2]="python3_6")
  218. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_7")
  219. declare -- _PYTHON_UTILS_R1="1"
  220. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  221. declare -- libbtrfs_soname="0"
  222. declare -- phase_func
  223. declare -- started_applying="1"
  224. PYTHON ()
  225. {
  226. 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"
  227. }
  228. __eapi6_src_install ()
  229. {
  230. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  231. emake DESTDIR="${D}" install;
  232. fi;
  233. einstalldocs
  234. }
  235. __eapi6_src_prepare ()
  236. {
  237. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  238. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  239. else
  240. if [[ -n ${PATCHES} ]]; then
  241. eapply ${PATCHES};
  242. fi;
  243. fi;
  244. eapply_user
  245. }
  246. _bash-completion-r1_get_bashcompdir ()
  247. {
  248. debug-print-function ${FUNCNAME} "${@}";
  249. _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
  250. }
  251. _bash-completion-r1_get_bashdir ()
  252. {
  253. debug-print-function ${FUNCNAME} "${@}";
  254. if $(tc-getPKG_CONFIG) --exists bash-completion &> /dev/null; then
  255. local path;
  256. path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die;
  257. echo "${path#${EPREFIX}}";
  258. else
  259. echo "${2}";
  260. fi
  261. }
  262. _bash-completion-r1_get_bashhelpersdir ()
  263. {
  264. debug-print-function ${FUNCNAME} "${@}";
  265. _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers
  266. }
  267. _clang_fullversion ()
  268. {
  269. local ver="$1";
  270. shift;
  271. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  272. eval echo "$ver"
  273. }
  274. _eapply_patch ()
  275. {
  276. local f=${1};
  277. local prefix=${2};
  278. started_applying=1;
  279. ebegin "${prefix:-Applying }${f##*/}";
  280. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  281. failed=${?};
  282. if ! eend "${failed}"; then
  283. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  284. fi
  285. }
  286. _gcc-install-dir ()
  287. {
  288. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  289. }
  290. _gcc-specs-directive_raw ()
  291. {
  292. local cc=$(tc-getCC);
  293. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  294. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  295. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  296. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  297. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  298. { spec=spec $0 }
  299. END { print spec }';
  300. return 0
  301. }
  302. _gcc-specs-exists ()
  303. {
  304. [[ -f $(_gcc-install-dir)/$1 ]]
  305. }
  306. _gcc_fullversion ()
  307. {
  308. local ver="$1";
  309. shift;
  310. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  311. eval echo "$ver"
  312. }
  313. _python_check_dead_variables ()
  314. {
  315. local v;
  316. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  317. do
  318. if [[ -n ${!v} ]]; then
  319. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  320. fi;
  321. done;
  322. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  323. do
  324. if [[ -n ${!v} ]]; then
  325. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  326. fi;
  327. done;
  328. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  329. do
  330. if [[ -n ${!v} ]]; then
  331. die "${v} is invalid for python-r1 suite";
  332. fi;
  333. done;
  334. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  335. do
  336. if [[ -n ${!v} ]]; then
  337. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  338. fi;
  339. done;
  340. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  341. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  342. fi;
  343. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  344. do
  345. if [[ -n ${!v} ]]; then
  346. die "${v} is invalid for python-r1 suite";
  347. fi;
  348. done
  349. }
  350. _python_check_locale_sanity ()
  351. {
  352. local -x LC_ALL=${1};
  353. local IFS=;
  354. local lc=({a..z});
  355. local uc=({A..Z});
  356. local input="${lc[*]}${uc[*]}";
  357. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  358. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  359. }
  360. _python_impl_matches ()
  361. {
  362. [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  363. local impl=${1} pattern;
  364. shift;
  365. for pattern in "$@";
  366. do
  367. if [[ ${pattern} == -2 ]]; then
  368. ! python_is_python3 "${impl}";
  369. return;
  370. else
  371. if [[ ${pattern} == -3 ]]; then
  372. python_is_python3 "${impl}";
  373. return;
  374. else
  375. if [[ ${impl/./_} == ${pattern/./_} ]]; then
  376. return 0;
  377. fi;
  378. fi;
  379. fi;
  380. done;
  381. return 1
  382. }
  383. _python_impl_supported ()
  384. {
  385. debug-print-function ${FUNCNAME} "${@}";
  386. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  387. local impl=${1};
  388. case "${impl}" in
  389. python2_7 | python3_[4567] | jython2_7)
  390. return 0
  391. ;;
  392. pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  393. return 1
  394. ;;
  395. pypy | pypy3)
  396. if [[ ${EAPI:-0} == [01234] ]]; then
  397. die "PyPy is supported in EAPI 5 and newer only.";
  398. fi
  399. ;;
  400. *)
  401. [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  402. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  403. ;;
  404. esac
  405. }
  406. _python_ln_rel ()
  407. {
  408. debug-print-function ${FUNCNAME} "${@}";
  409. local target=${1};
  410. local symname=${2};
  411. local tgpath=${target%/*}/;
  412. local sympath=${symname%/*}/;
  413. local rel_target=;
  414. while [[ -n ${sympath} ]]; do
  415. local tgseg= symseg=;
  416. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  417. tgseg=${tgpath%%/*};
  418. tgpath=${tgpath#${tgseg}/};
  419. done;
  420. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  421. symseg=${sympath%%/*};
  422. sympath=${sympath#${symseg}/};
  423. done;
  424. if [[ ${tgseg} != ${symseg} ]]; then
  425. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  426. fi;
  427. done;
  428. rel_target+=${tgpath}${target##*/};
  429. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  430. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  431. ln -fs "${rel_target}" "${symname}"
  432. }
  433. _python_set_impls ()
  434. {
  435. local i;
  436. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  437. die 'PYTHON_COMPAT not declared.';
  438. fi;
  439. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  440. die 'PYTHON_COMPAT must be an array.';
  441. fi;
  442. for i in "${PYTHON_COMPAT[@]}";
  443. do
  444. _python_impl_supported "${i}";
  445. done;
  446. local supp=() unsupp=();
  447. for i in "${_PYTHON_ALL_IMPLS[@]}";
  448. do
  449. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  450. supp+=("${i}");
  451. else
  452. unsupp+=("${i}");
  453. fi;
  454. done;
  455. if [[ ! -n ${supp[@]} ]]; then
  456. die "No supported implementation in PYTHON_COMPAT.";
  457. fi;
  458. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  459. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  460. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  461. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  462. eerror "Now : ${supp[*]}";
  463. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  464. fi;
  465. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  466. eerror "Unsupported impls changed between inherits!";
  467. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  468. eerror "Now : ${unsupp[*]}";
  469. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  470. fi;
  471. else
  472. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  473. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  474. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  475. fi
  476. }
  477. _tc-getPROG ()
  478. {
  479. local tuple=$1;
  480. local v var vars=$2;
  481. local prog=($3);
  482. var=${vars%% *};
  483. for v in ${vars};
  484. do
  485. if [[ -n ${!v} ]]; then
  486. export ${var}="${!v}";
  487. echo "${!v}";
  488. return 0;
  489. fi;
  490. done;
  491. local search=;
  492. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  493. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  494. [[ -n ${search} ]] && prog[0]=${search##*/};
  495. export ${var}="${prog[*]}";
  496. echo "${!var}"
  497. }
  498. bashcomp_alias ()
  499. {
  500. debug-print-function ${FUNCNAME} "${@}";
  501. [[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename> <alias>...";
  502. local base=${1} f;
  503. shift;
  504. for f in "$@";
  505. do
  506. dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" || return;
  507. done
  508. }
  509. clang-fullversion ()
  510. {
  511. _clang_fullversion '$1.$2.$3' "$@"
  512. }
  513. clang-major-version ()
  514. {
  515. _clang_fullversion '$1' "$@"
  516. }
  517. clang-micro-version ()
  518. {
  519. _clang_fullversion '$3' "$@"
  520. }
  521. clang-minor-version ()
  522. {
  523. _clang_fullversion '$2' "$@"
  524. }
  525. clang-version ()
  526. {
  527. _clang_fullversion '$1.$2' "$@"
  528. }
  529. dobashcomp ()
  530. {
  531. debug-print-function ${FUNCNAME} "${@}";
  532. ( insopts -m 0644;
  533. insinto "$(_bash-completion-r1_get_bashcompdir)";
  534. doins "${@}" )
  535. }
  536. eapply ()
  537. {
  538. local failed patch_cmd=patch;
  539. local -x LC_COLLATE=POSIX;
  540. type -P gpatch > /dev/null && patch_cmd=gpatch;
  541. function _eapply_patch ()
  542. {
  543. local f=${1};
  544. local prefix=${2};
  545. started_applying=1;
  546. ebegin "${prefix:-Applying }${f##*/}";
  547. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  548. failed=${?};
  549. if ! eend "${failed}"; then
  550. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  551. fi
  552. };
  553. local patch_options=() files=();
  554. local i found_doublehyphen;
  555. for ((i = 1; i <= ${#@}; ++i ))
  556. do
  557. if [[ ${@:i:1} == -- ]]; then
  558. patch_options=("${@:1:i-1}");
  559. files=("${@:i+1}");
  560. found_doublehyphen=1;
  561. break;
  562. fi;
  563. done;
  564. if [[ -z ${found_doublehyphen} ]]; then
  565. for ((i = 1; i <= ${#@}; ++i ))
  566. do
  567. if [[ ${@:i:1} != -* ]]; then
  568. patch_options=("${@:1:i-1}");
  569. files=("${@:i}");
  570. break;
  571. fi;
  572. done;
  573. for i in "${files[@]}";
  574. do
  575. if [[ ${i} == -* ]]; then
  576. die "eapply: all options must be passed before non-options";
  577. fi;
  578. done;
  579. fi;
  580. if [[ ${#files[@]} -eq 0 ]]; then
  581. die "eapply: no files specified";
  582. fi;
  583. local f;
  584. for f in "${files[@]}";
  585. do
  586. if [[ -d ${f} ]]; then
  587. function _eapply_get_files ()
  588. {
  589. local LC_ALL=POSIX;
  590. local prev_shopt=$(shopt -p nullglob);
  591. shopt -s nullglob;
  592. local f;
  593. for f in "${1}"/*;
  594. do
  595. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  596. files+=("${f}");
  597. fi;
  598. done;
  599. ${prev_shopt}
  600. };
  601. local files=();
  602. _eapply_get_files "${f}";
  603. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  604. einfo "Applying patches from ${f} ...";
  605. local f2;
  606. for f2 in "${files[@]}";
  607. do
  608. _eapply_patch "${f2}" ' ';
  609. [[ ${failed} -ne 0 ]] && return "${failed}";
  610. done;
  611. else
  612. _eapply_patch "${f}";
  613. [[ ${failed} -ne 0 ]] && return "${failed}";
  614. fi;
  615. done;
  616. return 0
  617. }
  618. eapply_user ()
  619. {
  620. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  621. local tagfile=${T}/.portage_user_patches_applied;
  622. [[ -f ${tagfile} ]] && return;
  623. >> "${tagfile}";
  624. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  625. local applied d f;
  626. local -A _eapply_user_patches;
  627. local prev_shopt=$(shopt -p nullglob);
  628. shopt -s nullglob;
  629. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  630. do
  631. for f in "${d}"/*;
  632. do
  633. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  634. _eapply_user_patches[${f##*/}]=${f};
  635. fi;
  636. done;
  637. done;
  638. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  639. while read -r -d '' f; do
  640. f=${_eapply_user_patches[${f}]};
  641. if [[ -s ${f} ]]; then
  642. eapply "${f}";
  643. applied=1;
  644. fi;
  645. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  646. LC_ALL=C sort -z);
  647. fi;
  648. ${prev_shopt};
  649. [[ -n ${applied} ]] && ewarn "User patches applied."
  650. }
  651. econf_build ()
  652. {
  653. local CBUILD=${CBUILD:-${CHOST}};
  654. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  655. }
  656. einstalldocs ()
  657. {
  658. ( if ! declare -p DOCS &> /dev/null; then
  659. local d;
  660. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  661. do
  662. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  663. done;
  664. else
  665. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  666. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  667. else
  668. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  669. fi;
  670. fi );
  671. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  672. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  673. else
  674. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  675. fi )
  676. }
  677. gcc-fullversion ()
  678. {
  679. _gcc_fullversion '$1.$2.$3' "$@"
  680. }
  681. gcc-major-version ()
  682. {
  683. _gcc_fullversion '$1' "$@"
  684. }
  685. gcc-micro-version ()
  686. {
  687. _gcc_fullversion '$3' "$@"
  688. }
  689. gcc-minor-version ()
  690. {
  691. _gcc_fullversion '$2' "$@"
  692. }
  693. gcc-specs-directive ()
  694. {
  695. local directive subdname subdirective;
  696. directive="$(_gcc-specs-directive_raw $1)";
  697. while [[ ${directive} == *%\(*\)* ]]; do
  698. subdname=${directive/*%\(};
  699. subdname=${subdname/\)*};
  700. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  701. directive="${directive//\%(${subdname})/${subdirective}}";
  702. done;
  703. echo "${directive}";
  704. return 0
  705. }
  706. gcc-specs-nostrict ()
  707. {
  708. local directive;
  709. directive=$(gcc-specs-directive cc1);
  710. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  711. }
  712. gcc-specs-now ()
  713. {
  714. local directive;
  715. directive=$(gcc-specs-directive link_command);
  716. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  717. }
  718. gcc-specs-pie ()
  719. {
  720. local directive;
  721. directive=$(gcc-specs-directive cc1);
  722. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  723. }
  724. gcc-specs-relro ()
  725. {
  726. local directive;
  727. directive=$(gcc-specs-directive link_command);
  728. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  729. }
  730. gcc-specs-ssp ()
  731. {
  732. local directive;
  733. directive=$(gcc-specs-directive cc1);
  734. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  735. }
  736. gcc-specs-ssp-to-all ()
  737. {
  738. local directive;
  739. directive=$(gcc-specs-directive cc1);
  740. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  741. }
  742. gcc-specs-stack-check ()
  743. {
  744. local directive;
  745. directive=$(gcc-specs-directive cc1);
  746. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  747. }
  748. gcc-version ()
  749. {
  750. _gcc_fullversion '$1.$2' "$@"
  751. }
  752. gen_usr_ldscript ()
  753. {
  754. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  755. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  756. tc-is-static-only && return;
  757. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  758. multilib_is_native_abi || return 0;
  759. fi;
  760. case ${CTARGET:-${CHOST}} in
  761. *-darwin*)
  762. ;;
  763. *-android*)
  764. return 0
  765. ;;
  766. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  767. use prefix && return 0
  768. ;;
  769. *)
  770. return 0
  771. ;;
  772. esac;
  773. dodir /usr/${libdir};
  774. if [[ $1 == "-a" ]]; then
  775. auto=true;
  776. shift;
  777. dodir /${libdir};
  778. fi;
  779. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  780. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  781. local d="${T}/bfd-linker";
  782. mkdir -p "${d}";
  783. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  784. flags+=(-B"${d}");
  785. fi;
  786. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  787. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  788. for lib in "$@";
  789. do
  790. local tlib;
  791. if ${auto}; then
  792. lib="lib${lib}${suffix}";
  793. else
  794. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  795. fi;
  796. case ${CTARGET:-${CHOST}} in
  797. *-darwin*)
  798. if ${auto}; then
  799. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  800. else
  801. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  802. fi;
  803. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  804. tlib=${tlib##*/};
  805. if ${auto}; then
  806. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  807. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  808. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  809. fi;
  810. rm -f "${ED}"/${libdir}/${lib};
  811. fi;
  812. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  813. chmod u+w "${ED}${libdir}/${tlib}";
  814. local nowrite=yes;
  815. fi;
  816. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  817. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  818. pushd "${ED}/usr/${libdir}" > /dev/null;
  819. ln -snf "../../${libdir}/${tlib}" "${lib}";
  820. popd > /dev/null
  821. ;;
  822. *)
  823. if ${auto}; then
  824. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  825. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  826. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  827. if [[ ${tlib} != ${lib}* ]]; then
  828. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  829. fi;
  830. rm -f "${ED}"/${libdir}/${lib};
  831. else
  832. tlib=${lib};
  833. fi;
  834. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  835. /* GNU ld script
  836. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  837. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  838. run into linking problems. This "fake" dynamic lib is a linker script that
  839. redirects the linker to the real lib. And yes, this works in the cross-
  840. compiling scenario as the sysroot-ed linker will prepend the real path.
  841. See bug https://bugs.gentoo.org/4411 for more info.
  842. */
  843. ${output_format}
  844. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  845. END_LDSCRIPT
  846. ;;
  847. esac
  848. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  849. done
  850. }
  851. get_abi_CFLAGS ()
  852. {
  853. get_abi_var CFLAGS "$@"
  854. }
  855. get_abi_CHOST ()
  856. {
  857. get_abi_var CHOST "$@"
  858. }
  859. get_abi_CTARGET ()
  860. {
  861. get_abi_var CTARGET "$@"
  862. }
  863. get_abi_FAKE_TARGETS ()
  864. {
  865. get_abi_var FAKE_TARGETS "$@"
  866. }
  867. get_abi_LDFLAGS ()
  868. {
  869. get_abi_var LDFLAGS "$@"
  870. }
  871. get_abi_LIBDIR ()
  872. {
  873. get_abi_var LIBDIR "$@"
  874. }
  875. get_abi_var ()
  876. {
  877. local flag=$1;
  878. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  879. local var="${flag}_${abi}";
  880. echo ${!var}
  881. }
  882. get_all_abis ()
  883. {
  884. local x order="" mvar dvar;
  885. mvar="MULTILIB_ABIS";
  886. dvar="DEFAULT_ABI";
  887. if [[ -n $1 ]]; then
  888. mvar="$1_${mvar}";
  889. dvar="$1_${dvar}";
  890. fi;
  891. if [[ -z ${!mvar} ]]; then
  892. echo "default";
  893. return 0;
  894. fi;
  895. for x in ${!mvar};
  896. do
  897. if [[ ${x} != ${!dvar} ]]; then
  898. order="${order:+${order} }${x}";
  899. fi;
  900. done;
  901. order="${order:+${order} }${!dvar}";
  902. echo ${order};
  903. return 0
  904. }
  905. get_all_libdirs ()
  906. {
  907. local libdirs abi;
  908. for abi in ${MULTILIB_ABIS};
  909. do
  910. libdirs+=" $(get_abi_LIBDIR ${abi})";
  911. done;
  912. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  913. echo "${libdirs}"
  914. }
  915. get_bashcompdir ()
  916. {
  917. debug-print-function ${FUNCNAME} "${@}";
  918. echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)"
  919. }
  920. get_bashhelpersdir ()
  921. {
  922. debug-print-function ${FUNCNAME} "${@}";
  923. echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)"
  924. }
  925. get_exeext ()
  926. {
  927. case ${CHOST} in
  928. *-cygwin* | mingw* | *-mingw*)
  929. echo ".exe"
  930. ;;
  931. esac
  932. }
  933. get_install_abis ()
  934. {
  935. local x order="";
  936. if [[ -z ${MULTILIB_ABIS} ]]; then
  937. echo "default";
  938. return 0;
  939. fi;
  940. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  941. for x in ${MULTILIB_ABIS};
  942. do
  943. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  944. has ${x} ${ABI_DENY} || order="${order} ${x}";
  945. fi;
  946. done;
  947. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  948. if [[ -n ${ABI_ALLOW} ]]; then
  949. local ordera="";
  950. for x in ${order};
  951. do
  952. if has ${x} ${ABI_ALLOW}; then
  953. ordera="${ordera} ${x}";
  954. fi;
  955. done;
  956. order=${ordera};
  957. fi;
  958. else
  959. order=${DEFAULT_ABI};
  960. fi;
  961. if [[ -z ${order} ]]; then
  962. 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.";
  963. fi;
  964. echo ${order};
  965. return 0
  966. }
  967. get_libdir ()
  968. {
  969. local libdir_var="LIBDIR_${ABI}";
  970. local libdir="lib";
  971. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  972. echo "${libdir}"
  973. }
  974. get_libname ()
  975. {
  976. local libname;
  977. local ver=$1;
  978. case ${CHOST} in
  979. *-cygwin*)
  980. libname="dll.a"
  981. ;;
  982. mingw* | *-mingw*)
  983. libname="dll"
  984. ;;
  985. *-darwin*)
  986. libname="dylib"
  987. ;;
  988. *-mint*)
  989. libname="irrelevant"
  990. ;;
  991. hppa*-hpux*)
  992. libname="sl"
  993. ;;
  994. *)
  995. libname="so"
  996. ;;
  997. esac;
  998. if [[ -z $* ]]; then
  999. echo ".${libname}";
  1000. else
  1001. for ver in "$@";
  1002. do
  1003. case ${CHOST} in
  1004. *-cygwin*)
  1005. echo ".${ver}.${libname}"
  1006. ;;
  1007. *-darwin*)
  1008. echo ".${ver}.${libname}"
  1009. ;;
  1010. *-mint*)
  1011. echo ".${libname}"
  1012. ;;
  1013. *)
  1014. echo ".${libname}.${ver}"
  1015. ;;
  1016. esac;
  1017. done;
  1018. fi
  1019. }
  1020. get_modname ()
  1021. {
  1022. local modname;
  1023. local ver=$1;
  1024. case ${CHOST} in
  1025. *-darwin*)
  1026. modname="bundle"
  1027. ;;
  1028. *)
  1029. modname="so"
  1030. ;;
  1031. esac;
  1032. echo ".${modname}"
  1033. }
  1034. has_multilib_profile ()
  1035. {
  1036. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1037. }
  1038. in_iuse ()
  1039. {
  1040. local use=${1};
  1041. if [[ -z "${use}" ]]; then
  1042. echo "!!! in_iuse() called without a parameter." 1>&2;
  1043. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1044. die "in_iuse() called without a parameter";
  1045. fi;
  1046. local liuse=(${IUSE_EFFECTIVE});
  1047. has "${use}" "${liuse[@]#[+-]}"
  1048. }
  1049. is_final_abi ()
  1050. {
  1051. has_multilib_profile || return 0;
  1052. set -- $(get_install_abis);
  1053. local LAST_ABI=$#;
  1054. [[ ${!LAST_ABI} == ${ABI} ]]
  1055. }
  1056. multilib_env ()
  1057. {
  1058. local CTARGET=${1:-${CTARGET}};
  1059. local cpu=${CTARGET%%*-};
  1060. case ${cpu} in
  1061. aarch64*)
  1062. export CFLAGS_arm=${CFLAGS_arm-};
  1063. case ${cpu} in
  1064. aarch64*be)
  1065. export CHOST_arm="armv8b-${CTARGET#*-}"
  1066. ;;
  1067. *)
  1068. export CHOST_arm="armv8l-${CTARGET#*-}"
  1069. ;;
  1070. esac;
  1071. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1072. export CTARGET_arm=${CHOST_arm};
  1073. export LIBDIR_arm="lib";
  1074. export CFLAGS_arm64=${CFLAGS_arm64-};
  1075. export CHOST_arm64=${CTARGET};
  1076. export CTARGET_arm64=${CHOST_arm64};
  1077. export LIBDIR_arm64="lib64";
  1078. : ${MULTILIB_ABIS=arm64};
  1079. : ${DEFAULT_ABI=arm64}
  1080. ;;
  1081. x86_64*)
  1082. export CFLAGS_x86=${CFLAGS_x86--m32};
  1083. export CHOST_x86=${CTARGET/x86_64/i686};
  1084. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1085. export CTARGET_x86=${CHOST_x86};
  1086. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1087. export LIBDIR_x86="lib32";
  1088. else
  1089. export LIBDIR_x86="lib";
  1090. fi;
  1091. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1092. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1093. export CTARGET_amd64=${CHOST_amd64};
  1094. export LIBDIR_amd64="lib64";
  1095. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1096. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1097. export CTARGET_x32=${CHOST_x32};
  1098. export LIBDIR_x32="libx32";
  1099. case ${CTARGET} in
  1100. *-gnux32)
  1101. : ${MULTILIB_ABIS=x32 amd64 x86};
  1102. : ${DEFAULT_ABI=x32}
  1103. ;;
  1104. *)
  1105. : ${MULTILIB_ABIS=amd64 x86};
  1106. : ${DEFAULT_ABI=amd64}
  1107. ;;
  1108. esac
  1109. ;;
  1110. mips64* | mipsisa64*)
  1111. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1112. export CHOST_o32=${CTARGET/mips64/mips};
  1113. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  1114. export CTARGET_o32=${CHOST_o32};
  1115. export LIBDIR_o32="lib";
  1116. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1117. export CHOST_n32=${CTARGET};
  1118. export CTARGET_n32=${CHOST_n32};
  1119. export LIBDIR_n32="lib32";
  1120. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1121. export CHOST_n64=${CTARGET};
  1122. export CTARGET_n64=${CHOST_n64};
  1123. export LIBDIR_n64="lib64";
  1124. : ${MULTILIB_ABIS=n64 n32 o32};
  1125. : ${DEFAULT_ABI=n32}
  1126. ;;
  1127. powerpc64*)
  1128. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1129. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1130. export CTARGET_ppc=${CHOST_ppc};
  1131. export LIBDIR_ppc="lib";
  1132. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1133. export CHOST_ppc64=${CTARGET};
  1134. export CTARGET_ppc64=${CHOST_ppc64};
  1135. export LIBDIR_ppc64="lib64";
  1136. : ${MULTILIB_ABIS=ppc64 ppc};
  1137. : ${DEFAULT_ABI=ppc64}
  1138. ;;
  1139. s390x*)
  1140. export CFLAGS_s390=${CFLAGS_s390--m31};
  1141. export CHOST_s390=${CTARGET/s390x/s390};
  1142. export CTARGET_s390=${CHOST_s390};
  1143. export LIBDIR_s390="lib";
  1144. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1145. export CHOST_s390x=${CTARGET};
  1146. export CTARGET_s390x=${CHOST_s390x};
  1147. export LIBDIR_s390x="lib64";
  1148. : ${MULTILIB_ABIS=s390x s390};
  1149. : ${DEFAULT_ABI=s390x}
  1150. ;;
  1151. sparc64*)
  1152. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1153. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1154. export CTARGET_sparc32=${CHOST_sparc32};
  1155. export LIBDIR_sparc32="lib";
  1156. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1157. export CHOST_sparc64=${CTARGET};
  1158. export CTARGET_sparc64=${CHOST_sparc64};
  1159. export LIBDIR_sparc64="lib64";
  1160. : ${MULTILIB_ABIS=sparc64 sparc32};
  1161. : ${DEFAULT_ABI=sparc64}
  1162. ;;
  1163. *)
  1164. : ${MULTILIB_ABIS=default};
  1165. : ${DEFAULT_ABI=default}
  1166. ;;
  1167. esac;
  1168. export MULTILIB_ABIS DEFAULT_ABI
  1169. }
  1170. multilib_toolchain_setup ()
  1171. {
  1172. local v vv;
  1173. export ABI=$1;
  1174. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  1175. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1176. do
  1177. vv="_abi_saved_${v}";
  1178. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  1179. unset ${vv};
  1180. done;
  1181. unset _DEFAULT_ABI_SAVED;
  1182. fi;
  1183. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  1184. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1185. do
  1186. vv="_abi_saved_${v}";
  1187. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  1188. done;
  1189. export _DEFAULT_ABI_SAVED="true";
  1190. if [[ ${CBUILD} == "${CHOST}" ]]; then
  1191. export CBUILD=$(get_abi_CHOST $1);
  1192. fi;
  1193. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  1194. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  1195. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  1196. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  1197. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  1198. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  1199. export CHOST=$(get_abi_CHOST $1);
  1200. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  1201. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  1202. fi
  1203. }
  1204. newbashcomp ()
  1205. {
  1206. debug-print-function ${FUNCNAME} "${@}";
  1207. ( insopts -m 0644;
  1208. insinto "$(_bash-completion-r1_get_bashcompdir)";
  1209. newins "${@}" )
  1210. }
  1211. number_abis ()
  1212. {
  1213. set -- `get_install_abis`;
  1214. echo $#
  1215. }
  1216. pkg_nofetch ()
  1217. {
  1218. default
  1219. }
  1220. pkg_setup ()
  1221. {
  1222. use python && python-single-r1_pkg_setup
  1223. }
  1224. python-single-r1_pkg_setup ()
  1225. {
  1226. debug-print-function ${FUNCNAME} "${@}";
  1227. [[ ${MERGE_TYPE} != binary ]] && python_setup
  1228. }
  1229. python_abi_depend ()
  1230. {
  1231. die "${FUNCNAME}() is invalid for python-r1 suite"
  1232. }
  1233. python_byte-compile_modules ()
  1234. {
  1235. die "${FUNCNAME}() is invalid for python-r1 suite"
  1236. }
  1237. python_clean_byte-compiled_modules ()
  1238. {
  1239. die "${FUNCNAME}() is invalid for python-r1 suite"
  1240. }
  1241. python_clean_installation_image ()
  1242. {
  1243. die "${FUNCNAME}() is invalid for python-r1 suite"
  1244. }
  1245. python_clean_py-compile_files ()
  1246. {
  1247. die "${FUNCNAME}() is invalid for python-r1 suite"
  1248. }
  1249. python_convert_shebangs ()
  1250. {
  1251. 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"
  1252. }
  1253. python_disable_pyc ()
  1254. {
  1255. die "${FUNCNAME}() is invalid for python-r1 suite"
  1256. }
  1257. python_doexe ()
  1258. {
  1259. debug-print-function ${FUNCNAME} "${@}";
  1260. local f;
  1261. for f in "$@";
  1262. do
  1263. python_newexe "${f}" "${f##*/}";
  1264. done
  1265. }
  1266. python_doheader ()
  1267. {
  1268. debug-print-function ${FUNCNAME} "${@}";
  1269. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1270. if [[ ${EAPI:-0} == [0123] ]]; then
  1271. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  1272. fi;
  1273. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  1274. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  1275. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  1276. ( insopts -m 0644;
  1277. insinto "${d}";
  1278. doins -r "${@}" || return ${?} )
  1279. }
  1280. python_domodule ()
  1281. {
  1282. debug-print-function ${FUNCNAME} "${@}";
  1283. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1284. if [[ ${EAPI:-0} == [0123] ]]; then
  1285. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  1286. fi;
  1287. local d;
  1288. if [[ ${python_moduleroot} == /* ]]; then
  1289. d=${python_moduleroot};
  1290. else
  1291. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  1292. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  1293. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  1294. fi;
  1295. ( insopts -m 0644;
  1296. insinto "${d}";
  1297. doins -r "${@}" || return ${?} );
  1298. python_optimize "${ED%/}/${d}"
  1299. }
  1300. python_doscript ()
  1301. {
  1302. debug-print-function ${FUNCNAME} "${@}";
  1303. local _PYTHON_REWRITE_SHEBANG=1;
  1304. python_doexe "${@}"
  1305. }
  1306. python_enable_pyc ()
  1307. {
  1308. die "${FUNCNAME}() is invalid for python-r1 suite"
  1309. }
  1310. python_execute_function ()
  1311. {
  1312. 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"
  1313. }
  1314. python_execute_nosetests ()
  1315. {
  1316. die "${FUNCNAME}() is invalid for python-r1 suite"
  1317. }
  1318. python_execute_py.test ()
  1319. {
  1320. die "${FUNCNAME}() is invalid for python-r1 suite"
  1321. }
  1322. python_execute_trial ()
  1323. {
  1324. die "${FUNCNAME}() is invalid for python-r1 suite"
  1325. }
  1326. python_export ()
  1327. {
  1328. debug-print-function ${FUNCNAME} "${@}";
  1329. local impl var;
  1330. case "${1}" in
  1331. python* | jython*)
  1332. impl=${1/_/.};
  1333. shift
  1334. ;;
  1335. pypy | pypy3)
  1336. impl=${1};
  1337. shift
  1338. ;;
  1339. *)
  1340. impl=${EPYTHON};
  1341. if [[ -z ${impl} ]]; then
  1342. die "python_export called without a python implementation and EPYTHON is unset";
  1343. fi
  1344. ;;
  1345. esac;
  1346. debug-print "${FUNCNAME}: implementation: ${impl}";
  1347. for var in "$@";
  1348. do
  1349. case "${var}" in
  1350. EPYTHON)
  1351. export EPYTHON=${impl};
  1352. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  1353. ;;
  1354. PYTHON)
  1355. export PYTHON=${EPREFIX}/usr/bin/${impl};
  1356. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  1357. ;;
  1358. PYTHON_SITEDIR)
  1359. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  1360. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  1361. export PYTHON_SITEDIR;
  1362. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  1363. ;;
  1364. PYTHON_INCLUDEDIR)
  1365. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  1366. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  1367. export PYTHON_INCLUDEDIR;
  1368. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  1369. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  1370. die "${impl} does not install any header files!";
  1371. fi
  1372. ;;
  1373. PYTHON_LIBPATH)
  1374. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  1375. 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;
  1376. export PYTHON_LIBPATH;
  1377. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  1378. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  1379. die "${impl} lacks a (usable) dynamic library";
  1380. fi
  1381. ;;
  1382. PYTHON_CFLAGS)
  1383. local val;
  1384. case "${impl}" in
  1385. python*)
  1386. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  1387. ;;
  1388. *)
  1389. die "${impl}: obtaining ${var} not supported"
  1390. ;;
  1391. esac;
  1392. export PYTHON_CFLAGS=${val};
  1393. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  1394. ;;
  1395. PYTHON_LIBS)
  1396. local val;
  1397. case "${impl}" in
  1398. python*)
  1399. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  1400. ;;
  1401. *)
  1402. die "${impl}: obtaining ${var} not supported"
  1403. ;;
  1404. esac;
  1405. export PYTHON_LIBS=${val};
  1406. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  1407. ;;
  1408. PYTHON_CONFIG)
  1409. local flags val;
  1410. case "${impl}" in
  1411. python*)
  1412. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  1413. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  1414. val=${PYTHON}${flags}-config
  1415. ;;
  1416. *)
  1417. die "${impl}: obtaining ${var} not supported"
  1418. ;;
  1419. esac;
  1420. export PYTHON_CONFIG=${val};
  1421. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  1422. ;;
  1423. PYTHON_PKG_DEP)
  1424. local d;
  1425. case ${impl} in
  1426. python2.7)
  1427. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  1428. ;;
  1429. python3.3)
  1430. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  1431. ;;
  1432. python*)
  1433. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  1434. ;;
  1435. pypy)
  1436. PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  1437. ;;
  1438. pypy3)
  1439. PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  1440. ;;
  1441. jython2.7)
  1442. PYTHON_PKG_DEP='dev-java/jython:2.7'
  1443. ;;
  1444. *)
  1445. die "Invalid implementation: ${impl}"
  1446. ;;
  1447. esac;
  1448. if [[ -n ${PYTHON_REQ_USE} ]]; then
  1449. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  1450. fi;
  1451. export PYTHON_PKG_DEP;
  1452. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  1453. ;;
  1454. PYTHON_SCRIPTDIR)
  1455. local dir;
  1456. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  1457. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  1458. ;;
  1459. *)
  1460. die "python_export: unknown variable ${var}"
  1461. ;;
  1462. esac;
  1463. done
  1464. }
  1465. python_export_utf8_locale ()
  1466. {
  1467. debug-print-function ${FUNCNAME} "${@}";
  1468. type locale > /dev/null || return 0;
  1469. if [[ $(locale charmap) != UTF-8 ]]; then
  1470. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  1471. for lang in ${locales};
  1472. do
  1473. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  1474. if _python_check_locale_sanity "${lang}"; then
  1475. export LC_CTYPE=${lang};
  1476. if [[ -n ${LC_ALL} ]]; then
  1477. export LC_NUMERIC=${LC_ALL};
  1478. export LC_TIME=${LC_ALL};
  1479. export LC_COLLATE=${LC_ALL};
  1480. export LC_MONETARY=${LC_ALL};
  1481. export LC_MESSAGES=${LC_ALL};
  1482. export LC_PAPER=${LC_ALL};
  1483. export LC_NAME=${LC_ALL};
  1484. export LC_ADDRESS=${LC_ALL};
  1485. export LC_TELEPHONE=${LC_ALL};
  1486. export LC_MEASUREMENT=${LC_ALL};
  1487. export LC_IDENTIFICATION=${LC_ALL};
  1488. export LC_ALL=;
  1489. fi;
  1490. return 0;
  1491. fi;
  1492. fi;
  1493. done;
  1494. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  1495. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  1496. ewarn "/etc/locale.gen and run locale-gen.";
  1497. return 1;
  1498. fi;
  1499. return 0
  1500. }
  1501. python_fix_shebang ()
  1502. {
  1503. debug-print-function ${FUNCNAME} "${@}";
  1504. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  1505. local force quiet;
  1506. while [[ -n ${@} ]]; do
  1507. case "${1}" in
  1508. -f | --force)
  1509. force=1;
  1510. shift
  1511. ;;
  1512. -q | --quiet)
  1513. quiet=1;
  1514. shift
  1515. ;;
  1516. --)
  1517. shift;
  1518. break
  1519. ;;
  1520. *)
  1521. break
  1522. ;;
  1523. esac;
  1524. done;
  1525. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  1526. local path f;
  1527. for path in "$@";
  1528. do
  1529. local any_correct any_fixed is_recursive;
  1530. [[ -d ${path} ]] && is_recursive=1;
  1531. while IFS= read -r -d '' f; do
  1532. local shebang i;
  1533. local error= from=;
  1534. IFS= read -r shebang < "${f}";
  1535. if [[ ${shebang} == '#!'* ]]; then
  1536. local split_shebang=();
  1537. read -r -a split_shebang <<< ${shebang} || die;
  1538. for i in "${split_shebang[@]}";
  1539. do
  1540. case "${i}" in
  1541. *"${EPYTHON}")
  1542. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  1543. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  1544. any_correct=1;
  1545. from=${EPYTHON};
  1546. break
  1547. ;;
  1548. *python | *python[23])
  1549. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  1550. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  1551. if [[ ${i} == *python2 ]]; then
  1552. from=python2;
  1553. if [[ ! -n ${force} ]]; then
  1554. python_is_python3 "${EPYTHON}" && error=1;
  1555. fi;
  1556. else
  1557. if [[ ${i} == *python3 ]]; then
  1558. from=python3;
  1559. if [[ ! -n ${force} ]]; then
  1560. python_is_python3 "${EPYTHON}" || error=1;
  1561. fi;
  1562. else
  1563. from=python;
  1564. fi;
  1565. fi;
  1566. break
  1567. ;;
  1568. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  1569. if [[ ! -n ${force} ]]; then
  1570. error=1;
  1571. else
  1572. case "${i}" in
  1573. *python[23].[0123456789])
  1574. from="python[23].[0123456789]"
  1575. ;;
  1576. *pypy)
  1577. from="pypy"
  1578. ;;
  1579. *pypy3)
  1580. from="pypy3"
  1581. ;;
  1582. *jython[23].[0123456789])
  1583. from="jython[23].[0123456789]"
  1584. ;;
  1585. *)
  1586. die "${FUNCNAME}: internal error in 2nd pattern match"
  1587. ;;
  1588. esac;
  1589. fi;
  1590. break
  1591. ;;
  1592. esac;
  1593. done;
  1594. fi;
  1595. if [[ ! -n ${error} && ! -n ${from} ]]; then
  1596. [[ -n ${is_recursive} ]] && continue;
  1597. error=1;
  1598. fi;
  1599. if [[ ! -n ${quiet} ]]; then
  1600. einfo "Fixing shebang in ${f#${D%/}}.";
  1601. fi;
  1602. if [[ ! -n ${error} ]]; then
  1603. if [[ ${shebang} == *${from}" "* ]]; then
  1604. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  1605. else
  1606. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  1607. fi;
  1608. any_fixed=1;
  1609. else
  1610. eerror "The file has incompatible shebang:";
  1611. eerror " file: ${f#${D%/}}";
  1612. eerror " current shebang: ${shebang}";
  1613. eerror " requested impl: ${EPYTHON}";
  1614. die "${FUNCNAME}: conversion of incompatible shebang requested";
  1615. fi;
  1616. done < <(find -H "${path}" -type f -print0 || die);
  1617. if [[ ! -n ${any_fixed} ]]; then
  1618. local cmd=eerror;
  1619. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  1620. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  1621. if [[ -n ${any_correct} ]]; then
  1622. "${cmd}" "All files have ${EPYTHON} shebang already.";
  1623. else
  1624. "${cmd}" "There are no Python files in specified directory.";
  1625. fi;
  1626. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  1627. fi;
  1628. done
  1629. }
  1630. python_gen_cond_dep ()
  1631. {
  1632. debug-print-function ${FUNCNAME} "${@}";
  1633. local flag_prefix impl matches=();
  1634. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  1635. flag_prefix=python_targets;
  1636. else
  1637. flag_prefix=python_single_target;
  1638. fi;
  1639. local dep=${1};
  1640. shift;
  1641. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1642. do
  1643. if _python_impl_matches "${impl}" "${@}"; then
  1644. if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  1645. local usedep=$(python_gen_usedep "${@}");
  1646. dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  1647. fi;
  1648. matches+=("${flag_prefix}_${impl}? ( ${dep} )");
  1649. fi;
  1650. done;
  1651. echo "${matches[@]}"
  1652. }
  1653. python_gen_impl_dep ()
  1654. {
  1655. debug-print-function ${FUNCNAME} "${@}";
  1656. local impl pattern;
  1657. local matches=();
  1658. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  1659. flag_prefix=python_targets;
  1660. else
  1661. flag_prefix=python_single_target;
  1662. fi;
  1663. local PYTHON_REQ_USE=${1};
  1664. shift;
  1665. local patterns=("${@-*}");
  1666. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1667. do
  1668. if _python_impl_matches "${impl}" "${patterns[@]}"; then
  1669. local PYTHON_PKG_DEP;
  1670. python_export "${impl}" PYTHON_PKG_DEP;
  1671. matches+=("${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )");
  1672. fi;
  1673. done;
  1674. echo "${matches[@]}"
  1675. }
  1676. python_gen_usedep ()
  1677. {
  1678. debug-print-function ${FUNCNAME} "${@}";
  1679. local impl matches=();
  1680. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1681. do
  1682. if _python_impl_matches "${impl}" "${@}"; then
  1683. matches+=("python_targets_${impl}(-)?" "python_single_target_${impl}(+)?");
  1684. fi;
  1685. done;
  1686. [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  1687. local out=${matches[@]};
  1688. echo "${out// /,}"
  1689. }
  1690. python_gen_useflags ()
  1691. {
  1692. debug-print-function ${FUNCNAME} "${@}";
  1693. local flag_prefix impl matches=();
  1694. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  1695. flag_prefix=python_targets;
  1696. else
  1697. flag_prefix=python_single_target;
  1698. fi;
  1699. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1700. do
  1701. if _python_impl_matches "${impl}" "${@}"; then
  1702. matches+=("${flag_prefix}_${impl}");
  1703. fi;
  1704. done;
  1705. echo "${matches[@]}"
  1706. }
  1707. python_generate_cffi_modules ()
  1708. {
  1709. die "${FUNCNAME}() is invalid for python-r1 suite"
  1710. }
  1711. python_generate_wrapper_scripts ()
  1712. {
  1713. die "${FUNCNAME}() is invalid for python-r1 suite"
  1714. }
  1715. python_get_CFLAGS ()
  1716. {
  1717. debug-print-function ${FUNCNAME} "${@}";
  1718. python_export "${@}" PYTHON_CFLAGS;
  1719. echo "${PYTHON_CFLAGS}"
  1720. }
  1721. python_get_LIBS ()
  1722. {
  1723. debug-print-function ${FUNCNAME} "${@}";
  1724. python_export "${@}" PYTHON_LIBS;
  1725. echo "${PYTHON_LIBS}"
  1726. }
  1727. python_get_PYTHON_CONFIG ()
  1728. {
  1729. debug-print-function ${FUNCNAME} "${@}";
  1730. python_export "${@}" PYTHON_CONFIG;
  1731. echo "${PYTHON_CONFIG}"
  1732. }
  1733. python_get_extension_module_suffix ()
  1734. {
  1735. die "${FUNCNAME}() is invalid for python-r1 suite"
  1736. }
  1737. python_get_implementation ()
  1738. {
  1739. die "${FUNCNAME}() is invalid for python-r1 suite"
  1740. }
  1741. python_get_implementation_and_version ()
  1742. {
  1743. die "${FUNCNAME}() is invalid for python-r1 suite"
  1744. }
  1745. python_get_implementational_package ()
  1746. {
  1747. die "${FUNCNAME}() is invalid for python-r1 suite"
  1748. }
  1749. python_get_includedir ()
  1750. {
  1751. debug-print-function ${FUNCNAME} "${@}";
  1752. python_export "${@}" PYTHON_INCLUDEDIR;
  1753. echo "${PYTHON_INCLUDEDIR}"
  1754. }
  1755. python_get_libdir ()
  1756. {
  1757. die "${FUNCNAME}() is invalid for python-r1 suite"
  1758. }
  1759. python_get_library ()
  1760. {
  1761. die "${FUNCNAME}() is invalid for python-r1 suite"
  1762. }
  1763. python_get_library_path ()
  1764. {
  1765. debug-print-function ${FUNCNAME} "${@}";
  1766. python_export "${@}" PYTHON_LIBPATH;
  1767. echo "${PYTHON_LIBPATH}"
  1768. }
  1769. python_get_scriptdir ()
  1770. {
  1771. debug-print-function ${FUNCNAME} "${@}";
  1772. python_export "${@}" PYTHON_SCRIPTDIR;
  1773. echo "${PYTHON_SCRIPTDIR}"
  1774. }
  1775. python_get_sitedir ()
  1776. {
  1777. debug-print-function ${FUNCNAME} "${@}";
  1778. python_export "${@}" PYTHON_SITEDIR;
  1779. echo "${PYTHON_SITEDIR}"
  1780. }
  1781. python_get_version ()
  1782. {
  1783. die "${FUNCNAME}() is invalid for python-r1 suite"
  1784. }
  1785. python_install_executables ()
  1786. {
  1787. die "${FUNCNAME}() is invalid for python-r1 suite"
  1788. }
  1789. python_is_installed ()
  1790. {
  1791. local impl=${1:-${EPYTHON}};
  1792. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  1793. local hasv_args=();
  1794. case ${EAPI:-0} in
  1795. 0 | 1 | 2 | 3 | 4)
  1796. local -x ROOT=/
  1797. ;;
  1798. 5 | 6)
  1799. hasv_args+=(--host-root)
  1800. ;;
  1801. *)
  1802. hasv_args+=(-b)
  1803. ;;
  1804. esac;
  1805. case "${impl}" in
  1806. pypy | pypy3)
  1807. local append=;
  1808. if [[ -n ${PYTHON_REQ_USE} ]]; then
  1809. append=[${PYTHON_REQ_USE}];
  1810. fi;
  1811. has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  1812. ;;
  1813. *)
  1814. local PYTHON_PKG_DEP;
  1815. python_export "${impl}" PYTHON_PKG_DEP;
  1816. has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  1817. ;;
  1818. esac
  1819. }
  1820. python_is_python3 ()
  1821. {
  1822. local impl=${1:-${EPYTHON}};
  1823. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  1824. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  1825. }
  1826. python_merge_intermediate_installation_images ()
  1827. {
  1828. die "${FUNCNAME}() is invalid for python-r1 suite"
  1829. }
  1830. python_mod_cleanup ()
  1831. {
  1832. 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"
  1833. }
  1834. python_mod_optimize ()
  1835. {
  1836. 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"
  1837. }
  1838. python_moduleinto ()
  1839. {
  1840. debug-print-function ${FUNCNAME} "${@}";
  1841. python_moduleroot=${1}
  1842. }
  1843. python_need_rebuild ()
  1844. {
  1845. die "${FUNCNAME}() is invalid for python-r1 suite"
  1846. }
  1847. python_newexe ()
  1848. {
  1849. debug-print-function ${FUNCNAME} "${@}";
  1850. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1851. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  1852. if [[ ${EAPI:-0} == [0123] ]]; then
  1853. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  1854. fi;
  1855. local wrapd=${python_scriptroot:-/usr/bin};
  1856. local f=${1};
  1857. local newfn=${2};
  1858. local PYTHON_SCRIPTDIR d;
  1859. python_export PYTHON_SCRIPTDIR;
  1860. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  1861. ( dodir "${wrapd}";
  1862. exeopts -m 0755;
  1863. exeinto "${d}";
  1864. newexe "${f}" "${newfn}" || return ${?} );
  1865. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  1866. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  1867. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  1868. fi
  1869. }
  1870. python_newscript ()
  1871. {
  1872. debug-print-function ${FUNCNAME} "${@}";
  1873. local _PYTHON_REWRITE_SHEBANG=1;
  1874. python_newexe "${@}"
  1875. }
  1876. python_optimize ()
  1877. {
  1878. debug-print-function ${FUNCNAME} "${@}";
  1879. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  1880. eerror "The new Python eclasses expect the compiled Python files to";
  1881. eerror "be controlled by the Package Manager. For this reason,";
  1882. eerror "the python_optimize function can be used only during src_* phases";
  1883. eerror "(src_install most commonly) and not during pkg_* phases.";
  1884. echo;
  1885. die "python_optimize is not to be used in pre/post* phases";
  1886. fi;
  1887. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  1888. local PYTHON=${PYTHON};
  1889. [[ -n ${PYTHON} ]] || python_export PYTHON;
  1890. if [[ ${#} -eq 0 ]]; then
  1891. local f;
  1892. while IFS= read -r -d '' f; do
  1893. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  1894. set -- "${D%/}${f}" "${@}";
  1895. fi;
  1896. done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  1897. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  1898. fi;
  1899. local d;
  1900. for d in "$@";
  1901. do
  1902. local instpath=${d#${D%/}};
  1903. instpath=/${instpath##/};
  1904. case "${EPYTHON}" in
  1905. python2.7 | python3.[34])
  1906. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  1907. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  1908. ;;
  1909. python* | pypy3)
  1910. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  1911. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  1912. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  1913. ;;
  1914. *)
  1915. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  1916. ;;
  1917. esac;
  1918. done
  1919. }
  1920. python_pkg_setup ()
  1921. {
  1922. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  1923. }
  1924. python_scriptinto ()
  1925. {
  1926. debug-print-function ${FUNCNAME} "${@}";
  1927. python_scriptroot=${1}
  1928. }
  1929. python_set_active_version ()
  1930. {
  1931. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  1932. }
  1933. python_setup ()
  1934. {
  1935. debug-print-function ${FUNCNAME} "${@}";
  1936. unset EPYTHON;
  1937. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  1938. local impls=(${PYTHON_COMPAT_OVERRIDE});
  1939. [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1";
  1940. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  1941. ewarn "implementation will be used:";
  1942. ewarn;
  1943. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  1944. ewarn;
  1945. ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored.";
  1946. python_export "${impls[0]}" EPYTHON PYTHON;
  1947. python_wrapper_setup;
  1948. return;
  1949. fi;
  1950. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  1951. if use "python_targets_${_PYTHON_SUPPORTED_IMPLS[0]}"; then
  1952. python_export "${_PYTHON_SUPPORTED_IMPLS[0]}" EPYTHON PYTHON;
  1953. python_wrapper_setup;
  1954. fi;
  1955. else
  1956. local impl;
  1957. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1958. do
  1959. if use "python_single_target_${impl}"; then
  1960. if [[ -n ${EPYTHON} ]]; then
  1961. eerror "Your PYTHON_SINGLE_TARGET setting lists more than a single Python";
  1962. eerror "implementation. Please set it to just one value. If you need";
  1963. eerror "to override the value for a single package, please use package.env";
  1964. eerror "or an equivalent solution (man 5 portage).";
  1965. echo;
  1966. die "More than one implementation in PYTHON_SINGLE_TARGET.";
  1967. fi;
  1968. if ! use "python_targets_${impl}"; then
  1969. eerror "The implementation chosen as PYTHON_SINGLE_TARGET must be added";
  1970. eerror "to PYTHON_TARGETS as well. This is in order to ensure that";
  1971. eerror "dependencies are satisfied correctly. We're sorry";
  1972. eerror "for the inconvenience.";
  1973. echo;
  1974. die "Build target (${impl}) not in PYTHON_TARGETS.";
  1975. fi;
  1976. python_export "${impl}" EPYTHON PYTHON;
  1977. python_wrapper_setup;
  1978. fi;
  1979. done;
  1980. fi;
  1981. if [[ ! -n ${EPYTHON} ]]; then
  1982. eerror "No Python implementation selected for the build. Please set";
  1983. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  1984. eerror "the PYTHON_TARGETS variable in your make.conf to include one";
  1985. else
  1986. eerror "the PYTHON_SINGLE_TARGET variable in your make.conf to one";
  1987. fi;
  1988. eerror "of the following values:";
  1989. eerror;
  1990. eerror "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1991. echo;
  1992. die "No supported Python implementation in PYTHON_SINGLE_TARGET/PYTHON_TARGETS.";
  1993. fi
  1994. }
  1995. python_wrapper_setup ()
  1996. {
  1997. debug-print-function ${FUNCNAME} "${@}";
  1998. local workdir=${1:-${T}/${EPYTHON}};
  1999. local impl=${2:-${EPYTHON}};
  2000. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  2001. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  2002. if [[ ! -x ${workdir}/bin/python ]]; then
  2003. _python_check_dead_variables;
  2004. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  2005. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  2006. rm -f "${workdir}"/bin/2to3 || die;
  2007. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  2008. local EPYTHON PYTHON;
  2009. python_export "${impl}" EPYTHON PYTHON;
  2010. local pyver pyother;
  2011. if python_is_python3; then
  2012. pyver=3;
  2013. pyother=2;
  2014. else
  2015. pyver=2;
  2016. pyother=3;
  2017. fi;
  2018. cat > "${workdir}/bin/python" <<-_EOF_ ||
  2019. #!/bin/sh
  2020. exec "${PYTHON}" "\${@}"
  2021. _EOF_
  2022. die
  2023. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2024. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2025. local nonsupp=("python${pyother}" "python${pyother}-config");
  2026. if [[ ${EPYTHON} == python* ]]; then
  2027. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  2028. #!/bin/sh
  2029. exec "${PYTHON}-config" "\${@}"
  2030. _EOF_
  2031. die
  2032. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2033. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2034. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  2035. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  2036. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  2037. else
  2038. nonsupp+=(2to3 python-config "python${pyver}-config");
  2039. fi;
  2040. local x;
  2041. for x in "${nonsupp[@]}";
  2042. do
  2043. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  2044. #!/bin/sh
  2045. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  2046. exit 127
  2047. _EOF_
  2048. die
  2049. chmod +x "${workdir}"/bin/${x} || die;
  2050. done;
  2051. fi;
  2052. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  2053. PATH=${workdir}/bin${PATH:+:${PATH}};
  2054. fi;
  2055. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  2056. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  2057. fi;
  2058. export PATH PKG_CONFIG_PATH
  2059. }
  2060. src_compile ()
  2061. {
  2062. emake V=1 all $(usev static)
  2063. }
  2064. src_configure ()
  2065. {
  2066. local myeconfargs=(--bindir="${EPREFIX}"/sbin $(use_enable convert) $(use_enable elibc_glibc backtrace) $(use_enable python) $(use_enable static-libs static) $(use_enable zstd) --with-convert=ext2$(usex reiserfs ',reiserfs' ''));
  2067. econf "${myeconfargs[@]}"
  2068. }
  2069. src_install ()
  2070. {
  2071. local makeargs=($(usex python install_python '') $(usex static install-static ''));
  2072. emake V=1 DESTDIR="${D}" install "${makeargs[@]}";
  2073. newbashcomp btrfs-completion btrfs;
  2074. use python && python_optimize
  2075. }
  2076. src_prepare ()
  2077. {
  2078. default;
  2079. if [[ ${PV} == 9999 ]]; then
  2080. AT_M4DIR=m4 eautoreconf;
  2081. mkdir config || die;
  2082. local automakedir="$(autotools_run_tool --at-output automake --print-libdir)";
  2083. [[ -e ${automakedir} ]] || die "Could not locate automake directory";
  2084. ln -s "${automakedir}"/install-sh config/install-sh || die;
  2085. ln -s "${EPREFIX}"/usr/share/gnuconfig/config.guess config/config.guess || die;
  2086. ln -s "${EPREFIX}"/usr/share/gnuconfig/config.sub config/config.sub || die;
  2087. fi
  2088. }
  2089. src_test ()
  2090. {
  2091. default
  2092. }
  2093. src_unpack ()
  2094. {
  2095. default
  2096. }
  2097. tc-arch ()
  2098. {
  2099. tc-ninja_magic_to_arch portage "$@"
  2100. }
  2101. tc-arch-kernel ()
  2102. {
  2103. tc-ninja_magic_to_arch kern "$@"
  2104. }
  2105. tc-check-openmp ()
  2106. {
  2107. if ! tc-has-openmp; then
  2108. eerror "Your current compiler does not support OpenMP!";
  2109. if tc-is-gcc; then
  2110. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  2111. else
  2112. if tc-is-clang; then
  2113. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  2114. fi;
  2115. fi;
  2116. die "Active compiler does not have required support for OpenMP";
  2117. fi
  2118. }
  2119. tc-cpp-is-true ()
  2120. {
  2121. local CONDITION=${1};
  2122. shift;
  2123. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  2124. #if ${CONDITION}
  2125. true
  2126. #endif
  2127. EOF
  2128. );
  2129. [[ ${RESULT} == true ]]
  2130. }
  2131. tc-detect-is-softfloat ()
  2132. {
  2133. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  2134. case ${CTARGET:-${CHOST}} in
  2135. *-newlib | *-elf | *-eabi)
  2136. return 1
  2137. ;;
  2138. arm*)
  2139. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  2140. echo "no";
  2141. else
  2142. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  2143. echo "yes";
  2144. else
  2145. echo "softfp";
  2146. fi;
  2147. fi;
  2148. return 0
  2149. ;;
  2150. *)
  2151. return 1
  2152. ;;
  2153. esac
  2154. }
  2155. tc-enables-pie ()
  2156. {
  2157. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  2158. }
  2159. tc-enables-ssp ()
  2160. {
  2161. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2162. }
  2163. tc-enables-ssp-all ()
  2164. {
  2165. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2166. }
  2167. tc-enables-ssp-strong ()
  2168. {
  2169. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2170. }
  2171. tc-endian ()
  2172. {
  2173. local host=$1;
  2174. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2175. host=${host%%-*};
  2176. case ${host} in
  2177. aarch64*be)
  2178. echo big
  2179. ;;
  2180. aarch64)
  2181. echo little
  2182. ;;
  2183. alpha*)
  2184. echo little
  2185. ;;
  2186. arm*b*)
  2187. echo big
  2188. ;;
  2189. arm*)
  2190. echo little
  2191. ;;
  2192. cris*)
  2193. echo little
  2194. ;;
  2195. hppa*)
  2196. echo big
  2197. ;;
  2198. i?86*)
  2199. echo little
  2200. ;;
  2201. ia64*)
  2202. echo little
  2203. ;;
  2204. m68*)
  2205. echo big
  2206. ;;
  2207. mips*l*)
  2208. echo little
  2209. ;;
  2210. mips*)
  2211. echo big
  2212. ;;
  2213. powerpc*le)
  2214. echo little
  2215. ;;
  2216. powerpc*)
  2217. echo big
  2218. ;;
  2219. s390*)
  2220. echo big
  2221. ;;
  2222. sh*b*)
  2223. echo big
  2224. ;;
  2225. sh*)
  2226. echo little
  2227. ;;
  2228. sparc*)
  2229. echo big
  2230. ;;
  2231. x86_64*)
  2232. echo little
  2233. ;;
  2234. *)
  2235. echo wtf
  2236. ;;
  2237. esac
  2238. }
  2239. tc-env_build ()
  2240. {
  2241. tc-export_build_env;
  2242. 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) "$@"
  2243. }
  2244. tc-export ()
  2245. {
  2246. local var;
  2247. for var in "$@";
  2248. do
  2249. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2250. "tc-get${var}" > /dev/null;
  2251. done
  2252. }
  2253. tc-export_build_env ()
  2254. {
  2255. tc-export "$@";
  2256. if tc-is-cross-compiler; then
  2257. : ${BUILD_CFLAGS:=-O1 -pipe};
  2258. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2259. : ${BUILD_CPPFLAGS:= };
  2260. : ${BUILD_LDFLAGS:= };
  2261. else
  2262. : ${BUILD_CFLAGS:=${CFLAGS}};
  2263. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  2264. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  2265. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  2266. fi;
  2267. export BUILD_{C,CXX,CPP,LD}FLAGS;
  2268. local v;
  2269. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  2270. do
  2271. export ${v#BUILD_}_FOR_BUILD="${!v}";
  2272. done
  2273. }
  2274. tc-get-compiler-type ()
  2275. {
  2276. local code='
  2277. #if defined(__PATHSCALE__)
  2278. HAVE_PATHCC
  2279. #elif defined(__clang__)
  2280. HAVE_CLANG
  2281. #elif defined(__GNUC__)
  2282. HAVE_GCC
  2283. #endif
  2284. ';
  2285. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  2286. case ${res} in
  2287. *HAVE_PATHCC*)
  2288. echo pathcc
  2289. ;;
  2290. *HAVE_CLANG*)
  2291. echo clang
  2292. ;;
  2293. *HAVE_GCC*)
  2294. echo gcc
  2295. ;;
  2296. *)
  2297. echo unknown
  2298. ;;
  2299. esac
  2300. }
  2301. tc-getAR ()
  2302. {
  2303. tc-getPROG AR ar "$@"
  2304. }
  2305. tc-getAS ()
  2306. {
  2307. tc-getPROG AS as "$@"
  2308. }
  2309. tc-getBUILD_AR ()
  2310. {
  2311. tc-getBUILD_PROG AR ar "$@"
  2312. }
  2313. tc-getBUILD_AS ()
  2314. {
  2315. tc-getBUILD_PROG AS as "$@"
  2316. }
  2317. tc-getBUILD_CC ()
  2318. {
  2319. tc-getBUILD_PROG CC gcc "$@"
  2320. }
  2321. tc-getBUILD_CPP ()
  2322. {
  2323. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  2324. }
  2325. tc-getBUILD_CXX ()
  2326. {
  2327. tc-getBUILD_PROG CXX g++ "$@"
  2328. }
  2329. tc-getBUILD_LD ()
  2330. {
  2331. tc-getBUILD_PROG LD ld "$@"
  2332. }
  2333. tc-getBUILD_NM ()
  2334. {
  2335. tc-getBUILD_PROG NM nm "$@"
  2336. }
  2337. tc-getBUILD_OBJCOPY ()
  2338. {
  2339. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2340. }
  2341. tc-getBUILD_PKG_CONFIG ()
  2342. {
  2343. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2344. }
  2345. tc-getBUILD_PROG ()
  2346. {
  2347. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  2348. tc-is-cross-compiler || vars+=" $1";
  2349. _tc-getPROG CBUILD "${vars}" "${@:2}"
  2350. }
  2351. tc-getBUILD_RANLIB ()
  2352. {
  2353. tc-getBUILD_PROG RANLIB ranlib "$@"
  2354. }
  2355. tc-getBUILD_STRIP ()
  2356. {
  2357. tc-getBUILD_PROG STRIP strip "$@"
  2358. }
  2359. tc-getCC ()
  2360. {
  2361. tc-getPROG CC gcc "$@"
  2362. }
  2363. tc-getCPP ()
  2364. {
  2365. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  2366. }
  2367. tc-getCXX ()
  2368. {
  2369. tc-getPROG CXX g++ "$@"
  2370. }
  2371. tc-getDLLWRAP ()
  2372. {
  2373. tc-getPROG DLLWRAP dllwrap "$@"
  2374. }
  2375. tc-getF77 ()
  2376. {
  2377. tc-getPROG F77 gfortran "$@"
  2378. }
  2379. tc-getFC ()
  2380. {
  2381. tc-getPROG FC gfortran "$@"
  2382. }
  2383. tc-getGCJ ()
  2384. {
  2385. tc-getPROG GCJ gcj "$@"
  2386. }
  2387. tc-getGO ()
  2388. {
  2389. tc-getPROG GO gccgo "$@"
  2390. }
  2391. tc-getLD ()
  2392. {
  2393. tc-getPROG LD ld "$@"
  2394. }
  2395. tc-getNM ()
  2396. {
  2397. tc-getPROG NM nm "$@"
  2398. }
  2399. tc-getOBJCOPY ()
  2400. {
  2401. tc-getPROG OBJCOPY objcopy "$@"
  2402. }
  2403. tc-getOBJDUMP ()
  2404. {
  2405. tc-getPROG OBJDUMP objdump "$@"
  2406. }
  2407. tc-getPKG_CONFIG ()
  2408. {
  2409. tc-getPROG PKG_CONFIG pkg-config "$@"
  2410. }
  2411. tc-getPROG ()
  2412. {
  2413. _tc-getPROG CHOST "$@"
  2414. }
  2415. tc-getRANLIB ()
  2416. {
  2417. tc-getPROG RANLIB ranlib "$@"
  2418. }
  2419. tc-getRC ()
  2420. {
  2421. tc-getPROG RC windres "$@"
  2422. }
  2423. tc-getSTRIP ()
  2424. {
  2425. tc-getPROG STRIP strip "$@"
  2426. }
  2427. tc-getTARGET_CPP ()
  2428. {
  2429. if [[ -n ${CTARGET} ]]; then
  2430. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  2431. else
  2432. tc-getCPP "$@";
  2433. fi
  2434. }
  2435. tc-has-openmp ()
  2436. {
  2437. local base="${T}/test-tc-openmp";
  2438. cat > "${base}.c" <<-EOF
  2439. #include <omp.h>
  2440. int main() {
  2441. int nthreads, tid, ret = 0;
  2442. #pragma omp parallel private(nthreads, tid)
  2443. {
  2444. tid = omp_get_thread_num();
  2445. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  2446. }
  2447. return ret;
  2448. }
  2449. EOF
  2450. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  2451. local ret=$?;
  2452. rm -f "${base}"*;
  2453. return ${ret}
  2454. }
  2455. tc-has-tls ()
  2456. {
  2457. local base="${T}/test-tc-tls";
  2458. cat > "${base}.c" <<-EOF
  2459. int foo(int *i) {
  2460. static __thread int j = 0;
  2461. return *i ? j : *i;
  2462. }
  2463. EOF
  2464. local flags;
  2465. case $1 in
  2466. -s)
  2467. flags="-S"
  2468. ;;
  2469. -c)
  2470. flags="-c"
  2471. ;;
  2472. -l)
  2473. ;;
  2474. -*)
  2475. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  2476. ;;
  2477. esac;
  2478. : ${flags:=-fPIC -shared -Wl,-z,defs};
  2479. [[ $1 == -* ]] && shift;
  2480. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  2481. local ret=$?;
  2482. rm -f "${base}"*;
  2483. return ${ret}
  2484. }
  2485. tc-is-clang ()
  2486. {
  2487. [[ $(tc-get-compiler-type) == clang ]]
  2488. }
  2489. tc-is-cross-compiler ()
  2490. {
  2491. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  2492. }
  2493. tc-is-gcc ()
  2494. {
  2495. [[ $(tc-get-compiler-type) == gcc ]]
  2496. }
  2497. tc-is-softfloat ()
  2498. {
  2499. tc-detect-is-softfloat || tc-tuple-is-softfloat
  2500. }
  2501. tc-is-static-only ()
  2502. {
  2503. local host=${CTARGET:-${CHOST}};
  2504. [[ ${host} == *-mint* ]]
  2505. }
  2506. tc-ld-disable-gold ()
  2507. {
  2508. if ! tc-ld-is-gold "$@"; then
  2509. return;
  2510. fi;
  2511. ewarn "Forcing usage of the BFD linker instead of GOLD";
  2512. local ld=$(tc-getLD "$@");
  2513. local bfd_ld="${ld%% *}.bfd";
  2514. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  2515. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  2516. local fallback="true";
  2517. if tc-is-gcc; then
  2518. local major=$(gcc-major-version "$@");
  2519. local minor=$(gcc-minor-version "$@");
  2520. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  2521. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  2522. fallback="false";
  2523. fi;
  2524. else
  2525. if tc-is-clang; then
  2526. local major=$(clang-major-version "$@");
  2527. local minor=$(clang-minor-version "$@");
  2528. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  2529. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  2530. fallback="false";
  2531. fi;
  2532. fi;
  2533. fi;
  2534. if [[ ${fallback} == "true" ]]; then
  2535. if [[ -e ${path_ld} ]]; then
  2536. local d="${T}/bfd-linker";
  2537. mkdir -p "${d}";
  2538. ln -sf "${path_ld}" "${d}"/ld;
  2539. export LDFLAGS="${LDFLAGS} -B${d}";
  2540. else
  2541. die "unable to locate a BFD linker to bypass gold";
  2542. fi;
  2543. fi
  2544. }
  2545. tc-ld-is-gold ()
  2546. {
  2547. local out;
  2548. out=$($(tc-getLD "$@") --version 2>&1);
  2549. if [[ ${out} == *"GNU gold"* ]]; then
  2550. return 0;
  2551. fi;
  2552. local base="${T}/test-tc-gold";
  2553. cat > "${base}.c" <<-EOF
  2554. int main() { return 0; }
  2555. EOF
  2556. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  2557. rm -f "${base}"*;
  2558. if [[ ${out} == *"GNU gold"* ]]; then
  2559. return 0;
  2560. fi;
  2561. return 1
  2562. }
  2563. tc-ninja_magic_to_arch ()
  2564. {
  2565. function ninj ()
  2566. {
  2567. [[ ${type} == "kern" ]] && echo $1 || echo $2
  2568. };
  2569. local type=$1;
  2570. local host=$2;
  2571. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2572. case ${host} in
  2573. aarch64*)
  2574. echo arm64
  2575. ;;
  2576. alpha*)
  2577. echo alpha
  2578. ;;
  2579. arm*)
  2580. echo arm
  2581. ;;
  2582. avr*)
  2583. ninj avr32 avr
  2584. ;;
  2585. bfin*)
  2586. ninj blackfin bfin
  2587. ;;
  2588. c6x*)
  2589. echo c6x
  2590. ;;
  2591. cris*)
  2592. echo cris
  2593. ;;
  2594. frv*)
  2595. echo frv
  2596. ;;
  2597. hexagon*)
  2598. echo hexagon
  2599. ;;
  2600. hppa*)
  2601. ninj parisc hppa
  2602. ;;
  2603. i?86*)
  2604. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  2605. echo i386;
  2606. else
  2607. echo x86;
  2608. fi
  2609. ;;
  2610. ia64*)
  2611. echo ia64
  2612. ;;
  2613. m68*)
  2614. echo m68k
  2615. ;;
  2616. metag*)
  2617. echo metag
  2618. ;;
  2619. microblaze*)
  2620. echo microblaze
  2621. ;;
  2622. mips*)
  2623. echo mips
  2624. ;;
  2625. nios2*)
  2626. echo nios2
  2627. ;;
  2628. nios*)
  2629. echo nios
  2630. ;;
  2631. or1k | or32*)
  2632. echo openrisc
  2633. ;;
  2634. powerpc*)
  2635. if [[ ${type} == "kern" ]]; then
  2636. echo powerpc;
  2637. else
  2638. if [[ ${host} == powerpc64* ]]; then
  2639. echo ppc64;
  2640. else
  2641. echo ppc;
  2642. fi;
  2643. fi
  2644. ;;
  2645. riscv*)
  2646. echo riscv
  2647. ;;
  2648. s390*)
  2649. echo s390
  2650. ;;
  2651. score*)
  2652. echo score
  2653. ;;
  2654. sh64*)
  2655. ninj sh64 sh
  2656. ;;
  2657. sh*)
  2658. echo sh
  2659. ;;
  2660. sparc64*)
  2661. ninj sparc64 sparc
  2662. ;;
  2663. sparc*)
  2664. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  2665. ;;
  2666. tile*)
  2667. echo tile
  2668. ;;
  2669. vax*)
  2670. echo vax
  2671. ;;
  2672. x86_64*freebsd*)
  2673. echo amd64
  2674. ;;
  2675. x86_64*)
  2676. if [[ ${type} == "kern" ]]; then
  2677. echo x86;
  2678. else
  2679. echo amd64;
  2680. fi
  2681. ;;
  2682. xtensa*)
  2683. echo xtensa
  2684. ;;
  2685. *)
  2686. echo unknown
  2687. ;;
  2688. esac
  2689. }
  2690. tc-stack-grows-down ()
  2691. {
  2692. case ${ARCH} in
  2693. hppa | metag)
  2694. return 1
  2695. ;;
  2696. esac;
  2697. return 0
  2698. }
  2699. tc-tuple-is-softfloat ()
  2700. {
  2701. local CTARGET=${CTARGET:-${CHOST}};
  2702. case ${CTARGET//_/-} in
  2703. bfin* | h8300*)
  2704. echo "only"
  2705. ;;
  2706. *-softfloat-*)
  2707. echo "yes"
  2708. ;;
  2709. *-softfp-*)
  2710. echo "softfp"
  2711. ;;
  2712. arm*-hardfloat-* | arm*eabihf)
  2713. echo "no"
  2714. ;;
  2715. *-newlib | *-elf | *-eabi)
  2716. echo "no"
  2717. ;;
  2718. arm*)
  2719. echo "yes"
  2720. ;;
  2721. *)
  2722. echo "no"
  2723. ;;
  2724. esac
  2725. }
  2726.