spacepaste

  1.  
  2. declare -x ABI="arm64"
  3. declare -x ABI_MIPS=""
  4. declare -x ABI_PPC=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86=""
  7. declare -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="arm64"
  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="virtual/pkgconfig "
  20. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  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="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error -ggdb "
  30. declare -x CFLAGS_default
  31. declare -x CHOST="aarch64-unknown-linux-gnu"
  32. declare -x CHOST_arm64="aarch64-unknown-linux-gnu"
  33. declare -x CHOST_default="aarch64-unknown-linux-gnu"
  34. declare -x COLLECTD_PLUGINS=""
  35. declare -x CPU_FLAGS_ARM=""
  36. declare -x CPU_FLAGS_X86=""
  37. declare -x CTARGET_default="aarch64-unknown-linux-gnu"
  38. declare -x CURL_SSL=""
  39. declare -x CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error -ggdb "
  40. declare -x DCC_EMAILLOG_WHOM_TO_BLAME=""
  41. declare -x DEFAULT_ABI="arm64"
  42. declare -x DEFINED_PHASES=" compile configure install postinst prepare test"
  43. declare DEPEND="app-text/docbook-xml-dtd:4.3
  44. app-text/docbook-xml-dtd:4.4
  45. app-text/docbook-xml-dtd:4.5
  46. nls? ( sys-devel/gettext ) >=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 filecaps? ( sys-libs/libcap )"
  50. declare DESCRIPTION="Linux-PAM (Pluggable Authentication Modules)"
  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 -x EVCS_OFFLINE="1"
  58. declare -x EXEOPTIONS="-m0755"
  59. declare -x FCFLAGS="-O2"
  60. 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}\""
  61. declare -x FFLAGS="-O2"
  62. declare -x FFTOOLS=""
  63. declare -x GCC_SPECS=""
  64. declare -x GENTOO_WS="/home/necktwi/Workspace/Gentoo/"
  65. declare -x GPSD_PROTOCOLS=""
  66. declare -x GRUB_PLATFORMS=""
  67. declare HDEPEND=""
  68. declare HOMEPAGE="https://github.com/linux-pam/linux-pam"
  69. declare -x HOSTCC="x86_64-pc-linux-gnu-gcc"
  70. declare -x INHERITED=" toolchain-funcs multilib libtool autotools eapi7-ver db-use fcaps multibuild multilib-build multilib-minimal"
  71. declare -x INPUT_DEVICES=""
  72. declare -x INSDESTTREE=""
  73. declare -x INSOPTIONS="-m0644"
  74. declare IUSE="audit berkdb +cracklib debug nis nls +pie selinux static-libs +filecaps 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"
  75. 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 audit berkdb cracklib debug 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 filecaps 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 nis nls pie ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest s390 selinux 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"
  76. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  77. declare -x KERNEL="linux"
  78. declare -x KERNEL_ABI="arm64"
  79. declare -x KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
  80. declare -x L10N=""
  81. declare -x LANG="en_US.utf8"
  82. declare -x LCD_DEVICES=""
  83. declare -x LC_COLLATE="C"
  84. declare -x LC_CTYPE="en_US.utf8"
  85. declare -x LC_MESSAGES="C"
  86. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  87. declare -x LDFLAGS_default
  88. declare -x LIBDIR_arm64="lib64"
  89. declare -x LIBDIR_default="lib"
  90. declare -x LIBOPTIONS="-m0644"
  91. declare -x LIBREOFFICE_EXTENSIONS=""
  92. declare -x LICENSE="|| ( BSD GPL-2 )"
  93. declare -x LIRC_DEVICES=""
  94. declare -x LLVM_TARGETS=""
  95. declare -x MAIL="/var/mail/necktwi"
  96. declare -x MAKEOPTS="-j5"
  97. declare -x MANPAGER="manpager"
  98. declare -x MONKEYD_PLUGINS=""
  99. declare -x MULTILIB_ABIS="arm64"
  100. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  101. declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
  102. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  103. 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(-)?"
  104. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  105. declare -x NETBEANS_MODULES=""
  106. declare -x NGINX_MODULES_HTTP=""
  107. declare -x NGINX_MODULES_MAIL=""
  108. declare -x NGINX_MODULES_STREAM=""
  109. declare -x OFED_DRIVERS=""
  110. declare -x OFFICE_IMPLEMENTATION=""
  111. declare -x OPENGL_PROFILE="xorg-x11"
  112. declare -x OPENMPI_FABRICS=""
  113. declare -x OPENMPI_OFED_FEATURES=""
  114. declare -x OPENMPI_RM=""
  115. declare -x PATH="/usr/lib64/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"
  116. declare PDEPEND="sys-auth/pambase "
  117. declare -x PHP_TARGETS=""
  118. declare -x PKG_CONFIG_PATH="/usr/aarch64-unknown-linux-gnu/usr/lib/pkgconfig/"
  119. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  120. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  121. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  122. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/pam-1.3.1/html")
  123. declare -a PORTAGE_DOSTRIP=([0]="/")
  124. declare -a PORTAGE_DOSTRIP_SKIP=()
  125. declare -x POSTGRES_TARGETS=""
  126. 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"
  127. declare -x PROPERTIES=""
  128. declare -x PYTHONDONTWRITEBYTECODE="1"
  129. declare -x PYTHON_SINGLE_TARGET=""
  130. declare -x PYTHON_TARGETS=""
  131. declare -x QEMU_SOFTMMU_TARGETS=""
  132. declare -x QEMU_USER_TARGETS=""
  133. declare RDEPEND="app-text/docbook-xml-dtd:4.3
  134. app-text/docbook-xml-dtd:4.4
  135. app-text/docbook-xml-dtd:4.5
  136. nls? ( sys-devel/gettext )
  137. audit? ( >=sys-process/audit-2.2.2[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(-)?] )
  138. berkdb? ( >=sys-libs/db-4.8.30-r1:=[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(-)?] )
  139. cracklib? ( >=sys-libs/cracklib-2.9.1-r1[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(-)?] )
  140. selinux? ( >=sys-libs/libselinux-2.2.2-r4[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(-)?] )
  141. nis? ( >=net-libs/libtirpc-0.2.4-r2[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(-)?] )
  142. nls? ( >=virtual/libintl-0-r1[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(-)?] )
  143. !<sys-apps/openrc-0.11.8
  144. !sys-auth/openpam
  145. !sys-auth/pam_userdb "
  146. declare REPOSITORY
  147. declare REQUIRED_USE=""
  148. declare -x RESTRICT=""
  149. 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}\""
  150. declare -x ROS_MESSAGES=""
  151. declare -x RUBY_TARGETS=""
  152. declare -x S="/usr/aarch64-unknown-linux-gnu/tmp/portage/sys-libs/pam-1.3.1/work/linux-pam-1.3.1"
  153. declare -x SANDBOX_DEBUG="0"
  154. declare -x SANDBOX_DENY=""
  155. declare -x SANDBOX_PREDICT="/usr/aarch64-unknown-linux-gnu/tmp/portage/sys-libs/pam-1.3.1/homedir"
  156. declare -x SANDBOX_READ="/:/usr/aarch64-unknown-linux-gnu/tmp:/var/CCache"
  157. declare -x SANDBOX_VERBOSE="1"
  158. 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/aarch64-unknown-linux-gnu/tmp:/usr/aarch64-unknown-linux-gnu/tmp/portage/sys-libs/pam-1.3.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/"
  159. declare -x SANE_BACKENDS=""
  160. declare -x SHELL="/bin/bash"
  161. declare -x SLOT="0"
  162. declare SRC_URI="https://github.com/linux-pam/linux-pam/archive/v1.3.1.tar.gz -> pam-1.3.1.tar.gz"
  163. declare -x SSH_CLIENT="192.168.2.21 61325 22"
  164. declare -x SSH_CONNECTION="192.168.2.21 61325 192.168.2.28 22"
  165. declare -x SSH_TTY="/dev/pts/0"
  166. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  167. declare -x UNCACHED_ERR_FD=""
  168. declare -x USE="arm64 berkdb cracklib elibc_glibc filecaps kernel_linux nls pie userland_GNU"
  169. declare -x USERLAND="GNU"
  170. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  171. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  172. 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"
  173. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  174. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  175. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  176. declare -x UWSGI_PLUGINS=""
  177. declare -x VIDEO_CARDS=""
  178. declare -x VISUAL="emacs"
  179. declare -x VOICEMAIL_STORAGE=""
  180. declare -x WANT_AUTOCONF="2.5"
  181. declare -x WANT_AUTOMAKE="1.16"
  182. declare -x WANT_LIBTOOL="latest"
  183. declare -x XFCE_PLUGINS=""
  184. declare -x XTABLES_ADDONS=""
  185. declare -- _AUTOTOOLS_ECLASS="1"
  186. declare -x _E_DOCDESTTREE_=""
  187. declare -x _E_EXEDESTTREE_=""
  188. declare -- _FCAPS_ECLASS="1"
  189. declare -a _LATEST_AUTOMAKE=([0]="1.16.1:1.16" [1]="1.15.1:1.15")
  190. declare -- _LIBTOOL_ECLASS="1"
  191. declare -- _MULTIBUILD="1"
  192. declare -- _MULTILIB_BUILD="1"
  193. declare -- _MULTILIB_ECLASS="1"
  194. 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")
  195. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  196. declare -- __AUTOTOOLS_AUTO_DEPEND="yes"
  197. declare -- _libtool_atom=">=sys-devel/libtool-2.4"
  198. declare -x ac_cv_header_xcrypt_h="no"
  199. declare -- phase_func
  200. declare -- started_applying="1"
  201. __eapi6_src_install ()
  202. {
  203. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  204. emake DESTDIR="${D}" install;
  205. fi;
  206. einstalldocs
  207. }
  208. __eapi6_src_prepare ()
  209. {
  210. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  211. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  212. else
  213. if [[ -n ${PATCHES} ]]; then
  214. eapply ${PATCHES};
  215. fi;
  216. fi;
  217. eapply_user
  218. }
  219. _at_uses_autoheader ()
  220. {
  221. _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  222. }
  223. _at_uses_automake ()
  224. {
  225. _at_uses_pkg AM_INIT_AUTOMAKE
  226. }
  227. _at_uses_gettext ()
  228. {
  229. _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  230. }
  231. _at_uses_glibgettext ()
  232. {
  233. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  234. }
  235. _at_uses_gnomedoc ()
  236. {
  237. _at_uses_pkg GNOME_DOC_INIT
  238. }
  239. _at_uses_gtkdoc ()
  240. {
  241. _at_uses_pkg GTK_DOC_CHECK
  242. }
  243. _at_uses_intltool ()
  244. {
  245. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  246. }
  247. _at_uses_libltdl ()
  248. {
  249. _at_uses_pkg LT_CONFIG_LTDL_DIR
  250. }
  251. _at_uses_libtool ()
  252. {
  253. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  254. }
  255. _at_uses_pkg ()
  256. {
  257. if [[ -n $(autotools_check_macro "$@") ]]; then
  258. return 0;
  259. else
  260. local macro args=();
  261. for macro in "$@";
  262. do
  263. args+=(-e "^[[:space:]]*${macro}\>");
  264. done;
  265. egrep -q "${args[@]}" configure.??;
  266. fi
  267. }
  268. _automake_version ()
  269. {
  270. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  271. }
  272. _autotools_m4dir_include ()
  273. {
  274. local x include_opts flag;
  275. [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  276. for x in "$@";
  277. do
  278. case ${x} in
  279. -${flag})
  280. ;;
  281. *)
  282. [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  283. include_opts+=" -${flag} ${x}"
  284. ;;
  285. esac;
  286. done;
  287. echo ${include_opts}
  288. }
  289. _clang_fullversion ()
  290. {
  291. local ver="$1";
  292. shift;
  293. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  294. eval echo "$ver"
  295. }
  296. _eapply_patch ()
  297. {
  298. local f=${1};
  299. local prefix=${2};
  300. started_applying=1;
  301. ebegin "${prefix:-Applying }${f##*/}";
  302. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  303. failed=${?};
  304. if ! eend "${failed}"; then
  305. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  306. fi
  307. }
  308. _elibtoolize ()
  309. {
  310. local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  311. if [[ $1 == "--auto-ltdl" ]]; then
  312. shift;
  313. _at_uses_libltdl && set -- "$@" --ltdl;
  314. fi;
  315. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  316. autotools_run_tool ${LIBTOOLIZE} "$@"
  317. }
  318. _gcc-install-dir ()
  319. {
  320. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  321. }
  322. _gcc-specs-directive_raw ()
  323. {
  324. local cc=$(tc-getCC);
  325. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  326. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  327. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  328. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  329. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  330. { spec=spec $0 }
  331. END { print spec }';
  332. return 0
  333. }
  334. _gcc-specs-exists ()
  335. {
  336. [[ -f $(_gcc-install-dir)/$1 ]]
  337. }
  338. _gcc_fullversion ()
  339. {
  340. local ver="$1";
  341. shift;
  342. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  343. eval echo "$ver"
  344. }
  345. _multibuild_run ()
  346. {
  347. local i=1;
  348. while [[ ${!i} == _* ]]; do
  349. (( i += 1 ));
  350. done;
  351. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  352. "${@}"
  353. }
  354. _multilib_multibuild_wrapper ()
  355. {
  356. debug-print-function ${FUNCNAME} "${@}";
  357. local ABI=${MULTIBUILD_VARIANT#*.};
  358. local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  359. multilib_toolchain_setup "${ABI}";
  360. readonly ABI;
  361. "${@}"
  362. }
  363. _tc-getPROG ()
  364. {
  365. local tuple=$1;
  366. local v var vars=$2;
  367. local prog=($3);
  368. var=${vars%% *};
  369. for v in ${vars};
  370. do
  371. if [[ -n ${!v} ]]; then
  372. export ${var}="${!v}";
  373. echo "${!v}";
  374. return 0;
  375. fi;
  376. done;
  377. local search=;
  378. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  379. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  380. [[ -n ${search} ]] && prog[0]=${search##*/};
  381. export ${var}="${prog[*]}";
  382. echo "${!var}"
  383. }
  384. _ver_compare ()
  385. {
  386. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  387. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  388. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  389. an=${BASH_REMATCH[1]};
  390. al=${BASH_REMATCH[3]};
  391. as=${BASH_REMATCH[4]};
  392. ar=${BASH_REMATCH[7]};
  393. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  394. bn=${BASH_REMATCH[1]};
  395. bl=${BASH_REMATCH[3]};
  396. bs=${BASH_REMATCH[4]};
  397. br=${BASH_REMATCH[7]};
  398. _ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  399. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  400. an=${an#*.};
  401. bn=${bn#*.};
  402. a=${an%%.*};
  403. b=${bn%%.*};
  404. if [[ ${a} == 0* || ${b} == 0* ]]; then
  405. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  406. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  407. [[ ${a} > ${b} ]] && return 3;
  408. [[ ${a} < ${b} ]] && return 1;
  409. else
  410. _ver_compare_int "${a}" "${b}" || return;
  411. fi;
  412. done;
  413. [[ ${an} == *.* ]] && return 3;
  414. [[ ${bn} == *.* ]] && return 1;
  415. [[ ${al} > ${bl} ]] && return 3;
  416. [[ ${al} < ${bl} ]] && return 1;
  417. as=${as#_}${as:+_};
  418. bs=${bs#_}${bs:+_};
  419. while [[ -n ${as} && -n ${bs} ]]; do
  420. a=${as%%_*};
  421. b=${bs%%_*};
  422. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  423. _ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  424. else
  425. [[ ${a%%[0-9]*} == p ]] && return 3;
  426. [[ ${b%%[0-9]*} == p ]] && return 1;
  427. [[ ${a} > ${b} ]] && return 3 || return 1;
  428. fi;
  429. as=${as#*_};
  430. bs=${bs#*_};
  431. done;
  432. if [[ -n ${as} ]]; then
  433. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  434. else
  435. if [[ -n ${bs} ]]; then
  436. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  437. fi;
  438. fi;
  439. _ver_compare_int "${ar#-r}" "${br#-r}" || return;
  440. return 2
  441. }
  442. _ver_compare_int ()
  443. {
  444. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  445. if [[ ${d} -gt 0 ]]; then
  446. printf -v b "%0${d}d%s" 0 "${b}";
  447. else
  448. if [[ ${d} -lt 0 ]]; then
  449. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  450. fi;
  451. fi;
  452. [[ ${a} > ${b} ]] && return 3;
  453. [[ ${a} == "${b}" ]]
  454. }
  455. _ver_parse_range ()
  456. {
  457. local range=${1};
  458. local max=${2};
  459. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  460. start=${range%-*};
  461. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  462. if [[ -n ${end} ]]; then
  463. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  464. [[ ${end} -le ${max} ]] || end=${max};
  465. else
  466. end=${max};
  467. fi
  468. }
  469. _ver_split ()
  470. {
  471. local v=${1} LC_ALL=C;
  472. comp=();
  473. local s c;
  474. while [[ -n ${v} ]]; do
  475. s=${v%%[a-zA-Z0-9]*};
  476. v=${v:${#s}};
  477. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  478. v=${v:${#c}};
  479. comp+=("${s}" "${c}");
  480. done
  481. }
  482. autotools_check_macro ()
  483. {
  484. [[ -f configure.ac || -f configure.in ]] || return 0;
  485. local trace_file=".__autoconf_trace_data";
  486. if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  487. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  488. fi;
  489. local macro args=();
  490. for macro in "$@";
  491. do
  492. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  493. args+=(-e ":${macro}:");
  494. done;
  495. grep "${args[@]}" ${trace_file}
  496. }
  497. autotools_check_macro_val ()
  498. {
  499. local macro scan_out;
  500. for macro in "$@";
  501. do
  502. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  503. if (match($0, macro ":(.*)$", res))
  504. print res[1]
  505. }' | uniq;
  506. done;
  507. return 0
  508. }
  509. autotools_env_setup ()
  510. {
  511. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  512. local pv;
  513. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  514. do
  515. local hv_args="";
  516. case ${EAPI:-0} in
  517. 5 | 6)
  518. hv_args="--host-root"
  519. ;;
  520. 7)
  521. hv_args="-b"
  522. ;;
  523. esac;
  524. ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break;
  525. done;
  526. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  527. fi;
  528. [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  529. }
  530. autotools_m4dir_include ()
  531. {
  532. _autotools_m4dir_include ${AT_M4DIR}
  533. }
  534. autotools_m4sysdir_include ()
  535. {
  536. local paths=($(eval echo ${AT_SYS_M4DIR}));
  537. if [[ ${#paths[@]} -eq 0 && -n ${SYSROOT} ]]; then
  538. local path="${SYSROOT}/usr/share/aclocal";
  539. [[ -d ${path} ]] && paths+=("${path}");
  540. fi;
  541. _autotools_m4dir_include "${paths[@]}"
  542. }
  543. autotools_run_tool ()
  544. {
  545. local autofail=true m4flags=false missing_ok=false return_output=false;
  546. while [[ -n $1 ]]; do
  547. case $1 in
  548. --at-no-fail)
  549. autofail=false
  550. ;;
  551. --at-m4flags)
  552. m4flags=true
  553. ;;
  554. --at-missing)
  555. missing_ok=true
  556. ;;
  557. --at-output)
  558. return_output=true
  559. ;;
  560. *)
  561. break
  562. ;;
  563. esac;
  564. shift;
  565. done;
  566. if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  567. ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  568. fi;
  569. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  570. einfo "Skipping '$*' due $1 not installed";
  571. return 0;
  572. fi;
  573. autotools_env_setup;
  574. local STDERR_TARGET="${T}/${1##*/}.out";
  575. if [[ -e ${STDERR_TARGET} ]]; then
  576. local i=1;
  577. while :; do
  578. STDERR_TARGET="${T}/${1##*/}-${i}.out";
  579. [[ -e ${STDERR_TARGET} ]] || break;
  580. : $(( i++ ));
  581. done;
  582. fi;
  583. if ${m4flags}; then
  584. set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  585. fi;
  586. if ${return_output}; then
  587. "$@";
  588. return;
  589. fi;
  590. printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  591. ebegin "Running $@";
  592. "$@" >> "${STDERR_TARGET}" 2>&1;
  593. if ! eend $? && ${autofail}; then
  594. echo;
  595. eerror "Failed Running $1 !";
  596. eerror;
  597. eerror "Include in your bugreport the contents of:";
  598. eerror;
  599. eerror " ${STDERR_TARGET}";
  600. echo;
  601. die "Failed Running $1 !";
  602. fi
  603. }
  604. clang-fullversion ()
  605. {
  606. _clang_fullversion '$1.$2.$3' "$@"
  607. }
  608. clang-major-version ()
  609. {
  610. _clang_fullversion '$1' "$@"
  611. }
  612. clang-micro-version ()
  613. {
  614. _clang_fullversion '$3' "$@"
  615. }
  616. clang-minor-version ()
  617. {
  618. _clang_fullversion '$2' "$@"
  619. }
  620. clang-version ()
  621. {
  622. _clang_fullversion '$1.$2' "$@"
  623. }
  624. config_rpath_update ()
  625. {
  626. local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  627. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  628. [[ $# -eq 0 ]] && return 0;
  629. einfo "Updating all config.rpath files";
  630. for dst in "$@";
  631. do
  632. einfo " ${dst}";
  633. cp "${src}" "${dst}" || die;
  634. done
  635. }
  636. darwintoolize ()
  637. {
  638. die "Use elibtoolize"
  639. }
  640. db_findver ()
  641. {
  642. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  643. if [ $# -ne 1 ]; then
  644. eerror "Function db_findver needs one argument" 1>&2;
  645. eerror "args given:" 1>&2;
  646. for f in $@;
  647. do
  648. eerror " - \"$@\"" 1>&2;
  649. done;
  650. return 1;
  651. fi;
  652. PKG="$(best_version $1)";
  653. VER="$(ver_cut 1-2 "${PKG/*db-/}")";
  654. if [ -d "${EPREFIX}"/usr/include/db$(db_ver_to_slot "$VER") ]; then
  655. echo -n "$VER";
  656. return 0;
  657. else
  658. return 1;
  659. fi
  660. }
  661. db_includedir ()
  662. {
  663. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  664. if [ $# -eq 0 ]; then
  665. VER="$(db_findver sys-libs/db)" || return 1;
  666. VER="$(db_ver_to_slot "$VER")";
  667. echo "include version ${VER}" 1>&2;
  668. if [ -d "${EPREFIX}/usr/include/db${VER}" ]; then
  669. echo -n "${EPREFIX}/usr/include/db${VER}";
  670. return 0;
  671. else
  672. eerror "sys-libs/db package requested, but headers not found" 1>&2;
  673. return 1;
  674. fi;
  675. else
  676. for x in $@;
  677. do
  678. if VER=$(db_findver "=sys-libs/db-${x}*") && [ -d "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" ]; then
  679. echo -n "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)";
  680. return 0;
  681. fi;
  682. done;
  683. eerror "No suitable db version found";
  684. return 1;
  685. fi
  686. }
  687. db_libname ()
  688. {
  689. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  690. if [ $# -eq 0 ]; then
  691. VER="$(db_findver sys-libs/db)" || return 1;
  692. if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
  693. echo -n "db-${VER}";
  694. return 0;
  695. else
  696. eerror "sys-libs/db package requested, but library not found" 1>&2;
  697. return 1;
  698. fi;
  699. else
  700. for x in $@;
  701. do
  702. if VER=$(db_findver "=sys-libs/db-${x}*"); then
  703. if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
  704. echo -n "db-${VER}";
  705. return 0;
  706. fi;
  707. fi;
  708. done;
  709. eerror "No suitable db version found" 1>&2;
  710. return 1;
  711. fi
  712. }
  713. db_ver_to_slot ()
  714. {
  715. if [ $# -ne 1 ]; then
  716. eerror "Function db_ver_to_slot needs one argument" 1>&2;
  717. eerror "args given:" 1>&2;
  718. for f in $@;
  719. do
  720. eerror " - \"$@\"" 1>&2;
  721. done;
  722. return 1;
  723. fi;
  724. echo -n "$1"
  725. }
  726. eaclocal ()
  727. {
  728. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  729. }
  730. eaclocal_amflags ()
  731. {
  732. local aclocal_opts amflags_file;
  733. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  734. do
  735. [[ -e ${amflags_file} ]] || continue;
  736. autotools_env_setup;
  737. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  738. s:[^=]*=::p; # then gobble up all escaped lines
  739. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  740. eval aclocal_opts=\""${aclocal_opts}"\";
  741. break;
  742. done;
  743. echo ${aclocal_opts}
  744. }
  745. eapply ()
  746. {
  747. local failed patch_cmd=patch;
  748. local -x LC_COLLATE=POSIX;
  749. type -P gpatch > /dev/null && patch_cmd=gpatch;
  750. function _eapply_patch ()
  751. {
  752. local f=${1};
  753. local prefix=${2};
  754. started_applying=1;
  755. ebegin "${prefix:-Applying }${f##*/}";
  756. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  757. failed=${?};
  758. if ! eend "${failed}"; then
  759. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  760. fi
  761. };
  762. local patch_options=() files=();
  763. local i found_doublehyphen;
  764. for ((i = 1; i <= ${#@}; ++i ))
  765. do
  766. if [[ ${@:i:1} == -- ]]; then
  767. patch_options=("${@:1:i-1}");
  768. files=("${@:i+1}");
  769. found_doublehyphen=1;
  770. break;
  771. fi;
  772. done;
  773. if [[ -z ${found_doublehyphen} ]]; then
  774. for ((i = 1; i <= ${#@}; ++i ))
  775. do
  776. if [[ ${@:i:1} != -* ]]; then
  777. patch_options=("${@:1:i-1}");
  778. files=("${@:i}");
  779. break;
  780. fi;
  781. done;
  782. for i in "${files[@]}";
  783. do
  784. if [[ ${i} == -* ]]; then
  785. die "eapply: all options must be passed before non-options";
  786. fi;
  787. done;
  788. fi;
  789. if [[ ${#files[@]} -eq 0 ]]; then
  790. die "eapply: no files specified";
  791. fi;
  792. local f;
  793. for f in "${files[@]}";
  794. do
  795. if [[ -d ${f} ]]; then
  796. function _eapply_get_files ()
  797. {
  798. local LC_ALL=POSIX;
  799. local prev_shopt=$(shopt -p nullglob);
  800. shopt -s nullglob;
  801. local f;
  802. for f in "${1}"/*;
  803. do
  804. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  805. files+=("${f}");
  806. fi;
  807. done;
  808. ${prev_shopt}
  809. };
  810. local files=();
  811. _eapply_get_files "${f}";
  812. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  813. einfo "Applying patches from ${f} ...";
  814. local f2;
  815. for f2 in "${files[@]}";
  816. do
  817. _eapply_patch "${f2}" ' ';
  818. [[ ${failed} -ne 0 ]] && return "${failed}";
  819. done;
  820. else
  821. _eapply_patch "${f}";
  822. [[ ${failed} -ne 0 ]] && return "${failed}";
  823. fi;
  824. done;
  825. return 0
  826. }
  827. eapply_user ()
  828. {
  829. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  830. local tagfile=${T}/.portage_user_patches_applied;
  831. [[ -f ${tagfile} ]] && return;
  832. >> "${tagfile}";
  833. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  834. local applied d f;
  835. local -A _eapply_user_patches;
  836. local prev_shopt=$(shopt -p nullglob);
  837. shopt -s nullglob;
  838. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  839. do
  840. for f in "${d}"/*;
  841. do
  842. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  843. _eapply_user_patches[${f##*/}]=${f};
  844. fi;
  845. done;
  846. done;
  847. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  848. while read -r -d '' f; do
  849. f=${_eapply_user_patches[${f}]};
  850. if [[ -s ${f} ]]; then
  851. eapply "${f}";
  852. applied=1;
  853. fi;
  854. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  855. LC_ALL=C sort -z);
  856. fi;
  857. ${prev_shopt};
  858. [[ -n ${applied} ]] && ewarn "User patches applied."
  859. }
  860. eautoconf ()
  861. {
  862. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  863. echo;
  864. eerror "No configure.{ac,in} present in '${PWD}'!";
  865. echo;
  866. die "No configure.{ac,in} present!";
  867. fi;
  868. if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  869. eqawarn "This package has a configure.in file which has long been deprecated. Please";
  870. eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  871. eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details.";
  872. fi;
  873. autotools_run_tool --at-m4flags autoconf "$@"
  874. }
  875. eautoheader ()
  876. {
  877. _at_uses_autoheader || return 0;
  878. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  879. }
  880. eautomake ()
  881. {
  882. local extra_opts=();
  883. local makefile_name;
  884. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  885. do
  886. [[ -f ${makefile_name} ]] && break;
  887. done;
  888. function _automake_version ()
  889. {
  890. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  891. };
  892. if [[ -z ${makefile_name} ]]; then
  893. _at_uses_automake || return 0;
  894. else
  895. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  896. local used_automake;
  897. local installed_automake;
  898. installed_automake=$(WANT_AUTOMAKE= _automake_version);
  899. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  900. if [[ ${installed_automake} != ${used_automake} ]]; then
  901. ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  902. ewarn "Forcing a full rebuild of the autotools to workaround.";
  903. eautoreconf;
  904. return 0;
  905. fi;
  906. fi;
  907. fi;
  908. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  909. case $(_automake_version) in
  910. 1.4 | 1.4[.-]*)
  911. ;;
  912. *)
  913. extra_opts+=(--force-missing)
  914. ;;
  915. esac;
  916. autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  917. }
  918. eautopoint ()
  919. {
  920. autotools_run_tool autopoint "$@"
  921. }
  922. eautoreconf ()
  923. {
  924. local x g;
  925. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  926. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  927. do
  928. if [[ -d ${x} ]]; then
  929. pushd "${x}" > /dev/null;
  930. AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  931. popd > /dev/null;
  932. fi;
  933. done;
  934. fi;
  935. einfo "Running eautoreconf in '${PWD}' ...";
  936. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  937. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  938. 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");
  939. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  940. do
  941. if _at_uses_${tools[i]}; then
  942. tools[i+1]=true;
  943. ${tools[i+2]};
  944. fi;
  945. done;
  946. local rerun_aclocal=false;
  947. eaclocal;
  948. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  949. do
  950. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  951. ${tools[i+2]};
  952. rerun_aclocal=true;
  953. fi;
  954. done;
  955. ${rerun_aclocal} && eaclocal;
  956. if [[ ${WANT_AUTOCONF} = 2.1 ]]; then
  957. eautoconf;
  958. else
  959. eautoconf --force;
  960. fi;
  961. eautoheader;
  962. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  963. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  964. elibtoolize --force "${PWD}";
  965. fi;
  966. return 0
  967. }
  968. econf_build ()
  969. {
  970. local CBUILD=${CBUILD:-${CHOST}};
  971. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  972. }
  973. einstalldocs ()
  974. {
  975. ( if ! declare -p DOCS &> /dev/null; then
  976. local d;
  977. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  978. do
  979. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  980. done;
  981. else
  982. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  983. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  984. else
  985. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  986. fi;
  987. fi );
  988. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  989. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  990. else
  991. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  992. fi )
  993. }
  994. elibtoolize ()
  995. {
  996. type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  997. ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  998. }
  999. fcaps ()
  1000. {
  1001. debug-print-function ${FUNCNAME} "$@";
  1002. local owner='root';
  1003. local group='0';
  1004. local mode='4711';
  1005. local caps_mode='711';
  1006. while [[ $# -gt 0 ]]; do
  1007. case $1 in
  1008. -o)
  1009. owner=$2;
  1010. shift
  1011. ;;
  1012. -g)
  1013. group=$2;
  1014. shift
  1015. ;;
  1016. -m)
  1017. mode=$2;
  1018. shift
  1019. ;;
  1020. -M)
  1021. caps_mode=$2;
  1022. shift
  1023. ;;
  1024. *)
  1025. break
  1026. ;;
  1027. esac;
  1028. shift;
  1029. done;
  1030. [[ $# -lt 2 ]] && die "${FUNCNAME}: wrong arg count";
  1031. local caps=$1;
  1032. [[ ${caps} == *[-=+]* ]] || caps+="=ep";
  1033. shift;
  1034. local root;
  1035. case ${EBUILD_PHASE} in
  1036. compile | install | preinst)
  1037. root=${ED:-${D}}
  1038. ;;
  1039. postinst)
  1040. root=${EROOT:-${ROOT}}
  1041. ;;
  1042. esac;
  1043. root=${root%/};
  1044. local file;
  1045. for file in "$@";
  1046. do
  1047. [[ ${file} != /* ]] && file="${root}/${file}";
  1048. if use filecaps; then
  1049. debug-print "${FUNCNAME}: setting caps '${caps}' on '${file}'";
  1050. chmod ${caps_mode} "${file}" || die;
  1051. function _libcap ()
  1052. {
  1053. setcap "${caps}" "${file}"
  1054. };
  1055. function _libcap_verify ()
  1056. {
  1057. setcap -v "${caps}" "${file}" > /dev/null
  1058. };
  1059. function _libcap_ng ()
  1060. {
  1061. local caps=",${caps%=ep}";
  1062. filecap "${file}" "${caps//,cap_}"
  1063. };
  1064. function _libcap_ng_verify ()
  1065. {
  1066. local rcaps icaps caps=",${caps%=ep}";
  1067. rcaps=$(filecap "${file}" | sed -nr -e "s:^.{${#file}} +::" -e 's:, +:\n:g' -e 2p | LC_ALL=C sort);
  1068. [[ ${PIPESTATUS[0]} -eq 0 ]] || return 1;
  1069. icaps=$(echo "${caps//,cap_}" | LC_ALL=C sort);
  1070. [[ ${rcaps} == ${icaps} ]]
  1071. };
  1072. local out cmd notfound=0;
  1073. for cmd in _libcap _libcap_ng;
  1074. do
  1075. if ! out=$(LC_ALL=C ${cmd} 2>&1); then
  1076. case ${out} in
  1077. *"command not found"*)
  1078. : $(( ++notfound ));
  1079. continue
  1080. ;;
  1081. *"Not supported"* | *"Operation not supported"*)
  1082. local fstype=$(stat -f -c %T "${file}");
  1083. ewarn "Could not set caps on '${file}' due to missing filesystem support:";
  1084. ewarn "* enable XATTR support for '${fstype}' in your kernel (if configurable)";
  1085. ewarn "* mount the fs with the user_xattr option (if not the default)";
  1086. ewarn "* enable the relevant FS_SECURITY option (if configurable)";
  1087. break
  1088. ;;
  1089. *)
  1090. eerror "Setting caps '${caps}' on file '${file}' failed:";
  1091. eerror "${out}";
  1092. die "could not set caps"
  1093. ;;
  1094. esac;
  1095. else
  1096. ${cmd}_verify || die "Checking caps '${caps}' on '${file}' failed";
  1097. continue 2;
  1098. fi;
  1099. done;
  1100. if [[ ${notfound} -eq 2 ]] && [[ -z ${_FCAPS_WARNED} ]]; then
  1101. _FCAPS_WARNED="true";
  1102. ewarn "Could not find cap utils; make sure libcap or libcap-ng is available.";
  1103. fi;
  1104. fi;
  1105. debug-print "${FUNCNAME}: setting owner/mode on '${file}'";
  1106. chown "${owner}:${group}" "${file}" || die;
  1107. chmod ${mode} "${file}" || die;
  1108. done
  1109. }
  1110. fcaps_pkg_postinst ()
  1111. {
  1112. local arg args=();
  1113. for arg in "${FILECAPS[@]}" "--";
  1114. do
  1115. if [[ ${arg} == "--" ]]; then
  1116. fcaps "${args[@]}";
  1117. args=();
  1118. else
  1119. args+=("${arg}");
  1120. fi;
  1121. done
  1122. }
  1123. gcc-fullversion ()
  1124. {
  1125. _gcc_fullversion '$1.$2.$3' "$@"
  1126. }
  1127. gcc-major-version ()
  1128. {
  1129. _gcc_fullversion '$1' "$@"
  1130. }
  1131. gcc-micro-version ()
  1132. {
  1133. _gcc_fullversion '$3' "$@"
  1134. }
  1135. gcc-minor-version ()
  1136. {
  1137. _gcc_fullversion '$2' "$@"
  1138. }
  1139. gcc-specs-directive ()
  1140. {
  1141. local directive subdname subdirective;
  1142. directive="$(_gcc-specs-directive_raw $1)";
  1143. while [[ ${directive} == *%\(*\)* ]]; do
  1144. subdname=${directive/*%\(};
  1145. subdname=${subdname/\)*};
  1146. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1147. directive="${directive//\%(${subdname})/${subdirective}}";
  1148. done;
  1149. echo "${directive}";
  1150. return 0
  1151. }
  1152. gcc-specs-nostrict ()
  1153. {
  1154. local directive;
  1155. directive=$(gcc-specs-directive cc1);
  1156. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1157. }
  1158. gcc-specs-now ()
  1159. {
  1160. local directive;
  1161. directive=$(gcc-specs-directive link_command);
  1162. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1163. }
  1164. gcc-specs-pie ()
  1165. {
  1166. local directive;
  1167. directive=$(gcc-specs-directive cc1);
  1168. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1169. }
  1170. gcc-specs-relro ()
  1171. {
  1172. local directive;
  1173. directive=$(gcc-specs-directive link_command);
  1174. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1175. }
  1176. gcc-specs-ssp ()
  1177. {
  1178. local directive;
  1179. directive=$(gcc-specs-directive cc1);
  1180. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1181. }
  1182. gcc-specs-ssp-to-all ()
  1183. {
  1184. local directive;
  1185. directive=$(gcc-specs-directive cc1);
  1186. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1187. }
  1188. gcc-specs-stack-check ()
  1189. {
  1190. local directive;
  1191. directive=$(gcc-specs-directive cc1);
  1192. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1193. }
  1194. gcc-version ()
  1195. {
  1196. _gcc_fullversion '$1.$2' "$@"
  1197. }
  1198. gen_usr_ldscript ()
  1199. {
  1200. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1201. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1202. tc-is-static-only && return;
  1203. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1204. multilib_is_native_abi || return 0;
  1205. fi;
  1206. case ${CTARGET:-${CHOST}} in
  1207. *-darwin*)
  1208. ;;
  1209. *-android*)
  1210. return 0
  1211. ;;
  1212. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1213. use prefix && return 0
  1214. ;;
  1215. *)
  1216. return 0
  1217. ;;
  1218. esac;
  1219. dodir /usr/${libdir};
  1220. if [[ $1 == "-a" ]]; then
  1221. auto=true;
  1222. shift;
  1223. dodir /${libdir};
  1224. fi;
  1225. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1226. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1227. local d="${T}/bfd-linker";
  1228. mkdir -p "${d}";
  1229. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1230. flags+=(-B"${d}");
  1231. fi;
  1232. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1233. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1234. for lib in "$@";
  1235. do
  1236. local tlib;
  1237. if ${auto}; then
  1238. lib="lib${lib}${suffix}";
  1239. else
  1240. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1241. fi;
  1242. case ${CTARGET:-${CHOST}} in
  1243. *-darwin*)
  1244. if ${auto}; then
  1245. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1246. else
  1247. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1248. fi;
  1249. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1250. tlib=${tlib##*/};
  1251. if ${auto}; then
  1252. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1253. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1254. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1255. fi;
  1256. rm -f "${ED}"/${libdir}/${lib};
  1257. fi;
  1258. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1259. chmod u+w "${ED}${libdir}/${tlib}";
  1260. local nowrite=yes;
  1261. fi;
  1262. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1263. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1264. pushd "${ED}/usr/${libdir}" > /dev/null;
  1265. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1266. popd > /dev/null
  1267. ;;
  1268. *)
  1269. if ${auto}; then
  1270. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1271. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1272. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1273. if [[ ${tlib} != ${lib}* ]]; then
  1274. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1275. fi;
  1276. rm -f "${ED}"/${libdir}/${lib};
  1277. else
  1278. tlib=${lib};
  1279. fi;
  1280. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1281. /* GNU ld script
  1282. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1283. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1284. run into linking problems. This "fake" dynamic lib is a linker script that
  1285. redirects the linker to the real lib. And yes, this works in the cross-
  1286. compiling scenario as the sysroot-ed linker will prepend the real path.
  1287. See bug https://bugs.gentoo.org/4411 for more info.
  1288. */
  1289. ${output_format}
  1290. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1291. END_LDSCRIPT
  1292. ;;
  1293. esac
  1294. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1295. done
  1296. }
  1297. get_abi_CFLAGS ()
  1298. {
  1299. get_abi_var CFLAGS "$@"
  1300. }
  1301. get_abi_CHOST ()
  1302. {
  1303. get_abi_var CHOST "$@"
  1304. }
  1305. get_abi_CTARGET ()
  1306. {
  1307. get_abi_var CTARGET "$@"
  1308. }
  1309. get_abi_FAKE_TARGETS ()
  1310. {
  1311. get_abi_var FAKE_TARGETS "$@"
  1312. }
  1313. get_abi_LDFLAGS ()
  1314. {
  1315. get_abi_var LDFLAGS "$@"
  1316. }
  1317. get_abi_LIBDIR ()
  1318. {
  1319. get_abi_var LIBDIR "$@"
  1320. }
  1321. get_abi_var ()
  1322. {
  1323. local flag=$1;
  1324. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1325. local var="${flag}_${abi}";
  1326. echo ${!var}
  1327. }
  1328. get_all_abis ()
  1329. {
  1330. local x order="" mvar dvar;
  1331. mvar="MULTILIB_ABIS";
  1332. dvar="DEFAULT_ABI";
  1333. if [[ -n $1 ]]; then
  1334. mvar="$1_${mvar}";
  1335. dvar="$1_${dvar}";
  1336. fi;
  1337. if [[ -z ${!mvar} ]]; then
  1338. echo "default";
  1339. return 0;
  1340. fi;
  1341. for x in ${!mvar};
  1342. do
  1343. if [[ ${x} != ${!dvar} ]]; then
  1344. order="${order:+${order} }${x}";
  1345. fi;
  1346. done;
  1347. order="${order:+${order} }${!dvar}";
  1348. echo ${order};
  1349. return 0
  1350. }
  1351. get_all_libdirs ()
  1352. {
  1353. local libdirs abi;
  1354. for abi in ${MULTILIB_ABIS};
  1355. do
  1356. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1357. done;
  1358. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1359. echo "${libdirs}"
  1360. }
  1361. get_exeext ()
  1362. {
  1363. case ${CHOST} in
  1364. *-cygwin* | mingw* | *-mingw*)
  1365. echo ".exe"
  1366. ;;
  1367. esac
  1368. }
  1369. get_install_abis ()
  1370. {
  1371. local x order="";
  1372. if [[ -z ${MULTILIB_ABIS} ]]; then
  1373. echo "default";
  1374. return 0;
  1375. fi;
  1376. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1377. for x in ${MULTILIB_ABIS};
  1378. do
  1379. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1380. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1381. fi;
  1382. done;
  1383. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1384. if [[ -n ${ABI_ALLOW} ]]; then
  1385. local ordera="";
  1386. for x in ${order};
  1387. do
  1388. if has ${x} ${ABI_ALLOW}; then
  1389. ordera="${ordera} ${x}";
  1390. fi;
  1391. done;
  1392. order=${ordera};
  1393. fi;
  1394. else
  1395. order=${DEFAULT_ABI};
  1396. fi;
  1397. if [[ -z ${order} ]]; then
  1398. 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.";
  1399. fi;
  1400. echo ${order};
  1401. return 0
  1402. }
  1403. get_libdir ()
  1404. {
  1405. local libdir_var="LIBDIR_${ABI}";
  1406. local libdir="lib";
  1407. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1408. echo "${libdir}"
  1409. }
  1410. get_libname ()
  1411. {
  1412. local libname;
  1413. local ver=$1;
  1414. case ${CHOST} in
  1415. *-cygwin*)
  1416. libname="dll.a"
  1417. ;;
  1418. mingw* | *-mingw*)
  1419. libname="dll"
  1420. ;;
  1421. *-darwin*)
  1422. libname="dylib"
  1423. ;;
  1424. *-mint*)
  1425. libname="irrelevant"
  1426. ;;
  1427. hppa*-hpux*)
  1428. libname="sl"
  1429. ;;
  1430. *)
  1431. libname="so"
  1432. ;;
  1433. esac;
  1434. if [[ -z $* ]]; then
  1435. echo ".${libname}";
  1436. else
  1437. for ver in "$@";
  1438. do
  1439. case ${CHOST} in
  1440. *-cygwin*)
  1441. echo ".${ver}.${libname}"
  1442. ;;
  1443. *-darwin*)
  1444. echo ".${ver}.${libname}"
  1445. ;;
  1446. *-mint*)
  1447. echo ".${libname}"
  1448. ;;
  1449. *)
  1450. echo ".${libname}.${ver}"
  1451. ;;
  1452. esac;
  1453. done;
  1454. fi
  1455. }
  1456. get_modname ()
  1457. {
  1458. local modname;
  1459. local ver=$1;
  1460. case ${CHOST} in
  1461. *-darwin*)
  1462. modname="bundle"
  1463. ;;
  1464. *)
  1465. modname="so"
  1466. ;;
  1467. esac;
  1468. echo ".${modname}"
  1469. }
  1470. has_multilib_profile ()
  1471. {
  1472. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1473. }
  1474. in_iuse ()
  1475. {
  1476. local use=${1};
  1477. if [[ -z "${use}" ]]; then
  1478. echo "!!! in_iuse() called without a parameter." 1>&2;
  1479. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1480. die "in_iuse() called without a parameter";
  1481. fi;
  1482. local liuse=(${IUSE_EFFECTIVE});
  1483. has "${use}" "${liuse[@]#[+-]}"
  1484. }
  1485. is_final_abi ()
  1486. {
  1487. has_multilib_profile || return 0;
  1488. set -- $(get_install_abis);
  1489. local LAST_ABI=$#;
  1490. [[ ${!LAST_ABI} == ${ABI} ]]
  1491. }
  1492. multibuild_copy_sources ()
  1493. {
  1494. debug-print-function ${FUNCNAME} "${@}";
  1495. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  1496. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  1497. local cp_args=();
  1498. if cp --reflink=auto --version &> /dev/null; then
  1499. cp_args+=(--reflink=auto);
  1500. fi;
  1501. function _multibuild_create_source_copy ()
  1502. {
  1503. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  1504. cp -p -R "${cp_args[@]}" "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  1505. };
  1506. multibuild_foreach_variant _multibuild_create_source_copy
  1507. }
  1508. multibuild_for_best_variant ()
  1509. {
  1510. debug-print-function ${FUNCNAME} "${@}";
  1511. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1512. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}");
  1513. multibuild_foreach_variant "${@}"
  1514. }
  1515. multibuild_foreach_variant ()
  1516. {
  1517. debug-print-function ${FUNCNAME} "${@}";
  1518. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1519. local bdir=${BUILD_DIR:-${S}};
  1520. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  1521. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  1522. local ret=0 lret=0 v;
  1523. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  1524. for v in "${MULTIBUILD_VARIANTS[@]}";
  1525. do
  1526. local MULTIBUILD_VARIANT=${v};
  1527. local MULTIBUILD_ID=${prev_id}${v};
  1528. local BUILD_DIR=${bdir%%/}-${v};
  1529. function _multibuild_run ()
  1530. {
  1531. local i=1;
  1532. while [[ ${!i} == _* ]]; do
  1533. (( i += 1 ));
  1534. done;
  1535. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  1536. "${@}"
  1537. };
  1538. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  1539. lret=${?};
  1540. done;
  1541. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  1542. return ${ret}
  1543. }
  1544. multibuild_merge_root ()
  1545. {
  1546. local src=${1};
  1547. local dest=${2};
  1548. local ret;
  1549. if use userland_BSD; then
  1550. tar -C "${src}" -f - -c . | tar -x -f - -C "${dest}";
  1551. [[ ${PIPESTATUS[*]} == '0 0' ]];
  1552. ret=${?};
  1553. else
  1554. local cp_args=();
  1555. if cp -a --version &> /dev/null; then
  1556. cp_args+=(-a);
  1557. else
  1558. cp_args+=(-P -R -p);
  1559. fi;
  1560. if cp --reflink=auto --version &> /dev/null; then
  1561. cp_args+=(--reflink=auto);
  1562. fi;
  1563. cp "${cp_args[@]}" "${src}"/. "${dest}"/;
  1564. ret=${?};
  1565. fi;
  1566. if [[ ${ret} -ne 0 ]]; then
  1567. die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
  1568. fi;
  1569. rm -rf "${src}"
  1570. }
  1571. multibuild_parallel_foreach_variant ()
  1572. {
  1573. debug-print-function ${FUNCNAME} "${@}";
  1574. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  1575. multibuild_foreach_variant "${@}"
  1576. }
  1577. multilib-minimal_abi_src_configure ()
  1578. {
  1579. debug-print-function ${FUNCNAME} "$@";
  1580. mkdir -p "${BUILD_DIR}" || die;
  1581. pushd "${BUILD_DIR}" > /dev/null || die;
  1582. if declare -f multilib_src_configure > /dev/null; then
  1583. multilib_src_configure;
  1584. else
  1585. default_src_configure;
  1586. fi;
  1587. popd > /dev/null || die
  1588. }
  1589. multilib-minimal_src_compile ()
  1590. {
  1591. debug-print-function ${FUNCNAME} "$@";
  1592. function multilib-minimal_abi_src_compile ()
  1593. {
  1594. debug-print-function ${FUNCNAME} "$@";
  1595. pushd "${BUILD_DIR}" > /dev/null || die;
  1596. if declare -f multilib_src_compile > /dev/null; then
  1597. multilib_src_compile;
  1598. else
  1599. default_src_compile;
  1600. fi;
  1601. popd > /dev/null || die
  1602. };
  1603. multilib_foreach_abi multilib-minimal_abi_src_compile
  1604. }
  1605. multilib-minimal_src_configure ()
  1606. {
  1607. debug-print-function ${FUNCNAME} "$@";
  1608. function multilib-minimal_abi_src_configure ()
  1609. {
  1610. debug-print-function ${FUNCNAME} "$@";
  1611. mkdir -p "${BUILD_DIR}" || die;
  1612. pushd "${BUILD_DIR}" > /dev/null || die;
  1613. if declare -f multilib_src_configure > /dev/null; then
  1614. multilib_src_configure;
  1615. else
  1616. default_src_configure;
  1617. fi;
  1618. popd > /dev/null || die
  1619. };
  1620. multilib_foreach_abi multilib-minimal_abi_src_configure
  1621. }
  1622. multilib-minimal_src_install ()
  1623. {
  1624. debug-print-function ${FUNCNAME} "$@";
  1625. function multilib-minimal_abi_src_install ()
  1626. {
  1627. debug-print-function ${FUNCNAME} "$@";
  1628. pushd "${BUILD_DIR}" > /dev/null || die;
  1629. if declare -f multilib_src_install > /dev/null; then
  1630. multilib_src_install;
  1631. else
  1632. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  1633. emake DESTDIR="${D}" install;
  1634. fi;
  1635. fi;
  1636. multilib_prepare_wrappers;
  1637. multilib_check_headers;
  1638. popd > /dev/null || die
  1639. };
  1640. multilib_foreach_abi multilib-minimal_abi_src_install;
  1641. multilib_install_wrappers;
  1642. if declare -f multilib_src_install_all > /dev/null; then
  1643. multilib_src_install_all;
  1644. else
  1645. einstalldocs;
  1646. fi
  1647. }
  1648. multilib-minimal_src_test ()
  1649. {
  1650. debug-print-function ${FUNCNAME} "$@";
  1651. function multilib-minimal_abi_src_test ()
  1652. {
  1653. debug-print-function ${FUNCNAME} "$@";
  1654. pushd "${BUILD_DIR}" > /dev/null || die;
  1655. if declare -f multilib_src_test > /dev/null; then
  1656. multilib_src_test;
  1657. else
  1658. default_src_test;
  1659. fi;
  1660. popd > /dev/null || die
  1661. };
  1662. multilib_foreach_abi multilib-minimal_abi_src_test
  1663. }
  1664. multilib_build_binaries ()
  1665. {
  1666. debug-print-function ${FUNCNAME} "${@}";
  1667. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  1668. eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent";
  1669. eqawarn "multilib_is_native_abi function instead.";
  1670. multilib_is_native_abi "${@}"
  1671. }
  1672. multilib_check_headers ()
  1673. {
  1674. function _multilib_header_cksum ()
  1675. {
  1676. set -o pipefail;
  1677. if [[ -d ${ED%/}/usr/include ]]; then
  1678. find "${ED%/}"/usr/include -type f -exec cksum {} + | sort -k2;
  1679. fi
  1680. };
  1681. local cksum cksum_prev;
  1682. local cksum_file=${T}/.multilib_header_cksum;
  1683. cksum=$(_multilib_header_cksum) || die;
  1684. unset -f _multilib_header_cksum;
  1685. if [[ -f ${cksum_file} ]]; then
  1686. cksum_prev=$(< "${cksum_file}") || die;
  1687. if [[ ${cksum} != ${cksum_prev} ]]; then
  1688. echo "${cksum}" > "${cksum_file}.new" || die;
  1689. eerror "Header files have changed between ABIs.";
  1690. if type -p diff &> /dev/null; then
  1691. eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  1692. else
  1693. eerror "Old checksums in: ${cksum_file}";
  1694. eerror "New checksums in: ${cksum_file}.new";
  1695. fi;
  1696. die "Header checksum mismatch, aborting.";
  1697. fi;
  1698. else
  1699. echo "${cksum}" > "${cksum_file}" || die;
  1700. fi
  1701. }
  1702. multilib_copy_sources ()
  1703. {
  1704. debug-print-function ${FUNCNAME} "${@}";
  1705. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  1706. multibuild_copy_sources
  1707. }
  1708. multilib_env ()
  1709. {
  1710. local CTARGET=${1:-${CTARGET}};
  1711. local cpu=${CTARGET%%*-};
  1712. case ${cpu} in
  1713. aarch64*)
  1714. export CFLAGS_arm=${CFLAGS_arm-};
  1715. case ${cpu} in
  1716. aarch64*be)
  1717. export CHOST_arm="armv8b-${CTARGET#*-}"
  1718. ;;
  1719. *)
  1720. export CHOST_arm="armv8l-${CTARGET#*-}"
  1721. ;;
  1722. esac;
  1723. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1724. export CTARGET_arm=${CHOST_arm};
  1725. export LIBDIR_arm="lib";
  1726. export CFLAGS_arm64=${CFLAGS_arm64-};
  1727. export CHOST_arm64=${CTARGET};
  1728. export CTARGET_arm64=${CHOST_arm64};
  1729. export LIBDIR_arm64="lib64";
  1730. : ${MULTILIB_ABIS=arm64};
  1731. : ${DEFAULT_ABI=arm64}
  1732. ;;
  1733. x86_64*)
  1734. export CFLAGS_x86=${CFLAGS_x86--m32};
  1735. export CHOST_x86=${CTARGET/x86_64/i686};
  1736. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1737. export CTARGET_x86=${CHOST_x86};
  1738. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1739. export LIBDIR_x86="lib32";
  1740. else
  1741. export LIBDIR_x86="lib";
  1742. fi;
  1743. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1744. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1745. export CTARGET_amd64=${CHOST_amd64};
  1746. export LIBDIR_amd64="lib64";
  1747. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1748. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1749. export CTARGET_x32=${CHOST_x32};
  1750. export LIBDIR_x32="libx32";
  1751. case ${CTARGET} in
  1752. *-gnux32)
  1753. : ${MULTILIB_ABIS=x32 amd64 x86};
  1754. : ${DEFAULT_ABI=x32}
  1755. ;;
  1756. *)
  1757. : ${MULTILIB_ABIS=amd64 x86};
  1758. : ${DEFAULT_ABI=amd64}
  1759. ;;
  1760. esac
  1761. ;;
  1762. mips64* | mipsisa64*)
  1763. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1764. export CHOST_o32=${CTARGET/mips64/mips};
  1765. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  1766. export CTARGET_o32=${CHOST_o32};
  1767. export LIBDIR_o32="lib";
  1768. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1769. export CHOST_n32=${CTARGET};
  1770. export CTARGET_n32=${CHOST_n32};
  1771. export LIBDIR_n32="lib32";
  1772. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1773. export CHOST_n64=${CTARGET};
  1774. export CTARGET_n64=${CHOST_n64};
  1775. export LIBDIR_n64="lib64";
  1776. : ${MULTILIB_ABIS=n64 n32 o32};
  1777. : ${DEFAULT_ABI=n32}
  1778. ;;
  1779. powerpc64*)
  1780. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1781. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1782. export CTARGET_ppc=${CHOST_ppc};
  1783. export LIBDIR_ppc="lib";
  1784. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1785. export CHOST_ppc64=${CTARGET};
  1786. export CTARGET_ppc64=${CHOST_ppc64};
  1787. export LIBDIR_ppc64="lib64";
  1788. : ${MULTILIB_ABIS=ppc64 ppc};
  1789. : ${DEFAULT_ABI=ppc64}
  1790. ;;
  1791. s390x*)
  1792. export CFLAGS_s390=${CFLAGS_s390--m31};
  1793. export CHOST_s390=${CTARGET/s390x/s390};
  1794. export CTARGET_s390=${CHOST_s390};
  1795. export LIBDIR_s390="lib";
  1796. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1797. export CHOST_s390x=${CTARGET};
  1798. export CTARGET_s390x=${CHOST_s390x};
  1799. export LIBDIR_s390x="lib64";
  1800. : ${MULTILIB_ABIS=s390x s390};
  1801. : ${DEFAULT_ABI=s390x}
  1802. ;;
  1803. sparc64*)
  1804. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1805. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1806. export CTARGET_sparc32=${CHOST_sparc32};
  1807. export LIBDIR_sparc32="lib";
  1808. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1809. export CHOST_sparc64=${CTARGET};
  1810. export CTARGET_sparc64=${CHOST_sparc64};
  1811. export LIBDIR_sparc64="lib64";
  1812. : ${MULTILIB_ABIS=sparc64 sparc32};
  1813. : ${DEFAULT_ABI=sparc64}
  1814. ;;
  1815. *)
  1816. : ${MULTILIB_ABIS=default};
  1817. : ${DEFAULT_ABI=default}
  1818. ;;
  1819. esac;
  1820. export MULTILIB_ABIS DEFAULT_ABI
  1821. }
  1822. multilib_for_best_abi ()
  1823. {
  1824. debug-print-function ${FUNCNAME} "${@}";
  1825. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead";
  1826. eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should";
  1827. eqawarn "not be used. The multilib_is_native_abi() check may be used instead.";
  1828. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  1829. multibuild_for_best_variant _multilib_multibuild_wrapper "${@}"
  1830. }
  1831. multilib_foreach_abi ()
  1832. {
  1833. debug-print-function ${FUNCNAME} "${@}";
  1834. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  1835. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  1836. }
  1837. multilib_get_enabled_abi_pairs ()
  1838. {
  1839. debug-print-function ${FUNCNAME} "${@}";
  1840. local abis=($(get_all_abis));
  1841. local abi i found;
  1842. for abi in "${abis[@]}";
  1843. do
  1844. for i in "${_MULTILIB_FLAGS[@]}";
  1845. do
  1846. local m_abis=${i#*:} m_abi;
  1847. local m_flag=${i%:*};
  1848. for m_abi in ${m_abis//,/ };
  1849. do
  1850. if [[ ${m_abi} == ${abi} ]] && {
  1851. [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  1852. } && use "${m_flag}"; then
  1853. echo "${m_flag}.${abi}";
  1854. found=1;
  1855. break 2;
  1856. fi;
  1857. done;
  1858. done;
  1859. done;
  1860. if [[ ! -n ${found} ]]; then
  1861. local abi=${ABI:-${DEFAULT_ABI}};
  1862. debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  1863. debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  1864. echo ".${abi}";
  1865. fi
  1866. }
  1867. multilib_get_enabled_abis ()
  1868. {
  1869. debug-print-function ${FUNCNAME} "${@}";
  1870. local pairs=($(multilib_get_enabled_abi_pairs));
  1871. echo "${pairs[@]#*.}"
  1872. }
  1873. multilib_install_wrappers ()
  1874. {
  1875. debug-print-function ${FUNCNAME} "${@}";
  1876. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  1877. [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  1878. local root=${1:-${ED}};
  1879. if [[ -d ${ED%/}/tmp/multilib-include ]]; then
  1880. multibuild_merge_root "${ED%/}"/tmp/multilib-include "${root}"/usr/include;
  1881. rmdir "${ED%/}"/tmp &> /dev/null;
  1882. fi
  1883. }
  1884. multilib_is_native_abi ()
  1885. {
  1886. debug-print-function ${FUNCNAME} "${@}";
  1887. [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  1888. [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  1889. }
  1890. multilib_native_enable ()
  1891. {
  1892. if multilib_is_native_abi; then
  1893. echo "--enable-${1}${2+=${2}}";
  1894. else
  1895. echo "--disable-${1}";
  1896. fi
  1897. }
  1898. multilib_native_use_enable ()
  1899. {
  1900. if multilib_is_native_abi; then
  1901. use_enable "${@}";
  1902. else
  1903. echo "--disable-${2:-${1}}";
  1904. fi
  1905. }
  1906. multilib_native_use_with ()
  1907. {
  1908. if multilib_is_native_abi; then
  1909. use_with "${@}";
  1910. else
  1911. echo "--without-${2:-${1}}";
  1912. fi
  1913. }
  1914. multilib_native_usex ()
  1915. {
  1916. if multilib_is_native_abi; then
  1917. usex "${@}";
  1918. else
  1919. echo "${3-no}${5}";
  1920. fi
  1921. }
  1922. multilib_native_with ()
  1923. {
  1924. if multilib_is_native_abi; then
  1925. echo "--with-${1}${2+=${2}}";
  1926. else
  1927. echo "--without-${1}";
  1928. fi
  1929. }
  1930. multilib_parallel_foreach_abi ()
  1931. {
  1932. debug-print-function ${FUNCNAME} "${@}";
  1933. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  1934. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  1935. }
  1936. multilib_prepare_wrappers ()
  1937. {
  1938. debug-print-function ${FUNCNAME} "${@}";
  1939. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  1940. local root=${1:-${ED%/}};
  1941. local f;
  1942. if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  1943. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  1944. do
  1945. f=${f#/};
  1946. local dir=${f%/*};
  1947. local fn=${f##*/};
  1948. ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  1949. done;
  1950. return;
  1951. fi;
  1952. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  1953. do
  1954. f=${f#/};
  1955. local dir=${f%/*};
  1956. local fn=${f##*/};
  1957. if [[ -L ${root}/${f} ]]; then
  1958. local target;
  1959. target=$(readlink "${root}/${f}") || die;
  1960. local target_dir target_fn=${target##*/};
  1961. [[ ${target} == */* ]] && target_dir=${target%/*};
  1962. ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  1963. fi;
  1964. mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  1965. if multilib_is_native_abi; then
  1966. ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  1967. fi;
  1968. done;
  1969. if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  1970. if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  1971. for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  1972. do
  1973. f=${f#/};
  1974. if [[ ${f} != usr/include/* ]]; then
  1975. die "Wrapping headers outside of /usr/include is not supported at the moment.";
  1976. fi;
  1977. f=${f#usr/include};
  1978. local dir=${f%/*};
  1979. if [[ -f ${root}/usr/include${f} ]]; then
  1980. local wrapper=${ED%/}/tmp/multilib-include${f};
  1981. if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then
  1982. dodir "/tmp/multilib-include${dir}";
  1983. cat > "${wrapper}" <<_EOF_ ||
  1984. /* This file is auto-generated by multilib-build.eclass
  1985. * as a multilib-friendly wrapper. For the original content,
  1986. * please see the files that are #included below.
  1987. */
  1988. #if defined(__x86_64__) /* amd64 */
  1989. # if defined(__ILP32__) /* x32 ABI */
  1990. # error "abi_x86_x32 not supported by the package."
  1991. # else /* 64-bit ABI */
  1992. # error "abi_x86_64 not supported by the package."
  1993. # endif
  1994. #elif defined(__i386__) /* plain x86 */
  1995. # error "abi_x86_32 not supported by the package."
  1996. #elif defined(__mips__)
  1997. # if(_MIPS_SIM == _ABIN32) /* n32 */
  1998. # error "abi_mips_n32 not supported by the package."
  1999. # elif(_MIPS_SIM == _ABI64) /* n64 */
  2000. # error "abi_mips_n64 not supported by the package."
  2001. # elif(_MIPS_SIM == _ABIO32) /* o32 */
  2002. # error "abi_mips_o32 not supported by the package."
  2003. # endif
  2004. #elif defined(__sparc__)
  2005. # if defined(__arch64__)
  2006. # error "abi_sparc_64 not supported by the package."
  2007. # else
  2008. # error "abi_sparc_32 not supported by the package."
  2009. # endif
  2010. #elif defined(__s390__)
  2011. # if defined(__s390x__)
  2012. # error "abi_s390_64 not supported by the package."
  2013. # else
  2014. # error "abi_s390_32 not supported by the package."
  2015. # endif
  2016. #elif defined(__powerpc__) || defined(__ppc__)
  2017. # if defined(__powerpc64__) || defined(__ppc64__)
  2018. # error "abi_ppc_64 not supported by the package."
  2019. # else
  2020. # error "abi_ppc_32 not supported by the package."
  2021. # endif
  2022. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  2023. # error "Native ABI not supported by the package."
  2024. #else
  2025. # error "No ABI matched, please report a bug to bugs.gentoo.org"
  2026. #endif
  2027. _EOF_
  2028. die;
  2029. fi
  2030. if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  2031. die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  2032. fi;
  2033. dodir "/tmp/multilib-include/${CHOST}${dir}";
  2034. mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die;
  2035. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2036. if multilib_is_native_abi; then
  2037. sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2038. fi;
  2039. fi;
  2040. done;
  2041. fi;
  2042. fi
  2043. }
  2044. multilib_src_compile ()
  2045. {
  2046. emake sepermitlockdir="${EPREFIX}/run/sepermit"
  2047. }
  2048. multilib_src_configure ()
  2049. {
  2050. unset BROWSER;
  2051. export ac_cv_header_xcrypt_h=no;
  2052. local myconf=(--with-db-uniquename=-$(db_findver sys-libs/db) --enable-securedir="${EPREFIX}"/$(get_libdir)/security --libdir=/usr/$(get_libdir) --disable-prelude $(use_enable audit) $(use_enable berkdb db) $(use_enable cracklib) $(use_enable debug) $(use_enable nis) $(use_enable nls) $(use_enable pie) $(use_enable selinux) $(use_enable static-libs static) --enable-isadir='.');
  2053. ECONF_SOURCE="${S}" econf ${myconf[@]}
  2054. }
  2055. multilib_src_install ()
  2056. {
  2057. emake DESTDIR="${D}" install sepermitlockdir="${EPREFIX}/run/sepermit";
  2058. local prefix;
  2059. if multilib_is_native_abi; then
  2060. prefix=;
  2061. gen_usr_ldscript -a pam pamc pam_misc;
  2062. else
  2063. prefix=/usr;
  2064. fi;
  2065. local lib;
  2066. for lib in pam pamc pam_misc;
  2067. do
  2068. if ! [[ -f "${ED}"${prefix}/$(get_libdir)/lib${lib}$(get_libname) ]]; then
  2069. dosym lib${lib}$(get_libname 0) ${prefix}/$(get_libdir)/lib${lib}$(get_libname);
  2070. fi;
  2071. done
  2072. }
  2073. multilib_src_install_all ()
  2074. {
  2075. find "${ED}" -type f -name '*.la' -delete || die;
  2076. if use selinux; then
  2077. dodir /usr/lib/tmpfiles.d;
  2078. cat - > "${D}"/usr/lib/tmpfiles.d/${CATEGORY}:${PN}:${SLOT}.conf <<EOF
  2079. d /run/sepermit 0755 root root
  2080. EOF
  2081. fi
  2082. }
  2083. multilib_toolchain_setup ()
  2084. {
  2085. local v vv;
  2086. export ABI=$1;
  2087. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2088. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2089. do
  2090. vv="_abi_saved_${v}";
  2091. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2092. unset ${vv};
  2093. done;
  2094. unset _DEFAULT_ABI_SAVED;
  2095. fi;
  2096. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2097. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2098. do
  2099. vv="_abi_saved_${v}";
  2100. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2101. done;
  2102. export _DEFAULT_ABI_SAVED="true";
  2103. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2104. export CBUILD=$(get_abi_CHOST $1);
  2105. fi;
  2106. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2107. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2108. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2109. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2110. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2111. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2112. export CHOST=$(get_abi_CHOST $1);
  2113. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2114. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2115. fi
  2116. }
  2117. number_abis ()
  2118. {
  2119. set -- `get_install_abis`;
  2120. echo $#
  2121. }
  2122. pkg_nofetch ()
  2123. {
  2124. default
  2125. }
  2126. pkg_postinst ()
  2127. {
  2128. ewarn "Some software with pre-loaded PAM libraries might experience";
  2129. ewarn "warnings or failures related to missing symbols and/or versions";
  2130. ewarn "after any update. While unfortunate this is a limit of the";
  2131. ewarn "implementation of PAM and the software, and it requires you to";
  2132. ewarn "restart the software manually after the update.";
  2133. ewarn "";
  2134. ewarn "You can get a list of such software running a command like";
  2135. ewarn " lsof / | egrep -i 'del.*libpam\\.so'";
  2136. ewarn "";
  2137. ewarn "Alternatively, simply reboot your system.";
  2138. fcaps cap_dac_override sbin/unix_chkpwd
  2139. }
  2140. run_in_build_dir ()
  2141. {
  2142. debug-print-function ${FUNCNAME} "${@}";
  2143. local ret;
  2144. [[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified.";
  2145. [[ -n ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set.";
  2146. mkdir -p "${BUILD_DIR}" || die;
  2147. pushd "${BUILD_DIR}" > /dev/null || die;
  2148. "${@}";
  2149. ret=${?};
  2150. popd > /dev/null || die;
  2151. return ${ret}
  2152. }
  2153. src_compile ()
  2154. {
  2155. multilib-minimal_src_compile "$@"
  2156. }
  2157. src_configure ()
  2158. {
  2159. multilib-minimal_src_configure "$@"
  2160. }
  2161. src_install ()
  2162. {
  2163. multilib-minimal_src_install "$@"
  2164. }
  2165. src_prepare ()
  2166. {
  2167. default;
  2168. eapply "${FILESDIR}/${PN}-remove-browsers.patch";
  2169. touch ChangeLog || die;
  2170. eautoreconf
  2171. }
  2172. src_test ()
  2173. {
  2174. multilib-minimal_src_test "$@"
  2175. }
  2176. src_unpack ()
  2177. {
  2178. default
  2179. }
  2180. tc-arch ()
  2181. {
  2182. tc-ninja_magic_to_arch portage "$@"
  2183. }
  2184. tc-arch-kernel ()
  2185. {
  2186. tc-ninja_magic_to_arch kern "$@"
  2187. }
  2188. tc-check-openmp ()
  2189. {
  2190. if ! tc-has-openmp; then
  2191. eerror "Your current compiler does not support OpenMP!";
  2192. if tc-is-gcc; then
  2193. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  2194. else
  2195. if tc-is-clang; then
  2196. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  2197. fi;
  2198. fi;
  2199. die "Active compiler does not have required support for OpenMP";
  2200. fi
  2201. }
  2202. tc-cpp-is-true ()
  2203. {
  2204. local CONDITION=${1};
  2205. shift;
  2206. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  2207. #if ${CONDITION}
  2208. true
  2209. #endif
  2210. EOF
  2211. );
  2212. [[ ${RESULT} == true ]]
  2213. }
  2214. tc-detect-is-softfloat ()
  2215. {
  2216. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  2217. case ${CTARGET:-${CHOST}} in
  2218. *-newlib | *-elf | *-eabi)
  2219. return 1
  2220. ;;
  2221. arm*)
  2222. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  2223. echo "no";
  2224. else
  2225. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  2226. echo "yes";
  2227. else
  2228. echo "softfp";
  2229. fi;
  2230. fi;
  2231. return 0
  2232. ;;
  2233. *)
  2234. return 1
  2235. ;;
  2236. esac
  2237. }
  2238. tc-enables-pie ()
  2239. {
  2240. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  2241. }
  2242. tc-enables-ssp ()
  2243. {
  2244. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2245. }
  2246. tc-enables-ssp-all ()
  2247. {
  2248. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2249. }
  2250. tc-enables-ssp-strong ()
  2251. {
  2252. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2253. }
  2254. tc-endian ()
  2255. {
  2256. local host=$1;
  2257. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2258. host=${host%%-*};
  2259. case ${host} in
  2260. aarch64*be)
  2261. echo big
  2262. ;;
  2263. aarch64)
  2264. echo little
  2265. ;;
  2266. alpha*)
  2267. echo little
  2268. ;;
  2269. arm*b*)
  2270. echo big
  2271. ;;
  2272. arm*)
  2273. echo little
  2274. ;;
  2275. cris*)
  2276. echo little
  2277. ;;
  2278. hppa*)
  2279. echo big
  2280. ;;
  2281. i?86*)
  2282. echo little
  2283. ;;
  2284. ia64*)
  2285. echo little
  2286. ;;
  2287. m68*)
  2288. echo big
  2289. ;;
  2290. mips*l*)
  2291. echo little
  2292. ;;
  2293. mips*)
  2294. echo big
  2295. ;;
  2296. powerpc*le)
  2297. echo little
  2298. ;;
  2299. powerpc*)
  2300. echo big
  2301. ;;
  2302. s390*)
  2303. echo big
  2304. ;;
  2305. sh*b*)
  2306. echo big
  2307. ;;
  2308. sh*)
  2309. echo little
  2310. ;;
  2311. sparc*)
  2312. echo big
  2313. ;;
  2314. x86_64*)
  2315. echo little
  2316. ;;
  2317. *)
  2318. echo wtf
  2319. ;;
  2320. esac
  2321. }
  2322. tc-env_build ()
  2323. {
  2324. tc-export_build_env;
  2325. 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) "$@"
  2326. }
  2327. tc-export ()
  2328. {
  2329. local var;
  2330. for var in "$@";
  2331. do
  2332. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2333. "tc-get${var}" > /dev/null;
  2334. done
  2335. }
  2336. tc-export_build_env ()
  2337. {
  2338. tc-export "$@";
  2339. if tc-is-cross-compiler; then
  2340. : ${BUILD_CFLAGS:=-O1 -pipe};
  2341. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2342. : ${BUILD_CPPFLAGS:= };
  2343. : ${BUILD_LDFLAGS:= };
  2344. else
  2345. : ${BUILD_CFLAGS:=${CFLAGS}};
  2346. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  2347. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  2348. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  2349. fi;
  2350. export BUILD_{C,CXX,CPP,LD}FLAGS;
  2351. local v;
  2352. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  2353. do
  2354. export ${v#BUILD_}_FOR_BUILD="${!v}";
  2355. done
  2356. }
  2357. tc-get-compiler-type ()
  2358. {
  2359. local code='
  2360. #if defined(__PATHSCALE__)
  2361. HAVE_PATHCC
  2362. #elif defined(__clang__)
  2363. HAVE_CLANG
  2364. #elif defined(__GNUC__)
  2365. HAVE_GCC
  2366. #endif
  2367. ';
  2368. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  2369. case ${res} in
  2370. *HAVE_PATHCC*)
  2371. echo pathcc
  2372. ;;
  2373. *HAVE_CLANG*)
  2374. echo clang
  2375. ;;
  2376. *HAVE_GCC*)
  2377. echo gcc
  2378. ;;
  2379. *)
  2380. echo unknown
  2381. ;;
  2382. esac
  2383. }
  2384. tc-getAR ()
  2385. {
  2386. tc-getPROG AR ar "$@"
  2387. }
  2388. tc-getAS ()
  2389. {
  2390. tc-getPROG AS as "$@"
  2391. }
  2392. tc-getBUILD_AR ()
  2393. {
  2394. tc-getBUILD_PROG AR ar "$@"
  2395. }
  2396. tc-getBUILD_AS ()
  2397. {
  2398. tc-getBUILD_PROG AS as "$@"
  2399. }
  2400. tc-getBUILD_CC ()
  2401. {
  2402. tc-getBUILD_PROG CC gcc "$@"
  2403. }
  2404. tc-getBUILD_CPP ()
  2405. {
  2406. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  2407. }
  2408. tc-getBUILD_CXX ()
  2409. {
  2410. tc-getBUILD_PROG CXX g++ "$@"
  2411. }
  2412. tc-getBUILD_LD ()
  2413. {
  2414. tc-getBUILD_PROG LD ld "$@"
  2415. }
  2416. tc-getBUILD_NM ()
  2417. {
  2418. tc-getBUILD_PROG NM nm "$@"
  2419. }
  2420. tc-getBUILD_OBJCOPY ()
  2421. {
  2422. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2423. }
  2424. tc-getBUILD_PKG_CONFIG ()
  2425. {
  2426. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2427. }
  2428. tc-getBUILD_PROG ()
  2429. {
  2430. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  2431. tc-is-cross-compiler || vars+=" $1";
  2432. _tc-getPROG CBUILD "${vars}" "${@:2}"
  2433. }
  2434. tc-getBUILD_RANLIB ()
  2435. {
  2436. tc-getBUILD_PROG RANLIB ranlib "$@"
  2437. }
  2438. tc-getBUILD_STRIP ()
  2439. {
  2440. tc-getBUILD_PROG STRIP strip "$@"
  2441. }
  2442. tc-getCC ()
  2443. {
  2444. tc-getPROG CC gcc "$@"
  2445. }
  2446. tc-getCPP ()
  2447. {
  2448. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  2449. }
  2450. tc-getCXX ()
  2451. {
  2452. tc-getPROG CXX g++ "$@"
  2453. }
  2454. tc-getDLLWRAP ()
  2455. {
  2456. tc-getPROG DLLWRAP dllwrap "$@"
  2457. }
  2458. tc-getF77 ()
  2459. {
  2460. tc-getPROG F77 gfortran "$@"
  2461. }
  2462. tc-getFC ()
  2463. {
  2464. tc-getPROG FC gfortran "$@"
  2465. }
  2466. tc-getGCJ ()
  2467. {
  2468. tc-getPROG GCJ gcj "$@"
  2469. }
  2470. tc-getGO ()
  2471. {
  2472. tc-getPROG GO gccgo "$@"
  2473. }
  2474. tc-getLD ()
  2475. {
  2476. tc-getPROG LD ld "$@"
  2477. }
  2478. tc-getNM ()
  2479. {
  2480. tc-getPROG NM nm "$@"
  2481. }
  2482. tc-getOBJCOPY ()
  2483. {
  2484. tc-getPROG OBJCOPY objcopy "$@"
  2485. }
  2486. tc-getOBJDUMP ()
  2487. {
  2488. tc-getPROG OBJDUMP objdump "$@"
  2489. }
  2490. tc-getPKG_CONFIG ()
  2491. {
  2492. tc-getPROG PKG_CONFIG pkg-config "$@"
  2493. }
  2494. tc-getPROG ()
  2495. {
  2496. _tc-getPROG CHOST "$@"
  2497. }
  2498. tc-getRANLIB ()
  2499. {
  2500. tc-getPROG RANLIB ranlib "$@"
  2501. }
  2502. tc-getRC ()
  2503. {
  2504. tc-getPROG RC windres "$@"
  2505. }
  2506. tc-getSTRIP ()
  2507. {
  2508. tc-getPROG STRIP strip "$@"
  2509. }
  2510. tc-getTARGET_CPP ()
  2511. {
  2512. if [[ -n ${CTARGET} ]]; then
  2513. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  2514. else
  2515. tc-getCPP "$@";
  2516. fi
  2517. }
  2518. tc-has-openmp ()
  2519. {
  2520. local base="${T}/test-tc-openmp";
  2521. cat > "${base}.c" <<-EOF
  2522. #include <omp.h>
  2523. int main() {
  2524. int nthreads, tid, ret = 0;
  2525. #pragma omp parallel private(nthreads, tid)
  2526. {
  2527. tid = omp_get_thread_num();
  2528. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  2529. }
  2530. return ret;
  2531. }
  2532. EOF
  2533. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  2534. local ret=$?;
  2535. rm -f "${base}"*;
  2536. return ${ret}
  2537. }
  2538. tc-has-tls ()
  2539. {
  2540. local base="${T}/test-tc-tls";
  2541. cat > "${base}.c" <<-EOF
  2542. int foo(int *i) {
  2543. static __thread int j = 0;
  2544. return *i ? j : *i;
  2545. }
  2546. EOF
  2547. local flags;
  2548. case $1 in
  2549. -s)
  2550. flags="-S"
  2551. ;;
  2552. -c)
  2553. flags="-c"
  2554. ;;
  2555. -l)
  2556. ;;
  2557. -*)
  2558. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  2559. ;;
  2560. esac;
  2561. : ${flags:=-fPIC -shared -Wl,-z,defs};
  2562. [[ $1 == -* ]] && shift;
  2563. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  2564. local ret=$?;
  2565. rm -f "${base}"*;
  2566. return ${ret}
  2567. }
  2568. tc-is-clang ()
  2569. {
  2570. [[ $(tc-get-compiler-type) == clang ]]
  2571. }
  2572. tc-is-cross-compiler ()
  2573. {
  2574. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  2575. }
  2576. tc-is-gcc ()
  2577. {
  2578. [[ $(tc-get-compiler-type) == gcc ]]
  2579. }
  2580. tc-is-softfloat ()
  2581. {
  2582. tc-detect-is-softfloat || tc-tuple-is-softfloat
  2583. }
  2584. tc-is-static-only ()
  2585. {
  2586. local host=${CTARGET:-${CHOST}};
  2587. [[ ${host} == *-mint* ]]
  2588. }
  2589. tc-ld-disable-gold ()
  2590. {
  2591. if ! tc-ld-is-gold "$@"; then
  2592. return;
  2593. fi;
  2594. ewarn "Forcing usage of the BFD linker instead of GOLD";
  2595. local ld=$(tc-getLD "$@");
  2596. local bfd_ld="${ld%% *}.bfd";
  2597. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  2598. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  2599. local fallback="true";
  2600. if tc-is-gcc; then
  2601. local major=$(gcc-major-version "$@");
  2602. local minor=$(gcc-minor-version "$@");
  2603. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  2604. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  2605. fallback="false";
  2606. fi;
  2607. else
  2608. if tc-is-clang; then
  2609. local major=$(clang-major-version "$@");
  2610. local minor=$(clang-minor-version "$@");
  2611. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  2612. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  2613. fallback="false";
  2614. fi;
  2615. fi;
  2616. fi;
  2617. if [[ ${fallback} == "true" ]]; then
  2618. if [[ -e ${path_ld} ]]; then
  2619. local d="${T}/bfd-linker";
  2620. mkdir -p "${d}";
  2621. ln -sf "${path_ld}" "${d}"/ld;
  2622. export LDFLAGS="${LDFLAGS} -B${d}";
  2623. else
  2624. die "unable to locate a BFD linker to bypass gold";
  2625. fi;
  2626. fi
  2627. }
  2628. tc-ld-is-gold ()
  2629. {
  2630. local out;
  2631. out=$($(tc-getLD "$@") --version 2>&1);
  2632. if [[ ${out} == *"GNU gold"* ]]; then
  2633. return 0;
  2634. fi;
  2635. local base="${T}/test-tc-gold";
  2636. cat > "${base}.c" <<-EOF
  2637. int main() { return 0; }
  2638. EOF
  2639. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  2640. rm -f "${base}"*;
  2641. if [[ ${out} == *"GNU gold"* ]]; then
  2642. return 0;
  2643. fi;
  2644. return 1
  2645. }
  2646. tc-ninja_magic_to_arch ()
  2647. {
  2648. function ninj ()
  2649. {
  2650. [[ ${type} == "kern" ]] && echo $1 || echo $2
  2651. };
  2652. local type=$1;
  2653. local host=$2;
  2654. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2655. case ${host} in
  2656. aarch64*)
  2657. echo arm64
  2658. ;;
  2659. alpha*)
  2660. echo alpha
  2661. ;;
  2662. arm*)
  2663. echo arm
  2664. ;;
  2665. avr*)
  2666. ninj avr32 avr
  2667. ;;
  2668. bfin*)
  2669. ninj blackfin bfin
  2670. ;;
  2671. c6x*)
  2672. echo c6x
  2673. ;;
  2674. cris*)
  2675. echo cris
  2676. ;;
  2677. frv*)
  2678. echo frv
  2679. ;;
  2680. hexagon*)
  2681. echo hexagon
  2682. ;;
  2683. hppa*)
  2684. ninj parisc hppa
  2685. ;;
  2686. i?86*)
  2687. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  2688. echo i386;
  2689. else
  2690. echo x86;
  2691. fi
  2692. ;;
  2693. ia64*)
  2694. echo ia64
  2695. ;;
  2696. m68*)
  2697. echo m68k
  2698. ;;
  2699. metag*)
  2700. echo metag
  2701. ;;
  2702. microblaze*)
  2703. echo microblaze
  2704. ;;
  2705. mips*)
  2706. echo mips
  2707. ;;
  2708. nios2*)
  2709. echo nios2
  2710. ;;
  2711. nios*)
  2712. echo nios
  2713. ;;
  2714. or1k | or32*)
  2715. echo openrisc
  2716. ;;
  2717. powerpc*)
  2718. if [[ ${type} == "kern" ]]; then
  2719. echo powerpc;
  2720. else
  2721. if [[ ${host} == powerpc64* ]]; then
  2722. echo ppc64;
  2723. else
  2724. echo ppc;
  2725. fi;
  2726. fi
  2727. ;;
  2728. riscv*)
  2729. echo riscv
  2730. ;;
  2731. s390*)
  2732. echo s390
  2733. ;;
  2734. score*)
  2735. echo score
  2736. ;;
  2737. sh64*)
  2738. ninj sh64 sh
  2739. ;;
  2740. sh*)
  2741. echo sh
  2742. ;;
  2743. sparc64*)
  2744. ninj sparc64 sparc
  2745. ;;
  2746. sparc*)
  2747. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  2748. ;;
  2749. tile*)
  2750. echo tile
  2751. ;;
  2752. vax*)
  2753. echo vax
  2754. ;;
  2755. x86_64*freebsd*)
  2756. echo amd64
  2757. ;;
  2758. x86_64*)
  2759. if [[ ${type} == "kern" ]]; then
  2760. echo x86;
  2761. else
  2762. echo amd64;
  2763. fi
  2764. ;;
  2765. xtensa*)
  2766. echo xtensa
  2767. ;;
  2768. *)
  2769. echo unknown
  2770. ;;
  2771. esac
  2772. }
  2773. tc-stack-grows-down ()
  2774. {
  2775. case ${ARCH} in
  2776. hppa | metag)
  2777. return 1
  2778. ;;
  2779. esac;
  2780. return 0
  2781. }
  2782. tc-tuple-is-softfloat ()
  2783. {
  2784. local CTARGET=${CTARGET:-${CHOST}};
  2785. case ${CTARGET//_/-} in
  2786. bfin* | h8300*)
  2787. echo "only"
  2788. ;;
  2789. *-softfloat-*)
  2790. echo "yes"
  2791. ;;
  2792. *-softfp-*)
  2793. echo "softfp"
  2794. ;;
  2795. arm*-hardfloat-* | arm*eabihf)
  2796. echo "no"
  2797. ;;
  2798. *-newlib | *-elf | *-eabi)
  2799. echo "no"
  2800. ;;
  2801. arm*)
  2802. echo "yes"
  2803. ;;
  2804. *)
  2805. echo "no"
  2806. ;;
  2807. esac
  2808. }
  2809. uclibctoolize ()
  2810. {
  2811. die "Use elibtoolize"
  2812. }
  2813. ver_cut ()
  2814. {
  2815. local range=${1};
  2816. local v=${2:-${PV}};
  2817. local start end;
  2818. local -a comp;
  2819. _ver_split "${v}";
  2820. local max=$((${#comp[@]}/2));
  2821. _ver_parse_range "${range}" "${max}";
  2822. if [[ ${start} -gt 0 ]]; then
  2823. start=$(( start*2 - 1 ));
  2824. fi;
  2825. printf "%s" "${comp[@]:start:end*2-start}" '
  2826. '
  2827. }
  2828. ver_rs ()
  2829. {
  2830. local v;
  2831. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  2832. local start end i;
  2833. local -a comp;
  2834. _ver_split "${v}";
  2835. local max=$((${#comp[@]}/2 - 1));
  2836. while [[ ${#} -ge 2 ]]; do
  2837. _ver_parse_range "${1}" "${max}";
  2838. for ((i = start*2; i <= end*2; i+=2 ))
  2839. do
  2840. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  2841. comp[i]=${2};
  2842. done;
  2843. shift 2;
  2844. done;
  2845. local IFS=;
  2846. echo "${comp[*]}"
  2847. }
  2848. ver_test ()
  2849. {
  2850. local va op vb;
  2851. if [[ $# -eq 3 ]]; then
  2852. va=${1};
  2853. shift;
  2854. else
  2855. va=${PVR};
  2856. fi;
  2857. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  2858. op=${1};
  2859. vb=${2};
  2860. case ${op} in
  2861. -eq | -ne | -lt | -le | -gt | -ge)
  2862. ;;
  2863. *)
  2864. die "${FUNCNAME}: invalid operator: ${op}"
  2865. ;;
  2866. esac;
  2867. _ver_compare "${va}" "${vb}";
  2868. test $? "${op}" 2
  2869. }
  2870.