spacepaste

  1.  
  2. declare -x ABI="arm"
  3. declare -x ABI_MIPS=""
  4. declare -x ABI_PPC=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86=""
  7. declare -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="arm"
  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. >=sys-devel/libtool-2.4"
  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 BUILD_CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
  22. declare -x BUILD_CPPFLAGS=""
  23. declare -x BUILD_CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
  24. declare -x BUILD_LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  25. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  26. declare -x CALLIGRA_FEATURES=""
  27. declare -x CAMERAS=""
  28. declare -x CBUILD="x86_64-pc-linux-gnu"
  29. declare -x CFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv6j -mfpu=vfp -mfloat-abi=hard"
  30. declare -x CFLAGS_default
  31. declare -x CHOST="armv6j-unknown-linux-gnueabihf"
  32. declare -x CHOST_arm="armv6j-unknown-linux-gnueabihf"
  33. declare -x CHOST_default="armv6j-unknown-linux-gnueabihf"
  34. declare -x COLLECTD_PLUGINS=""
  35. declare -x CONF_PREFIX="/usr"
  36. declare -x CPU_FLAGS_ARM=""
  37. declare -x CPU_FLAGS_X86=""
  38. declare -x CTARGET_default="armv6j-unknown-linux-gnueabihf"
  39. declare -x CURL_SSL=""
  40. declare -x CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv6j -mfpu=vfp -mfloat-abi=hard"
  41. declare -x DCC_EMAILLOG_WHOM_TO_BLAME=""
  42. declare -x DEFAULT_ABI="arm"
  43. declare -x DEFINED_PHASES=" compile configure install prepare test"
  44. declare DEPEND="
  45. readline? ( sys-libs/readline:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  46. >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3
  47. || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 )
  48. >=sys-devel/autoconf-2.69
  49. >=sys-devel/libtool-2.4"
  50. declare DESCRIPTION="Standard GNU database libraries"
  51. declare -x DESTTREE="/usr"
  52. declare -x DIROPTIONS="-m0755"
  53. declare -x EAPI="6"
  54. declare -x ELIBC="glibc"
  55. declare -x ENLIGHTENMENT_MODULES=""
  56. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  57. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  58. declare -- EPATCH_EXCLUDE=""
  59. declare -- EPATCH_FORCE="no"
  60. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  61. declare -- EPATCH_OPTS=""
  62. declare -- EPATCH_SINGLE_MSG=""
  63. declare -- EPATCH_SOURCE="/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/sys-libs/gdbm-1.18.1/work/patch"
  64. declare -- EPATCH_SUFFIX="patch.bz2"
  65. declare -x EXEOPTIONS="-m0755"
  66. declare -x FCFLAGS="-O2 -pipe -march=armv6j"
  67. 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}\""
  68. declare -x FFLAGS="-O2 -pipe -march=armv6j"
  69. declare -x FFTOOLS=""
  70. declare -x GCC_SPECS=""
  71. declare -x GPSD_PROTOCOLS=""
  72. declare -x GRUB_PLATFORMS=""
  73. declare HDEPEND=""
  74. declare HOMEPAGE="https://www.gnu.org/software/gdbm/"
  75. declare -x HOSTCC="x86_64-pc-linux-gnu-gcc"
  76. declare -x INHERITED=" toolchain-funcs multilib libtool autotools desktop epatch estack ltprune preserve-libs vcs-clean eutils flag-o-matic multibuild multilib-build multilib-minimal"
  77. declare -x INPUT_DEVICES=""
  78. declare -x INSDESTTREE=""
  79. declare -x INSOPTIONS="-m0644"
  80. declare IUSE="+berkdb nls +readline static-libs abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64"
  81. declare -x IUSE_EFFECTIVE="abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-fbsd amd64-linux arm arm64 berkdb elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mips nls ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest readline s390 sh sparc sparc-solaris sparc64-solaris static-libs userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  82. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  83. declare -x KERNEL="linux"
  84. declare -x KERNEL_ABI="arm"
  85. declare -x KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
  86. declare -x L10N=""
  87. declare -x LANG="en_US.utf8"
  88. declare -x LCD_DEVICES=""
  89. declare -x LC_ADDRESS="en_US.utf8"
  90. declare -x LC_COLLATE="C"
  91. declare -x LC_CTYPE="en_US.utf8"
  92. declare -x LC_IDENTIFICATION="en_US.utf8"
  93. declare -x LC_MEASUREMENT="en_US.utf8"
  94. declare -x LC_MESSAGES="en_US.utf8"
  95. declare -x LC_MONETARY="en_US.utf8"
  96. declare -x LC_NAME="en_US.utf8"
  97. declare -x LC_NUMERIC="en_US.utf8"
  98. declare -x LC_PAPER="en_US.utf8"
  99. declare -x LC_TELEPHONE="en_US.utf8"
  100. declare -x LC_TIME="en_US.utf8"
  101. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  102. declare -x LDFLAGS_default
  103. declare -x LIBDIR_arm="lib"
  104. declare -x LIBDIR_default="lib"
  105. declare -x LIBOPTIONS="-m0644"
  106. declare -x LIBREOFFICE_EXTENSIONS=""
  107. declare -x LICENSE="GPL-3"
  108. declare -x LIRC_DEVICES=""
  109. declare -x LLVM_TARGETS=""
  110. declare -x MAIL="/var/mail/necktwi"
  111. declare -x MAKEOPTS="-j5 -l4"
  112. declare -x MANPAGER="manpager"
  113. declare -x MONKEYD_PLUGINS=""
  114. declare -x MULTILIB_ABIS="arm"
  115. declare -- MULTILIB_USEDEP="abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?"
  116. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  117. declare -x NETBEANS_MODULES=""
  118. declare -x NGINX_MODULES_HTTP=""
  119. declare -x NGINX_MODULES_MAIL=""
  120. declare -x NGINX_MODULES_STREAM=""
  121. declare -x OFED_DRIVERS=""
  122. declare -x OFFICE_IMPLEMENTATION=""
  123. declare -x OPENGL_PROFILE="xorg-x11"
  124. declare -x OPENMPI_FABRICS=""
  125. declare -x OPENMPI_OFED_FEATURES=""
  126. declare -x OPENMPI_RM=""
  127. declare -x PATH="/usr/lib/ccache/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  128. declare PDEPEND=""
  129. declare -x PHP_TARGETS=""
  130. declare -x PKG_CONFIG_PATH="/usr/armv6j-unknown-linux-gnueabihf/usr/lib/pkgconfig/"
  131. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  132. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  133. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  134. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/gdbm-1.18.1/html")
  135. declare -a PORTAGE_DOSTRIP=([0]="/")
  136. declare -a PORTAGE_DOSTRIP_SKIP=()
  137. declare -x POSTGRES_TARGETS=""
  138. 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"
  139. declare -x PROPERTIES=""
  140. declare -x PYTHONDONTWRITEBYTECODE="1"
  141. declare -x PYTHON_SINGLE_TARGET=""
  142. declare -x PYTHON_TARGETS=""
  143. declare -x QEMU_SOFTMMU_TARGETS=""
  144. declare -x QEMU_USER_TARGETS=""
  145. declare RDEPEND="
  146. readline? ( sys-libs/readline:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )
  147. "
  148. declare REPOSITORY
  149. declare REQUIRED_USE=""
  150. declare -x RESTRICT=""
  151. 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}\""
  152. declare -x ROS_MESSAGES=""
  153. declare -x RUBY_TARGETS=""
  154. declare -x S="/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/sys-libs/gdbm-1.18.1/work/gdbm-1.18.1"
  155. declare -x SANDBOX_DEBUG="0"
  156. declare -x SANDBOX_DENY=""
  157. declare -x SANDBOX_PREDICT="/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/sys-libs/gdbm-1.18.1/homedir"
  158. declare -x SANDBOX_READ="/:/usr/armv6j-unknown-linux-gnueabihf/tmp:/var/CCache"
  159. declare -x SANDBOX_VERBOSE="1"
  160. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/armv6j-unknown-linux-gnueabihf/tmp:/usr/armv6j-unknown-linux-gnueabihf/tmp/portage/sys-libs/gdbm-1.18.1/homedir/.bash_history:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/CCache:/var/tmp/"
  161. declare -x SANE_BACKENDS=""
  162. declare -x SHELL="/bin/bash"
  163. declare -x SLOT="0/6"
  164. declare SRC_URI="mirror://gnu/gdbm/gdbm-1.18.1.tar.gz"
  165. declare -x SSH_CLIENT="192.168.19.1 53444 22"
  166. declare -x SSH_CONNECTION="192.168.19.1 53444 192.168.19.128 22"
  167. declare -x SSH_TTY="/dev/pts/0"
  168. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  169. declare -x UNCACHED_ERR_FD=""
  170. declare -x USE="arm berkdb elibc_glibc kernel_linux nls readline userland_GNU"
  171. declare -x USERLAND="GNU"
  172. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  173. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  174. 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"
  175. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  176. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  177. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  178. declare -x UWSGI_PLUGINS=""
  179. declare -x VIDEO_CARDS=""
  180. declare -x VISUAL="emacs"
  181. declare -x VOICEMAIL_STORAGE=""
  182. declare -x WANT_AUTOCONF="2.5"
  183. declare -x WANT_AUTOMAKE="1.16"
  184. declare -x WANT_LIBTOOL="latest"
  185. declare -x XFCE_PLUGINS=""
  186. declare -x XTABLES_ADDONS=""
  187. declare -- _AUTOTOOLS_ECLASS="1"
  188. declare -- _DESKTOP_ECLASS="1"
  189. declare -- _EPATCH_ECLASS="1"
  190. declare -- _ESTACK_ECLASS="1"
  191. declare -- _EUTILS_ECLASS="1"
  192. declare -x _E_DOCDESTTREE_=""
  193. declare -x _E_EXEDESTTREE_=""
  194. declare -- _FLAG_O_MATIC_ECLASS="1"
  195. declare -a _LATEST_AUTOMAKE=([0]="1.16.1:1.16" [1]="1.15.1:1.15")
  196. declare -- _LIBTOOL_ECLASS="1"
  197. declare -- _LTPRUNE_ECLASS="1"
  198. declare -- _MULTIBUILD="1"
  199. declare -- _MULTILIB_BUILD="1"
  200. declare -- _MULTILIB_ECLASS="1"
  201. declare -a _MULTILIB_FLAGS=([0]="abi_x86_32:x86,x86_fbsd,x86_freebsd,x86_linux,x86_macos,x86_solaris" [1]="abi_x86_64:amd64,amd64_fbsd,x64_freebsd,amd64_linux,x64_macos,x64_solaris" [2]="abi_x86_x32:x32" [3]="abi_mips_n32:n32" [4]="abi_mips_n64:n64" [5]="abi_mips_o32:o32" [6]="abi_ppc_32:ppc,ppc_aix,ppc_macos" [7]="abi_ppc_64:ppc64" [8]="abi_s390_32:s390" [9]="abi_s390_64:s390x")
  202. declare -- _PRESERVE_LIBS_ECLASS="1"
  203. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  204. declare -- __AUTOTOOLS_AUTO_DEPEND="yes"
  205. declare -- _libtool_atom=">=sys-devel/libtool-2.4"
  206. declare -x ac_cv_lib_dbm_main="no"
  207. declare -x ac_cv_lib_ndbm_main="no"
  208. declare -- phase_func
  209. __eapi6_src_install ()
  210. {
  211. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  212. emake DESTDIR="${D}" install;
  213. fi;
  214. einstalldocs
  215. }
  216. __eapi6_src_prepare ()
  217. {
  218. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  219. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  220. else
  221. if [[ -n ${PATCHES} ]]; then
  222. eapply ${PATCHES};
  223. fi;
  224. fi;
  225. eapply_user
  226. }
  227. _at_uses_autoheader ()
  228. {
  229. _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  230. }
  231. _at_uses_automake ()
  232. {
  233. _at_uses_pkg AM_INIT_AUTOMAKE
  234. }
  235. _at_uses_gettext ()
  236. {
  237. _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  238. }
  239. _at_uses_glibgettext ()
  240. {
  241. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  242. }
  243. _at_uses_gnomedoc ()
  244. {
  245. _at_uses_pkg GNOME_DOC_INIT
  246. }
  247. _at_uses_gtkdoc ()
  248. {
  249. _at_uses_pkg GTK_DOC_CHECK
  250. }
  251. _at_uses_intltool ()
  252. {
  253. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  254. }
  255. _at_uses_libltdl ()
  256. {
  257. _at_uses_pkg LT_CONFIG_LTDL_DIR
  258. }
  259. _at_uses_libtool ()
  260. {
  261. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  262. }
  263. _at_uses_pkg ()
  264. {
  265. if [[ -n $(autotools_check_macro "$@") ]]; then
  266. return 0;
  267. else
  268. local macro args=();
  269. for macro in "$@";
  270. do
  271. args+=(-e "^[[:space:]]*${macro}\>");
  272. done;
  273. egrep -q "${args[@]}" configure.??;
  274. fi
  275. }
  276. _automake_version ()
  277. {
  278. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  279. }
  280. _autotools_m4dir_include ()
  281. {
  282. local x include_opts flag;
  283. [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  284. for x in "$@";
  285. do
  286. case ${x} in
  287. -${flag})
  288. ;;
  289. *)
  290. [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  291. include_opts+=" -${flag} ${x}"
  292. ;;
  293. esac;
  294. done;
  295. echo ${include_opts}
  296. }
  297. _clang_fullversion ()
  298. {
  299. local ver="$1";
  300. shift;
  301. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  302. eval echo "$ver"
  303. }
  304. _elibtoolize ()
  305. {
  306. local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  307. if [[ $1 == "--auto-ltdl" ]]; then
  308. shift;
  309. _at_uses_libltdl && set -- "$@" --ltdl;
  310. fi;
  311. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  312. autotools_run_tool ${LIBTOOLIZE} "$@"
  313. }
  314. _filter-hardened ()
  315. {
  316. local f;
  317. for f in "$@";
  318. do
  319. case "${f}" in
  320. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  321. gcc-specs-pie || continue;
  322. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  323. if test-flags -nopie > /dev/null; then
  324. append-flags -nopie;
  325. else
  326. append-flags -no-pie;
  327. fi;
  328. fi
  329. ;;
  330. -fstack-protector)
  331. gcc-specs-ssp || continue;
  332. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  333. ;;
  334. -fstack-protector-all)
  335. gcc-specs-ssp-to-all || continue;
  336. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  337. ;;
  338. -fno-strict-overflow)
  339. gcc-specs-nostrict || continue;
  340. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  341. ;;
  342. esac;
  343. done
  344. }
  345. _filter-var ()
  346. {
  347. local f x var=$1 new=();
  348. shift;
  349. for f in ${!var};
  350. do
  351. for x in "$@";
  352. do
  353. [[ ${f} == ${x} ]] && continue 2;
  354. done;
  355. new+=("${f}");
  356. done;
  357. export ${var}="${new[*]}"
  358. }
  359. _gcc-install-dir ()
  360. {
  361. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  362. }
  363. _gcc-specs-directive_raw ()
  364. {
  365. local cc=$(tc-getCC);
  366. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  367. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  368. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  369. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  370. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  371. { spec=spec $0 }
  372. END { print spec }';
  373. return 0
  374. }
  375. _gcc-specs-exists ()
  376. {
  377. [[ -f $(_gcc-install-dir)/$1 ]]
  378. }
  379. _gcc_fullversion ()
  380. {
  381. local ver="$1";
  382. shift;
  383. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  384. eval echo "$ver"
  385. }
  386. _iconins ()
  387. {
  388. ( insopts -m 0644;
  389. local funcname=$1;
  390. shift;
  391. local size dir;
  392. local context=apps;
  393. local theme=hicolor;
  394. while [[ $# -gt 0 ]]; do
  395. case $1 in
  396. -s | --size)
  397. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  398. size=${2%%x*};
  399. else
  400. size=${2};
  401. fi;
  402. case ${size} in
  403. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  404. size=${size}x${size}
  405. ;;
  406. scalable)
  407. ;;
  408. *)
  409. eerror "${size} is an unsupported icon size!";
  410. exit 1
  411. ;;
  412. esac;
  413. shift 2
  414. ;;
  415. -t | --theme)
  416. theme=${2};
  417. shift 2
  418. ;;
  419. -c | --context)
  420. context=${2};
  421. shift 2
  422. ;;
  423. *)
  424. if [[ -z ${size} ]]; then
  425. insinto /usr/share/pixmaps;
  426. else
  427. insinto /usr/share/icons/${theme}/${size}/${context};
  428. fi;
  429. if [[ ${funcname} == doicon ]]; then
  430. if [[ -f $1 ]]; then
  431. doins "${1}";
  432. else
  433. if [[ -d $1 ]]; then
  434. shopt -s nullglob;
  435. doins "${1}"/*.{png,svg};
  436. shopt -u nullglob;
  437. else
  438. eerror "${1} is not a valid file/directory!";
  439. exit 1;
  440. fi;
  441. fi;
  442. else
  443. break;
  444. fi;
  445. shift 1
  446. ;;
  447. esac;
  448. done;
  449. if [[ ${funcname} == newicon ]]; then
  450. newins "$@";
  451. fi ) || die
  452. }
  453. _is_flagq ()
  454. {
  455. local x var="$1[*]";
  456. for x in ${!var};
  457. do
  458. [[ ${x} == $2 ]] && return 0;
  459. done;
  460. return 1
  461. }
  462. _multibuild_run ()
  463. {
  464. local i=1;
  465. while [[ ${!i} == _* ]]; do
  466. (( i += 1 ));
  467. done;
  468. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  469. "${@}"
  470. }
  471. _multilib_multibuild_wrapper ()
  472. {
  473. debug-print-function ${FUNCNAME} "${@}";
  474. local ABI=${MULTIBUILD_VARIANT#*.};
  475. local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  476. multilib_toolchain_setup "${ABI}";
  477. readonly ABI;
  478. "${@}"
  479. }
  480. _tc-getPROG ()
  481. {
  482. local tuple=$1;
  483. local v var vars=$2;
  484. local prog=($3);
  485. var=${vars%% *};
  486. for v in ${vars};
  487. do
  488. if [[ -n ${!v} ]]; then
  489. export ${var}="${!v}";
  490. echo "${!v}";
  491. return 0;
  492. fi;
  493. done;
  494. local search=;
  495. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  496. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  497. [[ -n ${search} ]] && prog[0]=${search##*/};
  498. export ${var}="${prog[*]}";
  499. echo "${!var}"
  500. }
  501. all-flag-vars ()
  502. {
  503. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  504. }
  505. append-cflags ()
  506. {
  507. [[ $# -eq 0 ]] && return 0;
  508. export CFLAGS+=" $*";
  509. return 0
  510. }
  511. append-cppflags ()
  512. {
  513. [[ $# -eq 0 ]] && return 0;
  514. export CPPFLAGS+=" $*";
  515. return 0
  516. }
  517. append-cxxflags ()
  518. {
  519. [[ $# -eq 0 ]] && return 0;
  520. export CXXFLAGS+=" $*";
  521. return 0
  522. }
  523. append-fflags ()
  524. {
  525. [[ $# -eq 0 ]] && return 0;
  526. export FFLAGS+=" $*";
  527. export FCFLAGS+=" $*";
  528. return 0
  529. }
  530. append-flags ()
  531. {
  532. [[ $# -eq 0 ]] && return 0;
  533. case " $* " in
  534. *' '-[DIU]*)
  535. eqawarn 'please use append-cppflags for preprocessor flags'
  536. ;;
  537. *' '-L* | *' '-Wl,*)
  538. eqawarn 'please use append-ldflags for linker flags'
  539. ;;
  540. esac;
  541. append-cflags "$@";
  542. append-cxxflags "$@";
  543. append-fflags "$@";
  544. return 0
  545. }
  546. append-ldflags ()
  547. {
  548. [[ $# -eq 0 ]] && return 0;
  549. local flag;
  550. for flag in "$@";
  551. do
  552. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  553. done;
  554. export LDFLAGS="${LDFLAGS} $*";
  555. return 0
  556. }
  557. append-lfs-flags ()
  558. {
  559. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  560. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  561. }
  562. append-libs ()
  563. {
  564. [[ $# -eq 0 ]] && return 0;
  565. local flag;
  566. for flag in "$@";
  567. do
  568. if [[ -z "${flag// }" ]]; then
  569. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  570. continue;
  571. fi;
  572. case $flag in
  573. -[lL]*)
  574. export LIBS="${LIBS} ${flag}"
  575. ;;
  576. -*)
  577. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  578. export LIBS="${LIBS} ${flag}"
  579. ;;
  580. *)
  581. export LIBS="${LIBS} -l${flag}"
  582. ;;
  583. esac;
  584. done;
  585. return 0
  586. }
  587. autotools_check_macro ()
  588. {
  589. [[ -f configure.ac || -f configure.in ]] || return 0;
  590. local trace_file=".__autoconf_trace_data";
  591. if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  592. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  593. fi;
  594. local macro args=();
  595. for macro in "$@";
  596. do
  597. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  598. args+=(-e ":${macro}:");
  599. done;
  600. grep "${args[@]}" ${trace_file}
  601. }
  602. autotools_check_macro_val ()
  603. {
  604. local macro scan_out;
  605. for macro in "$@";
  606. do
  607. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  608. if (match($0, macro ":(.*)$", res))
  609. print res[1]
  610. }' | uniq;
  611. done;
  612. return 0
  613. }
  614. autotools_env_setup ()
  615. {
  616. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  617. local pv;
  618. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  619. do
  620. local hv_args="";
  621. case ${EAPI:-0} in
  622. 5 | 6)
  623. hv_args="--host-root"
  624. ;;
  625. 7)
  626. hv_args="-b"
  627. ;;
  628. esac;
  629. ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break;
  630. done;
  631. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  632. fi;
  633. [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  634. }
  635. autotools_m4dir_include ()
  636. {
  637. _autotools_m4dir_include ${AT_M4DIR}
  638. }
  639. autotools_m4sysdir_include ()
  640. {
  641. local paths=($(eval echo ${AT_SYS_M4DIR}));
  642. if [[ ${#paths[@]} -eq 0 && -n ${SYSROOT} ]]; then
  643. local path="${SYSROOT}/usr/share/aclocal";
  644. [[ -d ${path} ]] && paths+=("${path}");
  645. fi;
  646. _autotools_m4dir_include "${paths[@]}"
  647. }
  648. autotools_run_tool ()
  649. {
  650. local autofail=true m4flags=false missing_ok=false return_output=false;
  651. while [[ -n $1 ]]; do
  652. case $1 in
  653. --at-no-fail)
  654. autofail=false
  655. ;;
  656. --at-m4flags)
  657. m4flags=true
  658. ;;
  659. --at-missing)
  660. missing_ok=true
  661. ;;
  662. --at-output)
  663. return_output=true
  664. ;;
  665. *)
  666. break
  667. ;;
  668. esac;
  669. shift;
  670. done;
  671. if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  672. ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  673. fi;
  674. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  675. einfo "Skipping '$*' due $1 not installed";
  676. return 0;
  677. fi;
  678. autotools_env_setup;
  679. local STDERR_TARGET="${T}/${1##*/}.out";
  680. if [[ -e ${STDERR_TARGET} ]]; then
  681. local i=1;
  682. while :; do
  683. STDERR_TARGET="${T}/${1##*/}-${i}.out";
  684. [[ -e ${STDERR_TARGET} ]] || break;
  685. : $(( i++ ));
  686. done;
  687. fi;
  688. if ${m4flags}; then
  689. set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  690. fi;
  691. if ${return_output}; then
  692. "$@";
  693. return;
  694. fi;
  695. printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  696. ebegin "Running $@";
  697. "$@" >> "${STDERR_TARGET}" 2>&1;
  698. if ! eend $? && ${autofail}; then
  699. echo;
  700. eerror "Failed Running $1 !";
  701. eerror;
  702. eerror "Include in your bugreport the contents of:";
  703. eerror;
  704. eerror " ${STDERR_TARGET}";
  705. echo;
  706. die "Failed Running $1 !";
  707. fi
  708. }
  709. clang-fullversion ()
  710. {
  711. _clang_fullversion '$1.$2.$3' "$@"
  712. }
  713. clang-major-version ()
  714. {
  715. _clang_fullversion '$1' "$@"
  716. }
  717. clang-micro-version ()
  718. {
  719. _clang_fullversion '$3' "$@"
  720. }
  721. clang-minor-version ()
  722. {
  723. _clang_fullversion '$2' "$@"
  724. }
  725. clang-version ()
  726. {
  727. _clang_fullversion '$1.$2' "$@"
  728. }
  729. config_rpath_update ()
  730. {
  731. local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  732. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  733. [[ $# -eq 0 ]] && return 0;
  734. einfo "Updating all config.rpath files";
  735. for dst in "$@";
  736. do
  737. einfo " ${dst}";
  738. cp "${src}" "${dst}" || die;
  739. done
  740. }
  741. darwintoolize ()
  742. {
  743. die "Use elibtoolize"
  744. }
  745. doicon ()
  746. {
  747. _iconins ${FUNCNAME} "$@"
  748. }
  749. domenu ()
  750. {
  751. ( local i ret=0;
  752. insopts -m 0644;
  753. insinto /usr/share/applications;
  754. for i in "$@";
  755. do
  756. if [[ -d ${i} ]]; then
  757. doins "${i}"/*.desktop;
  758. ((ret|=$?));
  759. else
  760. doins "${i}";
  761. ((ret|=$?));
  762. fi;
  763. done;
  764. exit ${ret} )
  765. }
  766. eaclocal ()
  767. {
  768. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  769. }
  770. eaclocal_amflags ()
  771. {
  772. local aclocal_opts amflags_file;
  773. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  774. do
  775. [[ -e ${amflags_file} ]] || continue;
  776. autotools_env_setup;
  777. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  778. s:[^=]*=::p; # then gobble up all escaped lines
  779. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  780. eval aclocal_opts=\""${aclocal_opts}"\";
  781. break;
  782. done;
  783. echo ${aclocal_opts}
  784. }
  785. eapply ()
  786. {
  787. local failed patch_cmd=patch;
  788. local -x LC_COLLATE=POSIX;
  789. type -P gpatch > /dev/null && patch_cmd=gpatch;
  790. function _eapply_patch ()
  791. {
  792. local f=${1};
  793. local prefix=${2};
  794. started_applying=1;
  795. ebegin "${prefix:-Applying }${f##*/}";
  796. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  797. failed=${?};
  798. if ! eend "${failed}"; then
  799. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  800. fi
  801. };
  802. local patch_options=() files=();
  803. local i found_doublehyphen;
  804. for ((i = 1; i <= ${#@}; ++i ))
  805. do
  806. if [[ ${@:i:1} == -- ]]; then
  807. patch_options=("${@:1:i-1}");
  808. files=("${@:i+1}");
  809. found_doublehyphen=1;
  810. break;
  811. fi;
  812. done;
  813. if [[ -z ${found_doublehyphen} ]]; then
  814. for ((i = 1; i <= ${#@}; ++i ))
  815. do
  816. if [[ ${@:i:1} != -* ]]; then
  817. patch_options=("${@:1:i-1}");
  818. files=("${@:i}");
  819. break;
  820. fi;
  821. done;
  822. for i in "${files[@]}";
  823. do
  824. if [[ ${i} == -* ]]; then
  825. die "eapply: all options must be passed before non-options";
  826. fi;
  827. done;
  828. fi;
  829. if [[ ${#files[@]} -eq 0 ]]; then
  830. die "eapply: no files specified";
  831. fi;
  832. local f;
  833. for f in "${files[@]}";
  834. do
  835. if [[ -d ${f} ]]; then
  836. function _eapply_get_files ()
  837. {
  838. local LC_ALL=POSIX;
  839. local prev_shopt=$(shopt -p nullglob);
  840. shopt -s nullglob;
  841. local f;
  842. for f in "${1}"/*;
  843. do
  844. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  845. files+=("${f}");
  846. fi;
  847. done;
  848. ${prev_shopt}
  849. };
  850. local files=();
  851. _eapply_get_files "${f}";
  852. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  853. einfo "Applying patches from ${f} ...";
  854. local f2;
  855. for f2 in "${files[@]}";
  856. do
  857. _eapply_patch "${f2}" ' ';
  858. [[ ${failed} -ne 0 ]] && return "${failed}";
  859. done;
  860. else
  861. _eapply_patch "${f}";
  862. [[ ${failed} -ne 0 ]] && return "${failed}";
  863. fi;
  864. done;
  865. return 0
  866. }
  867. eapply_user ()
  868. {
  869. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  870. local tagfile=${T}/.portage_user_patches_applied;
  871. [[ -f ${tagfile} ]] && return;
  872. >> "${tagfile}";
  873. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  874. local applied d f;
  875. local -A _eapply_user_patches;
  876. local prev_shopt=$(shopt -p nullglob);
  877. shopt -s nullglob;
  878. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  879. do
  880. for f in "${d}"/*;
  881. do
  882. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  883. _eapply_user_patches[${f##*/}]=${f};
  884. fi;
  885. done;
  886. done;
  887. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  888. while read -r -d '' f; do
  889. f=${_eapply_user_patches[${f}]};
  890. if [[ -s ${f} ]]; then
  891. eapply "${f}";
  892. applied=1;
  893. fi;
  894. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  895. LC_ALL=C sort -z);
  896. fi;
  897. ${prev_shopt};
  898. [[ -n ${applied} ]] && ewarn "User patches applied."
  899. }
  900. eautoconf ()
  901. {
  902. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  903. echo;
  904. eerror "No configure.{ac,in} present in '${PWD}'!";
  905. echo;
  906. die "No configure.{ac,in} present!";
  907. fi;
  908. if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  909. eqawarn "This package has a configure.in file which has long been deprecated. Please";
  910. eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  911. eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details.";
  912. fi;
  913. autotools_run_tool --at-m4flags autoconf "$@"
  914. }
  915. eautoheader ()
  916. {
  917. _at_uses_autoheader || return 0;
  918. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  919. }
  920. eautomake ()
  921. {
  922. local extra_opts=();
  923. local makefile_name;
  924. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  925. do
  926. [[ -f ${makefile_name} ]] && break;
  927. done;
  928. function _automake_version ()
  929. {
  930. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  931. };
  932. if [[ -z ${makefile_name} ]]; then
  933. _at_uses_automake || return 0;
  934. else
  935. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  936. local used_automake;
  937. local installed_automake;
  938. installed_automake=$(WANT_AUTOMAKE= _automake_version);
  939. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  940. if [[ ${installed_automake} != ${used_automake} ]]; then
  941. ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  942. ewarn "Forcing a full rebuild of the autotools to workaround.";
  943. eautoreconf;
  944. return 0;
  945. fi;
  946. fi;
  947. fi;
  948. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  949. case $(_automake_version) in
  950. 1.4 | 1.4[.-]*)
  951. ;;
  952. *)
  953. extra_opts+=(--force-missing)
  954. ;;
  955. esac;
  956. autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  957. }
  958. eautopoint ()
  959. {
  960. autotools_run_tool autopoint "$@"
  961. }
  962. eautoreconf ()
  963. {
  964. local x g;
  965. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  966. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  967. do
  968. if [[ -d ${x} ]]; then
  969. pushd "${x}" > /dev/null;
  970. AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  971. popd > /dev/null;
  972. fi;
  973. done;
  974. fi;
  975. einfo "Running eautoreconf in '${PWD}' ...";
  976. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  977. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  978. 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");
  979. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  980. do
  981. if _at_uses_${tools[i]}; then
  982. tools[i+1]=true;
  983. ${tools[i+2]};
  984. fi;
  985. done;
  986. local rerun_aclocal=false;
  987. eaclocal;
  988. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  989. do
  990. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  991. ${tools[i+2]};
  992. rerun_aclocal=true;
  993. fi;
  994. done;
  995. ${rerun_aclocal} && eaclocal;
  996. if [[ ${WANT_AUTOCONF} = 2.1 ]]; then
  997. eautoconf;
  998. else
  999. eautoconf --force;
  1000. fi;
  1001. eautoheader;
  1002. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  1003. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  1004. elibtoolize --force "${PWD}";
  1005. fi;
  1006. return 0
  1007. }
  1008. ebeep ()
  1009. {
  1010. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1011. }
  1012. econf_build ()
  1013. {
  1014. local CBUILD=${CBUILD:-${CHOST}};
  1015. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1016. }
  1017. ecvs_clean ()
  1018. {
  1019. [[ $# -eq 0 ]] && set -- .;
  1020. find "$@" '(' -type d -name 'CVS' -prune -o -type f -name '.cvs*' ')' -exec rm -rf '{}' +
  1021. }
  1022. edos2unix ()
  1023. {
  1024. [[ $# -eq 0 ]] && return 0;
  1025. sed -i 's/\r$//' -- "$@" || die
  1026. }
  1027. egit_clean ()
  1028. {
  1029. [[ $# -eq 0 ]] && set -- .;
  1030. find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' +
  1031. }
  1032. einstalldocs ()
  1033. {
  1034. ( if ! declare -p DOCS &> /dev/null; then
  1035. local d;
  1036. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1037. do
  1038. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1039. done;
  1040. else
  1041. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1042. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1043. else
  1044. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1045. fi;
  1046. fi );
  1047. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1048. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1049. else
  1050. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1051. fi )
  1052. }
  1053. elibtoolize ()
  1054. {
  1055. type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  1056. ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  1057. }
  1058. emktemp ()
  1059. {
  1060. local exe="touch";
  1061. [[ $1 == -d ]] && exe="mkdir" && shift;
  1062. local topdir=$1;
  1063. if [[ -z ${topdir} ]]; then
  1064. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1065. fi;
  1066. if ! type -P mktemp > /dev/null; then
  1067. local tmp=/;
  1068. while [[ -e ${tmp} ]]; do
  1069. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1070. done;
  1071. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1072. echo "${tmp}";
  1073. else
  1074. if [[ ${exe} == "touch" ]]; then
  1075. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1076. else
  1077. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1078. fi;
  1079. fi
  1080. }
  1081. epatch ()
  1082. {
  1083. function _epatch_draw_line ()
  1084. {
  1085. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1086. echo "${1//?/=}"
  1087. };
  1088. unset P4CONFIG P4PORT P4USER;
  1089. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1090. while [[ $# -gt 0 ]]; do
  1091. case $1 in
  1092. -*)
  1093. EPATCH_OPTS+=("$1")
  1094. ;;
  1095. *)
  1096. break
  1097. ;;
  1098. esac;
  1099. shift;
  1100. done;
  1101. if [[ $# -gt 1 ]]; then
  1102. local m;
  1103. for m in "$@";
  1104. do
  1105. epatch "${m}";
  1106. done;
  1107. return 0;
  1108. fi;
  1109. local SINGLE_PATCH="no";
  1110. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1111. if [[ -f $1 ]]; then
  1112. SINGLE_PATCH="yes";
  1113. set -- "$1";
  1114. local EPATCH_SUFFIX=$1;
  1115. else
  1116. if [[ -d $1 ]]; then
  1117. evar_push_set LC_COLLATE C;
  1118. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1119. evar_pop;
  1120. else
  1121. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1122. epatch "${EPATCH_SOURCE}/$1";
  1123. return $?;
  1124. else
  1125. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1126. echo;
  1127. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1128. eerror;
  1129. eerror " ${EPATCH_SOURCE}";
  1130. eerror " ( ${EPATCH_SOURCE##*/} )";
  1131. echo;
  1132. die "Cannot find \$EPATCH_SOURCE!";
  1133. fi;
  1134. fi;
  1135. fi;
  1136. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1137. local PIPE_CMD;
  1138. case ${EPATCH_SUFFIX##*\.} in
  1139. xz)
  1140. PIPE_CMD="xz -dc"
  1141. ;;
  1142. lzma)
  1143. PIPE_CMD="lzma -dc"
  1144. ;;
  1145. bz2)
  1146. PIPE_CMD="bzip2 -dc"
  1147. ;;
  1148. gz | Z | z)
  1149. PIPE_CMD="gzip -dc"
  1150. ;;
  1151. ZIP | zip)
  1152. PIPE_CMD="unzip -p"
  1153. ;;
  1154. *)
  1155. ;;
  1156. esac;
  1157. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1158. local x;
  1159. for x in "$@";
  1160. do
  1161. [[ ! -f ${x} ]] && continue;
  1162. local patchname=${x##*/};
  1163. local a=${patchname#*_};
  1164. a=${a%%_*};
  1165. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1166. continue;
  1167. fi;
  1168. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  1169. local prev_noglob=$(shopt -p -o noglob);
  1170. set -o noglob;
  1171. local ex;
  1172. for ex in ${EPATCH_EXCLUDE};
  1173. do
  1174. if [[ ${patchname} == ${ex} ]]; then
  1175. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  1176. ${prev_noglob};
  1177. continue 2;
  1178. fi;
  1179. done;
  1180. for ex in ${EPATCH_USER_EXCLUDE};
  1181. do
  1182. if [[ ${patchname} == ${ex} ]]; then
  1183. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  1184. ${prev_noglob};
  1185. continue 2;
  1186. fi;
  1187. done;
  1188. ${prev_noglob};
  1189. fi;
  1190. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1191. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1192. einfo "${EPATCH_SINGLE_MSG}";
  1193. else
  1194. einfo "Applying ${patchname} ...";
  1195. fi;
  1196. else
  1197. einfo " ${patchname} ...";
  1198. fi;
  1199. local patch="patch";
  1200. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  1201. local STDERR_TARGET="${T}/${patchname}.out";
  1202. if [[ -e ${STDERR_TARGET} ]]; then
  1203. STDERR_TARGET="${T}/${patchname}-$$.out";
  1204. fi;
  1205. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  1206. local count=0;
  1207. local PATCH_TARGET;
  1208. if [[ -n ${PIPE_CMD} ]]; then
  1209. PATCH_TARGET="${T}/$$.patch";
  1210. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1211. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1212. echo;
  1213. eerror "Could not extract patch!";
  1214. count=5;
  1215. break;
  1216. fi;
  1217. else
  1218. PATCH_TARGET=${x};
  1219. fi;
  1220. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1221. if [[ -n ${abs_paths} ]]; then
  1222. count=1;
  1223. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1224. fi;
  1225. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1226. if [[ -n ${rel_paths} ]]; then
  1227. echo;
  1228. eerror "Rejected Patch: ${patchname} !";
  1229. eerror " ( ${PATCH_TARGET} )";
  1230. eerror;
  1231. eerror "Your patch uses relative paths '../':";
  1232. eerror "${rel_paths}";
  1233. echo;
  1234. die "you need to fix the relative paths in patch";
  1235. fi;
  1236. local patch_cmd;
  1237. while [[ ${count} -lt 5 ]]; do
  1238. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  1239. ( _epatch_draw_line "***** ${patchname} *****";
  1240. echo;
  1241. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  1242. echo;
  1243. _epatch_draw_line "***** ${patchname} *****";
  1244. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1245. ret=$?;
  1246. echo;
  1247. echo "patch program exited with status ${ret}";
  1248. exit ${ret} ) >> "${STDERR_TARGET}";
  1249. if [ $? -eq 0 ]; then
  1250. ( _epatch_draw_line "***** ${patchname} *****";
  1251. echo;
  1252. echo "ACTUALLY APPLYING ${patchname} ...";
  1253. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1254. echo;
  1255. _epatch_draw_line "***** ${patchname} *****";
  1256. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1257. ret=$?;
  1258. echo;
  1259. echo "patch program exited with status ${ret}";
  1260. exit ${ret} ) >> "${STDERR_TARGET}";
  1261. if [ $? -ne 0 ]; then
  1262. echo;
  1263. eerror "A dry-run of patch command succeeded, but actually";
  1264. eerror "applying the patch failed!";
  1265. count=5;
  1266. fi;
  1267. break;
  1268. fi;
  1269. : $(( count++ ));
  1270. done;
  1271. (( EPATCH_N_APPLIED_PATCHES++ ));
  1272. if [[ -n ${PIPE_CMD} ]]; then
  1273. rm -f "${PATCH_TARGET}";
  1274. fi;
  1275. if [[ ${count} -ge 5 ]]; then
  1276. echo;
  1277. eerror "Failed Patch: ${patchname} !";
  1278. eerror " ( ${PATCH_TARGET} )";
  1279. eerror;
  1280. eerror "Include in your bugreport the contents of:";
  1281. eerror;
  1282. eerror " ${STDERR_TARGET}";
  1283. echo;
  1284. die "Failed Patch: ${patchname}!";
  1285. fi;
  1286. rm -f "${STDERR_TARGET}";
  1287. cat >> "${T}/epatch.log" <<-EOF
  1288. PATCH: ${x}
  1289. CMD: ${patch_cmd}
  1290. PWD: ${PWD}
  1291. EOF
  1292. eend 0;
  1293. done;
  1294. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1295. :
  1296. }
  1297. epause ()
  1298. {
  1299. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1300. }
  1301. eshopts_pop ()
  1302. {
  1303. local s;
  1304. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1305. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  1306. }
  1307. eshopts_push ()
  1308. {
  1309. if [[ $1 == -[su] ]]; then
  1310. estack_push eshopts "$(shopt -p)";
  1311. [[ $# -eq 0 ]] && return 0;
  1312. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1313. else
  1314. estack_push eshopts "$(shopt -p -o)";
  1315. [[ $# -eq 0 ]] && return 0;
  1316. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1317. fi
  1318. }
  1319. estack_pop ()
  1320. {
  1321. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1322. local _estack_name="_ESTACK_$1_";
  1323. shift;
  1324. local _estack_retvar=$1;
  1325. shift;
  1326. eval local _estack_i=\${#${_estack_name}\[@\]};
  1327. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  1328. if [[ -n ${_estack_retvar} ]]; then
  1329. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  1330. fi;
  1331. eval unset \"${_estack_name}\[${_estack_i}\]\"
  1332. }
  1333. estack_push ()
  1334. {
  1335. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1336. local stack_name="_ESTACK_$1_";
  1337. shift;
  1338. eval ${stack_name}+=\( \"\$@\" \)
  1339. }
  1340. esvn_clean ()
  1341. {
  1342. [[ $# -eq 0 ]] && set -- .;
  1343. find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' +
  1344. }
  1345. eumask_pop ()
  1346. {
  1347. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1348. local s;
  1349. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1350. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1351. }
  1352. eumask_push ()
  1353. {
  1354. estack_push eumask "$(umask)";
  1355. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1356. }
  1357. evar_pop ()
  1358. {
  1359. local cnt=${1:-bad};
  1360. case $# in
  1361. 0)
  1362. cnt=1
  1363. ;;
  1364. 1)
  1365. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  1366. ;;
  1367. *)
  1368. die "${FUNCNAME}: only accepts one arg: $*"
  1369. ;;
  1370. esac;
  1371. local var val;
  1372. while (( cnt-- )); do
  1373. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1374. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1375. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1376. done
  1377. }
  1378. evar_push ()
  1379. {
  1380. local var val;
  1381. for var in "$@";
  1382. do
  1383. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1384. estack_push evar "${var}" "${val}";
  1385. done
  1386. }
  1387. evar_push_set ()
  1388. {
  1389. local var=$1;
  1390. evar_push ${var};
  1391. case $# in
  1392. 1)
  1393. unset ${var}
  1394. ;;
  1395. 2)
  1396. printf -v "${var}" '%s' "$2"
  1397. ;;
  1398. *)
  1399. die "${FUNCNAME}: incorrect # of args: $*"
  1400. ;;
  1401. esac
  1402. }
  1403. filter-flags ()
  1404. {
  1405. _filter-hardened "$@";
  1406. local v;
  1407. for v in $(all-flag-vars);
  1408. do
  1409. _filter-var ${v} "$@";
  1410. done;
  1411. return 0
  1412. }
  1413. filter-ldflags ()
  1414. {
  1415. _filter-var LDFLAGS "$@";
  1416. return 0
  1417. }
  1418. filter-lfs-flags ()
  1419. {
  1420. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1421. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1422. }
  1423. filter-mfpmath ()
  1424. {
  1425. local orig_mfpmath new_math prune_math;
  1426. orig_mfpmath=$(get-flag -mfpmath);
  1427. new_math=$(get-flag mfpmath);
  1428. new_math=${new_math/both/387,sse};
  1429. new_math=" ${new_math//[,+]/ } ";
  1430. prune_math="";
  1431. for prune_math in "$@";
  1432. do
  1433. new_math=${new_math/ ${prune_math} / };
  1434. done;
  1435. new_math=$(echo ${new_math});
  1436. new_math=${new_math// /,};
  1437. if [[ -z ${new_math} ]]; then
  1438. filter-flags ${orig_mfpmath};
  1439. else
  1440. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1441. fi;
  1442. return 0
  1443. }
  1444. gcc-fullversion ()
  1445. {
  1446. _gcc_fullversion '$1.$2.$3' "$@"
  1447. }
  1448. gcc-major-version ()
  1449. {
  1450. _gcc_fullversion '$1' "$@"
  1451. }
  1452. gcc-micro-version ()
  1453. {
  1454. _gcc_fullversion '$3' "$@"
  1455. }
  1456. gcc-minor-version ()
  1457. {
  1458. _gcc_fullversion '$2' "$@"
  1459. }
  1460. gcc-specs-directive ()
  1461. {
  1462. local directive subdname subdirective;
  1463. directive="$(_gcc-specs-directive_raw $1)";
  1464. while [[ ${directive} == *%\(*\)* ]]; do
  1465. subdname=${directive/*%\(};
  1466. subdname=${subdname/\)*};
  1467. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1468. directive="${directive//\%(${subdname})/${subdirective}}";
  1469. done;
  1470. echo "${directive}";
  1471. return 0
  1472. }
  1473. gcc-specs-nostrict ()
  1474. {
  1475. local directive;
  1476. directive=$(gcc-specs-directive cc1);
  1477. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1478. }
  1479. gcc-specs-now ()
  1480. {
  1481. local directive;
  1482. directive=$(gcc-specs-directive link_command);
  1483. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1484. }
  1485. gcc-specs-pie ()
  1486. {
  1487. local directive;
  1488. directive=$(gcc-specs-directive cc1);
  1489. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1490. }
  1491. gcc-specs-relro ()
  1492. {
  1493. local directive;
  1494. directive=$(gcc-specs-directive link_command);
  1495. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1496. }
  1497. gcc-specs-ssp ()
  1498. {
  1499. local directive;
  1500. directive=$(gcc-specs-directive cc1);
  1501. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1502. }
  1503. gcc-specs-ssp-to-all ()
  1504. {
  1505. local directive;
  1506. directive=$(gcc-specs-directive cc1);
  1507. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1508. }
  1509. gcc-specs-stack-check ()
  1510. {
  1511. local directive;
  1512. directive=$(gcc-specs-directive cc1);
  1513. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1514. }
  1515. gcc-version ()
  1516. {
  1517. _gcc_fullversion '$1.$2' "$@"
  1518. }
  1519. gen_usr_ldscript ()
  1520. {
  1521. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1522. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1523. tc-is-static-only && return;
  1524. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1525. multilib_is_native_abi || return 0;
  1526. fi;
  1527. case ${CTARGET:-${CHOST}} in
  1528. *-darwin*)
  1529. ;;
  1530. *-android*)
  1531. return 0
  1532. ;;
  1533. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1534. use prefix && return 0
  1535. ;;
  1536. *)
  1537. return 0
  1538. ;;
  1539. esac;
  1540. dodir /usr/${libdir};
  1541. if [[ $1 == "-a" ]]; then
  1542. auto=true;
  1543. shift;
  1544. dodir /${libdir};
  1545. fi;
  1546. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1547. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1548. local d="${T}/bfd-linker";
  1549. mkdir -p "${d}";
  1550. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1551. flags+=(-B"${d}");
  1552. fi;
  1553. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1554. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1555. for lib in "$@";
  1556. do
  1557. local tlib;
  1558. if ${auto}; then
  1559. lib="lib${lib}${suffix}";
  1560. else
  1561. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1562. fi;
  1563. case ${CTARGET:-${CHOST}} in
  1564. *-darwin*)
  1565. if ${auto}; then
  1566. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1567. else
  1568. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1569. fi;
  1570. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1571. tlib=${tlib##*/};
  1572. if ${auto}; then
  1573. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1574. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1575. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1576. fi;
  1577. rm -f "${ED}"/${libdir}/${lib};
  1578. fi;
  1579. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1580. chmod u+w "${ED}${libdir}/${tlib}";
  1581. local nowrite=yes;
  1582. fi;
  1583. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1584. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1585. pushd "${ED}/usr/${libdir}" > /dev/null;
  1586. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1587. popd > /dev/null
  1588. ;;
  1589. *)
  1590. if ${auto}; then
  1591. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1592. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1593. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1594. if [[ ${tlib} != ${lib}* ]]; then
  1595. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1596. fi;
  1597. rm -f "${ED}"/${libdir}/${lib};
  1598. else
  1599. tlib=${lib};
  1600. fi;
  1601. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1602. /* GNU ld script
  1603. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1604. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1605. run into linking problems. This "fake" dynamic lib is a linker script that
  1606. redirects the linker to the real lib. And yes, this works in the cross-
  1607. compiling scenario as the sysroot-ed linker will prepend the real path.
  1608. See bug https://bugs.gentoo.org/4411 for more info.
  1609. */
  1610. ${output_format}
  1611. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1612. END_LDSCRIPT
  1613. ;;
  1614. esac
  1615. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1616. done
  1617. }
  1618. get-flag ()
  1619. {
  1620. local f var findflag="$1";
  1621. for var in $(all-flag-vars);
  1622. do
  1623. for f in ${!var};
  1624. do
  1625. if [ "${f/${findflag}}" != "${f}" ]; then
  1626. printf "%s\n" "${f/-${findflag}=}";
  1627. return 0;
  1628. fi;
  1629. done;
  1630. done;
  1631. return 1
  1632. }
  1633. get_abi_CFLAGS ()
  1634. {
  1635. get_abi_var CFLAGS "$@"
  1636. }
  1637. get_abi_CHOST ()
  1638. {
  1639. get_abi_var CHOST "$@"
  1640. }
  1641. get_abi_CTARGET ()
  1642. {
  1643. get_abi_var CTARGET "$@"
  1644. }
  1645. get_abi_FAKE_TARGETS ()
  1646. {
  1647. get_abi_var FAKE_TARGETS "$@"
  1648. }
  1649. get_abi_LDFLAGS ()
  1650. {
  1651. get_abi_var LDFLAGS "$@"
  1652. }
  1653. get_abi_LIBDIR ()
  1654. {
  1655. get_abi_var LIBDIR "$@"
  1656. }
  1657. get_abi_var ()
  1658. {
  1659. local flag=$1;
  1660. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1661. local var="${flag}_${abi}";
  1662. echo ${!var}
  1663. }
  1664. get_all_abis ()
  1665. {
  1666. local x order="" mvar dvar;
  1667. mvar="MULTILIB_ABIS";
  1668. dvar="DEFAULT_ABI";
  1669. if [[ -n $1 ]]; then
  1670. mvar="$1_${mvar}";
  1671. dvar="$1_${dvar}";
  1672. fi;
  1673. if [[ -z ${!mvar} ]]; then
  1674. echo "default";
  1675. return 0;
  1676. fi;
  1677. for x in ${!mvar};
  1678. do
  1679. if [[ ${x} != ${!dvar} ]]; then
  1680. order="${order:+${order} }${x}";
  1681. fi;
  1682. done;
  1683. order="${order:+${order} }${!dvar}";
  1684. echo ${order};
  1685. return 0
  1686. }
  1687. get_all_libdirs ()
  1688. {
  1689. local libdirs abi;
  1690. for abi in ${MULTILIB_ABIS};
  1691. do
  1692. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1693. done;
  1694. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1695. echo "${libdirs}"
  1696. }
  1697. get_exeext ()
  1698. {
  1699. case ${CHOST} in
  1700. *-cygwin* | mingw* | *-mingw*)
  1701. echo ".exe"
  1702. ;;
  1703. esac
  1704. }
  1705. get_install_abis ()
  1706. {
  1707. local x order="";
  1708. if [[ -z ${MULTILIB_ABIS} ]]; then
  1709. echo "default";
  1710. return 0;
  1711. fi;
  1712. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1713. for x in ${MULTILIB_ABIS};
  1714. do
  1715. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1716. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1717. fi;
  1718. done;
  1719. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1720. if [[ -n ${ABI_ALLOW} ]]; then
  1721. local ordera="";
  1722. for x in ${order};
  1723. do
  1724. if has ${x} ${ABI_ALLOW}; then
  1725. ordera="${ordera} ${x}";
  1726. fi;
  1727. done;
  1728. order=${ordera};
  1729. fi;
  1730. else
  1731. order=${DEFAULT_ABI};
  1732. fi;
  1733. if [[ -z ${order} ]]; then
  1734. 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.";
  1735. fi;
  1736. echo ${order};
  1737. return 0
  1738. }
  1739. get_libdir ()
  1740. {
  1741. local libdir_var="LIBDIR_${ABI}";
  1742. local libdir="lib";
  1743. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1744. echo "${libdir}"
  1745. }
  1746. get_libname ()
  1747. {
  1748. local libname;
  1749. local ver=$1;
  1750. case ${CHOST} in
  1751. *-cygwin*)
  1752. libname="dll.a"
  1753. ;;
  1754. mingw* | *-mingw*)
  1755. libname="dll"
  1756. ;;
  1757. *-darwin*)
  1758. libname="dylib"
  1759. ;;
  1760. *-mint*)
  1761. libname="irrelevant"
  1762. ;;
  1763. hppa*-hpux*)
  1764. libname="sl"
  1765. ;;
  1766. *)
  1767. libname="so"
  1768. ;;
  1769. esac;
  1770. if [[ -z $* ]]; then
  1771. echo ".${libname}";
  1772. else
  1773. for ver in "$@";
  1774. do
  1775. case ${CHOST} in
  1776. *-cygwin*)
  1777. echo ".${ver}.${libname}"
  1778. ;;
  1779. *-darwin*)
  1780. echo ".${ver}.${libname}"
  1781. ;;
  1782. *-mint*)
  1783. echo ".${libname}"
  1784. ;;
  1785. *)
  1786. echo ".${libname}.${ver}"
  1787. ;;
  1788. esac;
  1789. done;
  1790. fi
  1791. }
  1792. get_modname ()
  1793. {
  1794. local modname;
  1795. local ver=$1;
  1796. case ${CHOST} in
  1797. *-darwin*)
  1798. modname="bundle"
  1799. ;;
  1800. *)
  1801. modname="so"
  1802. ;;
  1803. esac;
  1804. echo ".${modname}"
  1805. }
  1806. has_m32 ()
  1807. {
  1808. die "${FUNCNAME}: don't use this anymore"
  1809. }
  1810. has_m64 ()
  1811. {
  1812. die "${FUNCNAME}: don't use this anymore"
  1813. }
  1814. has_multilib_profile ()
  1815. {
  1816. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1817. }
  1818. in_iuse ()
  1819. {
  1820. local use=${1};
  1821. if [[ -z "${use}" ]]; then
  1822. echo "!!! in_iuse() called without a parameter." 1>&2;
  1823. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1824. die "in_iuse() called without a parameter";
  1825. fi;
  1826. local liuse=(${IUSE_EFFECTIVE});
  1827. has "${use}" "${liuse[@]#[+-]}"
  1828. }
  1829. is-flag ()
  1830. {
  1831. is-flagq "$@" && echo true
  1832. }
  1833. is-flagq ()
  1834. {
  1835. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1836. local var;
  1837. for var in $(all-flag-vars);
  1838. do
  1839. _is_flagq ${var} "$1" && return 0;
  1840. done;
  1841. return 1
  1842. }
  1843. is-ldflag ()
  1844. {
  1845. is-ldflagq "$@" && echo true
  1846. }
  1847. is-ldflagq ()
  1848. {
  1849. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1850. _is_flagq LDFLAGS $1
  1851. }
  1852. is_final_abi ()
  1853. {
  1854. has_multilib_profile || return 0;
  1855. set -- $(get_install_abis);
  1856. local LAST_ABI=$#;
  1857. [[ ${!LAST_ABI} == ${ABI} ]]
  1858. }
  1859. isdigit ()
  1860. {
  1861. local d;
  1862. for d in "$@";
  1863. do
  1864. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  1865. done;
  1866. return 0
  1867. }
  1868. make_desktop_entry ()
  1869. {
  1870. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  1871. local exec=${1};
  1872. local name=${2:-${PN}};
  1873. local icon=${3:-${PN}};
  1874. local type=${4};
  1875. local fields=${5};
  1876. if [[ -z ${type} ]]; then
  1877. local catmaj=${CATEGORY%%-*};
  1878. local catmin=${CATEGORY##*-};
  1879. case ${catmaj} in
  1880. app)
  1881. case ${catmin} in
  1882. accessibility)
  1883. type="Utility;Accessibility"
  1884. ;;
  1885. admin)
  1886. type=System
  1887. ;;
  1888. antivirus)
  1889. type=System
  1890. ;;
  1891. arch)
  1892. type="Utility;Archiving"
  1893. ;;
  1894. backup)
  1895. type="Utility;Archiving"
  1896. ;;
  1897. cdr)
  1898. type="AudioVideo;DiscBurning"
  1899. ;;
  1900. dicts)
  1901. type="Office;Dictionary"
  1902. ;;
  1903. doc)
  1904. type=Documentation
  1905. ;;
  1906. editors)
  1907. type="Utility;TextEditor"
  1908. ;;
  1909. emacs)
  1910. type="Development;TextEditor"
  1911. ;;
  1912. emulation)
  1913. type="System;Emulator"
  1914. ;;
  1915. laptop)
  1916. type="Settings;HardwareSettings"
  1917. ;;
  1918. office)
  1919. type=Office
  1920. ;;
  1921. pda)
  1922. type="Office;PDA"
  1923. ;;
  1924. vim)
  1925. type="Development;TextEditor"
  1926. ;;
  1927. xemacs)
  1928. type="Development;TextEditor"
  1929. ;;
  1930. esac
  1931. ;;
  1932. dev)
  1933. type="Development"
  1934. ;;
  1935. games)
  1936. case ${catmin} in
  1937. action | fps)
  1938. type=ActionGame
  1939. ;;
  1940. arcade)
  1941. type=ArcadeGame
  1942. ;;
  1943. board)
  1944. type=BoardGame
  1945. ;;
  1946. emulation)
  1947. type=Emulator
  1948. ;;
  1949. kids)
  1950. type=KidsGame
  1951. ;;
  1952. puzzle)
  1953. type=LogicGame
  1954. ;;
  1955. roguelike)
  1956. type=RolePlaying
  1957. ;;
  1958. rpg)
  1959. type=RolePlaying
  1960. ;;
  1961. simulation)
  1962. type=Simulation
  1963. ;;
  1964. sports)
  1965. type=SportsGame
  1966. ;;
  1967. strategy)
  1968. type=StrategyGame
  1969. ;;
  1970. esac;
  1971. type="Game;${type}"
  1972. ;;
  1973. gnome)
  1974. type="Gnome;GTK"
  1975. ;;
  1976. kde)
  1977. type="KDE;Qt"
  1978. ;;
  1979. mail)
  1980. type="Network;Email"
  1981. ;;
  1982. media)
  1983. case ${catmin} in
  1984. gfx)
  1985. type=Graphics
  1986. ;;
  1987. *)
  1988. case ${catmin} in
  1989. radio)
  1990. type=Tuner
  1991. ;;
  1992. sound)
  1993. type=Audio
  1994. ;;
  1995. tv)
  1996. type=TV
  1997. ;;
  1998. video)
  1999. type=Video
  2000. ;;
  2001. esac;
  2002. type="AudioVideo;${type}"
  2003. ;;
  2004. esac
  2005. ;;
  2006. net)
  2007. case ${catmin} in
  2008. dialup)
  2009. type=Dialup
  2010. ;;
  2011. ftp)
  2012. type=FileTransfer
  2013. ;;
  2014. im)
  2015. type=InstantMessaging
  2016. ;;
  2017. irc)
  2018. type=IRCClient
  2019. ;;
  2020. mail)
  2021. type=Email
  2022. ;;
  2023. news)
  2024. type=News
  2025. ;;
  2026. nntp)
  2027. type=News
  2028. ;;
  2029. p2p)
  2030. type=FileTransfer
  2031. ;;
  2032. voip)
  2033. type=Telephony
  2034. ;;
  2035. esac;
  2036. type="Network;${type}"
  2037. ;;
  2038. sci)
  2039. case ${catmin} in
  2040. astro*)
  2041. type=Astronomy
  2042. ;;
  2043. bio*)
  2044. type=Biology
  2045. ;;
  2046. calc*)
  2047. type=Calculator
  2048. ;;
  2049. chem*)
  2050. type=Chemistry
  2051. ;;
  2052. elec*)
  2053. type=Electronics
  2054. ;;
  2055. geo*)
  2056. type=Geology
  2057. ;;
  2058. math*)
  2059. type=Math
  2060. ;;
  2061. physics)
  2062. type=Physics
  2063. ;;
  2064. visual*)
  2065. type=DataVisualization
  2066. ;;
  2067. esac;
  2068. type="Education;Science;${type}"
  2069. ;;
  2070. sys)
  2071. type="System"
  2072. ;;
  2073. www)
  2074. case ${catmin} in
  2075. client)
  2076. type=WebBrowser
  2077. ;;
  2078. esac;
  2079. type="Network;${type}"
  2080. ;;
  2081. *)
  2082. type=
  2083. ;;
  2084. esac;
  2085. fi;
  2086. local slot=${SLOT%/*};
  2087. if [[ ${slot} == "0" ]]; then
  2088. local desktop_name="${PN}";
  2089. else
  2090. local desktop_name="${PN}-${slot}";
  2091. fi;
  2092. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2093. type=${type%;}${type:+;};
  2094. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2095. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2096. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2097. icon=${icon%.*};
  2098. fi;
  2099. cat > "${desktop}" <<-EOF ||
  2100. [Desktop Entry]
  2101. Name=${name}
  2102. Type=Application
  2103. Comment=${DESCRIPTION}
  2104. Exec=${exec}
  2105. TryExec=${exec%% *}
  2106. Icon=${icon}
  2107. Categories=${type}
  2108. EOF
  2109. die
  2110. if [[ ${fields:-=} != *=* ]]; then
  2111. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2112. fields="Path=${fields}";
  2113. fi;
  2114. if [[ -n ${fields} ]]; then
  2115. printf '%b\n' "${fields}" >> "${desktop}" || die;
  2116. fi;
  2117. ( insopts -m 0644;
  2118. insinto /usr/share/applications;
  2119. doins "${desktop}" ) || die "installing desktop file failed"
  2120. }
  2121. make_session_desktop ()
  2122. {
  2123. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2124. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2125. local title=$1;
  2126. local command=$2;
  2127. local desktop=${T}/${wm:-${PN}}.desktop;
  2128. shift 2;
  2129. cat > "${desktop}" <<-EOF ||
  2130. [Desktop Entry]
  2131. Name=${title}
  2132. Comment=This session logs you into ${title}
  2133. Exec=${command} $*
  2134. TryExec=${command}
  2135. Type=XSession
  2136. EOF
  2137. die
  2138. ( insopts -m 0644;
  2139. insinto /usr/share/xsessions;
  2140. doins "${desktop}" )
  2141. }
  2142. make_wrapper ()
  2143. {
  2144. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2145. local tmpwrapper=$(emktemp);
  2146. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  2147. ( echo '#!/bin/sh';
  2148. if [[ -n ${libdir} ]]; then
  2149. local var;
  2150. if [[ ${CHOST} == *-darwin* ]]; then
  2151. var=DYLD_LIBRARY_PATH;
  2152. else
  2153. var=LD_LIBRARY_PATH;
  2154. fi;
  2155. cat <<-EOF
  2156. if [ "\${${var}+set}" = "set" ] ; then
  2157. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  2158. else
  2159. export ${var}="${EPREFIX}${libdir}"
  2160. fi
  2161. EOF
  2162. fi
  2163. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  2164. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  2165. chmod go+rx "${tmpwrapper}";
  2166. if [[ -n ${path} ]]; then
  2167. ( exeopts -m 0755;
  2168. exeinto "${path}";
  2169. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2170. else
  2171. newbin "${tmpwrapper}" "${wrapper}" || die;
  2172. fi
  2173. }
  2174. multibuild_copy_sources ()
  2175. {
  2176. debug-print-function ${FUNCNAME} "${@}";
  2177. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  2178. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  2179. local cp_args=();
  2180. if cp --reflink=auto --version &> /dev/null; then
  2181. cp_args+=(--reflink=auto);
  2182. fi;
  2183. function _multibuild_create_source_copy ()
  2184. {
  2185. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  2186. cp -p -R "${cp_args[@]}" "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  2187. };
  2188. multibuild_foreach_variant _multibuild_create_source_copy
  2189. }
  2190. multibuild_for_best_variant ()
  2191. {
  2192. debug-print-function ${FUNCNAME} "${@}";
  2193. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2194. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}");
  2195. multibuild_foreach_variant "${@}"
  2196. }
  2197. multibuild_foreach_variant ()
  2198. {
  2199. debug-print-function ${FUNCNAME} "${@}";
  2200. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2201. local bdir=${BUILD_DIR:-${S}};
  2202. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  2203. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  2204. local ret=0 lret=0 v;
  2205. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  2206. for v in "${MULTIBUILD_VARIANTS[@]}";
  2207. do
  2208. local MULTIBUILD_VARIANT=${v};
  2209. local MULTIBUILD_ID=${prev_id}${v};
  2210. local BUILD_DIR=${bdir%%/}-${v};
  2211. function _multibuild_run ()
  2212. {
  2213. local i=1;
  2214. while [[ ${!i} == _* ]]; do
  2215. (( i += 1 ));
  2216. done;
  2217. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  2218. "${@}"
  2219. };
  2220. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  2221. lret=${?};
  2222. done;
  2223. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  2224. return ${ret}
  2225. }
  2226. multibuild_merge_root ()
  2227. {
  2228. local src=${1};
  2229. local dest=${2};
  2230. local ret;
  2231. if use userland_BSD; then
  2232. tar -C "${src}" -f - -c . | tar -x -f - -C "${dest}";
  2233. [[ ${PIPESTATUS[*]} == '0 0' ]];
  2234. ret=${?};
  2235. else
  2236. local cp_args=();
  2237. if cp -a --version &> /dev/null; then
  2238. cp_args+=(-a);
  2239. else
  2240. cp_args+=(-P -R -p);
  2241. fi;
  2242. if cp --reflink=auto --version &> /dev/null; then
  2243. cp_args+=(--reflink=auto);
  2244. fi;
  2245. cp "${cp_args[@]}" "${src}"/. "${dest}"/;
  2246. ret=${?};
  2247. fi;
  2248. if [[ ${ret} -ne 0 ]]; then
  2249. die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
  2250. fi;
  2251. rm -rf "${src}"
  2252. }
  2253. multibuild_parallel_foreach_variant ()
  2254. {
  2255. debug-print-function ${FUNCNAME} "${@}";
  2256. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  2257. multibuild_foreach_variant "${@}"
  2258. }
  2259. multilib-minimal_abi_src_configure ()
  2260. {
  2261. debug-print-function ${FUNCNAME} "$@";
  2262. mkdir -p "${BUILD_DIR}" || die;
  2263. pushd "${BUILD_DIR}" > /dev/null || die;
  2264. if declare -f multilib_src_configure > /dev/null; then
  2265. multilib_src_configure;
  2266. else
  2267. default_src_configure;
  2268. fi;
  2269. popd > /dev/null || die
  2270. }
  2271. multilib-minimal_src_compile ()
  2272. {
  2273. debug-print-function ${FUNCNAME} "$@";
  2274. function multilib-minimal_abi_src_compile ()
  2275. {
  2276. debug-print-function ${FUNCNAME} "$@";
  2277. pushd "${BUILD_DIR}" > /dev/null || die;
  2278. if declare -f multilib_src_compile > /dev/null; then
  2279. multilib_src_compile;
  2280. else
  2281. default_src_compile;
  2282. fi;
  2283. popd > /dev/null || die
  2284. };
  2285. multilib_foreach_abi multilib-minimal_abi_src_compile
  2286. }
  2287. multilib-minimal_src_configure ()
  2288. {
  2289. debug-print-function ${FUNCNAME} "$@";
  2290. function multilib-minimal_abi_src_configure ()
  2291. {
  2292. debug-print-function ${FUNCNAME} "$@";
  2293. mkdir -p "${BUILD_DIR}" || die;
  2294. pushd "${BUILD_DIR}" > /dev/null || die;
  2295. if declare -f multilib_src_configure > /dev/null; then
  2296. multilib_src_configure;
  2297. else
  2298. default_src_configure;
  2299. fi;
  2300. popd > /dev/null || die
  2301. };
  2302. multilib_foreach_abi multilib-minimal_abi_src_configure
  2303. }
  2304. multilib-minimal_src_install ()
  2305. {
  2306. debug-print-function ${FUNCNAME} "$@";
  2307. function multilib-minimal_abi_src_install ()
  2308. {
  2309. debug-print-function ${FUNCNAME} "$@";
  2310. pushd "${BUILD_DIR}" > /dev/null || die;
  2311. if declare -f multilib_src_install > /dev/null; then
  2312. multilib_src_install;
  2313. else
  2314. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  2315. emake DESTDIR="${D}" install;
  2316. fi;
  2317. fi;
  2318. multilib_prepare_wrappers;
  2319. multilib_check_headers;
  2320. popd > /dev/null || die
  2321. };
  2322. multilib_foreach_abi multilib-minimal_abi_src_install;
  2323. multilib_install_wrappers;
  2324. if declare -f multilib_src_install_all > /dev/null; then
  2325. multilib_src_install_all;
  2326. else
  2327. einstalldocs;
  2328. fi
  2329. }
  2330. multilib-minimal_src_test ()
  2331. {
  2332. debug-print-function ${FUNCNAME} "$@";
  2333. function multilib-minimal_abi_src_test ()
  2334. {
  2335. debug-print-function ${FUNCNAME} "$@";
  2336. pushd "${BUILD_DIR}" > /dev/null || die;
  2337. if declare -f multilib_src_test > /dev/null; then
  2338. multilib_src_test;
  2339. else
  2340. default_src_test;
  2341. fi;
  2342. popd > /dev/null || die
  2343. };
  2344. multilib_foreach_abi multilib-minimal_abi_src_test
  2345. }
  2346. multilib_build_binaries ()
  2347. {
  2348. debug-print-function ${FUNCNAME} "${@}";
  2349. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  2350. eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent";
  2351. eqawarn "multilib_is_native_abi function instead.";
  2352. multilib_is_native_abi "${@}"
  2353. }
  2354. multilib_check_headers ()
  2355. {
  2356. function _multilib_header_cksum ()
  2357. {
  2358. set -o pipefail;
  2359. if [[ -d ${ED%/}/usr/include ]]; then
  2360. find "${ED%/}"/usr/include -type f -exec cksum {} + | sort -k2;
  2361. fi
  2362. };
  2363. local cksum cksum_prev;
  2364. local cksum_file=${T}/.multilib_header_cksum;
  2365. cksum=$(_multilib_header_cksum) || die;
  2366. unset -f _multilib_header_cksum;
  2367. if [[ -f ${cksum_file} ]]; then
  2368. cksum_prev=$(< "${cksum_file}") || die;
  2369. if [[ ${cksum} != ${cksum_prev} ]]; then
  2370. echo "${cksum}" > "${cksum_file}.new" || die;
  2371. eerror "Header files have changed between ABIs.";
  2372. if type -p diff &> /dev/null; then
  2373. eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  2374. else
  2375. eerror "Old checksums in: ${cksum_file}";
  2376. eerror "New checksums in: ${cksum_file}.new";
  2377. fi;
  2378. die "Header checksum mismatch, aborting.";
  2379. fi;
  2380. else
  2381. echo "${cksum}" > "${cksum_file}" || die;
  2382. fi
  2383. }
  2384. multilib_copy_sources ()
  2385. {
  2386. debug-print-function ${FUNCNAME} "${@}";
  2387. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2388. multibuild_copy_sources
  2389. }
  2390. multilib_env ()
  2391. {
  2392. local CTARGET=${1:-${CTARGET}};
  2393. local cpu=${CTARGET%%*-};
  2394. case ${cpu} in
  2395. aarch64*)
  2396. export CFLAGS_arm=${CFLAGS_arm-};
  2397. case ${cpu} in
  2398. aarch64*be)
  2399. export CHOST_arm="armv8b-${CTARGET#*-}"
  2400. ;;
  2401. *)
  2402. export CHOST_arm="armv8l-${CTARGET#*-}"
  2403. ;;
  2404. esac;
  2405. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2406. export CTARGET_arm=${CHOST_arm};
  2407. export LIBDIR_arm="lib";
  2408. export CFLAGS_arm64=${CFLAGS_arm64-};
  2409. export CHOST_arm64=${CTARGET};
  2410. export CTARGET_arm64=${CHOST_arm64};
  2411. export LIBDIR_arm64="lib64";
  2412. : ${MULTILIB_ABIS=arm64};
  2413. : ${DEFAULT_ABI=arm64}
  2414. ;;
  2415. x86_64*)
  2416. export CFLAGS_x86=${CFLAGS_x86--m32};
  2417. export CHOST_x86=${CTARGET/x86_64/i686};
  2418. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2419. export CTARGET_x86=${CHOST_x86};
  2420. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2421. export LIBDIR_x86="lib32";
  2422. else
  2423. export LIBDIR_x86="lib";
  2424. fi;
  2425. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2426. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2427. export CTARGET_amd64=${CHOST_amd64};
  2428. export LIBDIR_amd64="lib64";
  2429. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2430. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2431. export CTARGET_x32=${CHOST_x32};
  2432. export LIBDIR_x32="libx32";
  2433. case ${CTARGET} in
  2434. *-gnux32)
  2435. : ${MULTILIB_ABIS=x32 amd64 x86};
  2436. : ${DEFAULT_ABI=x32}
  2437. ;;
  2438. *)
  2439. : ${MULTILIB_ABIS=amd64 x86};
  2440. : ${DEFAULT_ABI=amd64}
  2441. ;;
  2442. esac
  2443. ;;
  2444. mips64* | mipsisa64*)
  2445. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2446. export CHOST_o32=${CTARGET/mips64/mips};
  2447. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2448. export CTARGET_o32=${CHOST_o32};
  2449. export LIBDIR_o32="lib";
  2450. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2451. export CHOST_n32=${CTARGET};
  2452. export CTARGET_n32=${CHOST_n32};
  2453. export LIBDIR_n32="lib32";
  2454. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2455. export CHOST_n64=${CTARGET};
  2456. export CTARGET_n64=${CHOST_n64};
  2457. export LIBDIR_n64="lib64";
  2458. : ${MULTILIB_ABIS=n64 n32 o32};
  2459. : ${DEFAULT_ABI=n32}
  2460. ;;
  2461. powerpc64*)
  2462. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2463. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2464. export CTARGET_ppc=${CHOST_ppc};
  2465. export LIBDIR_ppc="lib";
  2466. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2467. export CHOST_ppc64=${CTARGET};
  2468. export CTARGET_ppc64=${CHOST_ppc64};
  2469. export LIBDIR_ppc64="lib64";
  2470. : ${MULTILIB_ABIS=ppc64 ppc};
  2471. : ${DEFAULT_ABI=ppc64}
  2472. ;;
  2473. s390x*)
  2474. export CFLAGS_s390=${CFLAGS_s390--m31};
  2475. export CHOST_s390=${CTARGET/s390x/s390};
  2476. export CTARGET_s390=${CHOST_s390};
  2477. export LIBDIR_s390="lib";
  2478. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2479. export CHOST_s390x=${CTARGET};
  2480. export CTARGET_s390x=${CHOST_s390x};
  2481. export LIBDIR_s390x="lib64";
  2482. : ${MULTILIB_ABIS=s390x s390};
  2483. : ${DEFAULT_ABI=s390x}
  2484. ;;
  2485. sparc64*)
  2486. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2487. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2488. export CTARGET_sparc32=${CHOST_sparc32};
  2489. export LIBDIR_sparc32="lib";
  2490. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2491. export CHOST_sparc64=${CTARGET};
  2492. export CTARGET_sparc64=${CHOST_sparc64};
  2493. export LIBDIR_sparc64="lib64";
  2494. : ${MULTILIB_ABIS=sparc64 sparc32};
  2495. : ${DEFAULT_ABI=sparc64}
  2496. ;;
  2497. *)
  2498. : ${MULTILIB_ABIS=default};
  2499. : ${DEFAULT_ABI=default}
  2500. ;;
  2501. esac;
  2502. export MULTILIB_ABIS DEFAULT_ABI
  2503. }
  2504. multilib_for_best_abi ()
  2505. {
  2506. debug-print-function ${FUNCNAME} "${@}";
  2507. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  2508. eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should";
  2509. eqawarn "not be used. The multilib_is_native_abi() check may be used instead.";
  2510. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2511. multibuild_for_best_variant _multilib_multibuild_wrapper "${@}"
  2512. }
  2513. multilib_foreach_abi ()
  2514. {
  2515. debug-print-function ${FUNCNAME} "${@}";
  2516. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2517. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2518. }
  2519. multilib_get_enabled_abi_pairs ()
  2520. {
  2521. debug-print-function ${FUNCNAME} "${@}";
  2522. local abis=($(get_all_abis));
  2523. local abi i found;
  2524. for abi in "${abis[@]}";
  2525. do
  2526. for i in "${_MULTILIB_FLAGS[@]}";
  2527. do
  2528. local m_abis=${i#*:} m_abi;
  2529. local m_flag=${i%:*};
  2530. for m_abi in ${m_abis//,/ };
  2531. do
  2532. if [[ ${m_abi} == ${abi} ]] && {
  2533. [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  2534. } && use "${m_flag}"; then
  2535. echo "${m_flag}.${abi}";
  2536. found=1;
  2537. break 2;
  2538. fi;
  2539. done;
  2540. done;
  2541. done;
  2542. if [[ ! -n ${found} ]]; then
  2543. local abi=${ABI:-${DEFAULT_ABI}};
  2544. debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  2545. debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  2546. echo ".${abi}";
  2547. fi
  2548. }
  2549. multilib_get_enabled_abis ()
  2550. {
  2551. debug-print-function ${FUNCNAME} "${@}";
  2552. local pairs=($(multilib_get_enabled_abi_pairs));
  2553. echo "${pairs[@]#*.}"
  2554. }
  2555. multilib_install_wrappers ()
  2556. {
  2557. debug-print-function ${FUNCNAME} "${@}";
  2558. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2559. [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  2560. local root=${1:-${ED}};
  2561. if [[ -d ${ED%/}/tmp/multilib-include ]]; then
  2562. multibuild_merge_root "${ED%/}"/tmp/multilib-include "${root}"/usr/include;
  2563. rmdir "${ED%/}"/tmp &> /dev/null;
  2564. fi
  2565. }
  2566. multilib_is_native_abi ()
  2567. {
  2568. debug-print-function ${FUNCNAME} "${@}";
  2569. [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  2570. [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  2571. }
  2572. multilib_native_enable ()
  2573. {
  2574. if multilib_is_native_abi; then
  2575. echo "--enable-${1}${2+=${2}}";
  2576. else
  2577. echo "--disable-${1}";
  2578. fi
  2579. }
  2580. multilib_native_use_enable ()
  2581. {
  2582. if multilib_is_native_abi; then
  2583. use_enable "${@}";
  2584. else
  2585. echo "--disable-${2:-${1}}";
  2586. fi
  2587. }
  2588. multilib_native_use_with ()
  2589. {
  2590. if multilib_is_native_abi; then
  2591. use_with "${@}";
  2592. else
  2593. echo "--without-${2:-${1}}";
  2594. fi
  2595. }
  2596. multilib_native_usex ()
  2597. {
  2598. if multilib_is_native_abi; then
  2599. usex "${@}";
  2600. else
  2601. echo "${3-no}${5}";
  2602. fi
  2603. }
  2604. multilib_native_with ()
  2605. {
  2606. if multilib_is_native_abi; then
  2607. echo "--with-${1}${2+=${2}}";
  2608. else
  2609. echo "--without-${1}";
  2610. fi
  2611. }
  2612. multilib_parallel_foreach_abi ()
  2613. {
  2614. debug-print-function ${FUNCNAME} "${@}";
  2615. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2616. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2617. }
  2618. multilib_prepare_wrappers ()
  2619. {
  2620. debug-print-function ${FUNCNAME} "${@}";
  2621. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2622. local root=${1:-${ED%/}};
  2623. local f;
  2624. if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  2625. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2626. do
  2627. f=${f#/};
  2628. local dir=${f%/*};
  2629. local fn=${f##*/};
  2630. ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2631. done;
  2632. return;
  2633. fi;
  2634. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2635. do
  2636. f=${f#/};
  2637. local dir=${f%/*};
  2638. local fn=${f##*/};
  2639. if [[ -L ${root}/${f} ]]; then
  2640. local target;
  2641. target=$(readlink "${root}/${f}") || die;
  2642. local target_dir target_fn=${target##*/};
  2643. [[ ${target} == */* ]] && target_dir=${target%/*};
  2644. ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  2645. fi;
  2646. mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2647. if multilib_is_native_abi; then
  2648. ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  2649. fi;
  2650. done;
  2651. if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  2652. if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  2653. for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  2654. do
  2655. f=${f#/};
  2656. if [[ ${f} != usr/include/* ]]; then
  2657. die "Wrapping headers outside of /usr/include is not supported at the moment.";
  2658. fi;
  2659. f=${f#usr/include};
  2660. local dir=${f%/*};
  2661. if [[ -f ${root}/usr/include${f} ]]; then
  2662. local wrapper=${ED%/}/tmp/multilib-include${f};
  2663. if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then
  2664. dodir "/tmp/multilib-include${dir}";
  2665. cat > "${wrapper}" <<_EOF_ ||
  2666. /* This file is auto-generated by multilib-build.eclass
  2667. * as a multilib-friendly wrapper. For the original content,
  2668. * please see the files that are #included below.
  2669. */
  2670. #if defined(__x86_64__) /* amd64 */
  2671. # if defined(__ILP32__) /* x32 ABI */
  2672. # error "abi_x86_x32 not supported by the package."
  2673. # else /* 64-bit ABI */
  2674. # error "abi_x86_64 not supported by the package."
  2675. # endif
  2676. #elif defined(__i386__) /* plain x86 */
  2677. # error "abi_x86_32 not supported by the package."
  2678. #elif defined(__mips__)
  2679. # if(_MIPS_SIM == _ABIN32) /* n32 */
  2680. # error "abi_mips_n32 not supported by the package."
  2681. # elif(_MIPS_SIM == _ABI64) /* n64 */
  2682. # error "abi_mips_n64 not supported by the package."
  2683. # elif(_MIPS_SIM == _ABIO32) /* o32 */
  2684. # error "abi_mips_o32 not supported by the package."
  2685. # endif
  2686. #elif defined(__sparc__)
  2687. # if defined(__arch64__)
  2688. # error "abi_sparc_64 not supported by the package."
  2689. # else
  2690. # error "abi_sparc_32 not supported by the package."
  2691. # endif
  2692. #elif defined(__s390__)
  2693. # if defined(__s390x__)
  2694. # error "abi_s390_64 not supported by the package."
  2695. # else
  2696. # error "abi_s390_32 not supported by the package."
  2697. # endif
  2698. #elif defined(__powerpc__) || defined(__ppc__)
  2699. # if defined(__powerpc64__) || defined(__ppc64__)
  2700. # error "abi_ppc_64 not supported by the package."
  2701. # else
  2702. # error "abi_ppc_32 not supported by the package."
  2703. # endif
  2704. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  2705. # error "Native ABI not supported by the package."
  2706. #else
  2707. # error "No ABI matched, please report a bug to bugs.gentoo.org"
  2708. #endif
  2709. _EOF_
  2710. die;
  2711. fi
  2712. if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  2713. die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  2714. fi;
  2715. dodir "/tmp/multilib-include/${CHOST}${dir}";
  2716. mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die;
  2717. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2718. if multilib_is_native_abi; then
  2719. sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2720. fi;
  2721. fi;
  2722. done;
  2723. fi;
  2724. fi
  2725. }
  2726. multilib_src_configure ()
  2727. {
  2728. export ac_cv_lib_dbm_main=no ac_cv_lib_ndbm_main=no;
  2729. local myeconfargs=(--includedir="${EPREFIX}"/usr/include/gdbm $(use_enable berkdb libgdbm-compat) $(use_enable nls) $(use_enable static-libs static) $(use_with readline));
  2730. ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
  2731. }
  2732. multilib_src_install_all ()
  2733. {
  2734. einstalldocs;
  2735. if ! use static-libs; then
  2736. find "${ED}" -name '*.la' -delete || die;
  2737. fi;
  2738. mv "${ED%/}"/usr/include/gdbm/gdbm.h "${ED%/}"/usr/include/ || die
  2739. }
  2740. multilib_toolchain_setup ()
  2741. {
  2742. local v vv;
  2743. export ABI=$1;
  2744. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2745. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2746. do
  2747. vv="_abi_saved_${v}";
  2748. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2749. unset ${vv};
  2750. done;
  2751. unset _DEFAULT_ABI_SAVED;
  2752. fi;
  2753. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2754. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2755. do
  2756. vv="_abi_saved_${v}";
  2757. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2758. done;
  2759. export _DEFAULT_ABI_SAVED="true";
  2760. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2761. export CBUILD=$(get_abi_CHOST $1);
  2762. fi;
  2763. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2764. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2765. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2766. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2767. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2768. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2769. export CHOST=$(get_abi_CHOST $1);
  2770. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2771. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2772. fi
  2773. }
  2774. newicon ()
  2775. {
  2776. _iconins ${FUNCNAME} "$@"
  2777. }
  2778. newmenu ()
  2779. {
  2780. ( insopts -m 0644;
  2781. insinto /usr/share/applications;
  2782. newins "$@" )
  2783. }
  2784. no-as-needed ()
  2785. {
  2786. case $($(tc-getLD) -v 2>&1 </dev/null) in
  2787. *GNU*)
  2788. echo "-Wl,--no-as-needed"
  2789. ;;
  2790. esac
  2791. }
  2792. number_abis ()
  2793. {
  2794. set -- `get_install_abis`;
  2795. echo $#
  2796. }
  2797. optfeature ()
  2798. {
  2799. debug-print-function ${FUNCNAME} "$@";
  2800. local i j msg;
  2801. local desc=$1;
  2802. local flag=0;
  2803. shift;
  2804. for i in "$@";
  2805. do
  2806. for j in ${i};
  2807. do
  2808. if has_version "${j}"; then
  2809. flag=1;
  2810. else
  2811. flag=0;
  2812. break;
  2813. fi;
  2814. done;
  2815. if [[ ${flag} -eq 1 ]]; then
  2816. break;
  2817. fi;
  2818. done;
  2819. if [[ ${flag} -eq 0 ]]; then
  2820. for i in "$@";
  2821. do
  2822. msg=" ";
  2823. for j in ${i};
  2824. do
  2825. msg+=" ${j} and";
  2826. done;
  2827. msg="${msg:0: -4} for ${desc}";
  2828. elog "${msg}";
  2829. done;
  2830. fi
  2831. }
  2832. path_exists ()
  2833. {
  2834. eerror "path_exists has been removed. Please see the following post";
  2835. eerror "for a replacement snippet:";
  2836. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  2837. die "path_exists is banned"
  2838. }
  2839. pkg_nofetch ()
  2840. {
  2841. default
  2842. }
  2843. preserve_old_lib ()
  2844. {
  2845. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2846. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2847. die "Invalid preserve_old_lib() usage";
  2848. fi;
  2849. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2850. has preserve-libs ${FEATURES} && return 0;
  2851. has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT};
  2852. local lib dir;
  2853. for lib in "$@";
  2854. do
  2855. [[ -e ${EROOT}/${lib} ]] || continue;
  2856. dir=${lib%/*};
  2857. dodir ${dir} || die "dodir ${dir} failed";
  2858. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  2859. touch "${ED}"/${lib};
  2860. done
  2861. }
  2862. preserve_old_lib_notify ()
  2863. {
  2864. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2865. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2866. die "Invalid preserve_old_lib_notify() usage";
  2867. fi;
  2868. has preserve-libs ${FEATURES} && return 0;
  2869. has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT};
  2870. local lib notice=0;
  2871. for lib in "$@";
  2872. do
  2873. [[ -e ${EROOT}/${lib} ]] || continue;
  2874. if [[ ${notice} -eq 0 ]]; then
  2875. notice=1;
  2876. ewarn "Old versions of installed libraries were detected on your system.";
  2877. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2878. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2879. ewarn "in order to remove these old dependencies. If you do not have this";
  2880. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2881. ewarn;
  2882. fi;
  2883. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2884. done
  2885. }
  2886. prune_libtool_files ()
  2887. {
  2888. debug-print-function ${FUNCNAME} "$@";
  2889. local removing_all removing_modules opt;
  2890. for opt in "$@";
  2891. do
  2892. case "${opt}" in
  2893. --all)
  2894. removing_all=1;
  2895. removing_modules=1
  2896. ;;
  2897. --modules)
  2898. removing_modules=1
  2899. ;;
  2900. *)
  2901. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2902. ;;
  2903. esac;
  2904. done;
  2905. local f;
  2906. local queue=();
  2907. while IFS= read -r -d '' f; do
  2908. local archivefile=${f/%.la/.a};
  2909. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  2910. continue;
  2911. fi;
  2912. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2913. local reason= pkgconfig_scanned=;
  2914. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  2915. if [[ ${snotlink} == yes ]]; then
  2916. if [[ -f ${archivefile} ]]; then
  2917. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2918. queue+=("${archivefile}");
  2919. fi;
  2920. if [[ -n ${removing_modules} ]]; then
  2921. reason='module';
  2922. fi;
  2923. else
  2924. if [[ -n ${removing_all} ]]; then
  2925. reason='requested';
  2926. else
  2927. if [[ ! -f ${archivefile} ]]; then
  2928. reason='no static archive';
  2929. else
  2930. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2931. reason='no libs & flags';
  2932. else
  2933. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2934. local pc_libs=();
  2935. if [[ ! -n ${removing_all} ]]; then
  2936. local pc;
  2937. local tf=${T}/prune-lt-files.pc;
  2938. local pkgconf=$(tc-getPKG_CONFIG);
  2939. while IFS= read -r -d '' pc; do
  2940. local arg libs;
  2941. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  2942. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2943. libs=$(${pkgconf} --libs "${tf}");
  2944. else
  2945. libs=$(sed -ne 's/^Libs://p' "${pc}");
  2946. fi;
  2947. for arg in ${libs};
  2948. do
  2949. if [[ ${arg} == -l* ]]; then
  2950. if [[ ${arg} == '*$*' ]]; then
  2951. eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2952. eerror "(arg: ${arg})";
  2953. eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2954. die "${FUNCNAME}: unsubstituted variable found in .pc";
  2955. fi;
  2956. pc_libs+=(lib${arg#-l}.la);
  2957. fi;
  2958. done;
  2959. done < <(find "${D}" -type f -name '*.pc' -print0);
  2960. rm -f "${tf}";
  2961. fi;
  2962. pkgconfig_scanned=1;
  2963. fi;
  2964. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2965. fi;
  2966. fi;
  2967. fi;
  2968. fi;
  2969. if [[ -n ${reason} ]]; then
  2970. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2971. queue+=("${f}");
  2972. fi;
  2973. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2974. if [[ -n ${queue[@]} ]]; then
  2975. rm -f "${queue[@]}";
  2976. fi
  2977. }
  2978. raw-ldflags ()
  2979. {
  2980. local x input="$@";
  2981. [[ -z ${input} ]] && input=${LDFLAGS};
  2982. set --;
  2983. for x in ${input};
  2984. do
  2985. case ${x} in
  2986. -Wl,*)
  2987. x=${x#-Wl,};
  2988. set -- "$@" ${x//,/ }
  2989. ;;
  2990. *)
  2991. ;;
  2992. esac;
  2993. done;
  2994. echo "$@"
  2995. }
  2996. replace-cpu-flags ()
  2997. {
  2998. local newcpu="$#";
  2999. newcpu="${!newcpu}";
  3000. while [ $# -gt 1 ]; do
  3001. replace-flags "-march=${1}" "-march=${newcpu}";
  3002. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3003. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3004. shift;
  3005. done;
  3006. return 0
  3007. }
  3008. replace-flags ()
  3009. {
  3010. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3011. local f var new;
  3012. for var in $(all-flag-vars);
  3013. do
  3014. new=();
  3015. for f in ${!var};
  3016. do
  3017. [[ ${f} == ${1} ]] && f=${2};
  3018. new+=("${f}");
  3019. done;
  3020. export ${var}="${new[*]}";
  3021. done;
  3022. return 0
  3023. }
  3024. replace-sparc64-flags ()
  3025. {
  3026. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3027. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3028. for x in ${SPARC64_CPUS};
  3029. do
  3030. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3031. done;
  3032. else
  3033. for x in ${SPARC64_CPUS};
  3034. do
  3035. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3036. done;
  3037. fi;
  3038. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3039. for x in ${SPARC64_CPUS};
  3040. do
  3041. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3042. done;
  3043. else
  3044. for x in ${SPARC64_CPUS};
  3045. do
  3046. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3047. done;
  3048. fi;
  3049. export CFLAGS CXXFLAGS
  3050. }
  3051. run_in_build_dir ()
  3052. {
  3053. debug-print-function ${FUNCNAME} "${@}";
  3054. local ret;
  3055. [[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified.";
  3056. [[ -n ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set.";
  3057. mkdir -p "${BUILD_DIR}" || die;
  3058. pushd "${BUILD_DIR}" > /dev/null || die;
  3059. "${@}";
  3060. ret=${?};
  3061. popd > /dev/null || die;
  3062. return ${ret}
  3063. }
  3064. setup-allowed-flags ()
  3065. {
  3066. 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');
  3067. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  3068. 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)
  3069. }
  3070. src_compile ()
  3071. {
  3072. multilib-minimal_src_compile "$@"
  3073. }
  3074. src_configure ()
  3075. {
  3076. multilib-minimal_src_configure "$@"
  3077. }
  3078. src_install ()
  3079. {
  3080. multilib-minimal_src_install "$@"
  3081. }
  3082. src_prepare ()
  3083. {
  3084. default;
  3085. eautoreconf
  3086. }
  3087. src_test ()
  3088. {
  3089. multilib-minimal_src_test "$@"
  3090. }
  3091. src_unpack ()
  3092. {
  3093. default
  3094. }
  3095. strip-flags ()
  3096. {
  3097. local x y var;
  3098. local ALLOWED_FLAGS;
  3099. setup-allowed-flags;
  3100. set -f;
  3101. for var in $(all-flag-vars);
  3102. do
  3103. local new=();
  3104. for x in ${!var};
  3105. do
  3106. local flag=${x%%=*};
  3107. for y in "${ALLOWED_FLAGS[@]}";
  3108. do
  3109. if [[ -z ${flag%%${y}} ]]; then
  3110. new+=("${x}");
  3111. break;
  3112. fi;
  3113. done;
  3114. done;
  3115. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  3116. new+=(-O2);
  3117. fi;
  3118. if [[ ${!var} != "${new[*]}" ]]; then
  3119. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  3120. fi;
  3121. export ${var}="${new[*]}";
  3122. done;
  3123. set +f;
  3124. return 0
  3125. }
  3126. strip-linguas ()
  3127. {
  3128. local ls newls nols;
  3129. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  3130. local op=$1;
  3131. shift;
  3132. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  3133. shift;
  3134. local d f;
  3135. for d in "$@";
  3136. do
  3137. if [[ ${op} == "-u" ]]; then
  3138. newls=${ls};
  3139. else
  3140. newls="";
  3141. fi;
  3142. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  3143. do
  3144. if [[ ${op} == "-i" ]]; then
  3145. has ${f} ${ls} && newls="${newls} ${f}";
  3146. else
  3147. has ${f} ${ls} || newls="${newls} ${f}";
  3148. fi;
  3149. done;
  3150. ls=${newls};
  3151. done;
  3152. else
  3153. ls="$@";
  3154. fi;
  3155. nols="";
  3156. newls="";
  3157. for f in ${LINGUAS};
  3158. do
  3159. if has ${f} ${ls}; then
  3160. newls="${newls} ${f}";
  3161. else
  3162. nols="${nols} ${f}";
  3163. fi;
  3164. done;
  3165. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  3166. export LINGUAS=${newls:1}
  3167. }
  3168. strip-unsupported-flags ()
  3169. {
  3170. export CFLAGS=$(test-flags-CC ${CFLAGS});
  3171. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3172. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3173. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  3174. export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  3175. }
  3176. tc-arch ()
  3177. {
  3178. tc-ninja_magic_to_arch portage "$@"
  3179. }
  3180. tc-arch-kernel ()
  3181. {
  3182. tc-ninja_magic_to_arch kern "$@"
  3183. }
  3184. tc-check-openmp ()
  3185. {
  3186. if ! tc-has-openmp; then
  3187. eerror "Your current compiler does not support OpenMP!";
  3188. if tc-is-gcc; then
  3189. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  3190. else
  3191. if tc-is-clang; then
  3192. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  3193. fi;
  3194. fi;
  3195. die "Active compiler does not have required support for OpenMP";
  3196. fi
  3197. }
  3198. tc-cpp-is-true ()
  3199. {
  3200. local CONDITION=${1};
  3201. shift;
  3202. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  3203. #if ${CONDITION}
  3204. true
  3205. #endif
  3206. EOF
  3207. );
  3208. [[ ${RESULT} == true ]]
  3209. }
  3210. tc-detect-is-softfloat ()
  3211. {
  3212. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  3213. case ${CTARGET:-${CHOST}} in
  3214. *-newlib | *-elf | *-eabi)
  3215. return 1
  3216. ;;
  3217. arm*)
  3218. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  3219. echo "no";
  3220. else
  3221. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  3222. echo "yes";
  3223. else
  3224. echo "softfp";
  3225. fi;
  3226. fi;
  3227. return 0
  3228. ;;
  3229. *)
  3230. return 1
  3231. ;;
  3232. esac
  3233. }
  3234. tc-enables-pie ()
  3235. {
  3236. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  3237. }
  3238. tc-enables-ssp ()
  3239. {
  3240. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3241. }
  3242. tc-enables-ssp-all ()
  3243. {
  3244. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3245. }
  3246. tc-enables-ssp-strong ()
  3247. {
  3248. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  3249. }
  3250. tc-endian ()
  3251. {
  3252. local host=$1;
  3253. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3254. host=${host%%-*};
  3255. case ${host} in
  3256. aarch64*be)
  3257. echo big
  3258. ;;
  3259. aarch64)
  3260. echo little
  3261. ;;
  3262. alpha*)
  3263. echo little
  3264. ;;
  3265. arm*b*)
  3266. echo big
  3267. ;;
  3268. arm*)
  3269. echo little
  3270. ;;
  3271. cris*)
  3272. echo little
  3273. ;;
  3274. hppa*)
  3275. echo big
  3276. ;;
  3277. i?86*)
  3278. echo little
  3279. ;;
  3280. ia64*)
  3281. echo little
  3282. ;;
  3283. m68*)
  3284. echo big
  3285. ;;
  3286. mips*l*)
  3287. echo little
  3288. ;;
  3289. mips*)
  3290. echo big
  3291. ;;
  3292. powerpc*le)
  3293. echo little
  3294. ;;
  3295. powerpc*)
  3296. echo big
  3297. ;;
  3298. s390*)
  3299. echo big
  3300. ;;
  3301. sh*b*)
  3302. echo big
  3303. ;;
  3304. sh*)
  3305. echo little
  3306. ;;
  3307. sparc*)
  3308. echo big
  3309. ;;
  3310. x86_64*)
  3311. echo little
  3312. ;;
  3313. *)
  3314. echo wtf
  3315. ;;
  3316. esac
  3317. }
  3318. tc-env_build ()
  3319. {
  3320. tc-export_build_env;
  3321. 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) "$@"
  3322. }
  3323. tc-export ()
  3324. {
  3325. local var;
  3326. for var in "$@";
  3327. do
  3328. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3329. "tc-get${var}" > /dev/null;
  3330. done
  3331. }
  3332. tc-export_build_env ()
  3333. {
  3334. tc-export "$@";
  3335. if tc-is-cross-compiler; then
  3336. : ${BUILD_CFLAGS:=-O1 -pipe};
  3337. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  3338. : ${BUILD_CPPFLAGS:= };
  3339. : ${BUILD_LDFLAGS:= };
  3340. else
  3341. : ${BUILD_CFLAGS:=${CFLAGS}};
  3342. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  3343. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  3344. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  3345. fi;
  3346. export BUILD_{C,CXX,CPP,LD}FLAGS;
  3347. local v;
  3348. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  3349. do
  3350. export ${v#BUILD_}_FOR_BUILD="${!v}";
  3351. done
  3352. }
  3353. tc-get-compiler-type ()
  3354. {
  3355. local code='
  3356. #if defined(__PATHSCALE__)
  3357. HAVE_PATHCC
  3358. #elif defined(__clang__)
  3359. HAVE_CLANG
  3360. #elif defined(__GNUC__)
  3361. HAVE_GCC
  3362. #endif
  3363. ';
  3364. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  3365. case ${res} in
  3366. *HAVE_PATHCC*)
  3367. echo pathcc
  3368. ;;
  3369. *HAVE_CLANG*)
  3370. echo clang
  3371. ;;
  3372. *HAVE_GCC*)
  3373. echo gcc
  3374. ;;
  3375. *)
  3376. echo unknown
  3377. ;;
  3378. esac
  3379. }
  3380. tc-getAR ()
  3381. {
  3382. tc-getPROG AR ar "$@"
  3383. }
  3384. tc-getAS ()
  3385. {
  3386. tc-getPROG AS as "$@"
  3387. }
  3388. tc-getBUILD_AR ()
  3389. {
  3390. tc-getBUILD_PROG AR ar "$@"
  3391. }
  3392. tc-getBUILD_AS ()
  3393. {
  3394. tc-getBUILD_PROG AS as "$@"
  3395. }
  3396. tc-getBUILD_CC ()
  3397. {
  3398. tc-getBUILD_PROG CC gcc "$@"
  3399. }
  3400. tc-getBUILD_CPP ()
  3401. {
  3402. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  3403. }
  3404. tc-getBUILD_CXX ()
  3405. {
  3406. tc-getBUILD_PROG CXX g++ "$@"
  3407. }
  3408. tc-getBUILD_LD ()
  3409. {
  3410. tc-getBUILD_PROG LD ld "$@"
  3411. }
  3412. tc-getBUILD_NM ()
  3413. {
  3414. tc-getBUILD_PROG NM nm "$@"
  3415. }
  3416. tc-getBUILD_OBJCOPY ()
  3417. {
  3418. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3419. }
  3420. tc-getBUILD_PKG_CONFIG ()
  3421. {
  3422. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3423. }
  3424. tc-getBUILD_PROG ()
  3425. {
  3426. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  3427. tc-is-cross-compiler || vars+=" $1";
  3428. _tc-getPROG CBUILD "${vars}" "${@:2}"
  3429. }
  3430. tc-getBUILD_RANLIB ()
  3431. {
  3432. tc-getBUILD_PROG RANLIB ranlib "$@"
  3433. }
  3434. tc-getBUILD_STRIP ()
  3435. {
  3436. tc-getBUILD_PROG STRIP strip "$@"
  3437. }
  3438. tc-getCC ()
  3439. {
  3440. tc-getPROG CC gcc "$@"
  3441. }
  3442. tc-getCPP ()
  3443. {
  3444. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  3445. }
  3446. tc-getCXX ()
  3447. {
  3448. tc-getPROG CXX g++ "$@"
  3449. }
  3450. tc-getDLLWRAP ()
  3451. {
  3452. tc-getPROG DLLWRAP dllwrap "$@"
  3453. }
  3454. tc-getF77 ()
  3455. {
  3456. tc-getPROG F77 gfortran "$@"
  3457. }
  3458. tc-getFC ()
  3459. {
  3460. tc-getPROG FC gfortran "$@"
  3461. }
  3462. tc-getGCJ ()
  3463. {
  3464. tc-getPROG GCJ gcj "$@"
  3465. }
  3466. tc-getGO ()
  3467. {
  3468. tc-getPROG GO gccgo "$@"
  3469. }
  3470. tc-getLD ()
  3471. {
  3472. tc-getPROG LD ld "$@"
  3473. }
  3474. tc-getNM ()
  3475. {
  3476. tc-getPROG NM nm "$@"
  3477. }
  3478. tc-getOBJCOPY ()
  3479. {
  3480. tc-getPROG OBJCOPY objcopy "$@"
  3481. }
  3482. tc-getOBJDUMP ()
  3483. {
  3484. tc-getPROG OBJDUMP objdump "$@"
  3485. }
  3486. tc-getPKG_CONFIG ()
  3487. {
  3488. tc-getPROG PKG_CONFIG pkg-config "$@"
  3489. }
  3490. tc-getPROG ()
  3491. {
  3492. _tc-getPROG CHOST "$@"
  3493. }
  3494. tc-getRANLIB ()
  3495. {
  3496. tc-getPROG RANLIB ranlib "$@"
  3497. }
  3498. tc-getRC ()
  3499. {
  3500. tc-getPROG RC windres "$@"
  3501. }
  3502. tc-getSTRIP ()
  3503. {
  3504. tc-getPROG STRIP strip "$@"
  3505. }
  3506. tc-getTARGET_CPP ()
  3507. {
  3508. if [[ -n ${CTARGET} ]]; then
  3509. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  3510. else
  3511. tc-getCPP "$@";
  3512. fi
  3513. }
  3514. tc-has-openmp ()
  3515. {
  3516. local base="${T}/test-tc-openmp";
  3517. cat > "${base}.c" <<-EOF
  3518. #include <omp.h>
  3519. int main() {
  3520. int nthreads, tid, ret = 0;
  3521. #pragma omp parallel private(nthreads, tid)
  3522. {
  3523. tid = omp_get_thread_num();
  3524. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3525. }
  3526. return ret;
  3527. }
  3528. EOF
  3529. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  3530. local ret=$?;
  3531. rm -f "${base}"*;
  3532. return ${ret}
  3533. }
  3534. tc-has-tls ()
  3535. {
  3536. local base="${T}/test-tc-tls";
  3537. cat > "${base}.c" <<-EOF
  3538. int foo(int *i) {
  3539. static __thread int j = 0;
  3540. return *i ? j : *i;
  3541. }
  3542. EOF
  3543. local flags;
  3544. case $1 in
  3545. -s)
  3546. flags="-S"
  3547. ;;
  3548. -c)
  3549. flags="-c"
  3550. ;;
  3551. -l)
  3552. ;;
  3553. -*)
  3554. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3555. ;;
  3556. esac;
  3557. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3558. [[ $1 == -* ]] && shift;
  3559. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  3560. local ret=$?;
  3561. rm -f "${base}"*;
  3562. return ${ret}
  3563. }
  3564. tc-is-clang ()
  3565. {
  3566. [[ $(tc-get-compiler-type) == clang ]]
  3567. }
  3568. tc-is-cross-compiler ()
  3569. {
  3570. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  3571. }
  3572. tc-is-gcc ()
  3573. {
  3574. [[ $(tc-get-compiler-type) == gcc ]]
  3575. }
  3576. tc-is-softfloat ()
  3577. {
  3578. tc-detect-is-softfloat || tc-tuple-is-softfloat
  3579. }
  3580. tc-is-static-only ()
  3581. {
  3582. local host=${CTARGET:-${CHOST}};
  3583. [[ ${host} == *-mint* ]]
  3584. }
  3585. tc-ld-disable-gold ()
  3586. {
  3587. if ! tc-ld-is-gold "$@"; then
  3588. return;
  3589. fi;
  3590. ewarn "Forcing usage of the BFD linker instead of GOLD";
  3591. local ld=$(tc-getLD "$@");
  3592. local bfd_ld="${ld%% *}.bfd";
  3593. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  3594. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  3595. local fallback="true";
  3596. if tc-is-gcc; then
  3597. local major=$(gcc-major-version "$@");
  3598. local minor=$(gcc-minor-version "$@");
  3599. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  3600. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3601. fallback="false";
  3602. fi;
  3603. else
  3604. if tc-is-clang; then
  3605. local major=$(clang-major-version "$@");
  3606. local minor=$(clang-minor-version "$@");
  3607. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  3608. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3609. fallback="false";
  3610. fi;
  3611. fi;
  3612. fi;
  3613. if [[ ${fallback} == "true" ]]; then
  3614. if [[ -e ${path_ld} ]]; then
  3615. local d="${T}/bfd-linker";
  3616. mkdir -p "${d}";
  3617. ln -sf "${path_ld}" "${d}"/ld;
  3618. export LDFLAGS="${LDFLAGS} -B${d}";
  3619. else
  3620. die "unable to locate a BFD linker to bypass gold";
  3621. fi;
  3622. fi
  3623. }
  3624. tc-ld-is-gold ()
  3625. {
  3626. local out;
  3627. out=$($(tc-getLD "$@") --version 2>&1);
  3628. if [[ ${out} == *"GNU gold"* ]]; then
  3629. return 0;
  3630. fi;
  3631. local base="${T}/test-tc-gold";
  3632. cat > "${base}.c" <<-EOF
  3633. int main() { return 0; }
  3634. EOF
  3635. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3636. rm -f "${base}"*;
  3637. if [[ ${out} == *"GNU gold"* ]]; then
  3638. return 0;
  3639. fi;
  3640. return 1
  3641. }
  3642. tc-ninja_magic_to_arch ()
  3643. {
  3644. function ninj ()
  3645. {
  3646. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3647. };
  3648. local type=$1;
  3649. local host=$2;
  3650. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3651. case ${host} in
  3652. aarch64*)
  3653. echo arm64
  3654. ;;
  3655. alpha*)
  3656. echo alpha
  3657. ;;
  3658. arm*)
  3659. echo arm
  3660. ;;
  3661. avr*)
  3662. ninj avr32 avr
  3663. ;;
  3664. bfin*)
  3665. ninj blackfin bfin
  3666. ;;
  3667. c6x*)
  3668. echo c6x
  3669. ;;
  3670. cris*)
  3671. echo cris
  3672. ;;
  3673. frv*)
  3674. echo frv
  3675. ;;
  3676. hexagon*)
  3677. echo hexagon
  3678. ;;
  3679. hppa*)
  3680. ninj parisc hppa
  3681. ;;
  3682. i?86*)
  3683. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  3684. echo i386;
  3685. else
  3686. echo x86;
  3687. fi
  3688. ;;
  3689. ia64*)
  3690. echo ia64
  3691. ;;
  3692. m68*)
  3693. echo m68k
  3694. ;;
  3695. metag*)
  3696. echo metag
  3697. ;;
  3698. microblaze*)
  3699. echo microblaze
  3700. ;;
  3701. mips*)
  3702. echo mips
  3703. ;;
  3704. nios2*)
  3705. echo nios2
  3706. ;;
  3707. nios*)
  3708. echo nios
  3709. ;;
  3710. or1k | or32*)
  3711. echo openrisc
  3712. ;;
  3713. powerpc*)
  3714. if [[ ${type} == "kern" ]]; then
  3715. echo powerpc;
  3716. else
  3717. if [[ ${host} == powerpc64* ]]; then
  3718. echo ppc64;
  3719. else
  3720. echo ppc;
  3721. fi;
  3722. fi
  3723. ;;
  3724. riscv*)
  3725. echo riscv
  3726. ;;
  3727. s390*)
  3728. echo s390
  3729. ;;
  3730. score*)
  3731. echo score
  3732. ;;
  3733. sh64*)
  3734. ninj sh64 sh
  3735. ;;
  3736. sh*)
  3737. echo sh
  3738. ;;
  3739. sparc64*)
  3740. ninj sparc64 sparc
  3741. ;;
  3742. sparc*)
  3743. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3744. ;;
  3745. tile*)
  3746. echo tile
  3747. ;;
  3748. vax*)
  3749. echo vax
  3750. ;;
  3751. x86_64*freebsd*)
  3752. echo amd64
  3753. ;;
  3754. x86_64*)
  3755. if [[ ${type} == "kern" ]]; then
  3756. echo x86;
  3757. else
  3758. echo amd64;
  3759. fi
  3760. ;;
  3761. xtensa*)
  3762. echo xtensa
  3763. ;;
  3764. *)
  3765. echo unknown
  3766. ;;
  3767. esac
  3768. }
  3769. tc-stack-grows-down ()
  3770. {
  3771. case ${ARCH} in
  3772. hppa | metag)
  3773. return 1
  3774. ;;
  3775. esac;
  3776. return 0
  3777. }
  3778. tc-tuple-is-softfloat ()
  3779. {
  3780. local CTARGET=${CTARGET:-${CHOST}};
  3781. case ${CTARGET//_/-} in
  3782. bfin* | h8300*)
  3783. echo "only"
  3784. ;;
  3785. *-softfloat-*)
  3786. echo "yes"
  3787. ;;
  3788. *-softfp-*)
  3789. echo "softfp"
  3790. ;;
  3791. arm*-hardfloat-* | arm*eabihf)
  3792. echo "no"
  3793. ;;
  3794. *-newlib | *-elf | *-eabi)
  3795. echo "no"
  3796. ;;
  3797. arm*)
  3798. echo "yes"
  3799. ;;
  3800. *)
  3801. echo "no"
  3802. ;;
  3803. esac
  3804. }
  3805. test-flag-CC ()
  3806. {
  3807. test-flag-PROG "CC" c "$@"
  3808. }
  3809. test-flag-CXX ()
  3810. {
  3811. test-flag-PROG "CXX" c++ "$@"
  3812. }
  3813. test-flag-F77 ()
  3814. {
  3815. test-flag-PROG "F77" f77 "$@"
  3816. }
  3817. test-flag-FC ()
  3818. {
  3819. test-flag-PROG "FC" f95 "$@"
  3820. }
  3821. test-flag-PROG ()
  3822. {
  3823. local comp=$1;
  3824. local lang=$2;
  3825. shift 2;
  3826. [[ -z ${comp} || -z $1 ]] && return 1;
  3827. local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  3828. if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  3829. cmdline+=("$@" -x${lang} -);
  3830. else
  3831. cmdline+=("$@" -c -o /dev/null /dev/null);
  3832. fi;
  3833. if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  3834. cmdline+=(-Qunused-arguments);
  3835. "${cmdline[@]}" < /dev/null &> /dev/null;
  3836. fi
  3837. }
  3838. test-flags ()
  3839. {
  3840. test-flags-CC "$@"
  3841. }
  3842. test-flags-CC ()
  3843. {
  3844. test-flags-PROG "CC" "$@"
  3845. }
  3846. test-flags-CXX ()
  3847. {
  3848. test-flags-PROG "CXX" "$@"
  3849. }
  3850. test-flags-F77 ()
  3851. {
  3852. test-flags-PROG "F77" "$@"
  3853. }
  3854. test-flags-FC ()
  3855. {
  3856. test-flags-PROG "FC" "$@"
  3857. }
  3858. test-flags-PROG ()
  3859. {
  3860. local comp=$1;
  3861. local flags=();
  3862. local x;
  3863. shift;
  3864. [[ -z ${comp} ]] && return 1;
  3865. while (( $# )); do
  3866. case "$1" in
  3867. --param)
  3868. if test-flag-${comp} "$1" "$2"; then
  3869. flags+=("$1" "$2");
  3870. fi;
  3871. shift 2
  3872. ;;
  3873. *)
  3874. if test-flag-${comp} "$1"; then
  3875. flags+=("$1");
  3876. fi;
  3877. shift 1
  3878. ;;
  3879. esac;
  3880. done;
  3881. echo "${flags[*]}";
  3882. [[ ${#flags[@]} -gt 0 ]]
  3883. }
  3884. test_version_info ()
  3885. {
  3886. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  3887. return 0;
  3888. else
  3889. return 1;
  3890. fi
  3891. }
  3892. uclibctoolize ()
  3893. {
  3894. die "Use elibtoolize"
  3895. }
  3896. use_if_iuse ()
  3897. {
  3898. in_iuse $1 || return 1;
  3899. use $1
  3900. }
  3901.