Guest User

Untitled

a guest
Feb 4th, 2019
183
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. declare -x ABI="x86"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_PPC=""
  4. declare -x ABI_S390=""
  5. declare -x ABI_X86="32"
  6. declare -x ADAFLAGS=""
  7. declare -a ALL_AUTOTOOLS_MACROS=([0]="AC_PROG_LIBTOOL" [1]="AM_PROG_LIBTOOL" [2]="LT_INIT" [3]="LT_CONFIG_LTDL_DIR" [4]="AC_CONFIG_HEADERS" [5]="AC_CONFIG_HEADER" [6]="AM_CONFIG_HEADERS" [7]="AM_CONFIG_HEADER" [8]="AC_CONFIG_SUBDIRS" [9]="AC_CONFIG_AUX_DIR" [10]="AC_CONFIG_MACRO_DIR" [11]="AM_INIT_AUTOMAKE" [12]="AM_GLIB_GNU_GETTEXT" [13]="AM_GNU_GETTEXT_VERSION" [14]="AM_GNU_GETTEXT_REQUIRE_VERSION" [15]="AC_PROG_INTLTOOL" [16]="IT_PROG_INTLTOOL" [17]="GTK_DOC_CHECK" [18]="GNOME_DOC_INIT")
  8. declare -x ALSA_CARDS=""
  9. declare -x APACHE2_MODULES=""
  10. declare -x APACHE2_MPMS=""
  11. declare -x ARCH="x86"
  12. declare -- AT_M4DIR=""
  13. declare -- AT_SYS_M4DIR=""
  14. declare -- AUTOTOOLS_AUTO_DEPEND="yes"
  15. declare -- AUTOTOOLS_DEPEND="!<sys-devel/gettext-0.18.1.1-r3
  16. || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 )
  17. >=sys-devel/autoconf-2.69
  18. "
  19. declare BDEPEND=""
  20. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7"
  21. declare -x CALLIGRA_FEATURES=""
  22. declare -x CAMERAS=""
  23. declare -x CBUILD="i686-pc-linux-gnu"
  24. declare -x CCASFLAGS=""
  25. declare -x CFLAGS="-O2 -march=atom -mtune=atom -pipe --param l1-cache-line-size=64 --param l1-cache-size=24 --param l2-cache-size=512 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -fwrapv"
  26. declare -x CFLAGS_default
  27. declare -x CHOST="i686-pc-linux-gnu"
  28. declare -x CHOST_default="i686-pc-linux-gnu"
  29. declare -x CHOST_x86="i686-pc-linux-gnu"
  30. declare -x COLLECTD_PLUGINS=""
  31. declare -x CONF_PREFIX="/usr"
  32. declare -x CPPFLAGS=""
  33. declare -x CPU_FLAGS_ARM=""
  34. declare -x CPU_FLAGS_X86=""
  35. declare -x CTARGET_default="i686-pc-linux-gnu"
  36. declare -x CURL_SSL=""
  37. declare -x CXX="i686-pc-linux-gnu-g++"
  38. declare -x CXXFLAGS="-O3 -march=atom -mtune=atom -pipe --param l1-cache-line-size=64 --param l1-cache-size=24 --param l2-cache-size=512 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -fexcess-precision=fast -fmerge-all-constants -fno-gcse -funroll-all-loops -g0 -Wno-all -ffast-math -fomit-frame-pointer -fwrapv"
  39. declare -x DEFAULT_ABI="x86"
  40. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare test"
  41. declare DEPEND="app-arch/bzip2:0=
  42. app-arch/xz-utils:0=
  43. >=sys-libs/zlib-1.1.3:0=
  44. virtual/libffi:=
  45. virtual/libintl
  46. gdbm? ( sys-libs/gdbm:0=[berkdb] )
  47. ncurses? ( >=sys-libs/ncurses-5.2:0= )
  48. readline? ( >=sys-libs/readline-4.1:0= )
  49. sqlite? ( >=dev-db/sqlite-3.3.8:3= )
  50. ssl? (
  51. !libressl? ( dev-libs/openssl:0= )
  52. libressl? ( dev-libs/libressl:0= )
  53. )
  54. tk? (
  55. >=dev-lang/tcl-8.0:0=
  56. >=dev-lang/tk-8.0:0=
  57. dev-tcltk/blt:0=
  58. dev-tcltk/tix
  59. )
  60. xml? ( >=dev-libs/expat-2.1:0= )
  61. !!<sys-apps/sandbox-2.6-r1
  62. test? ( app-arch/xz-utils[extra-filters(+)] )
  63. virtual/pkgconfig
  64. !sys-devel/gcc[libffi(-)] >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3
  65. || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 )
  66. >=sys-devel/autoconf-2.69
  67. "
  68. declare DESCRIPTION="An interpreted, interactive, object-oriented programming language"
  69. declare -x DESTTREE="/usr"
  70. declare -x DIROPTIONS="-m0755"
  71. declare -x EAPI="6"
  72. declare -- ECONF_SOURCE="."
  73. declare -x ELIBC="glibc"
  74. declare -x ENLIGHTENMENT_MODULES=""
  75. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  76. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  77. declare -- EPATCH_EXCLUDE=""
  78. declare -- EPATCH_FORCE="no"
  79. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  80. declare -- EPATCH_OPTS=""
  81. declare -- EPATCH_SINGLE_MSG=""
  82. declare -- EPATCH_SOURCE="/var/tmp/portage/dev-lang/python-3.6.5/work/patch"
  83. declare -- EPATCH_SUFFIX="patch.bz2"
  84. declare -x EXEOPTIONS="-m0755"
  85. declare -x FCFLAGS="-O2 -march=i686 -pipe -fwrapv"
  86. 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}\""
  87. declare -x FFLAGS="-O2 -march=i686 -pipe -fwrapv"
  88. declare -x FFTOOLS=""
  89. declare -x GCC_SPECS=""
  90. declare -x GPSD_PROTOCOLS=""
  91. declare -x GRUB_PLATFORMS=""
  92. declare -x GSETTINGS_BACKEND="dconf"
  93. declare HDEPEND=""
  94. declare HOMEPAGE="https://www.python.org/"
  95. declare -x HUSHLOGIN="FALSE"
  96. declare -x INHERITED=" toolchain-funcs multilib libtool autotools desktop epatch estack ltprune preserve-libs vcs-clean eutils flag-o-matic pax-utils python-utils-r1"
  97. declare -x INPUT_DEVICES=""
  98. declare -x INSDESTTREE=""
  99. declare -x INSOPTIONS="-m0644"
  100. declare IUSE="build examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl test +threads tk wininst +xml "
  101. declare -x IUSE_EFFECTIVE="abi_x86_32 alpha amd64 amd64-fbsd amd64-linux arm arm64 build elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc examples gdbm hardened hppa ia64 ipv6 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux libressl m68k m68k-mint mips ncurses ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest readline s390 sh sparc sparc-solaris sparc64-solaris sqlite ssl test threads tk userland_BSD userland_GNU wininst x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt xml"
  102. declare -x IUSE_IMPLICIT="abi_x86_32 prefix prefix-chain prefix-guest"
  103. declare -x KERNEL="linux"
  104. declare -x KERNEL_ABI="x86"
  105. declare -x KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd"
  106. declare -x L10N=""
  107. declare -x LANG="en_US.utf8"
  108. declare -x LCD_DEVICES=""
  109. declare -x LC_COLLATE="C"
  110. declare -x LC_MESSAGES="C"
  111. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed -L."
  112. declare -x LDFLAGS_default
  113. declare -x LIBDIR_default="lib"
  114. declare -x LIBDIR_x86="lib"
  115. declare -x LIBOPTIONS="-m0644"
  116. declare -x LIBREOFFICE_EXTENSIONS=""
  117. declare -x LICENSE="PSF-2"
  118. declare -x LIRC_DEVICES=""
  119. declare -x LLVM_TARGETS=""
  120. declare -x MAIL="/var/mail/root"
  121. declare -x MAKEOPTS="-j5"
  122. declare -x MANPAGER="manpager"
  123. declare -x MONKEYD_PLUGINS=""
  124. declare -x MULTILIB_ABIS="x86"
  125. declare -- MY_P="Python-3.6.5"
  126. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  127. declare -x NETBEANS_MODULES=""
  128. declare -x NGINX_MODULES_HTTP=""
  129. declare -x NGINX_MODULES_MAIL=""
  130. declare -x NGINX_MODULES_STREAM=""
  131. declare -x OFED_DRIVERS=""
  132. declare -x OFFICE_IMPLEMENTATION=""
  133. declare -x OPENGL_PROFILE="xorg-x11"
  134. declare -x OPENMPI_FABRICS=""
  135. declare -x OPENMPI_OFED_FEATURES=""
  136. declare -x OPENMPI_RM=""
  137. declare -- PATCHSET_VERSION="3.6.4"
  138. declare -x PATH="/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/lib/llvm/6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  139. declare -- PAX_MARKINGS="PT XT"
  140. declare PDEPEND=">=app-eselect/eselect-python-20140125-r1 "
  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/python-3.6.5/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 -x PYTHON_DISABLE_MODULES=""
  154. declare -x PYTHON_SINGLE_TARGET=""
  155. declare -x PYTHON_TARGETS=""
  156. declare -- PYVER="3.6"
  157. declare -x QEMU_SOFTMMU_TARGETS=""
  158. declare -x QEMU_USER_TARGETS=""
  159. declare RDEPEND="app-arch/bzip2:0=
  160. app-arch/xz-utils:0=
  161. >=sys-libs/zlib-1.1.3:0=
  162. virtual/libffi:=
  163. virtual/libintl
  164. gdbm? ( sys-libs/gdbm:0=[berkdb] )
  165. ncurses? ( >=sys-libs/ncurses-5.2:0= )
  166. readline? ( >=sys-libs/readline-4.1:0= )
  167. sqlite? ( >=dev-db/sqlite-3.3.8:3= )
  168. ssl? (
  169. !libressl? ( dev-libs/openssl:0= )
  170. libressl? ( dev-libs/libressl:0= )
  171. )
  172. tk? (
  173. >=dev-lang/tcl-8.0:0=
  174. >=dev-lang/tk-8.0:0=
  175. dev-tcltk/blt:0=
  176. dev-tcltk/tix
  177. )
  178. xml? ( >=dev-libs/expat-2.1:0= )
  179. !!<sys-apps/sandbox-2.6-r1 !build? ( app-misc/mime-types ) "
  180. declare REPOSITORY
  181. declare REQUIRED_USE=""
  182. declare -x RESTRICT="test"
  183. 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}\""
  184. declare -x ROS_MESSAGES=""
  185. declare -x RUBY_TARGETS=""
  186. declare -x S="/var/tmp/portage/dev-lang/python-3.6.5/work/Python-3.6.5"
  187. declare -x SANDBOX_DEBUG="0"
  188. declare -x SANDBOX_DENY=""
  189. declare -x SANDBOX_PREDICT="/var/tmp/portage/dev-lang/python-3.6.5/homedir:/dev/crypto:/var/cache/fontconfig"
  190. declare -x SANDBOX_READ="/:/var/tmp"
  191. declare -x SANDBOX_VERBOSE="1"
  192. 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/dev-lang/python-3.6.5/homedir/.bash_history"
  193. declare -x SANE_BACKENDS=""
  194. declare -x SHELL="/bin/bash"
  195. declare -x SLOT="3.6/3.6m"
  196. declare SRC_URI="https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
  197. https://dev.gentoo.org/~floppym/python/python-gentoo-patches-3.6.4.tar.xz"
  198. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  199. declare -x USE="abi_x86_32 elibc_glibc gdbm kernel_linux ncurses readline sqlite ssl threads tk userland_GNU x86 xml"
  200. declare -x USERLAND="GNU"
  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 WANT_AUTOCONF="2.5"
  211. declare -x WANT_AUTOMAKE="1.16"
  212. declare -x WANT_LIBTOOL="none"
  213. declare -x XFCE_PLUGINS=""
  214. declare -x XTABLES_ADDONS=""
  215. declare -- _AUTOTOOLS_ECLASS="1"
  216. declare -- _DESKTOP_ECLASS="1"
  217. declare -- _EPATCH_ECLASS="1"
  218. declare -- _ESTACK_ECLASS="1"
  219. declare -- _EUTILS_ECLASS="1"
  220. declare -x _E_DOCDESTTREE_=""
  221. declare -x _E_EXEDESTTREE_=""
  222. declare -- _FLAG_O_MATIC_ECLASS="1"
  223. declare -a _LATEST_AUTOMAKE=([0]="1.16.1:1.16" [1]="1.15.1:1.15")
  224. declare -- _LIBTOOL_ECLASS="1"
  225. declare -- _LTPRUNE_ECLASS="1"
  226. declare -- _MULTILIB_ECLASS="1"
  227. declare -- _PAX_UTILS_ECLASS="1"
  228. declare -- _PRESERVE_LIBS_ECLASS="1"
  229. 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")
  230. declare -- _PYTHON_UTILS_R1="1"
  231. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  232. declare -- __AUTOTOOLS_AUTO_DEPEND="yes"
  233. declare -- _libtool_atom=""
  234. declare -- phase_func
  235. declare -- started_applying="1"
  236. PYTHON ()
  237. {
  238. 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"
  239. }
  240. __eapi6_src_install ()
  241. {
  242. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  243. emake DESTDIR="${D}" install;
  244. fi;
  245. einstalldocs
  246. }
  247. __eapi6_src_prepare ()
  248. {
  249. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  250. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  251. else
  252. if [[ -n ${PATCHES} ]]; then
  253. eapply ${PATCHES};
  254. fi;
  255. fi;
  256. eapply_user
  257. }
  258. _at_uses_autoheader ()
  259. {
  260. _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  261. }
  262. _at_uses_automake ()
  263. {
  264. _at_uses_pkg AM_INIT_AUTOMAKE
  265. }
  266. _at_uses_gettext ()
  267. {
  268. _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  269. }
  270. _at_uses_glibgettext ()
  271. {
  272. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  273. }
  274. _at_uses_gnomedoc ()
  275. {
  276. _at_uses_pkg GNOME_DOC_INIT
  277. }
  278. _at_uses_gtkdoc ()
  279. {
  280. _at_uses_pkg GTK_DOC_CHECK
  281. }
  282. _at_uses_intltool ()
  283. {
  284. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  285. }
  286. _at_uses_libltdl ()
  287. {
  288. _at_uses_pkg LT_CONFIG_LTDL_DIR
  289. }
  290. _at_uses_libtool ()
  291. {
  292. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  293. }
  294. _at_uses_pkg ()
  295. {
  296. if [[ -n $(autotools_check_macro "$@") ]]; then
  297. return 0;
  298. else
  299. local macro args=();
  300. for macro in "$@";
  301. do
  302. args+=(-e "^[[:space:]]*${macro}\>");
  303. done;
  304. egrep -q "${args[@]}" configure.??;
  305. fi
  306. }
  307. _automake_version ()
  308. {
  309. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  310. }
  311. _autotools_m4dir_include ()
  312. {
  313. local x include_opts flag;
  314. [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  315. for x in "$@";
  316. do
  317. case ${x} in
  318. -${flag})
  319.  
  320. ;;
  321. *)
  322. [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  323. include_opts+=" -${flag} ${x}"
  324. ;;
  325. esac;
  326. done;
  327. echo ${include_opts}
  328. }
  329. _clang_fullversion ()
  330. {
  331. local ver="$1";
  332. shift;
  333. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  334. eval echo "$ver"
  335. }
  336. _eapply_get_files ()
  337. {
  338. local LC_ALL=POSIX;
  339. local prev_shopt=$(shopt -p nullglob);
  340. shopt -s nullglob;
  341. local f;
  342. for f in "${1}"/*;
  343. do
  344. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  345. files+=("${f}");
  346. fi;
  347. done;
  348. ${prev_shopt}
  349. }
  350. _eapply_patch ()
  351. {
  352. local f=${1};
  353. local prefix=${2};
  354. started_applying=1;
  355. ebegin "${prefix:-Applying }${f##*/}";
  356. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  357. failed=${?};
  358. if ! eend "${failed}"; then
  359. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  360. fi
  361. }
  362. _elibtoolize ()
  363. {
  364. local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  365. if [[ $1 == "--auto-ltdl" ]]; then
  366. shift;
  367. _at_uses_libltdl && set -- "$@" --ltdl;
  368. fi;
  369. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  370. autotools_run_tool ${LIBTOOLIZE} "$@"
  371. }
  372. _filter-hardened ()
  373. {
  374. local f;
  375. for f in "$@";
  376. do
  377. case "${f}" in
  378. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  379. gcc-specs-pie || continue;
  380. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  381. if test-flags -nopie > /dev/null; then
  382. append-flags -nopie;
  383. else
  384. append-flags -no-pie;
  385. fi;
  386. fi
  387. ;;
  388. -fstack-protector)
  389. gcc-specs-ssp || continue;
  390. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  391. ;;
  392. -fstack-protector-all)
  393. gcc-specs-ssp-to-all || continue;
  394. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  395. ;;
  396. -fno-strict-overflow)
  397. gcc-specs-nostrict || continue;
  398. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  399. ;;
  400. esac;
  401. done
  402. }
  403. _filter-var ()
  404. {
  405. local f x var=$1 new=();
  406. shift;
  407. for f in ${!var};
  408. do
  409. for x in "$@";
  410. do
  411. [[ ${f} == ${x} ]] && continue 2;
  412. done;
  413. new+=("${f}");
  414. done;
  415. export ${var}="${new[*]}"
  416. }
  417. _gcc-install-dir ()
  418. {
  419. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  420. }
  421. _gcc-specs-directive_raw ()
  422. {
  423. local cc=$(tc-getCC);
  424. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  425. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  426. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  427. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  428. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  429. { spec=spec $0 }
  430. END { print spec }';
  431. return 0
  432. }
  433. _gcc-specs-exists ()
  434. {
  435. [[ -f $(_gcc-install-dir)/$1 ]]
  436. }
  437. _gcc_fullversion ()
  438. {
  439. local ver="$1";
  440. shift;
  441. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  442. eval echo "$ver"
  443. }
  444. _iconins ()
  445. {
  446. ( insopts -m 0644;
  447. local funcname=$1;
  448. shift;
  449. local size dir;
  450. local context=apps;
  451. local theme=hicolor;
  452. while [[ $# -gt 0 ]]; do
  453. case $1 in
  454. -s | --size)
  455. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  456. size=${2%%x*};
  457. else
  458. size=${2};
  459. fi;
  460. case ${size} in
  461. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  462. size=${size}x${size}
  463. ;;
  464. scalable)
  465.  
  466. ;;
  467. *)
  468. eerror "${size} is an unsupported icon size!";
  469. exit 1
  470. ;;
  471. esac;
  472. shift 2
  473. ;;
  474. -t | --theme)
  475. theme=${2};
  476. shift 2
  477. ;;
  478. -c | --context)
  479. context=${2};
  480. shift 2
  481. ;;
  482. *)
  483. if [[ -z ${size} ]]; then
  484. insinto /usr/share/pixmaps;
  485. else
  486. insinto /usr/share/icons/${theme}/${size}/${context};
  487. fi;
  488. if [[ ${funcname} == doicon ]]; then
  489. if [[ -f $1 ]]; then
  490. doins "${1}";
  491. else
  492. if [[ -d $1 ]]; then
  493. shopt -s nullglob;
  494. doins "${1}"/*.{png,svg};
  495. shopt -u nullglob;
  496. else
  497. eerror "${1} is not a valid file/directory!";
  498. exit 1;
  499. fi;
  500. fi;
  501. else
  502. break;
  503. fi;
  504. shift 1
  505. ;;
  506. esac;
  507. done;
  508. if [[ ${funcname} == newicon ]]; then
  509. newins "$@";
  510. fi ) || die
  511. }
  512. _is_flagq ()
  513. {
  514. local x var="$1[*]";
  515. for x in ${!var};
  516. do
  517. [[ ${x} == $2 ]] && return 0;
  518. done;
  519. return 1
  520. }
  521. _pax_list_files ()
  522. {
  523. local f cmd;
  524. cmd=$1;
  525. shift;
  526. for f in "$@";
  527. do
  528. ${cmd} " ${f}";
  529. done
  530. }
  531. _python_check_dead_variables ()
  532. {
  533. local v;
  534. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  535. do
  536. if [[ -n ${!v} ]]; then
  537. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  538. fi;
  539. done;
  540. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  541. do
  542. if [[ -n ${!v} ]]; then
  543. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  544. fi;
  545. done;
  546. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  547. do
  548. if [[ -n ${!v} ]]; then
  549. die "${v} is invalid for python-r1 suite";
  550. fi;
  551. done;
  552. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  553. do
  554. if [[ -n ${!v} ]]; then
  555. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  556. fi;
  557. done;
  558. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  559. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  560. fi;
  561. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  562. do
  563. if [[ -n ${!v} ]]; then
  564. die "${v} is invalid for python-r1 suite";
  565. fi;
  566. done
  567. }
  568. _python_check_locale_sanity ()
  569. {
  570. local -x LC_ALL=${1};
  571. local IFS=;
  572. local lc=({a..z});
  573. local uc=({A..Z});
  574. local input="${lc[*]}${uc[*]}";
  575. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  576. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  577. }
  578. _python_impl_matches ()
  579. {
  580. [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  581. local impl=${1} pattern;
  582. shift;
  583. for pattern in "$@";
  584. do
  585. if [[ ${pattern} == -2 ]]; then
  586. ! python_is_python3 "${impl}";
  587. return;
  588. else
  589. if [[ ${pattern} == -3 ]]; then
  590. python_is_python3 "${impl}";
  591. return;
  592. else
  593. if [[ ${impl/./_} == ${pattern/./_} ]]; then
  594. return 0;
  595. fi;
  596. fi;
  597. fi;
  598. done;
  599. return 1
  600. }
  601. _python_impl_supported ()
  602. {
  603. debug-print-function ${FUNCNAME} "${@}";
  604. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  605. local impl=${1};
  606. case "${impl}" in
  607. python2_7 | python3_[4567] | jython2_7)
  608. return 0
  609. ;;
  610. pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  611. return 1
  612. ;;
  613. pypy | pypy3)
  614. if [[ ${EAPI:-0} == [01234] ]]; then
  615. die "PyPy is supported in EAPI 5 and newer only.";
  616. fi
  617. ;;
  618. *)
  619. [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  620. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  621. ;;
  622. esac
  623. }
  624. _python_ln_rel ()
  625. {
  626. debug-print-function ${FUNCNAME} "${@}";
  627. local target=${1};
  628. local symname=${2};
  629. local tgpath=${target%/*}/;
  630. local sympath=${symname%/*}/;
  631. local rel_target=;
  632. while [[ -n ${sympath} ]]; do
  633. local tgseg= symseg=;
  634. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  635. tgseg=${tgpath%%/*};
  636. tgpath=${tgpath#${tgseg}/};
  637. done;
  638. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  639. symseg=${sympath%%/*};
  640. sympath=${sympath#${symseg}/};
  641. done;
  642. if [[ ${tgseg} != ${symseg} ]]; then
  643. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  644. fi;
  645. done;
  646. rel_target+=${tgpath}${target##*/};
  647. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  648. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  649. ln -fs "${rel_target}" "${symname}"
  650. }
  651. _python_set_impls ()
  652. {
  653. local i;
  654. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  655. die 'PYTHON_COMPAT not declared.';
  656. fi;
  657. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  658. die 'PYTHON_COMPAT must be an array.';
  659. fi;
  660. for i in "${PYTHON_COMPAT[@]}";
  661. do
  662. _python_impl_supported "${i}";
  663. done;
  664. local supp=() unsupp=();
  665. for i in "${_PYTHON_ALL_IMPLS[@]}";
  666. do
  667. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  668. supp+=("${i}");
  669. else
  670. unsupp+=("${i}");
  671. fi;
  672. done;
  673. if [[ ! -n ${supp[@]} ]]; then
  674. die "No supported implementation in PYTHON_COMPAT.";
  675. fi;
  676. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  677. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  678. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  679. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  680. eerror "Now : ${supp[*]}";
  681. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  682. fi;
  683. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  684. eerror "Unsupported impls changed between inherits!";
  685. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  686. eerror "Now : ${unsupp[*]}";
  687. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  688. fi;
  689. else
  690. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  691. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  692. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  693. fi
  694. }
  695. _tc-getPROG ()
  696. {
  697. local tuple=$1;
  698. local v var vars=$2;
  699. local prog=($3);
  700. var=${vars%% *};
  701. for v in ${vars};
  702. do
  703. if [[ -n ${!v} ]]; then
  704. export ${var}="${!v}";
  705. echo "${!v}";
  706. return 0;
  707. fi;
  708. done;
  709. local search=;
  710. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  711. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  712. [[ -n ${search} ]] && prog[0]=${search##*/};
  713. export ${var}="${prog[*]}";
  714. echo "${!var}"
  715. }
  716. all-flag-vars ()
  717. {
  718. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  719. }
  720. append-cflags ()
  721. {
  722. [[ $# -eq 0 ]] && return 0;
  723. export CFLAGS+=" $*";
  724. return 0
  725. }
  726. append-cppflags ()
  727. {
  728. [[ $# -eq 0 ]] && return 0;
  729. export CPPFLAGS+=" $*";
  730. return 0
  731. }
  732. append-cxxflags ()
  733. {
  734. [[ $# -eq 0 ]] && return 0;
  735. export CXXFLAGS+=" $*";
  736. return 0
  737. }
  738. append-fflags ()
  739. {
  740. [[ $# -eq 0 ]] && return 0;
  741. export FFLAGS+=" $*";
  742. export FCFLAGS+=" $*";
  743. return 0
  744. }
  745. append-flags ()
  746. {
  747. [[ $# -eq 0 ]] && return 0;
  748. case " $* " in
  749. *' '-[DIU]*)
  750. eqawarn 'please use append-cppflags for preprocessor flags'
  751. ;;
  752. *' '-L* | *' '-Wl,*)
  753. eqawarn 'please use append-ldflags for linker flags'
  754. ;;
  755. esac;
  756. append-cflags "$@";
  757. append-cxxflags "$@";
  758. append-fflags "$@";
  759. return 0
  760. }
  761. append-ldflags ()
  762. {
  763. [[ $# -eq 0 ]] && return 0;
  764. local flag;
  765. for flag in "$@";
  766. do
  767. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  768. done;
  769. export LDFLAGS="${LDFLAGS} $*";
  770. return 0
  771. }
  772. append-lfs-flags ()
  773. {
  774. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  775. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  776. }
  777. append-libs ()
  778. {
  779. [[ $# -eq 0 ]] && return 0;
  780. local flag;
  781. for flag in "$@";
  782. do
  783. if [[ -z "${flag// }" ]]; then
  784. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  785. continue;
  786. fi;
  787. case $flag in
  788. -[lL]*)
  789. export LIBS="${LIBS} ${flag}"
  790. ;;
  791. -*)
  792. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  793. export LIBS="${LIBS} ${flag}"
  794. ;;
  795. *)
  796. export LIBS="${LIBS} -l${flag}"
  797. ;;
  798. esac;
  799. done;
  800. return 0
  801. }
  802. autotools_check_macro ()
  803. {
  804. [[ -f configure.ac || -f configure.in ]] || return 0;
  805. local trace_file=".__autoconf_trace_data";
  806. if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  807. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  808. fi;
  809. local macro args=();
  810. for macro in "$@";
  811. do
  812. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  813. args+=(-e ":${macro}:");
  814. done;
  815. grep "${args[@]}" ${trace_file}
  816. }
  817. autotools_check_macro_val ()
  818. {
  819. local macro scan_out;
  820. for macro in "$@";
  821. do
  822. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  823. if (match($0, macro ":(.*)$", res))
  824. print res[1]
  825. }' | uniq;
  826. done;
  827. return 0
  828. }
  829. autotools_env_setup ()
  830. {
  831. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  832. local pv;
  833. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  834. do
  835. local hv_args="";
  836. case ${EAPI:-0} in
  837. 5 | 6)
  838. hv_args="--host-root"
  839. ;;
  840. 7)
  841. hv_args="-b"
  842. ;;
  843. esac;
  844. ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break;
  845. done;
  846. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  847. fi;
  848. [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  849. }
  850. autotools_m4dir_include ()
  851. {
  852. _autotools_m4dir_include ${AT_M4DIR}
  853. }
  854. autotools_m4sysdir_include ()
  855. {
  856. local paths=($(eval echo ${AT_SYS_M4DIR}));
  857. if [[ ${#paths[@]} -eq 0 && -n ${SYSROOT} ]]; then
  858. local path="${SYSROOT}/usr/share/aclocal";
  859. [[ -d ${path} ]] && paths+=("${path}");
  860. fi;
  861. _autotools_m4dir_include "${paths[@]}"
  862. }
  863. autotools_run_tool ()
  864. {
  865. local autofail=true m4flags=false missing_ok=false return_output=false;
  866. while [[ -n $1 ]]; do
  867. case $1 in
  868. --at-no-fail)
  869. autofail=false
  870. ;;
  871. --at-m4flags)
  872. m4flags=true
  873. ;;
  874. --at-missing)
  875. missing_ok=true
  876. ;;
  877. --at-output)
  878. return_output=true
  879. ;;
  880. *)
  881. break
  882. ;;
  883. esac;
  884. shift;
  885. done;
  886. if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  887. ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  888. fi;
  889. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  890. einfo "Skipping '$*' due $1 not installed";
  891. return 0;
  892. fi;
  893. autotools_env_setup;
  894. local STDERR_TARGET="${T}/${1##*/}.out";
  895. if [[ -e ${STDERR_TARGET} ]]; then
  896. local i=1;
  897. while :; do
  898. STDERR_TARGET="${T}/${1##*/}-${i}.out";
  899. [[ -e ${STDERR_TARGET} ]] || break;
  900. : $(( i++ ));
  901. done;
  902. fi;
  903. if ${m4flags}; then
  904. set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  905. fi;
  906. if ${return_output}; then
  907. "$@";
  908. return;
  909. fi;
  910. printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  911. ebegin "Running $@";
  912. "$@" >> "${STDERR_TARGET}" 2>&1;
  913. if ! eend $? && ${autofail}; then
  914. echo;
  915. eerror "Failed Running $1 !";
  916. eerror;
  917. eerror "Include in your bugreport the contents of:";
  918. eerror;
  919. eerror " ${STDERR_TARGET}";
  920. echo;
  921. die "Failed Running $1 !";
  922. fi
  923. }
  924. clang-fullversion ()
  925. {
  926. _clang_fullversion '$1.$2.$3' "$@"
  927. }
  928. clang-major-version ()
  929. {
  930. _clang_fullversion '$1' "$@"
  931. }
  932. clang-micro-version ()
  933. {
  934. _clang_fullversion '$3' "$@"
  935. }
  936. clang-minor-version ()
  937. {
  938. _clang_fullversion '$2' "$@"
  939. }
  940. clang-version ()
  941. {
  942. _clang_fullversion '$1.$2' "$@"
  943. }
  944. config_rpath_update ()
  945. {
  946. local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  947. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  948. [[ $# -eq 0 ]] && return 0;
  949. einfo "Updating all config.rpath files";
  950. for dst in "$@";
  951. do
  952. einfo " ${dst}";
  953. cp "${src}" "${dst}" || die;
  954. done
  955. }
  956. darwintoolize ()
  957. {
  958. die "Use elibtoolize"
  959. }
  960. doicon ()
  961. {
  962. _iconins ${FUNCNAME} "$@"
  963. }
  964. domenu ()
  965. {
  966. ( local i ret=0;
  967. insopts -m 0644;
  968. insinto /usr/share/applications;
  969. for i in "$@";
  970. do
  971. if [[ -d ${i} ]]; then
  972. doins "${i}"/*.desktop;
  973. ((ret|=$?));
  974. else
  975. doins "${i}";
  976. ((ret|=$?));
  977. fi;
  978. done;
  979. exit ${ret} )
  980. }
  981. eaclocal ()
  982. {
  983. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  984. }
  985. eaclocal_amflags ()
  986. {
  987. local aclocal_opts amflags_file;
  988. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  989. do
  990. [[ -e ${amflags_file} ]] || continue;
  991. autotools_env_setup;
  992. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  993. s:[^=]*=::p; # then gobble up all escaped lines
  994. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  995. eval aclocal_opts=\""${aclocal_opts}"\";
  996. break;
  997. done;
  998. echo ${aclocal_opts}
  999. }
  1000. eapply ()
  1001. {
  1002. local failed patch_cmd=patch;
  1003. local -x LC_COLLATE=POSIX;
  1004. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1005. function _eapply_patch ()
  1006. {
  1007. local f=${1};
  1008. local prefix=${2};
  1009. started_applying=1;
  1010. ebegin "${prefix:-Applying }${f##*/}";
  1011. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1012. failed=${?};
  1013. if ! eend "${failed}"; then
  1014. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1015. fi
  1016. };
  1017. local patch_options=() files=();
  1018. local i found_doublehyphen;
  1019. for ((i = 1; i <= ${#@}; ++i ))
  1020. do
  1021. if [[ ${@:i:1} == -- ]]; then
  1022. patch_options=("${@:1:i-1}");
  1023. files=("${@:i+1}");
  1024. found_doublehyphen=1;
  1025. break;
  1026. fi;
  1027. done;
  1028. if [[ -z ${found_doublehyphen} ]]; then
  1029. for ((i = 1; i <= ${#@}; ++i ))
  1030. do
  1031. if [[ ${@:i:1} != -* ]]; then
  1032. patch_options=("${@:1:i-1}");
  1033. files=("${@:i}");
  1034. break;
  1035. fi;
  1036. done;
  1037. for i in "${files[@]}";
  1038. do
  1039. if [[ ${i} == -* ]]; then
  1040. die "eapply: all options must be passed before non-options";
  1041. fi;
  1042. done;
  1043. fi;
  1044. if [[ ${#files[@]} -eq 0 ]]; then
  1045. die "eapply: no files specified";
  1046. fi;
  1047. local f;
  1048. for f in "${files[@]}";
  1049. do
  1050. if [[ -d ${f} ]]; then
  1051. function _eapply_get_files ()
  1052. {
  1053. local LC_ALL=POSIX;
  1054. local prev_shopt=$(shopt -p nullglob);
  1055. shopt -s nullglob;
  1056. local f;
  1057. for f in "${1}"/*;
  1058. do
  1059. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1060. files+=("${f}");
  1061. fi;
  1062. done;
  1063. ${prev_shopt}
  1064. };
  1065. local files=();
  1066. _eapply_get_files "${f}";
  1067. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1068. einfo "Applying patches from ${f} ...";
  1069. local f2;
  1070. for f2 in "${files[@]}";
  1071. do
  1072. _eapply_patch "${f2}" ' ';
  1073. [[ ${failed} -ne 0 ]] && return "${failed}";
  1074. done;
  1075. else
  1076. _eapply_patch "${f}";
  1077. [[ ${failed} -ne 0 ]] && return "${failed}";
  1078. fi;
  1079. done;
  1080. return 0
  1081. }
  1082. eapply_user ()
  1083. {
  1084. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1085. local tagfile=${T}/.portage_user_patches_applied;
  1086. [[ -f ${tagfile} ]] && return;
  1087. >> "${tagfile}";
  1088. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1089. local applied d f;
  1090. local -A _eapply_user_patches;
  1091. local prev_shopt=$(shopt -p nullglob);
  1092. shopt -s nullglob;
  1093. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1094. do
  1095. for f in "${d}"/*;
  1096. do
  1097. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1098. _eapply_user_patches[${f##*/}]=${f};
  1099. fi;
  1100. done;
  1101. done;
  1102. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1103. while read -r -d '' f; do
  1104. f=${_eapply_user_patches[${f}]};
  1105. if [[ -s ${f} ]]; then
  1106. eapply "${f}";
  1107. applied=1;
  1108. fi;
  1109. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1110. LC_ALL=C sort -z);
  1111. fi;
  1112. ${prev_shopt};
  1113. [[ -n ${applied} ]] && ewarn "User patches applied."
  1114. }
  1115. eautoconf ()
  1116. {
  1117. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  1118. echo;
  1119. eerror "No configure.{ac,in} present in '${PWD}'!";
  1120. echo;
  1121. die "No configure.{ac,in} present!";
  1122. fi;
  1123. if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  1124. eqawarn "This package has a configure.in file which has long been deprecated. Please";
  1125. eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  1126. eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details.";
  1127. fi;
  1128. autotools_run_tool --at-m4flags autoconf "$@"
  1129. }
  1130. eautoheader ()
  1131. {
  1132. _at_uses_autoheader || return 0;
  1133. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  1134. }
  1135. eautomake ()
  1136. {
  1137. local extra_opts=();
  1138. local makefile_name;
  1139. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  1140. do
  1141. [[ -f ${makefile_name} ]] && break;
  1142. done;
  1143. function _automake_version ()
  1144. {
  1145. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  1146. };
  1147. if [[ -z ${makefile_name} ]]; then
  1148. _at_uses_automake || return 0;
  1149. else
  1150. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  1151. local used_automake;
  1152. local installed_automake;
  1153. installed_automake=$(WANT_AUTOMAKE= _automake_version);
  1154. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  1155. if [[ ${installed_automake} != ${used_automake} ]]; then
  1156. ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  1157. ewarn "Forcing a full rebuild of the autotools to workaround.";
  1158. eautoreconf;
  1159. return 0;
  1160. fi;
  1161. fi;
  1162. fi;
  1163. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  1164. case $(_automake_version) in
  1165. 1.4 | 1.4[.-]*)
  1166.  
  1167. ;;
  1168. *)
  1169. extra_opts+=(--force-missing)
  1170. ;;
  1171. esac;
  1172. autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  1173. }
  1174. eautopoint ()
  1175. {
  1176. autotools_run_tool autopoint "$@"
  1177. }
  1178. eautoreconf ()
  1179. {
  1180. local x g;
  1181. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  1182. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  1183. do
  1184. if [[ -d ${x} ]]; then
  1185. pushd "${x}" > /dev/null;
  1186. AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  1187. popd > /dev/null;
  1188. fi;
  1189. done;
  1190. fi;
  1191. einfo "Running eautoreconf in '${PWD}' ...";
  1192. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  1193. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  1194. local i tools=(glibgettext false "autotools_run_tool glib-gettextize --copy --force" gettext false "autotools_run_tool --at-missing autopoint --force" intltool false "autotools_run_tool intltoolize --automake --copy --force" gtkdoc false "autotools_run_tool --at-missing gtkdocize --copy" gnomedoc false "autotools_run_tool --at-missing gnome-doc-prepare --copy --force" libtool false "_elibtoolize --auto-ltdl --install --copy --force");
  1195. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1196. do
  1197. if _at_uses_${tools[i]}; then
  1198. tools[i+1]=true;
  1199. ${tools[i+2]};
  1200. fi;
  1201. done;
  1202. local rerun_aclocal=false;
  1203. eaclocal;
  1204. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1205. do
  1206. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  1207. ${tools[i+2]};
  1208. rerun_aclocal=true;
  1209. fi;
  1210. done;
  1211. ${rerun_aclocal} && eaclocal;
  1212. if [[ ${WANT_AUTOCONF} = 2.1 ]]; then
  1213. eautoconf;
  1214. else
  1215. eautoconf --force;
  1216. fi;
  1217. eautoheader;
  1218. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  1219. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  1220. elibtoolize --force "${PWD}";
  1221. fi;
  1222. return 0
  1223. }
  1224. ebeep ()
  1225. {
  1226. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1227. }
  1228. econf_build ()
  1229. {
  1230. local CBUILD=${CBUILD:-${CHOST}};
  1231. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1232. }
  1233. ecvs_clean ()
  1234. {
  1235. [[ $# -eq 0 ]] && set -- .;
  1236. find "$@" '(' -type d -name 'CVS' -prune -o -type f -name '.cvs*' ')' -exec rm -rf '{}' +
  1237. }
  1238. edos2unix ()
  1239. {
  1240. [[ $# -eq 0 ]] && return 0;
  1241. sed -i 's/\r$//' -- "$@" || die
  1242. }
  1243. egit_clean ()
  1244. {
  1245. [[ $# -eq 0 ]] && set -- .;
  1246. find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' +
  1247. }
  1248. einstalldocs ()
  1249. {
  1250. ( if ! declare -p DOCS &> /dev/null; then
  1251. local d;
  1252. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1253. do
  1254. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1255. done;
  1256. else
  1257. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1258. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1259. else
  1260. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1261. fi;
  1262. fi );
  1263. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1264. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1265. else
  1266. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1267. fi )
  1268. }
  1269. elibtoolize ()
  1270. {
  1271. type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  1272. ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  1273. }
  1274. emktemp ()
  1275. {
  1276. local exe="touch";
  1277. [[ $1 == -d ]] && exe="mkdir" && shift;
  1278. local topdir=$1;
  1279. if [[ -z ${topdir} ]]; then
  1280. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1281. fi;
  1282. if ! type -P mktemp > /dev/null; then
  1283. local tmp=/;
  1284. while [[ -e ${tmp} ]]; do
  1285. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1286. done;
  1287. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1288. echo "${tmp}";
  1289. else
  1290. if [[ ${exe} == "touch" ]]; then
  1291. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1292. else
  1293. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1294. fi;
  1295. fi
  1296. }
  1297. epatch ()
  1298. {
  1299. function _epatch_draw_line ()
  1300. {
  1301. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1302. echo "${1//?/=}"
  1303. };
  1304. unset P4CONFIG P4PORT P4USER;
  1305. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1306. while [[ $# -gt 0 ]]; do
  1307. case $1 in
  1308. -*)
  1309. EPATCH_OPTS+=("$1")
  1310. ;;
  1311. *)
  1312. break
  1313. ;;
  1314. esac;
  1315. shift;
  1316. done;
  1317. if [[ $# -gt 1 ]]; then
  1318. local m;
  1319. for m in "$@";
  1320. do
  1321. epatch "${m}";
  1322. done;
  1323. return 0;
  1324. fi;
  1325. local SINGLE_PATCH="no";
  1326. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1327. if [[ -f $1 ]]; then
  1328. SINGLE_PATCH="yes";
  1329. set -- "$1";
  1330. local EPATCH_SUFFIX=$1;
  1331. else
  1332. if [[ -d $1 ]]; then
  1333. evar_push_set LC_COLLATE C;
  1334. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1335. evar_pop;
  1336. else
  1337. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1338. epatch "${EPATCH_SOURCE}/$1";
  1339. return $?;
  1340. else
  1341. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1342. echo;
  1343. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1344. eerror;
  1345. eerror " ${EPATCH_SOURCE}";
  1346. eerror " ( ${EPATCH_SOURCE##*/} )";
  1347. echo;
  1348. die "Cannot find \$EPATCH_SOURCE!";
  1349. fi;
  1350. fi;
  1351. fi;
  1352. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1353. local PIPE_CMD;
  1354. case ${EPATCH_SUFFIX##*\.} in
  1355. xz)
  1356. PIPE_CMD="xz -dc"
  1357. ;;
  1358. lzma)
  1359. PIPE_CMD="lzma -dc"
  1360. ;;
  1361. bz2)
  1362. PIPE_CMD="bzip2 -dc"
  1363. ;;
  1364. gz | Z | z)
  1365. PIPE_CMD="gzip -dc"
  1366. ;;
  1367. ZIP | zip)
  1368. PIPE_CMD="unzip -p"
  1369. ;;
  1370. *)
  1371.  
  1372. ;;
  1373. esac;
  1374. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1375. local x;
  1376. for x in "$@";
  1377. do
  1378. [[ ! -f ${x} ]] && continue;
  1379. local patchname=${x##*/};
  1380. local a=${patchname#*_};
  1381. a=${a%%_*};
  1382. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1383. continue;
  1384. fi;
  1385. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  1386. local prev_noglob=$(shopt -p -o noglob);
  1387. set -o noglob;
  1388. local ex;
  1389. for ex in ${EPATCH_EXCLUDE};
  1390. do
  1391. if [[ ${patchname} == ${ex} ]]; then
  1392. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  1393. ${prev_noglob};
  1394. continue 2;
  1395. fi;
  1396. done;
  1397. for ex in ${EPATCH_USER_EXCLUDE};
  1398. do
  1399. if [[ ${patchname} == ${ex} ]]; then
  1400. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  1401. ${prev_noglob};
  1402. continue 2;
  1403. fi;
  1404. done;
  1405. ${prev_noglob};
  1406. fi;
  1407. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1408. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1409. einfo "${EPATCH_SINGLE_MSG}";
  1410. else
  1411. einfo "Applying ${patchname} ...";
  1412. fi;
  1413. else
  1414. einfo " ${patchname} ...";
  1415. fi;
  1416. local patch="patch";
  1417. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  1418. local STDERR_TARGET="${T}/${patchname}.out";
  1419. if [[ -e ${STDERR_TARGET} ]]; then
  1420. STDERR_TARGET="${T}/${patchname}-$$.out";
  1421. fi;
  1422. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  1423. local count=0;
  1424. local PATCH_TARGET;
  1425. if [[ -n ${PIPE_CMD} ]]; then
  1426. PATCH_TARGET="${T}/$$.patch";
  1427. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1428. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1429. echo;
  1430. eerror "Could not extract patch!";
  1431. count=5;
  1432. break;
  1433. fi;
  1434. else
  1435. PATCH_TARGET=${x};
  1436. fi;
  1437. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1438. if [[ -n ${abs_paths} ]]; then
  1439. count=1;
  1440. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1441. fi;
  1442. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1443. if [[ -n ${rel_paths} ]]; then
  1444. echo;
  1445. eerror "Rejected Patch: ${patchname} !";
  1446. eerror " ( ${PATCH_TARGET} )";
  1447. eerror;
  1448. eerror "Your patch uses relative paths '../':";
  1449. eerror "${rel_paths}";
  1450. echo;
  1451. die "you need to fix the relative paths in patch";
  1452. fi;
  1453. local patch_cmd;
  1454. while [[ ${count} -lt 5 ]]; do
  1455. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  1456. ( _epatch_draw_line "***** ${patchname} *****";
  1457. echo;
  1458. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  1459. echo;
  1460. _epatch_draw_line "***** ${patchname} *****";
  1461. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1462. ret=$?;
  1463. echo;
  1464. echo "patch program exited with status ${ret}";
  1465. exit ${ret} ) >> "${STDERR_TARGET}";
  1466. if [ $? -eq 0 ]; then
  1467. ( _epatch_draw_line "***** ${patchname} *****";
  1468. echo;
  1469. echo "ACTUALLY APPLYING ${patchname} ...";
  1470. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1471. echo;
  1472. _epatch_draw_line "***** ${patchname} *****";
  1473. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1474. ret=$?;
  1475. echo;
  1476. echo "patch program exited with status ${ret}";
  1477. exit ${ret} ) >> "${STDERR_TARGET}";
  1478. if [ $? -ne 0 ]; then
  1479. echo;
  1480. eerror "A dry-run of patch command succeeded, but actually";
  1481. eerror "applying the patch failed!";
  1482. count=5;
  1483. fi;
  1484. break;
  1485. fi;
  1486. : $(( count++ ));
  1487. done;
  1488. (( EPATCH_N_APPLIED_PATCHES++ ));
  1489. if [[ -n ${PIPE_CMD} ]]; then
  1490. rm -f "${PATCH_TARGET}";
  1491. fi;
  1492. if [[ ${count} -ge 5 ]]; then
  1493. echo;
  1494. eerror "Failed Patch: ${patchname} !";
  1495. eerror " ( ${PATCH_TARGET} )";
  1496. eerror;
  1497. eerror "Include in your bugreport the contents of:";
  1498. eerror;
  1499. eerror " ${STDERR_TARGET}";
  1500. echo;
  1501. die "Failed Patch: ${patchname}!";
  1502. fi;
  1503. rm -f "${STDERR_TARGET}";
  1504. cat >> "${T}/epatch.log" <<-EOF
  1505. PATCH: ${x}
  1506. CMD: ${patch_cmd}
  1507. PWD: ${PWD}
  1508.  
  1509. EOF
  1510.  
  1511. eend 0;
  1512. done;
  1513. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1514. :
  1515. }
  1516. epause ()
  1517. {
  1518. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1519. }
  1520. eselect_python_update ()
  1521. {
  1522. if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
  1523. eselect python update;
  1524. fi;
  1525. if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
  1526. eselect python update --python${PV%%.*};
  1527. fi
  1528. }
  1529. eshopts_pop ()
  1530. {
  1531. local s;
  1532. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1533. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  1534. }
  1535. eshopts_push ()
  1536. {
  1537. if [[ $1 == -[su] ]]; then
  1538. estack_push eshopts "$(shopt -p)";
  1539. [[ $# -eq 0 ]] && return 0;
  1540. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1541. else
  1542. estack_push eshopts "$(shopt -p -o)";
  1543. [[ $# -eq 0 ]] && return 0;
  1544. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1545. fi
  1546. }
  1547. estack_pop ()
  1548. {
  1549. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1550. local _estack_name="_ESTACK_$1_";
  1551. shift;
  1552. local _estack_retvar=$1;
  1553. shift;
  1554. eval local _estack_i=\${#${_estack_name}\[@\]};
  1555. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  1556. if [[ -n ${_estack_retvar} ]]; then
  1557. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  1558. fi;
  1559. eval unset \"${_estack_name}\[${_estack_i}\]\"
  1560. }
  1561. estack_push ()
  1562. {
  1563. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1564. local stack_name="_ESTACK_$1_";
  1565. shift;
  1566. eval ${stack_name}+=\( \"\$@\" \)
  1567. }
  1568. esvn_clean ()
  1569. {
  1570. [[ $# -eq 0 ]] && set -- .;
  1571. find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' +
  1572. }
  1573. eumask_pop ()
  1574. {
  1575. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1576. local s;
  1577. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1578. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1579. }
  1580. eumask_push ()
  1581. {
  1582. estack_push eumask "$(umask)";
  1583. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1584. }
  1585. evar_pop ()
  1586. {
  1587. local cnt=${1:-bad};
  1588. case $# in
  1589. 0)
  1590. cnt=1
  1591. ;;
  1592. 1)
  1593. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  1594. ;;
  1595. *)
  1596. die "${FUNCNAME}: only accepts one arg: $*"
  1597. ;;
  1598. esac;
  1599. local var val;
  1600. while (( cnt-- )); do
  1601. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1602. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1603. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1604. done
  1605. }
  1606. evar_push ()
  1607. {
  1608. local var val;
  1609. for var in "$@";
  1610. do
  1611. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1612. estack_push evar "${var}" "${val}";
  1613. done
  1614. }
  1615. evar_push_set ()
  1616. {
  1617. local var=$1;
  1618. evar_push ${var};
  1619. case $# in
  1620. 1)
  1621. unset ${var}
  1622. ;;
  1623. 2)
  1624. printf -v "${var}" '%s' "$2"
  1625. ;;
  1626. *)
  1627. die "${FUNCNAME}: incorrect # of args: $*"
  1628. ;;
  1629. esac
  1630. }
  1631. filter-flags ()
  1632. {
  1633. _filter-hardened "$@";
  1634. local v;
  1635. for v in $(all-flag-vars);
  1636. do
  1637. _filter-var ${v} "$@";
  1638. done;
  1639. return 0
  1640. }
  1641. filter-ldflags ()
  1642. {
  1643. _filter-var LDFLAGS "$@";
  1644. return 0
  1645. }
  1646. filter-lfs-flags ()
  1647. {
  1648. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1649. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1650. }
  1651. filter-mfpmath ()
  1652. {
  1653. local orig_mfpmath new_math prune_math;
  1654. orig_mfpmath=$(get-flag -mfpmath);
  1655. new_math=$(get-flag mfpmath);
  1656. new_math=${new_math/both/387,sse};
  1657. new_math=" ${new_math//[,+]/ } ";
  1658. prune_math="";
  1659. for prune_math in "$@";
  1660. do
  1661. new_math=${new_math/ ${prune_math} / };
  1662. done;
  1663. new_math=$(echo ${new_math});
  1664. new_math=${new_math// /,};
  1665. if [[ -z ${new_math} ]]; then
  1666. filter-flags ${orig_mfpmath};
  1667. else
  1668. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1669. fi;
  1670. return 0
  1671. }
  1672. gcc-fullversion ()
  1673. {
  1674. _gcc_fullversion '$1.$2.$3' "$@"
  1675. }
  1676. gcc-major-version ()
  1677. {
  1678. _gcc_fullversion '$1' "$@"
  1679. }
  1680. gcc-micro-version ()
  1681. {
  1682. _gcc_fullversion '$3' "$@"
  1683. }
  1684. gcc-minor-version ()
  1685. {
  1686. _gcc_fullversion '$2' "$@"
  1687. }
  1688. gcc-specs-directive ()
  1689. {
  1690. local directive subdname subdirective;
  1691. directive="$(_gcc-specs-directive_raw $1)";
  1692. while [[ ${directive} == *%\(*\)* ]]; do
  1693. subdname=${directive/*%\(};
  1694. subdname=${subdname/\)*};
  1695. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1696. directive="${directive//\%(${subdname})/${subdirective}}";
  1697. done;
  1698. echo "${directive}";
  1699. return 0
  1700. }
  1701. gcc-specs-nostrict ()
  1702. {
  1703. local directive;
  1704. directive=$(gcc-specs-directive cc1);
  1705. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1706. }
  1707. gcc-specs-now ()
  1708. {
  1709. local directive;
  1710. directive=$(gcc-specs-directive link_command);
  1711. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1712. }
  1713. gcc-specs-pie ()
  1714. {
  1715. local directive;
  1716. directive=$(gcc-specs-directive cc1);
  1717. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1718. }
  1719. gcc-specs-relro ()
  1720. {
  1721. local directive;
  1722. directive=$(gcc-specs-directive link_command);
  1723. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1724. }
  1725. gcc-specs-ssp ()
  1726. {
  1727. local directive;
  1728. directive=$(gcc-specs-directive cc1);
  1729. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1730. }
  1731. gcc-specs-ssp-to-all ()
  1732. {
  1733. local directive;
  1734. directive=$(gcc-specs-directive cc1);
  1735. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1736. }
  1737. gcc-specs-stack-check ()
  1738. {
  1739. local directive;
  1740. directive=$(gcc-specs-directive cc1);
  1741. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1742. }
  1743. gcc-version ()
  1744. {
  1745. _gcc_fullversion '$1.$2' "$@"
  1746. }
  1747. gen_usr_ldscript ()
  1748. {
  1749. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1750. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1751. tc-is-static-only && return;
  1752. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1753. multilib_is_native_abi || return 0;
  1754. fi;
  1755. case ${CTARGET:-${CHOST}} in
  1756. *-darwin*)
  1757.  
  1758. ;;
  1759. *-android*)
  1760. return 0
  1761. ;;
  1762. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1763. use prefix && return 0
  1764. ;;
  1765. *)
  1766. return 0
  1767. ;;
  1768. esac;
  1769. dodir /usr/${libdir};
  1770. if [[ $1 == "-a" ]]; then
  1771. auto=true;
  1772. shift;
  1773. dodir /${libdir};
  1774. fi;
  1775. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1776. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1777. local d="${T}/bfd-linker";
  1778. mkdir -p "${d}";
  1779. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1780. flags+=(-B"${d}");
  1781. fi;
  1782. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1783. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1784. for lib in "$@";
  1785. do
  1786. local tlib;
  1787. if ${auto}; then
  1788. lib="lib${lib}${suffix}";
  1789. else
  1790. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1791. fi;
  1792. case ${CTARGET:-${CHOST}} in
  1793. *-darwin*)
  1794. if ${auto}; then
  1795. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1796. else
  1797. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1798. fi;
  1799. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1800. tlib=${tlib##*/};
  1801. if ${auto}; then
  1802. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1803. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1804. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1805. fi;
  1806. rm -f "${ED}"/${libdir}/${lib};
  1807. fi;
  1808. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1809. chmod u+w "${ED}${libdir}/${tlib}";
  1810. local nowrite=yes;
  1811. fi;
  1812. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1813. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1814. pushd "${ED}/usr/${libdir}" > /dev/null;
  1815. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1816. popd > /dev/null
  1817. ;;
  1818. *)
  1819. if ${auto}; then
  1820. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1821. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1822. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1823. if [[ ${tlib} != ${lib}* ]]; then
  1824. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1825. fi;
  1826. rm -f "${ED}"/${libdir}/${lib};
  1827. else
  1828. tlib=${lib};
  1829. fi;
  1830. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1831. /* GNU ld script
  1832. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1833. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1834. run into linking problems. This "fake" dynamic lib is a linker script that
  1835. redirects the linker to the real lib. And yes, this works in the cross-
  1836. compiling scenario as the sysroot-ed linker will prepend the real path.
  1837.  
  1838. See bug https://bugs.gentoo.org/4411 for more info.
  1839. */
  1840. ${output_format}
  1841. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1842. END_LDSCRIPT
  1843.  
  1844. ;;
  1845. esac
  1846. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1847. done
  1848. }
  1849. get-flag ()
  1850. {
  1851. local f var findflag="$1";
  1852. for var in $(all-flag-vars);
  1853. do
  1854. for f in ${!var};
  1855. do
  1856. if [ "${f/${findflag}}" != "${f}" ]; then
  1857. printf "%s\n" "${f/-${findflag}=}";
  1858. return 0;
  1859. fi;
  1860. done;
  1861. done;
  1862. return 1
  1863. }
  1864. get_abi_CFLAGS ()
  1865. {
  1866. get_abi_var CFLAGS "$@"
  1867. }
  1868. get_abi_CHOST ()
  1869. {
  1870. get_abi_var CHOST "$@"
  1871. }
  1872. get_abi_CTARGET ()
  1873. {
  1874. get_abi_var CTARGET "$@"
  1875. }
  1876. get_abi_FAKE_TARGETS ()
  1877. {
  1878. get_abi_var FAKE_TARGETS "$@"
  1879. }
  1880. get_abi_LDFLAGS ()
  1881. {
  1882. get_abi_var LDFLAGS "$@"
  1883. }
  1884. get_abi_LIBDIR ()
  1885. {
  1886. get_abi_var LIBDIR "$@"
  1887. }
  1888. get_abi_var ()
  1889. {
  1890. local flag=$1;
  1891. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1892. local var="${flag}_${abi}";
  1893. echo ${!var}
  1894. }
  1895. get_all_abis ()
  1896. {
  1897. local x order="" mvar dvar;
  1898. mvar="MULTILIB_ABIS";
  1899. dvar="DEFAULT_ABI";
  1900. if [[ -n $1 ]]; then
  1901. mvar="$1_${mvar}";
  1902. dvar="$1_${dvar}";
  1903. fi;
  1904. if [[ -z ${!mvar} ]]; then
  1905. echo "default";
  1906. return 0;
  1907. fi;
  1908. for x in ${!mvar};
  1909. do
  1910. if [[ ${x} != ${!dvar} ]]; then
  1911. order="${order:+${order} }${x}";
  1912. fi;
  1913. done;
  1914. order="${order:+${order} }${!dvar}";
  1915. echo ${order};
  1916. return 0
  1917. }
  1918. get_all_libdirs ()
  1919. {
  1920. local libdirs abi;
  1921. for abi in ${MULTILIB_ABIS};
  1922. do
  1923. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1924. done;
  1925. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1926. echo "${libdirs}"
  1927. }
  1928. get_exeext ()
  1929. {
  1930. case ${CHOST} in
  1931. *-cygwin* | mingw* | *-mingw*)
  1932. echo ".exe"
  1933. ;;
  1934. esac
  1935. }
  1936. get_install_abis ()
  1937. {
  1938. local x order="";
  1939. if [[ -z ${MULTILIB_ABIS} ]]; then
  1940. echo "default";
  1941. return 0;
  1942. fi;
  1943. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1944. for x in ${MULTILIB_ABIS};
  1945. do
  1946. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1947. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1948. fi;
  1949. done;
  1950. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1951. if [[ -n ${ABI_ALLOW} ]]; then
  1952. local ordera="";
  1953. for x in ${order};
  1954. do
  1955. if has ${x} ${ABI_ALLOW}; then
  1956. ordera="${ordera} ${x}";
  1957. fi;
  1958. done;
  1959. order=${ordera};
  1960. fi;
  1961. else
  1962. order=${DEFAULT_ABI};
  1963. fi;
  1964. if [[ -z ${order} ]]; then
  1965. 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.";
  1966. fi;
  1967. echo ${order};
  1968. return 0
  1969. }
  1970. get_libdir ()
  1971. {
  1972. local libdir_var="LIBDIR_${ABI}";
  1973. local libdir="lib";
  1974. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1975. echo "${libdir}"
  1976. }
  1977. get_libname ()
  1978. {
  1979. local libname;
  1980. local ver=$1;
  1981. case ${CHOST} in
  1982. *-cygwin*)
  1983. libname="dll.a"
  1984. ;;
  1985. mingw* | *-mingw*)
  1986. libname="dll"
  1987. ;;
  1988. *-darwin*)
  1989. libname="dylib"
  1990. ;;
  1991. *-mint*)
  1992. libname="irrelevant"
  1993. ;;
  1994. hppa*-hpux*)
  1995. libname="sl"
  1996. ;;
  1997. *)
  1998. libname="so"
  1999. ;;
  2000. esac;
  2001. if [[ -z $* ]]; then
  2002. echo ".${libname}";
  2003. else
  2004. for ver in "$@";
  2005. do
  2006. case ${CHOST} in
  2007. *-cygwin*)
  2008. echo ".${ver}.${libname}"
  2009. ;;
  2010. *-darwin*)
  2011. echo ".${ver}.${libname}"
  2012. ;;
  2013. *-mint*)
  2014. echo ".${libname}"
  2015. ;;
  2016. *)
  2017. echo ".${libname}.${ver}"
  2018. ;;
  2019. esac;
  2020. done;
  2021. fi
  2022. }
  2023. get_modname ()
  2024. {
  2025. local modname;
  2026. local ver=$1;
  2027. case ${CHOST} in
  2028. *-darwin*)
  2029. modname="bundle"
  2030. ;;
  2031. *)
  2032. modname="so"
  2033. ;;
  2034. esac;
  2035. echo ".${modname}"
  2036. }
  2037. has_m32 ()
  2038. {
  2039. die "${FUNCNAME}: don't use this anymore"
  2040. }
  2041. has_m64 ()
  2042. {
  2043. die "${FUNCNAME}: don't use this anymore"
  2044. }
  2045. has_multilib_profile ()
  2046. {
  2047. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2048. }
  2049. host-is-pax ()
  2050. {
  2051. grep -qs ^PaX: /proc/self/status
  2052. }
  2053. in_iuse ()
  2054. {
  2055. local use=${1};
  2056. if [[ -z "${use}" ]]; then
  2057. echo "!!! in_iuse() called without a parameter." 1>&2;
  2058. echo "!!! in_iuse <USEFLAG>" 1>&2;
  2059. die "in_iuse() called without a parameter";
  2060. fi;
  2061. local liuse=(${IUSE_EFFECTIVE});
  2062. has "${use}" "${liuse[@]#[+-]}"
  2063. }
  2064. is-flag ()
  2065. {
  2066. is-flagq "$@" && echo true
  2067. }
  2068. is-flagq ()
  2069. {
  2070. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2071. local var;
  2072. for var in $(all-flag-vars);
  2073. do
  2074. _is_flagq ${var} "$1" && return 0;
  2075. done;
  2076. return 1
  2077. }
  2078. is-ldflag ()
  2079. {
  2080. is-ldflagq "$@" && echo true
  2081. }
  2082. is-ldflagq ()
  2083. {
  2084. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2085. _is_flagq LDFLAGS $1
  2086. }
  2087. is_final_abi ()
  2088. {
  2089. has_multilib_profile || return 0;
  2090. set -- $(get_install_abis);
  2091. local LAST_ABI=$#;
  2092. [[ ${!LAST_ABI} == ${ABI} ]]
  2093. }
  2094. isdigit ()
  2095. {
  2096. local d;
  2097. for d in "$@";
  2098. do
  2099. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  2100. done;
  2101. return 0
  2102. }
  2103. list-paxables ()
  2104. {
  2105. file "$@" 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//'
  2106. }
  2107. make_desktop_entry ()
  2108. {
  2109. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2110. local exec=${1};
  2111. local name=${2:-${PN}};
  2112. local icon=${3:-${PN}};
  2113. local type=${4};
  2114. local fields=${5};
  2115. if [[ -z ${type} ]]; then
  2116. local catmaj=${CATEGORY%%-*};
  2117. local catmin=${CATEGORY##*-};
  2118. case ${catmaj} in
  2119. app)
  2120. case ${catmin} in
  2121. accessibility)
  2122. type="Utility;Accessibility"
  2123. ;;
  2124. admin)
  2125. type=System
  2126. ;;
  2127. antivirus)
  2128. type=System
  2129. ;;
  2130. arch)
  2131. type="Utility;Archiving"
  2132. ;;
  2133. backup)
  2134. type="Utility;Archiving"
  2135. ;;
  2136. cdr)
  2137. type="AudioVideo;DiscBurning"
  2138. ;;
  2139. dicts)
  2140. type="Office;Dictionary"
  2141. ;;
  2142. doc)
  2143. type=Documentation
  2144. ;;
  2145. editors)
  2146. type="Utility;TextEditor"
  2147. ;;
  2148. emacs)
  2149. type="Development;TextEditor"
  2150. ;;
  2151. emulation)
  2152. type="System;Emulator"
  2153. ;;
  2154. laptop)
  2155. type="Settings;HardwareSettings"
  2156. ;;
  2157. office)
  2158. type=Office
  2159. ;;
  2160. pda)
  2161. type="Office;PDA"
  2162. ;;
  2163. vim)
  2164. type="Development;TextEditor"
  2165. ;;
  2166. xemacs)
  2167. type="Development;TextEditor"
  2168. ;;
  2169. esac
  2170. ;;
  2171. dev)
  2172. type="Development"
  2173. ;;
  2174. games)
  2175. case ${catmin} in
  2176. action | fps)
  2177. type=ActionGame
  2178. ;;
  2179. arcade)
  2180. type=ArcadeGame
  2181. ;;
  2182. board)
  2183. type=BoardGame
  2184. ;;
  2185. emulation)
  2186. type=Emulator
  2187. ;;
  2188. kids)
  2189. type=KidsGame
  2190. ;;
  2191. puzzle)
  2192. type=LogicGame
  2193. ;;
  2194. roguelike)
  2195. type=RolePlaying
  2196. ;;
  2197. rpg)
  2198. type=RolePlaying
  2199. ;;
  2200. simulation)
  2201. type=Simulation
  2202. ;;
  2203. sports)
  2204. type=SportsGame
  2205. ;;
  2206. strategy)
  2207. type=StrategyGame
  2208. ;;
  2209. esac;
  2210. type="Game;${type}"
  2211. ;;
  2212. gnome)
  2213. type="Gnome;GTK"
  2214. ;;
  2215. kde)
  2216. type="KDE;Qt"
  2217. ;;
  2218. mail)
  2219. type="Network;Email"
  2220. ;;
  2221. media)
  2222. case ${catmin} in
  2223. gfx)
  2224. type=Graphics
  2225. ;;
  2226. *)
  2227. case ${catmin} in
  2228. radio)
  2229. type=Tuner
  2230. ;;
  2231. sound)
  2232. type=Audio
  2233. ;;
  2234. tv)
  2235. type=TV
  2236. ;;
  2237. video)
  2238. type=Video
  2239. ;;
  2240. esac;
  2241. type="AudioVideo;${type}"
  2242. ;;
  2243. esac
  2244. ;;
  2245. net)
  2246. case ${catmin} in
  2247. dialup)
  2248. type=Dialup
  2249. ;;
  2250. ftp)
  2251. type=FileTransfer
  2252. ;;
  2253. im)
  2254. type=InstantMessaging
  2255. ;;
  2256. irc)
  2257. type=IRCClient
  2258. ;;
  2259. mail)
  2260. type=Email
  2261. ;;
  2262. news)
  2263. type=News
  2264. ;;
  2265. nntp)
  2266. type=News
  2267. ;;
  2268. p2p)
  2269. type=FileTransfer
  2270. ;;
  2271. voip)
  2272. type=Telephony
  2273. ;;
  2274. esac;
  2275. type="Network;${type}"
  2276. ;;
  2277. sci)
  2278. case ${catmin} in
  2279. astro*)
  2280. type=Astronomy
  2281. ;;
  2282. bio*)
  2283. type=Biology
  2284. ;;
  2285. calc*)
  2286. type=Calculator
  2287. ;;
  2288. chem*)
  2289. type=Chemistry
  2290. ;;
  2291. elec*)
  2292. type=Electronics
  2293. ;;
  2294. geo*)
  2295. type=Geology
  2296. ;;
  2297. math*)
  2298. type=Math
  2299. ;;
  2300. physics)
  2301. type=Physics
  2302. ;;
  2303. visual*)
  2304. type=DataVisualization
  2305. ;;
  2306. esac;
  2307. type="Education;Science;${type}"
  2308. ;;
  2309. sys)
  2310. type="System"
  2311. ;;
  2312. www)
  2313. case ${catmin} in
  2314. client)
  2315. type=WebBrowser
  2316. ;;
  2317. esac;
  2318. type="Network;${type}"
  2319. ;;
  2320. *)
  2321. type=
  2322. ;;
  2323. esac;
  2324. fi;
  2325. local slot=${SLOT%/*};
  2326. if [[ ${slot} == "0" ]]; then
  2327. local desktop_name="${PN}";
  2328. else
  2329. local desktop_name="${PN}-${slot}";
  2330. fi;
  2331. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2332. type=${type%;}${type:+;};
  2333. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2334. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2335. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2336. icon=${icon%.*};
  2337. fi;
  2338. cat > "${desktop}" <<-EOF ||
  2339. [Desktop Entry]
  2340. Name=${name}
  2341. Type=Application
  2342. Comment=${DESCRIPTION}
  2343. Exec=${exec}
  2344. TryExec=${exec%% *}
  2345. Icon=${icon}
  2346. Categories=${type}
  2347. EOF
  2348. die
  2349. if [[ ${fields:-=} != *=* ]]; then
  2350. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2351. fields="Path=${fields}";
  2352. fi;
  2353. if [[ -n ${fields} ]]; then
  2354. printf '%b\n' "${fields}" >> "${desktop}" || die;
  2355. fi;
  2356. ( insopts -m 0644;
  2357. insinto /usr/share/applications;
  2358. doins "${desktop}" ) || die "installing desktop file failed"
  2359. }
  2360. make_session_desktop ()
  2361. {
  2362. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2363. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2364. local title=$1;
  2365. local command=$2;
  2366. local desktop=${T}/${wm:-${PN}}.desktop;
  2367. shift 2;
  2368. cat > "${desktop}" <<-EOF ||
  2369. [Desktop Entry]
  2370. Name=${title}
  2371. Comment=This session logs you into ${title}
  2372. Exec=${command} $*
  2373. TryExec=${command}
  2374. Type=XSession
  2375. EOF
  2376. die
  2377. ( insopts -m 0644;
  2378. insinto /usr/share/xsessions;
  2379. doins "${desktop}" )
  2380. }
  2381. make_wrapper ()
  2382. {
  2383. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2384. local tmpwrapper=$(emktemp);
  2385. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  2386. ( echo '#!/bin/sh';
  2387. if [[ -n ${libdir} ]]; then
  2388. local var;
  2389. if [[ ${CHOST} == *-darwin* ]]; then
  2390. var=DYLD_LIBRARY_PATH;
  2391. else
  2392. var=LD_LIBRARY_PATH;
  2393. fi;
  2394. cat <<-EOF
  2395. if [ "\${${var}+set}" = "set" ] ; then
  2396. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  2397. else
  2398. export ${var}="${EPREFIX}${libdir}"
  2399. fi
  2400. EOF
  2401.  
  2402. fi
  2403. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  2404. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  2405. chmod go+rx "${tmpwrapper}";
  2406. if [[ -n ${path} ]]; then
  2407. ( exeopts -m 0755;
  2408. exeinto "${path}";
  2409. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2410. else
  2411. newbin "${tmpwrapper}" "${wrapper}" || die;
  2412. fi
  2413. }
  2414. multilib_env ()
  2415. {
  2416. local CTARGET=${1:-${CTARGET}};
  2417. local cpu=${CTARGET%%*-};
  2418. case ${cpu} in
  2419. aarch64*)
  2420. export CFLAGS_arm=${CFLAGS_arm-};
  2421. case ${cpu} in
  2422. aarch64*be)
  2423. export CHOST_arm="armv8b-${CTARGET#*-}"
  2424. ;;
  2425. *)
  2426. export CHOST_arm="armv8l-${CTARGET#*-}"
  2427. ;;
  2428. esac;
  2429. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2430. export CTARGET_arm=${CHOST_arm};
  2431. export LIBDIR_arm="lib";
  2432. export CFLAGS_arm64=${CFLAGS_arm64-};
  2433. export CHOST_arm64=${CTARGET};
  2434. export CTARGET_arm64=${CHOST_arm64};
  2435. export LIBDIR_arm64="lib64";
  2436. : ${MULTILIB_ABIS=arm64};
  2437. : ${DEFAULT_ABI=arm64}
  2438. ;;
  2439. x86_64*)
  2440. export CFLAGS_x86=${CFLAGS_x86--m32};
  2441. export CHOST_x86=${CTARGET/x86_64/i686};
  2442. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2443. export CTARGET_x86=${CHOST_x86};
  2444. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2445. export LIBDIR_x86="lib32";
  2446. else
  2447. export LIBDIR_x86="lib";
  2448. fi;
  2449. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2450. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2451. export CTARGET_amd64=${CHOST_amd64};
  2452. export LIBDIR_amd64="lib64";
  2453. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2454. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2455. export CTARGET_x32=${CHOST_x32};
  2456. export LIBDIR_x32="libx32";
  2457. case ${CTARGET} in
  2458. *-gnux32)
  2459. : ${MULTILIB_ABIS=x32 amd64 x86};
  2460. : ${DEFAULT_ABI=x32}
  2461. ;;
  2462. *)
  2463. : ${MULTILIB_ABIS=amd64 x86};
  2464. : ${DEFAULT_ABI=amd64}
  2465. ;;
  2466. esac
  2467. ;;
  2468. mips64* | mipsisa64*)
  2469. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2470. export CHOST_o32=${CTARGET/mips64/mips};
  2471. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2472. export CTARGET_o32=${CHOST_o32};
  2473. export LIBDIR_o32="lib";
  2474. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2475. export CHOST_n32=${CTARGET};
  2476. export CTARGET_n32=${CHOST_n32};
  2477. export LIBDIR_n32="lib32";
  2478. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2479. export CHOST_n64=${CTARGET};
  2480. export CTARGET_n64=${CHOST_n64};
  2481. export LIBDIR_n64="lib64";
  2482. : ${MULTILIB_ABIS=n64 n32 o32};
  2483. : ${DEFAULT_ABI=n32}
  2484. ;;
  2485. powerpc64*)
  2486. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2487. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2488. export CTARGET_ppc=${CHOST_ppc};
  2489. export LIBDIR_ppc="lib";
  2490. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2491. export CHOST_ppc64=${CTARGET};
  2492. export CTARGET_ppc64=${CHOST_ppc64};
  2493. export LIBDIR_ppc64="lib64";
  2494. : ${MULTILIB_ABIS=ppc64 ppc};
  2495. : ${DEFAULT_ABI=ppc64}
  2496. ;;
  2497. s390x*)
  2498. export CFLAGS_s390=${CFLAGS_s390--m31};
  2499. export CHOST_s390=${CTARGET/s390x/s390};
  2500. export CTARGET_s390=${CHOST_s390};
  2501. export LIBDIR_s390="lib";
  2502. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2503. export CHOST_s390x=${CTARGET};
  2504. export CTARGET_s390x=${CHOST_s390x};
  2505. export LIBDIR_s390x="lib64";
  2506. : ${MULTILIB_ABIS=s390x s390};
  2507. : ${DEFAULT_ABI=s390x}
  2508. ;;
  2509. sparc64*)
  2510. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2511. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2512. export CTARGET_sparc32=${CHOST_sparc32};
  2513. export LIBDIR_sparc32="lib";
  2514. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2515. export CHOST_sparc64=${CTARGET};
  2516. export CTARGET_sparc64=${CHOST_sparc64};
  2517. export LIBDIR_sparc64="lib64";
  2518. : ${MULTILIB_ABIS=sparc64 sparc32};
  2519. : ${DEFAULT_ABI=sparc64}
  2520. ;;
  2521. *)
  2522. : ${MULTILIB_ABIS=default};
  2523. : ${DEFAULT_ABI=default}
  2524. ;;
  2525. esac;
  2526. export MULTILIB_ABIS DEFAULT_ABI
  2527. }
  2528. multilib_toolchain_setup ()
  2529. {
  2530. local v vv;
  2531. export ABI=$1;
  2532. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2533. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2534. do
  2535. vv="_abi_saved_${v}";
  2536. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2537. unset ${vv};
  2538. done;
  2539. unset _DEFAULT_ABI_SAVED;
  2540. fi;
  2541. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2542. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2543. do
  2544. vv="_abi_saved_${v}";
  2545. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2546. done;
  2547. export _DEFAULT_ABI_SAVED="true";
  2548. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2549. export CBUILD=$(get_abi_CHOST $1);
  2550. fi;
  2551. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2552. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2553. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2554. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2555. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2556. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2557. export CHOST=$(get_abi_CHOST $1);
  2558. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2559. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2560. fi
  2561. }
  2562. newicon ()
  2563. {
  2564. _iconins ${FUNCNAME} "$@"
  2565. }
  2566. newmenu ()
  2567. {
  2568. ( insopts -m 0644;
  2569. insinto /usr/share/applications;
  2570. newins "$@" )
  2571. }
  2572. no-as-needed ()
  2573. {
  2574. case $($(tc-getLD) -v 2>&1 </dev/null) in
  2575. *GNU*)
  2576. echo "-Wl,--no-as-needed"
  2577. ;;
  2578. esac
  2579. }
  2580. number_abis ()
  2581. {
  2582. set -- `get_install_abis`;
  2583. echo $#
  2584. }
  2585. optfeature ()
  2586. {
  2587. debug-print-function ${FUNCNAME} "$@";
  2588. local i j msg;
  2589. local desc=$1;
  2590. local flag=0;
  2591. shift;
  2592. for i in "$@";
  2593. do
  2594. for j in ${i};
  2595. do
  2596. if has_version "${j}"; then
  2597. flag=1;
  2598. else
  2599. flag=0;
  2600. break;
  2601. fi;
  2602. done;
  2603. if [[ ${flag} -eq 1 ]]; then
  2604. break;
  2605. fi;
  2606. done;
  2607. if [[ ${flag} -eq 0 ]]; then
  2608. for i in "$@";
  2609. do
  2610. msg=" ";
  2611. for j in ${i};
  2612. do
  2613. msg+=" ${j} and";
  2614. done;
  2615. msg="${msg:0: -4} for ${desc}";
  2616. elog "${msg}";
  2617. done;
  2618. fi
  2619. }
  2620. path_exists ()
  2621. {
  2622. eerror "path_exists has been removed. Please see the following post";
  2623. eerror "for a replacement snippet:";
  2624. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  2625. die "path_exists is banned"
  2626. }
  2627. pax-mark ()
  2628. {
  2629. local f;
  2630. local flags;
  2631. local ret=0;
  2632. flags="${1//[!zPpEeMmRrSs]}";
  2633. [[ -n "${flags}" ]] || return 0;
  2634. shift;
  2635. local dodefault="";
  2636. [[ -n "${flags//[!z]}" ]] && dodefault="yes";
  2637. if has PT ${PAX_MARKINGS}; then
  2638. for f in "$@";
  2639. do
  2640. if type -p paxctl > /dev/null; then
  2641. einfo "PT_PAX marking -${flags} ${f} with paxctl";
  2642. paxctl -q${flags} "${f}" > /dev/null 2>&1 && continue;
  2643. fi;
  2644. if type -p paxctl-ng > /dev/null && paxctl-ng -L; then
  2645. einfo "PT_PAX marking -${flags} ${f} with paxctl-ng";
  2646. flags="${flags//z}";
  2647. [[ ${dodefault} == "yes" ]] && paxctl-ng -L -z "${f}" > /dev/null 2>&1;
  2648. [[ -n "${flags}" ]] || continue;
  2649. paxctl-ng -L -${flags} "${f}" > /dev/null 2>&1 && continue;
  2650. fi;
  2651. if type -p scanelf > /dev/null && [[ ${PAX_MARKINGS} != "none" ]]; then
  2652. einfo "PT_PAX marking -${flags} ${f} with scanelf";
  2653. scanelf -Xxz ${flags} "$f" > /dev/null 2>&1;
  2654. else
  2655. if [[ ${PAX_MARKINGS} != "none" ]]; then
  2656. elog "Failed to set PT_PAX markings -${flags} ${f}.";
  2657. ret=1;
  2658. fi;
  2659. fi;
  2660. done;
  2661. fi;
  2662. if has XT ${PAX_MARKINGS}; then
  2663. flags="${flags//z}";
  2664. for f in "$@";
  2665. do
  2666. if type -p paxctl-ng > /dev/null && paxctl-ng -l; then
  2667. einfo "XATTR_PAX marking -${flags} ${f} with paxctl-ng";
  2668. [[ ${dodefault} == "yes" ]] && paxctl-ng -d "${f}" > /dev/null 2>&1;
  2669. [[ -n "${flags}" ]] || continue;
  2670. paxctl-ng -l -${flags} "${f}" > /dev/null 2>&1 && continue;
  2671. fi;
  2672. if type -p setfattr > /dev/null; then
  2673. [[ -n "${flags//[!Ee]}" ]] || flags+="e";
  2674. einfo "XATTR_PAX marking -${flags} ${f} with setfattr";
  2675. [[ ${dodefault} == "yes" ]] && setfattr -x "user.pax.flags" "${f}" > /dev/null 2>&1;
  2676. setfattr -n "user.pax.flags" -v "${flags}" "${f}" > /dev/null 2>&1 && continue;
  2677. fi;
  2678. if [[ ${PAX_MARKINGS} != "none" ]]; then
  2679. elog "Failed to set XATTR_PAX markings -${flags} ${f}.";
  2680. ret=1;
  2681. fi;
  2682. done;
  2683. fi;
  2684. return ${ret}
  2685. }
  2686. pkg_nofetch ()
  2687. {
  2688. default
  2689. }
  2690. pkg_postinst ()
  2691. {
  2692. eselect_python_update;
  2693. if [[ "${python_updater_warning}" == "1" ]]; then
  2694. ewarn "You have just upgraded from an older version of Python.";
  2695. ewarn;
  2696. ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules.";
  2697. fi
  2698. }
  2699. pkg_postrm ()
  2700. {
  2701. eselect_python_update
  2702. }
  2703. pkg_preinst ()
  2704. {
  2705. if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then
  2706. python_updater_warning="1";
  2707. fi
  2708. }
  2709. preserve_old_lib ()
  2710. {
  2711. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2712. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2713. die "Invalid preserve_old_lib() usage";
  2714. fi;
  2715. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2716. has preserve-libs ${FEATURES} && return 0;
  2717. has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT};
  2718. local lib dir;
  2719. for lib in "$@";
  2720. do
  2721. [[ -e ${EROOT}/${lib} ]] || continue;
  2722. dir=${lib%/*};
  2723. dodir ${dir} || die "dodir ${dir} failed";
  2724. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  2725. touch "${ED}"/${lib};
  2726. done
  2727. }
  2728. preserve_old_lib_notify ()
  2729. {
  2730. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2731. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2732. die "Invalid preserve_old_lib_notify() usage";
  2733. fi;
  2734. has preserve-libs ${FEATURES} && return 0;
  2735. has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT};
  2736. local lib notice=0;
  2737. for lib in "$@";
  2738. do
  2739. [[ -e ${EROOT}/${lib} ]] || continue;
  2740. if [[ ${notice} -eq 0 ]]; then
  2741. notice=1;
  2742. ewarn "Old versions of installed libraries were detected on your system.";
  2743. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2744. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2745. ewarn "in order to remove these old dependencies. If you do not have this";
  2746. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2747. ewarn;
  2748. fi;
  2749. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2750. done
  2751. }
  2752. prune_libtool_files ()
  2753. {
  2754. debug-print-function ${FUNCNAME} "$@";
  2755. local removing_all removing_modules opt;
  2756. for opt in "$@";
  2757. do
  2758. case "${opt}" in
  2759. --all)
  2760. removing_all=1;
  2761. removing_modules=1
  2762. ;;
  2763. --modules)
  2764. removing_modules=1
  2765. ;;
  2766. *)
  2767. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2768. ;;
  2769. esac;
  2770. done;
  2771. local f;
  2772. local queue=();
  2773. while IFS= read -r -d '' f; do
  2774. local archivefile=${f/%.la/.a};
  2775. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  2776. continue;
  2777. fi;
  2778. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2779. local reason= pkgconfig_scanned=;
  2780. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  2781. if [[ ${snotlink} == yes ]]; then
  2782. if [[ -f ${archivefile} ]]; then
  2783. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2784. queue+=("${archivefile}");
  2785. fi;
  2786. if [[ -n ${removing_modules} ]]; then
  2787. reason='module';
  2788. fi;
  2789. else
  2790. if [[ -n ${removing_all} ]]; then
  2791. reason='requested';
  2792. else
  2793. if [[ ! -f ${archivefile} ]]; then
  2794. reason='no static archive';
  2795. else
  2796. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2797. reason='no libs & flags';
  2798. else
  2799. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2800. local pc_libs=();
  2801. if [[ ! -n ${removing_all} ]]; then
  2802. local pc;
  2803. local tf=${T}/prune-lt-files.pc;
  2804. local pkgconf=$(tc-getPKG_CONFIG);
  2805. while IFS= read -r -d '' pc; do
  2806. local arg libs;
  2807. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  2808. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2809. libs=$(${pkgconf} --libs "${tf}");
  2810. else
  2811. libs=$(sed -ne 's/^Libs://p' "${pc}");
  2812. fi;
  2813. for arg in ${libs};
  2814. do
  2815. if [[ ${arg} == -l* ]]; then
  2816. if [[ ${arg} == '*$*' ]]; then
  2817. eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2818. eerror "(arg: ${arg})";
  2819. eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2820. die "${FUNCNAME}: unsubstituted variable found in .pc";
  2821. fi;
  2822. pc_libs+=(lib${arg#-l}.la);
  2823. fi;
  2824. done;
  2825. done < <(find "${D}" -type f -name '*.pc' -print0);
  2826. rm -f "${tf}";
  2827. fi;
  2828. pkgconfig_scanned=1;
  2829. fi;
  2830. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2831. fi;
  2832. fi;
  2833. fi;
  2834. fi;
  2835. if [[ -n ${reason} ]]; then
  2836. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2837. queue+=("${f}");
  2838. fi;
  2839. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2840. if [[ -n ${queue[@]} ]]; then
  2841. rm -f "${queue[@]}";
  2842. fi
  2843. }
  2844. python_abi_depend ()
  2845. {
  2846. die "${FUNCNAME}() is invalid for python-r1 suite"
  2847. }
  2848. python_byte-compile_modules ()
  2849. {
  2850. die "${FUNCNAME}() is invalid for python-r1 suite"
  2851. }
  2852. python_clean_byte-compiled_modules ()
  2853. {
  2854. die "${FUNCNAME}() is invalid for python-r1 suite"
  2855. }
  2856. python_clean_installation_image ()
  2857. {
  2858. die "${FUNCNAME}() is invalid for python-r1 suite"
  2859. }
  2860. python_clean_py-compile_files ()
  2861. {
  2862. die "${FUNCNAME}() is invalid for python-r1 suite"
  2863. }
  2864. python_convert_shebangs ()
  2865. {
  2866. 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"
  2867. }
  2868. python_disable_pyc ()
  2869. {
  2870. die "${FUNCNAME}() is invalid for python-r1 suite"
  2871. }
  2872. python_doexe ()
  2873. {
  2874. debug-print-function ${FUNCNAME} "${@}";
  2875. local f;
  2876. for f in "$@";
  2877. do
  2878. python_newexe "${f}" "${f##*/}";
  2879. done
  2880. }
  2881. python_doheader ()
  2882. {
  2883. debug-print-function ${FUNCNAME} "${@}";
  2884. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2885. if [[ ${EAPI:-0} == [0123] ]]; then
  2886. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2887. fi;
  2888. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  2889. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  2890. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  2891. ( insopts -m 0644;
  2892. insinto "${d}";
  2893. doins -r "${@}" || return ${?} )
  2894. }
  2895. python_domodule ()
  2896. {
  2897. debug-print-function ${FUNCNAME} "${@}";
  2898. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2899. if [[ ${EAPI:-0} == [0123] ]]; then
  2900. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2901. fi;
  2902. local d;
  2903. if [[ ${python_moduleroot} == /* ]]; then
  2904. d=${python_moduleroot};
  2905. else
  2906. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  2907. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  2908. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  2909. fi;
  2910. ( insopts -m 0644;
  2911. insinto "${d}";
  2912. doins -r "${@}" || return ${?} );
  2913. python_optimize "${ED%/}/${d}"
  2914. }
  2915. python_doscript ()
  2916. {
  2917. debug-print-function ${FUNCNAME} "${@}";
  2918. local _PYTHON_REWRITE_SHEBANG=1;
  2919. python_doexe "${@}"
  2920. }
  2921. python_enable_pyc ()
  2922. {
  2923. die "${FUNCNAME}() is invalid for python-r1 suite"
  2924. }
  2925. python_execute_function ()
  2926. {
  2927. 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"
  2928. }
  2929. python_execute_nosetests ()
  2930. {
  2931. die "${FUNCNAME}() is invalid for python-r1 suite"
  2932. }
  2933. python_execute_py.test ()
  2934. {
  2935. die "${FUNCNAME}() is invalid for python-r1 suite"
  2936. }
  2937. python_execute_trial ()
  2938. {
  2939. die "${FUNCNAME}() is invalid for python-r1 suite"
  2940. }
  2941. python_export ()
  2942. {
  2943. debug-print-function ${FUNCNAME} "${@}";
  2944. local impl var;
  2945. case "${1}" in
  2946. python* | jython*)
  2947. impl=${1/_/.};
  2948. shift
  2949. ;;
  2950. pypy | pypy3)
  2951. impl=${1};
  2952. shift
  2953. ;;
  2954. *)
  2955. impl=${EPYTHON};
  2956. if [[ -z ${impl} ]]; then
  2957. die "python_export called without a python implementation and EPYTHON is unset";
  2958. fi
  2959. ;;
  2960. esac;
  2961. debug-print "${FUNCNAME}: implementation: ${impl}";
  2962. for var in "$@";
  2963. do
  2964. case "${var}" in
  2965. EPYTHON)
  2966. export EPYTHON=${impl};
  2967. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  2968. ;;
  2969. PYTHON)
  2970. export PYTHON=${EPREFIX}/usr/bin/${impl};
  2971. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  2972. ;;
  2973. PYTHON_SITEDIR)
  2974. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2975. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  2976. export PYTHON_SITEDIR;
  2977. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  2978. ;;
  2979. PYTHON_INCLUDEDIR)
  2980. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2981. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  2982. export PYTHON_INCLUDEDIR;
  2983. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  2984. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  2985. die "${impl} does not install any header files!";
  2986. fi
  2987. ;;
  2988. PYTHON_LIBPATH)
  2989. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2990. 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;
  2991. export PYTHON_LIBPATH;
  2992. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  2993. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  2994. die "${impl} lacks a (usable) dynamic library";
  2995. fi
  2996. ;;
  2997. PYTHON_CFLAGS)
  2998. local val;
  2999. case "${impl}" in
  3000. python*)
  3001. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  3002. ;;
  3003. *)
  3004. die "${impl}: obtaining ${var} not supported"
  3005. ;;
  3006. esac;
  3007. export PYTHON_CFLAGS=${val};
  3008. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  3009. ;;
  3010. PYTHON_LIBS)
  3011. local val;
  3012. case "${impl}" in
  3013. python*)
  3014. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  3015. ;;
  3016. *)
  3017. die "${impl}: obtaining ${var} not supported"
  3018. ;;
  3019. esac;
  3020. export PYTHON_LIBS=${val};
  3021. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  3022. ;;
  3023. PYTHON_CONFIG)
  3024. local flags val;
  3025. case "${impl}" in
  3026. python*)
  3027. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3028. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  3029. val=${PYTHON}${flags}-config
  3030. ;;
  3031. *)
  3032. die "${impl}: obtaining ${var} not supported"
  3033. ;;
  3034. esac;
  3035. export PYTHON_CONFIG=${val};
  3036. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  3037. ;;
  3038. PYTHON_PKG_DEP)
  3039. local d;
  3040. case ${impl} in
  3041. python2.7)
  3042. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  3043. ;;
  3044. python3.3)
  3045. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  3046. ;;
  3047. python*)
  3048. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  3049. ;;
  3050. pypy)
  3051. PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  3052. ;;
  3053. pypy3)
  3054. PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  3055. ;;
  3056. jython2.7)
  3057. PYTHON_PKG_DEP='dev-java/jython:2.7'
  3058. ;;
  3059. *)
  3060. die "Invalid implementation: ${impl}"
  3061. ;;
  3062. esac;
  3063. if [[ -n ${PYTHON_REQ_USE} ]]; then
  3064. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  3065. fi;
  3066. export PYTHON_PKG_DEP;
  3067. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  3068. ;;
  3069. PYTHON_SCRIPTDIR)
  3070. local dir;
  3071. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  3072. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  3073. ;;
  3074. *)
  3075. die "python_export: unknown variable ${var}"
  3076. ;;
  3077. esac;
  3078. done
  3079. }
  3080. python_export_utf8_locale ()
  3081. {
  3082. debug-print-function ${FUNCNAME} "${@}";
  3083. type locale > /dev/null || return 0;
  3084. if [[ $(locale charmap) != UTF-8 ]]; then
  3085. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  3086. for lang in ${locales};
  3087. do
  3088. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  3089. if _python_check_locale_sanity "${lang}"; then
  3090. export LC_CTYPE=${lang};
  3091. if [[ -n ${LC_ALL} ]]; then
  3092. export LC_NUMERIC=${LC_ALL};
  3093. export LC_TIME=${LC_ALL};
  3094. export LC_COLLATE=${LC_ALL};
  3095. export LC_MONETARY=${LC_ALL};
  3096. export LC_MESSAGES=${LC_ALL};
  3097. export LC_PAPER=${LC_ALL};
  3098. export LC_NAME=${LC_ALL};
  3099. export LC_ADDRESS=${LC_ALL};
  3100. export LC_TELEPHONE=${LC_ALL};
  3101. export LC_MEASUREMENT=${LC_ALL};
  3102. export LC_IDENTIFICATION=${LC_ALL};
  3103. export LC_ALL=;
  3104. fi;
  3105. return 0;
  3106. fi;
  3107. fi;
  3108. done;
  3109. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  3110. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  3111. ewarn "/etc/locale.gen and run locale-gen.";
  3112. return 1;
  3113. fi;
  3114. return 0
  3115. }
  3116. python_fix_shebang ()
  3117. {
  3118. debug-print-function ${FUNCNAME} "${@}";
  3119. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  3120. local force quiet;
  3121. while [[ -n ${@} ]]; do
  3122. case "${1}" in
  3123. -f | --force)
  3124. force=1;
  3125. shift
  3126. ;;
  3127. -q | --quiet)
  3128. quiet=1;
  3129. shift
  3130. ;;
  3131. --)
  3132. shift;
  3133. break
  3134. ;;
  3135. *)
  3136. break
  3137. ;;
  3138. esac;
  3139. done;
  3140. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  3141. local path f;
  3142. for path in "$@";
  3143. do
  3144. local any_correct any_fixed is_recursive;
  3145. [[ -d ${path} ]] && is_recursive=1;
  3146. while IFS= read -r -d '' f; do
  3147. local shebang i;
  3148. local error= from=;
  3149. IFS= read -r shebang < "${f}";
  3150. if [[ ${shebang} == '#!'* ]]; then
  3151. local split_shebang=();
  3152. read -r -a split_shebang <<< ${shebang} || die;
  3153. for i in "${split_shebang[@]}";
  3154. do
  3155. case "${i}" in
  3156. *"${EPYTHON}")
  3157. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3158. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  3159. any_correct=1;
  3160. from=${EPYTHON};
  3161. break
  3162. ;;
  3163. *python | *python[23])
  3164. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3165. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  3166. if [[ ${i} == *python2 ]]; then
  3167. from=python2;
  3168. if [[ ! -n ${force} ]]; then
  3169. python_is_python3 "${EPYTHON}" && error=1;
  3170. fi;
  3171. else
  3172. if [[ ${i} == *python3 ]]; then
  3173. from=python3;
  3174. if [[ ! -n ${force} ]]; then
  3175. python_is_python3 "${EPYTHON}" || error=1;
  3176. fi;
  3177. else
  3178. from=python;
  3179. fi;
  3180. fi;
  3181. break
  3182. ;;
  3183. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  3184. if [[ ! -n ${force} ]]; then
  3185. error=1;
  3186. else
  3187. case "${i}" in
  3188. *python[23].[0123456789])
  3189. from="python[23].[0123456789]"
  3190. ;;
  3191. *pypy)
  3192. from="pypy"
  3193. ;;
  3194. *pypy3)
  3195. from="pypy3"
  3196. ;;
  3197. *jython[23].[0123456789])
  3198. from="jython[23].[0123456789]"
  3199. ;;
  3200. *)
  3201. die "${FUNCNAME}: internal error in 2nd pattern match"
  3202. ;;
  3203. esac;
  3204. fi;
  3205. break
  3206. ;;
  3207. esac;
  3208. done;
  3209. fi;
  3210. if [[ ! -n ${error} && ! -n ${from} ]]; then
  3211. [[ -n ${is_recursive} ]] && continue;
  3212. error=1;
  3213. fi;
  3214. if [[ ! -n ${quiet} ]]; then
  3215. einfo "Fixing shebang in ${f#${D%/}}.";
  3216. fi;
  3217. if [[ ! -n ${error} ]]; then
  3218. if [[ ${shebang} == *${from}" "* ]]; then
  3219. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  3220. else
  3221. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  3222. fi;
  3223. any_fixed=1;
  3224. else
  3225. eerror "The file has incompatible shebang:";
  3226. eerror " file: ${f#${D%/}}";
  3227. eerror " current shebang: ${shebang}";
  3228. eerror " requested impl: ${EPYTHON}";
  3229. die "${FUNCNAME}: conversion of incompatible shebang requested";
  3230. fi;
  3231. done < <(find -H "${path}" -type f -print0 || die);
  3232. if [[ ! -n ${any_fixed} ]]; then
  3233. local cmd=eerror;
  3234. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  3235. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  3236. if [[ -n ${any_correct} ]]; then
  3237. "${cmd}" "All files have ${EPYTHON} shebang already.";
  3238. else
  3239. "${cmd}" "There are no Python files in specified directory.";
  3240. fi;
  3241. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  3242. fi;
  3243. done
  3244. }
  3245. python_generate_cffi_modules ()
  3246. {
  3247. die "${FUNCNAME}() is invalid for python-r1 suite"
  3248. }
  3249. python_generate_wrapper_scripts ()
  3250. {
  3251. die "${FUNCNAME}() is invalid for python-r1 suite"
  3252. }
  3253. python_get_CFLAGS ()
  3254. {
  3255. debug-print-function ${FUNCNAME} "${@}";
  3256. python_export "${@}" PYTHON_CFLAGS;
  3257. echo "${PYTHON_CFLAGS}"
  3258. }
  3259. python_get_LIBS ()
  3260. {
  3261. debug-print-function ${FUNCNAME} "${@}";
  3262. python_export "${@}" PYTHON_LIBS;
  3263. echo "${PYTHON_LIBS}"
  3264. }
  3265. python_get_PYTHON_CONFIG ()
  3266. {
  3267. debug-print-function ${FUNCNAME} "${@}";
  3268. python_export "${@}" PYTHON_CONFIG;
  3269. echo "${PYTHON_CONFIG}"
  3270. }
  3271. python_get_extension_module_suffix ()
  3272. {
  3273. die "${FUNCNAME}() is invalid for python-r1 suite"
  3274. }
  3275. python_get_implementation ()
  3276. {
  3277. die "${FUNCNAME}() is invalid for python-r1 suite"
  3278. }
  3279. python_get_implementation_and_version ()
  3280. {
  3281. die "${FUNCNAME}() is invalid for python-r1 suite"
  3282. }
  3283. python_get_implementational_package ()
  3284. {
  3285. die "${FUNCNAME}() is invalid for python-r1 suite"
  3286. }
  3287. python_get_includedir ()
  3288. {
  3289. debug-print-function ${FUNCNAME} "${@}";
  3290. python_export "${@}" PYTHON_INCLUDEDIR;
  3291. echo "${PYTHON_INCLUDEDIR}"
  3292. }
  3293. python_get_libdir ()
  3294. {
  3295. die "${FUNCNAME}() is invalid for python-r1 suite"
  3296. }
  3297. python_get_library ()
  3298. {
  3299. die "${FUNCNAME}() is invalid for python-r1 suite"
  3300. }
  3301. python_get_library_path ()
  3302. {
  3303. debug-print-function ${FUNCNAME} "${@}";
  3304. python_export "${@}" PYTHON_LIBPATH;
  3305. echo "${PYTHON_LIBPATH}"
  3306. }
  3307. python_get_scriptdir ()
  3308. {
  3309. debug-print-function ${FUNCNAME} "${@}";
  3310. python_export "${@}" PYTHON_SCRIPTDIR;
  3311. echo "${PYTHON_SCRIPTDIR}"
  3312. }
  3313. python_get_sitedir ()
  3314. {
  3315. debug-print-function ${FUNCNAME} "${@}";
  3316. python_export "${@}" PYTHON_SITEDIR;
  3317. echo "${PYTHON_SITEDIR}"
  3318. }
  3319. python_get_version ()
  3320. {
  3321. die "${FUNCNAME}() is invalid for python-r1 suite"
  3322. }
  3323. python_install_executables ()
  3324. {
  3325. die "${FUNCNAME}() is invalid for python-r1 suite"
  3326. }
  3327. python_is_installed ()
  3328. {
  3329. local impl=${1:-${EPYTHON}};
  3330. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  3331. local hasv_args=();
  3332. case ${EAPI:-0} in
  3333. 0 | 1 | 2 | 3 | 4)
  3334. local -x ROOT=/
  3335. ;;
  3336. 5 | 6)
  3337. hasv_args+=(--host-root)
  3338. ;;
  3339. *)
  3340. hasv_args+=(-b)
  3341. ;;
  3342. esac;
  3343. case "${impl}" in
  3344. pypy | pypy3)
  3345. local append=;
  3346. if [[ -n ${PYTHON_REQ_USE} ]]; then
  3347. append=[${PYTHON_REQ_USE}];
  3348. fi;
  3349. has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  3350. ;;
  3351. *)
  3352. local PYTHON_PKG_DEP;
  3353. python_export "${impl}" PYTHON_PKG_DEP;
  3354. has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  3355. ;;
  3356. esac
  3357. }
  3358. python_is_python3 ()
  3359. {
  3360. local impl=${1:-${EPYTHON}};
  3361. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  3362. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  3363. }
  3364. python_merge_intermediate_installation_images ()
  3365. {
  3366. die "${FUNCNAME}() is invalid for python-r1 suite"
  3367. }
  3368. python_mod_cleanup ()
  3369. {
  3370. 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"
  3371. }
  3372. python_mod_optimize ()
  3373. {
  3374. 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"
  3375. }
  3376. python_moduleinto ()
  3377. {
  3378. debug-print-function ${FUNCNAME} "${@}";
  3379. python_moduleroot=${1}
  3380. }
  3381. python_need_rebuild ()
  3382. {
  3383. die "${FUNCNAME}() is invalid for python-r1 suite"
  3384. }
  3385. python_newexe ()
  3386. {
  3387. debug-print-function ${FUNCNAME} "${@}";
  3388. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3389. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3390. if [[ ${EAPI:-0} == [0123] ]]; then
  3391. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  3392. fi;
  3393. local wrapd=${python_scriptroot:-/usr/bin};
  3394. local f=${1};
  3395. local newfn=${2};
  3396. local PYTHON_SCRIPTDIR d;
  3397. python_export PYTHON_SCRIPTDIR;
  3398. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  3399. ( dodir "${wrapd}";
  3400. exeopts -m 0755;
  3401. exeinto "${d}";
  3402. newexe "${f}" "${newfn}" || return ${?} );
  3403. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  3404. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3405. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3406. fi
  3407. }
  3408. python_newscript ()
  3409. {
  3410. debug-print-function ${FUNCNAME} "${@}";
  3411. local _PYTHON_REWRITE_SHEBANG=1;
  3412. python_newexe "${@}"
  3413. }
  3414. python_optimize ()
  3415. {
  3416. debug-print-function ${FUNCNAME} "${@}";
  3417. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  3418. eerror "The new Python eclasses expect the compiled Python files to";
  3419. eerror "be controlled by the Package Manager. For this reason,";
  3420. eerror "the python_optimize function can be used only during src_* phases";
  3421. eerror "(src_install most commonly) and not during pkg_* phases.";
  3422. echo;
  3423. die "python_optimize is not to be used in pre/post* phases";
  3424. fi;
  3425. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3426. local PYTHON=${PYTHON};
  3427. [[ -n ${PYTHON} ]] || python_export PYTHON;
  3428. if [[ ${#} -eq 0 ]]; then
  3429. local f;
  3430. while IFS= read -r -d '' f; do
  3431. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  3432. set -- "${D%/}${f}" "${@}";
  3433. fi;
  3434. done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  3435. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  3436. fi;
  3437. local d;
  3438. for d in "$@";
  3439. do
  3440. local instpath=${d#${D%/}};
  3441. instpath=/${instpath##/};
  3442. case "${EPYTHON}" in
  3443. python2.7 | python3.[34])
  3444. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3445. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3446. ;;
  3447. python* | pypy3)
  3448. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3449. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  3450. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3451. ;;
  3452. *)
  3453. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  3454. ;;
  3455. esac;
  3456. done
  3457. }
  3458. python_pkg_setup ()
  3459. {
  3460. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3461. }
  3462. python_scriptinto ()
  3463. {
  3464. debug-print-function ${FUNCNAME} "${@}";
  3465. python_scriptroot=${1}
  3466. }
  3467. python_set_active_version ()
  3468. {
  3469. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3470. }
  3471. python_wrapper_setup ()
  3472. {
  3473. debug-print-function ${FUNCNAME} "${@}";
  3474. local workdir=${1:-${T}/${EPYTHON}};
  3475. local impl=${2:-${EPYTHON}};
  3476. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  3477. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  3478. if [[ ! -x ${workdir}/bin/python ]]; then
  3479. _python_check_dead_variables;
  3480. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  3481. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  3482. rm -f "${workdir}"/bin/2to3 || die;
  3483. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  3484. local EPYTHON PYTHON;
  3485. python_export "${impl}" EPYTHON PYTHON;
  3486. local pyver pyother;
  3487. if python_is_python3; then
  3488. pyver=3;
  3489. pyother=2;
  3490. else
  3491. pyver=2;
  3492. pyother=3;
  3493. fi;
  3494. cat > "${workdir}/bin/python" <<-_EOF_ ||
  3495. #!/bin/sh
  3496. exec "${PYTHON}" "\${@}"
  3497. _EOF_
  3498. die
  3499. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3500. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3501. local nonsupp=("python${pyother}" "python${pyother}-config");
  3502. if [[ ${EPYTHON} == python* ]]; then
  3503. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  3504. #!/bin/sh
  3505. exec "${PYTHON}-config" "\${@}"
  3506. _EOF_
  3507. die
  3508. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3509. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3510. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  3511. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  3512. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  3513. else
  3514. nonsupp+=(2to3 python-config "python${pyver}-config");
  3515. fi;
  3516. local x;
  3517. for x in "${nonsupp[@]}";
  3518. do
  3519. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  3520. #!/bin/sh
  3521. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  3522. exit 127
  3523. _EOF_
  3524. die
  3525. chmod +x "${workdir}"/bin/${x} || die;
  3526. done;
  3527. fi;
  3528. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  3529. PATH=${workdir}/bin${PATH:+:${PATH}};
  3530. fi;
  3531. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  3532. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  3533. fi;
  3534. export PATH PKG_CONFIG_PATH
  3535. }
  3536. raw-ldflags ()
  3537. {
  3538. local x input="$@";
  3539. [[ -z ${input} ]] && input=${LDFLAGS};
  3540. set --;
  3541. for x in ${input};
  3542. do
  3543. case ${x} in
  3544. -Wl,*)
  3545. x=${x#-Wl,};
  3546. set -- "$@" ${x//,/ }
  3547. ;;
  3548. *)
  3549.  
  3550. ;;
  3551. esac;
  3552. done;
  3553. echo "$@"
  3554. }
  3555. replace-cpu-flags ()
  3556. {
  3557. local newcpu="$#";
  3558. newcpu="${!newcpu}";
  3559. while [ $# -gt 1 ]; do
  3560. replace-flags "-march=${1}" "-march=${newcpu}";
  3561. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3562. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3563. shift;
  3564. done;
  3565. return 0
  3566. }
  3567. replace-flags ()
  3568. {
  3569. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3570. local f var new;
  3571. for var in $(all-flag-vars);
  3572. do
  3573. new=();
  3574. for f in ${!var};
  3575. do
  3576. [[ ${f} == ${1} ]] && f=${2};
  3577. new+=("${f}");
  3578. done;
  3579. export ${var}="${new[*]}";
  3580. done;
  3581. return 0
  3582. }
  3583. replace-sparc64-flags ()
  3584. {
  3585. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3586. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3587. for x in ${SPARC64_CPUS};
  3588. do
  3589. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3590. done;
  3591. else
  3592. for x in ${SPARC64_CPUS};
  3593. do
  3594. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3595. done;
  3596. fi;
  3597. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3598. for x in ${SPARC64_CPUS};
  3599. do
  3600. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3601. done;
  3602. else
  3603. for x in ${SPARC64_CPUS};
  3604. do
  3605. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3606. done;
  3607. fi;
  3608. export CFLAGS CXXFLAGS
  3609. }
  3610. setup-allowed-flags ()
  3611. {
  3612. ALLOWED_FLAGS=(-pipe -O '-O[12sg]' -mcpu -march -mtune '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check -fbounds-check -fbounds-checking -fno-strict-overflow -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -gz -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld');
  3613. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  3614. ALLOWED_FLAGS+=(-mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi -mfix-r10000 -mno-fix-r10000 -mthumb -marm -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha)
  3615. }
  3616. src_compile ()
  3617. {
  3618. local -x LC_ALL=C;
  3619. emake CPPFLAGS= CFLAGS= LDFLAGS=;
  3620. if has_version dev-libs/libffi[pax_kernel]; then
  3621. pax-mark E python;
  3622. else
  3623. pax-mark m python;
  3624. fi
  3625. }
  3626. src_configure ()
  3627. {
  3628. local disable;
  3629. use gdbm || disable+=" gdbm";
  3630. use ncurses || disable+=" _curses _curses_panel";
  3631. use readline || disable+=" readline";
  3632. use sqlite || disable+=" _sqlite3";
  3633. use ssl || export PYTHON_DISABLE_SSL="1";
  3634. use tk || disable+=" _tkinter";
  3635. use xml || disable+=" _elementtree pyexpat";
  3636. export PYTHON_DISABLE_MODULES="${disable}";
  3637. if ! use xml; then
  3638. ewarn "You have configured Python without XML support.";
  3639. ewarn "This is NOT a recommended configuration as you";
  3640. ewarn "may face problems parsing any XML documents.";
  3641. fi;
  3642. if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
  3643. einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}";
  3644. fi;
  3645. if [[ "$(gcc-major-version)" -ge 4 ]]; then
  3646. append-flags -fwrapv;
  3647. fi;
  3648. filter-flags -malign-double;
  3649. if is-flagq -O3; then
  3650. is-flagq -fstack-protector-all && replace-flags -O3 -O2;
  3651. use hardened && replace-flags -O3 -O2;
  3652. fi;
  3653. tc-export CXX;
  3654. append-ldflags "-L.";
  3655. local dbmliborder;
  3656. if use gdbm; then
  3657. dbmliborder+="${dbmliborder:+:}gdbm";
  3658. fi;
  3659. local myeconfargs=(--with-fpectl --enable-shared $(use_enable ipv6) $(use_with threads) --infodir='${prefix}/share/info' --mandir='${prefix}/share/man' --with-computed-gotos --with-dbmliborder="${dbmliborder}" --with-libc= --enable-loadable-sqlite-extensions --without-ensurepip --with-system-expat --with-system-ffi);
  3660. OPT="" econf "${myeconfargs[@]}";
  3661. if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
  3662. eerror "configure has detected that the sem_open function is broken.";
  3663. eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777.";
  3664. die "Broken sem_open function (bug 496328)";
  3665. fi
  3666. }
  3667. src_install ()
  3668. {
  3669. local libdir=${ED}/usr/$(get_libdir)/python${PYVER};
  3670. emake DESTDIR="${D}" altinstall;
  3671. sed -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" -e "s/\(PY_LDFLAGS=\).*/\1/" -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed";
  3672. rm -f "${ED}usr/$(get_libdir)/libpython3.so";
  3673. local abiver=$(cd "${ED}usr/include"; echo python*);
  3674. if [[ ${abiver} != python${PYVER} ]]; then
  3675. rm "${ED}usr/bin/python${PYVER}" || die;
  3676. dosym "${abiver}" "/usr/bin/python${PYVER}";
  3677. dosym "${abiver}-config" "/usr/bin/python${PYVER}-config";
  3678. dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc";
  3679. fi;
  3680. if has_version dev-libs/libffi[pax_kernel]; then
  3681. pax-mark E "${ED}usr/bin/${abiver}";
  3682. else
  3683. pax-mark m "${ED}usr/bin/${abiver}";
  3684. fi;
  3685. use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die;
  3686. use tk || rm -r "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die;
  3687. use threads || rm -r "${libdir}/multiprocessing" || die;
  3688. use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die;
  3689. dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS};
  3690. if use examples; then
  3691. insinto /usr/share/doc/${PF}/examples;
  3692. find "${S}"/Tools -name __pycache__ -print0 | xargs -0 rm -fr;
  3693. doins -r "${S}"/Tools;
  3694. fi;
  3695. insinto /usr/share/gdb/auto-load/usr/$(get_libdir);
  3696. local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | emake --no-print-directory -s -f - 2>/dev/null);
  3697. newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py;
  3698. newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER};
  3699. newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER};
  3700. sed -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" -e "s:@PYDOC@:pydoc${PYVER}:" -i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed";
  3701. local vars=(EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR);
  3702. if ! tc-is-cross-compiler; then
  3703. local -x PYTHON=./python;
  3704. local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD};
  3705. else
  3706. vars=(PYTHON "${vars[@]}");
  3707. fi;
  3708. python_export "python${PYVER}" "${vars[@]}";
  3709. echo "EPYTHON='${EPYTHON}'" > epython.py || die;
  3710. python_domodule epython.py;
  3711. local pymajor=${PYVER%.*};
  3712. mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die;
  3713. ln -s "../../../bin/${abiver}" "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die;
  3714. ln -s "python${pymajor}" "${D}${PYTHON_SCRIPTDIR}/python" || die;
  3715. cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF ||
  3716. #!/bin/sh
  3717. exec "${abiver}-config" "\${@}"
  3718. EOF
  3719. die
  3720. chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die;
  3721. ln -s "python${pymajor}-config" "${D}${PYTHON_SCRIPTDIR}/python-config" || die;
  3722. ln -s "../../../bin/2to3-${PYVER}" "${D}${PYTHON_SCRIPTDIR}/2to3" || die;
  3723. ln -s "../../../bin/pydoc${PYVER}" "${D}${PYTHON_SCRIPTDIR}/pydoc" || die;
  3724. ln -s "../../../bin/pyvenv-${PYVER}" "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die;
  3725. if use tk; then
  3726. ln -s "../../../bin/idle${PYVER}" "${D}${PYTHON_SCRIPTDIR}/idle" || die;
  3727. fi
  3728. }
  3729. src_prepare ()
  3730. {
  3731. rm -fr Modules/expat;
  3732. rm -fr Modules/_ctypes/libffi*;
  3733. rm -fr Modules/zlib;
  3734. local PATCHES=("${WORKDIR}/patches" "${FILESDIR}/${PN}-3.5-distutils-OO-build.patch" "${FILESDIR}/3.6.5-disable-nis.patch" "${FILESDIR}/python-3.6.5-libressl-compatibility.patch" "${FILESDIR}/python-3.6.5-hash-unaligned.patch");
  3735. default;
  3736. sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" Lib/distutils/command/install.py Lib/distutils/sysconfig.py Lib/site.py Lib/sysconfig.py Lib/test/test_site.py Makefile.pre.in Modules/Setup.dist Modules/getpath.c configure.ac setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@";
  3737. eautoreconf
  3738. }
  3739. src_test ()
  3740. {
  3741. if tc-is-cross-compiler; then
  3742. elog "Disabling tests due to crosscompiling.";
  3743. return;
  3744. fi;
  3745. local skipped_tests="gdb";
  3746. for test in ${skipped_tests};
  3747. do
  3748. mv "${S}"/Lib/test/test_${test}.py "${T}";
  3749. done;
  3750. local -x PYTHONDONTWRITEBYTECODE=;
  3751. emake test EXTRATESTOPTS="-u-network" CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty;
  3752. local result=$?;
  3753. for test in ${skipped_tests};
  3754. do
  3755. mv "${T}/test_${test}.py" "${S}"/Lib/test;
  3756. done;
  3757. elog "The following tests have been skipped:";
  3758. for test in ${skipped_tests};
  3759. do
  3760. elog "test_${test}.py";
  3761. done;
  3762. elog "If you would like to run them, you may:";
  3763. elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'";
  3764. elog "and run the tests separately.";
  3765. if [[ ${result} -ne 0 ]]; then
  3766. die "emake test failed";
  3767. fi
  3768. }
  3769. src_unpack ()
  3770. {
  3771. default
  3772. }
  3773. strip-flags ()
  3774. {
  3775. local x y var;
  3776. local ALLOWED_FLAGS;
  3777. setup-allowed-flags;
  3778. set -f;
  3779. for var in $(all-flag-vars);
  3780. do
  3781. local new=();
  3782. for x in ${!var};
  3783. do
  3784. local flag=${x%%=*};
  3785. for y in "${ALLOWED_FLAGS[@]}";
  3786. do
  3787. if [[ -z ${flag%%${y}} ]]; then
  3788. new+=("${x}");
  3789. break;
  3790. fi;
  3791. done;
  3792. done;
  3793. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  3794. new+=(-O2);
  3795. fi;
  3796. if [[ ${!var} != "${new[*]}" ]]; then
  3797. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  3798. fi;
  3799. export ${var}="${new[*]}";
  3800. done;
  3801. set +f;
  3802. return 0
  3803. }
  3804. strip-linguas ()
  3805. {
  3806. local ls newls nols;
  3807. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  3808. local op=$1;
  3809. shift;
  3810. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  3811. shift;
  3812. local d f;
  3813. for d in "$@";
  3814. do
  3815. if [[ ${op} == "-u" ]]; then
  3816. newls=${ls};
  3817. else
  3818. newls="";
  3819. fi;
  3820. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  3821. do
  3822. if [[ ${op} == "-i" ]]; then
  3823. has ${f} ${ls} && newls="${newls} ${f}";
  3824. else
  3825. has ${f} ${ls} || newls="${newls} ${f}";
  3826. fi;
  3827. done;
  3828. ls=${newls};
  3829. done;
  3830. else
  3831. ls="$@";
  3832. fi;
  3833. nols="";
  3834. newls="";
  3835. for f in ${LINGUAS};
  3836. do
  3837. if has ${f} ${ls}; then
  3838. newls="${newls} ${f}";
  3839. else
  3840. nols="${nols} ${f}";
  3841. fi;
  3842. done;
  3843. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  3844. export LINGUAS=${newls:1}
  3845. }
  3846. strip-unsupported-flags ()
  3847. {
  3848. export CFLAGS=$(test-flags-CC ${CFLAGS});
  3849. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3850. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3851. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  3852. export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  3853. }
  3854. tc-arch ()
  3855. {
  3856. tc-ninja_magic_to_arch portage "$@"
  3857. }
  3858. tc-arch-kernel ()
  3859. {
  3860. tc-ninja_magic_to_arch kern "$@"
  3861. }
  3862. tc-check-openmp ()
  3863. {
  3864. if ! tc-has-openmp; then
  3865. eerror "Your current compiler does not support OpenMP!";
  3866. if tc-is-gcc; then
  3867. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  3868. else
  3869. if tc-is-clang; then
  3870. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  3871. fi;
  3872. fi;
  3873. die "Active compiler does not have required support for OpenMP";
  3874. fi
  3875. }
  3876. tc-cpp-is-true ()
  3877. {
  3878. local CONDITION=${1};
  3879. shift;
  3880. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  3881. #if ${CONDITION}
  3882. true
  3883. #endif
  3884. EOF
  3885. );
  3886. [[ ${RESULT} == true ]]
  3887. }
  3888. tc-detect-is-softfloat ()
  3889. {
  3890. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  3891. case ${CTARGET:-${CHOST}} in
  3892. *-newlib | *-elf | *-eabi)
  3893. return 1
  3894. ;;
  3895. arm*)
  3896. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  3897. echo "no";
  3898. else
  3899. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  3900. echo "yes";
  3901. else
  3902. echo "softfp";
  3903. fi;
  3904. fi;
  3905. return 0
  3906. ;;
  3907. *)
  3908. return 1
  3909. ;;
  3910. esac
  3911. }
  3912. tc-enables-pie ()
  3913. {
  3914. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  3915. }
  3916. tc-enables-ssp ()
  3917. {
  3918. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3919. }
  3920. tc-enables-ssp-all ()
  3921. {
  3922. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3923. }
  3924. tc-enables-ssp-strong ()
  3925. {
  3926. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3927. }
  3928. tc-endian ()
  3929. {
  3930. local host=$1;
  3931. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3932. host=${host%%-*};
  3933. case ${host} in
  3934. aarch64*be)
  3935. echo big
  3936. ;;
  3937. aarch64)
  3938. echo little
  3939. ;;
  3940. alpha*)
  3941. echo little
  3942. ;;
  3943. arm*b*)
  3944. echo big
  3945. ;;
  3946. arm*)
  3947. echo little
  3948. ;;
  3949. cris*)
  3950. echo little
  3951. ;;
  3952. hppa*)
  3953. echo big
  3954. ;;
  3955. i?86*)
  3956. echo little
  3957. ;;
  3958. ia64*)
  3959. echo little
  3960. ;;
  3961. m68*)
  3962. echo big
  3963. ;;
  3964. mips*l*)
  3965. echo little
  3966. ;;
  3967. mips*)
  3968. echo big
  3969. ;;
  3970. powerpc*le)
  3971. echo little
  3972. ;;
  3973. powerpc*)
  3974. echo big
  3975. ;;
  3976. s390*)
  3977. echo big
  3978. ;;
  3979. sh*b*)
  3980. echo big
  3981. ;;
  3982. sh*)
  3983. echo little
  3984. ;;
  3985. sparc*)
  3986. echo big
  3987. ;;
  3988. x86_64*)
  3989. echo little
  3990. ;;
  3991. *)
  3992. echo wtf
  3993. ;;
  3994. esac
  3995. }
  3996. tc-env_build ()
  3997. {
  3998. tc-export_build_env;
  3999. 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) "$@"
  4000. }
  4001. tc-export ()
  4002. {
  4003. local var;
  4004. for var in "$@";
  4005. do
  4006. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4007. "tc-get${var}" > /dev/null;
  4008. done
  4009. }
  4010. tc-export_build_env ()
  4011. {
  4012. tc-export "$@";
  4013. if tc-is-cross-compiler; then
  4014. : ${BUILD_CFLAGS:=-O1 -pipe};
  4015. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  4016. : ${BUILD_CPPFLAGS:= };
  4017. : ${BUILD_LDFLAGS:= };
  4018. else
  4019. : ${BUILD_CFLAGS:=${CFLAGS}};
  4020. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  4021. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  4022. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  4023. fi;
  4024. export BUILD_{C,CXX,CPP,LD}FLAGS;
  4025. local v;
  4026. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4027. do
  4028. export ${v#BUILD_}_FOR_BUILD="${!v}";
  4029. done
  4030. }
  4031. tc-get-compiler-type ()
  4032. {
  4033. local code='
  4034. #if defined(__PATHSCALE__)
  4035. HAVE_PATHCC
  4036. #elif defined(__clang__)
  4037. HAVE_CLANG
  4038. #elif defined(__GNUC__)
  4039. HAVE_GCC
  4040. #endif
  4041. ';
  4042. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4043. case ${res} in
  4044. *HAVE_PATHCC*)
  4045. echo pathcc
  4046. ;;
  4047. *HAVE_CLANG*)
  4048. echo clang
  4049. ;;
  4050. *HAVE_GCC*)
  4051. echo gcc
  4052. ;;
  4053. *)
  4054. echo unknown
  4055. ;;
  4056. esac
  4057. }
  4058. tc-getAR ()
  4059. {
  4060. tc-getPROG AR ar "$@"
  4061. }
  4062. tc-getAS ()
  4063. {
  4064. tc-getPROG AS as "$@"
  4065. }
  4066. tc-getBUILD_AR ()
  4067. {
  4068. tc-getBUILD_PROG AR ar "$@"
  4069. }
  4070. tc-getBUILD_AS ()
  4071. {
  4072. tc-getBUILD_PROG AS as "$@"
  4073. }
  4074. tc-getBUILD_CC ()
  4075. {
  4076. tc-getBUILD_PROG CC gcc "$@"
  4077. }
  4078. tc-getBUILD_CPP ()
  4079. {
  4080. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4081. }
  4082. tc-getBUILD_CXX ()
  4083. {
  4084. tc-getBUILD_PROG CXX g++ "$@"
  4085. }
  4086. tc-getBUILD_LD ()
  4087. {
  4088. tc-getBUILD_PROG LD ld "$@"
  4089. }
  4090. tc-getBUILD_NM ()
  4091. {
  4092. tc-getBUILD_PROG NM nm "$@"
  4093. }
  4094. tc-getBUILD_OBJCOPY ()
  4095. {
  4096. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4097. }
  4098. tc-getBUILD_PKG_CONFIG ()
  4099. {
  4100. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4101. }
  4102. tc-getBUILD_PROG ()
  4103. {
  4104. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4105. tc-is-cross-compiler || vars+=" $1";
  4106. _tc-getPROG CBUILD "${vars}" "${@:2}"
  4107. }
  4108. tc-getBUILD_RANLIB ()
  4109. {
  4110. tc-getBUILD_PROG RANLIB ranlib "$@"
  4111. }
  4112. tc-getBUILD_STRIP ()
  4113. {
  4114. tc-getBUILD_PROG STRIP strip "$@"
  4115. }
  4116. tc-getCC ()
  4117. {
  4118. tc-getPROG CC gcc "$@"
  4119. }
  4120. tc-getCPP ()
  4121. {
  4122. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4123. }
  4124. tc-getCXX ()
  4125. {
  4126. tc-getPROG CXX g++ "$@"
  4127. }
  4128. tc-getDLLWRAP ()
  4129. {
  4130. tc-getPROG DLLWRAP dllwrap "$@"
  4131. }
  4132. tc-getF77 ()
  4133. {
  4134. tc-getPROG F77 gfortran "$@"
  4135. }
  4136. tc-getFC ()
  4137. {
  4138. tc-getPROG FC gfortran "$@"
  4139. }
  4140. tc-getGCJ ()
  4141. {
  4142. tc-getPROG GCJ gcj "$@"
  4143. }
  4144. tc-getGO ()
  4145. {
  4146. tc-getPROG GO gccgo "$@"
  4147. }
  4148. tc-getLD ()
  4149. {
  4150. tc-getPROG LD ld "$@"
  4151. }
  4152. tc-getNM ()
  4153. {
  4154. tc-getPROG NM nm "$@"
  4155. }
  4156. tc-getOBJCOPY ()
  4157. {
  4158. tc-getPROG OBJCOPY objcopy "$@"
  4159. }
  4160. tc-getOBJDUMP ()
  4161. {
  4162. tc-getPROG OBJDUMP objdump "$@"
  4163. }
  4164. tc-getPKG_CONFIG ()
  4165. {
  4166. tc-getPROG PKG_CONFIG pkg-config "$@"
  4167. }
  4168. tc-getPROG ()
  4169. {
  4170. _tc-getPROG CHOST "$@"
  4171. }
  4172. tc-getRANLIB ()
  4173. {
  4174. tc-getPROG RANLIB ranlib "$@"
  4175. }
  4176. tc-getRC ()
  4177. {
  4178. tc-getPROG RC windres "$@"
  4179. }
  4180. tc-getSTRIP ()
  4181. {
  4182. tc-getPROG STRIP strip "$@"
  4183. }
  4184. tc-getTARGET_CPP ()
  4185. {
  4186. if [[ -n ${CTARGET} ]]; then
  4187. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4188. else
  4189. tc-getCPP "$@";
  4190. fi
  4191. }
  4192. tc-has-openmp ()
  4193. {
  4194. local base="${T}/test-tc-openmp";
  4195. cat > "${base}.c" <<-EOF
  4196. #include <omp.h>
  4197. int main() {
  4198. int nthreads, tid, ret = 0;
  4199. #pragma omp parallel private(nthreads, tid)
  4200. {
  4201. tid = omp_get_thread_num();
  4202. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  4203. }
  4204. return ret;
  4205. }
  4206. EOF
  4207.  
  4208. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  4209. local ret=$?;
  4210. rm -f "${base}"*;
  4211. return ${ret}
  4212. }
  4213. tc-has-tls ()
  4214. {
  4215. local base="${T}/test-tc-tls";
  4216. cat > "${base}.c" <<-EOF
  4217. int foo(int *i) {
  4218. static __thread int j = 0;
  4219. return *i ? j : *i;
  4220. }
  4221. EOF
  4222.  
  4223. local flags;
  4224. case $1 in
  4225. -s)
  4226. flags="-S"
  4227. ;;
  4228. -c)
  4229. flags="-c"
  4230. ;;
  4231. -l)
  4232.  
  4233. ;;
  4234. -*)
  4235. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4236. ;;
  4237. esac;
  4238. : ${flags:=-fPIC -shared -Wl,-z,defs};
  4239. [[ $1 == -* ]] && shift;
  4240. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4241. local ret=$?;
  4242. rm -f "${base}"*;
  4243. return ${ret}
  4244. }
  4245. tc-is-clang ()
  4246. {
  4247. [[ $(tc-get-compiler-type) == clang ]]
  4248. }
  4249. tc-is-cross-compiler ()
  4250. {
  4251. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4252. }
  4253. tc-is-gcc ()
  4254. {
  4255. [[ $(tc-get-compiler-type) == gcc ]]
  4256. }
  4257. tc-is-softfloat ()
  4258. {
  4259. tc-detect-is-softfloat || tc-tuple-is-softfloat
  4260. }
  4261. tc-is-static-only ()
  4262. {
  4263. local host=${CTARGET:-${CHOST}};
  4264. [[ ${host} == *-mint* ]]
  4265. }
  4266. tc-ld-disable-gold ()
  4267. {
  4268. if ! tc-ld-is-gold "$@"; then
  4269. return;
  4270. fi;
  4271. ewarn "Forcing usage of the BFD linker instead of GOLD";
  4272. local ld=$(tc-getLD "$@");
  4273. local bfd_ld="${ld%% *}.bfd";
  4274. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  4275. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  4276. local fallback="true";
  4277. if tc-is-gcc; then
  4278. local major=$(gcc-major-version "$@");
  4279. local minor=$(gcc-minor-version "$@");
  4280. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  4281. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4282. fallback="false";
  4283. fi;
  4284. else
  4285. if tc-is-clang; then
  4286. local major=$(clang-major-version "$@");
  4287. local minor=$(clang-minor-version "$@");
  4288. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  4289. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4290. fallback="false";
  4291. fi;
  4292. fi;
  4293. fi;
  4294. if [[ ${fallback} == "true" ]]; then
  4295. if [[ -e ${path_ld} ]]; then
  4296. local d="${T}/bfd-linker";
  4297. mkdir -p "${d}";
  4298. ln -sf "${path_ld}" "${d}"/ld;
  4299. export LDFLAGS="${LDFLAGS} -B${d}";
  4300. else
  4301. die "unable to locate a BFD linker to bypass gold";
  4302. fi;
  4303. fi
  4304. }
  4305. tc-ld-is-gold ()
  4306. {
  4307. local out;
  4308. out=$($(tc-getLD "$@") --version 2>&1);
  4309. if [[ ${out} == *"GNU gold"* ]]; then
  4310. return 0;
  4311. fi;
  4312. local base="${T}/test-tc-gold";
  4313. cat > "${base}.c" <<-EOF
  4314. int main() { return 0; }
  4315. EOF
  4316.  
  4317. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4318. rm -f "${base}"*;
  4319. if [[ ${out} == *"GNU gold"* ]]; then
  4320. return 0;
  4321. fi;
  4322. return 1
  4323. }
  4324. tc-ninja_magic_to_arch ()
  4325. {
  4326. function ninj ()
  4327. {
  4328. [[ ${type} == "kern" ]] && echo $1 || echo $2
  4329. };
  4330. local type=$1;
  4331. local host=$2;
  4332. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4333. case ${host} in
  4334. aarch64*)
  4335. echo arm64
  4336. ;;
  4337. alpha*)
  4338. echo alpha
  4339. ;;
  4340. arm*)
  4341. echo arm
  4342. ;;
  4343. avr*)
  4344. ninj avr32 avr
  4345. ;;
  4346. bfin*)
  4347. ninj blackfin bfin
  4348. ;;
  4349. c6x*)
  4350. echo c6x
  4351. ;;
  4352. cris*)
  4353. echo cris
  4354. ;;
  4355. frv*)
  4356. echo frv
  4357. ;;
  4358. hexagon*)
  4359. echo hexagon
  4360. ;;
  4361. hppa*)
  4362. ninj parisc hppa
  4363. ;;
  4364. i?86*)
  4365. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  4366. echo i386;
  4367. else
  4368. echo x86;
  4369. fi
  4370. ;;
  4371. ia64*)
  4372. echo ia64
  4373. ;;
  4374. m68*)
  4375. echo m68k
  4376. ;;
  4377. metag*)
  4378. echo metag
  4379. ;;
  4380. microblaze*)
  4381. echo microblaze
  4382. ;;
  4383. mips*)
  4384. echo mips
  4385. ;;
  4386. nios2*)
  4387. echo nios2
  4388. ;;
  4389. nios*)
  4390. echo nios
  4391. ;;
  4392. or1k | or32*)
  4393. echo openrisc
  4394. ;;
  4395. powerpc*)
  4396. if [[ ${type} == "kern" ]]; then
  4397. echo powerpc;
  4398. else
  4399. if [[ ${host} == powerpc64* ]]; then
  4400. echo ppc64;
  4401. else
  4402. echo ppc;
  4403. fi;
  4404. fi
  4405. ;;
  4406. riscv*)
  4407. echo riscv
  4408. ;;
  4409. s390*)
  4410. echo s390
  4411. ;;
  4412. score*)
  4413. echo score
  4414. ;;
  4415. sh64*)
  4416. ninj sh64 sh
  4417. ;;
  4418. sh*)
  4419. echo sh
  4420. ;;
  4421. sparc64*)
  4422. ninj sparc64 sparc
  4423. ;;
  4424. sparc*)
  4425. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  4426. ;;
  4427. tile*)
  4428. echo tile
  4429. ;;
  4430. vax*)
  4431. echo vax
  4432. ;;
  4433. x86_64*freebsd*)
  4434. echo amd64
  4435. ;;
  4436. x86_64*)
  4437. if [[ ${type} == "kern" ]]; then
  4438. echo x86;
  4439. else
  4440. echo amd64;
  4441. fi
  4442. ;;
  4443. xtensa*)
  4444. echo xtensa
  4445. ;;
  4446. *)
  4447. echo unknown
  4448. ;;
  4449. esac
  4450. }
  4451. tc-stack-grows-down ()
  4452. {
  4453. case ${ARCH} in
  4454. hppa | metag)
  4455. return 1
  4456. ;;
  4457. esac;
  4458. return 0
  4459. }
  4460. tc-tuple-is-softfloat ()
  4461. {
  4462. local CTARGET=${CTARGET:-${CHOST}};
  4463. case ${CTARGET//_/-} in
  4464. bfin* | h8300*)
  4465. echo "only"
  4466. ;;
  4467. *-softfloat-*)
  4468. echo "yes"
  4469. ;;
  4470. *-softfp-*)
  4471. echo "softfp"
  4472. ;;
  4473. arm*-hardfloat-* | arm*eabihf)
  4474. echo "no"
  4475. ;;
  4476. *-newlib | *-elf | *-eabi)
  4477. echo "no"
  4478. ;;
  4479. arm*)
  4480. echo "yes"
  4481. ;;
  4482. *)
  4483. echo "no"
  4484. ;;
  4485. esac
  4486. }
  4487. test-flag-CC ()
  4488. {
  4489. test-flag-PROG "CC" c "$@"
  4490. }
  4491. test-flag-CXX ()
  4492. {
  4493. test-flag-PROG "CXX" c++ "$@"
  4494. }
  4495. test-flag-F77 ()
  4496. {
  4497. test-flag-PROG "F77" f77 "$@"
  4498. }
  4499. test-flag-FC ()
  4500. {
  4501. test-flag-PROG "FC" f95 "$@"
  4502. }
  4503. test-flag-PROG ()
  4504. {
  4505. local comp=$1;
  4506. local lang=$2;
  4507. shift 2;
  4508. [[ -z ${comp} || -z $1 ]] && return 1;
  4509. local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  4510. if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  4511. cmdline+=("$@" -x${lang} -);
  4512. else
  4513. cmdline+=("$@" -c -o /dev/null /dev/null);
  4514. fi;
  4515. if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  4516. cmdline+=(-Qunused-arguments);
  4517. "${cmdline[@]}" < /dev/null &> /dev/null;
  4518. fi
  4519. }
  4520. test-flags ()
  4521. {
  4522. test-flags-CC "$@"
  4523. }
  4524. test-flags-CC ()
  4525. {
  4526. test-flags-PROG "CC" "$@"
  4527. }
  4528. test-flags-CXX ()
  4529. {
  4530. test-flags-PROG "CXX" "$@"
  4531. }
  4532. test-flags-F77 ()
  4533. {
  4534. test-flags-PROG "F77" "$@"
  4535. }
  4536. test-flags-FC ()
  4537. {
  4538. test-flags-PROG "FC" "$@"
  4539. }
  4540. test-flags-PROG ()
  4541. {
  4542. local comp=$1;
  4543. local flags=();
  4544. local x;
  4545. shift;
  4546. [[ -z ${comp} ]] && return 1;
  4547. while (( $# )); do
  4548. case "$1" in
  4549. --param)
  4550. if test-flag-${comp} "$1" "$2"; then
  4551. flags+=("$1" "$2");
  4552. fi;
  4553. shift 2
  4554. ;;
  4555. *)
  4556. if test-flag-${comp} "$1"; then
  4557. flags+=("$1");
  4558. fi;
  4559. shift 1
  4560. ;;
  4561. esac;
  4562. done;
  4563. echo "${flags[*]}";
  4564. [[ ${#flags[@]} -gt 0 ]]
  4565. }
  4566. test_version_info ()
  4567. {
  4568. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  4569. return 0;
  4570. else
  4571. return 1;
  4572. fi
  4573. }
  4574. uclibctoolize ()
  4575. {
  4576. die "Use elibtoolize"
  4577. }
  4578. use_if_iuse ()
  4579. {
  4580. in_iuse $1 || return 1;
  4581. use $1
  4582. }
RAW Paste Data