Guest User

emerge fail

a guest
Dec 21st, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 127.64 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_S390=""
  4. declare -x ABI_X86="64"
  5. declare -x ADA_TARGET=""
  6. 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")
  7. declare -x ALSA_CARDS=""
  8. declare -x AMDGPU_TARGETS=""
  9. declare -- AM_OPTS=""
  10. declare -x APACHE2_MODULES=""
  11. declare -x APACHE2_MPMS=""
  12. declare -x ARCH="amd64"
  13. declare -- AT_M4DIR=""
  14. declare -- AT_NOEAUTOHEADER=""
  15. declare -- AT_NOEAUTOMAKE=""
  16. declare -- AT_NOELIBTOOLIZE=""
  17. declare -- AT_SYS_M4DIR=""
  18. declare -- AUTOTOOLS_AUTO_DEPEND="yes"
  19. declare -- AUTOTOOLS_DEPEND=$'\n\tsys-devel/gnuconfig\n\t|| ( >=dev-build/automake-1.17-r1:1.17 >=dev-build/automake-1.16.5:1.16 )\n\t|| ( >=dev-build/autoconf-2.72-r1:2.72 >=dev-build/autoconf-2.71-r6:2.71 )\n\t>=dev-build/libtool-2.4.7-r3\n'
  20. declare BDEPEND=$'virtual/libcrypt\n\tberkdb? ( >=sys-libs/db-4.8.30-r1:4.8 )\n\tgdbm? ( >=sys-libs/gdbm-1.10-r1 ) >=app-portage/elt-patches-20240116 \n\tsys-devel/gnuconfig\n\t|| ( >=dev-build/automake-1.17-r1:1.17 >=dev-build/automake-1.16.5:1.16 )\n\t|| ( >=dev-build/autoconf-2.72-r1:2.72 >=dev-build/autoconf-2.71-r6:2.71 )\n\t>=dev-build/libtool-2.4.7-r3\n virtual/pkgconfig'
  21. declare -x BINPKG_FORMAT="xpak"
  22. declare -x BINPKG_GPG_SIGNING_BASE_COMMAND="/usr/bin/flock /run/lock/portage-binpkg-gpg.lock /usr/bin/gpg --sign --armor [PORTAGE_CONFIG]"
  23. declare -x BINPKG_GPG_SIGNING_DIGEST="SHA512"
  24. declare -x BINPKG_GPG_VERIFY_BASE_COMMAND="/usr/bin/gpg --verify --batch --no-tty --no-auto-check-trustdb --status-fd 2 [PORTAGE_CONFIG] [SIGNATURE]"
  25. declare -x BINPKG_GPG_VERIFY_GPG_HOME="/etc/portage/gnupg"
  26. declare -x BOOTSTRAP_USE="unicode pkg-config split-usr xml python_targets_python3_12 python_single_target_python3_12 multilib zstd cet"
  27. declare -x CALLIGRA_FEATURES=""
  28. declare -x CAMERAS=""
  29. declare -x CBUILD="x86_64-pc-linux-gnu"
  30. declare -x CC_FOR_BUILD="x86_64-pc-linux-gnu-gcc"
  31. declare -x CFLAGS="-O2 -pipe -std=gnu17"
  32. declare -x CFLAGS_amd64="-m64"
  33. declare -x CFLAGS_default
  34. declare -x CFLAGS_x32="-mx32"
  35. declare -x CFLAGS_x86="-m32 -mfpmath=sse"
  36. declare -x CHOST="x86_64-pc-linux-gnu"
  37. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  38. declare -x CHOST_default="x86_64-pc-linux-gnu"
  39. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  40. declare -x CHOST_x86="i686-pc-linux-gnu"
  41. declare -x COLLECTD_PLUGINS=""
  42. declare -x CONF_PREFIX="/usr"
  43. declare -x CPPFLAGS=" -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -DLDAP_DEPRECATED -D_DEFAULT_SOURCE"
  44. declare -x CPU_FLAGS_ARM=""
  45. declare -x CPU_FLAGS_PPC=""
  46. declare -x CPU_FLAGS_X86=""
  47. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  48. declare -x CURL_QUIC=""
  49. declare -x CURL_SSL=""
  50. declare -x CXXFLAGS="-O2 -pipe -std=gnu17"
  51. declare -x DEFAULT_ABI="amd64"
  52. declare -x DEFINED_PHASES=" compile configure install postinst prepare test"
  53. declare DEPEND=$'net-mail/mailbase\n\tvirtual/libcrypt:=\n\tauthdaemond? ( || ( net-mail/courier-imap mail-mta/courier ) )\n\tberkdb? ( >=sys-libs/db-4.8.30-r1:4.8[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tgdbm? ( >=sys-libs/gdbm-1.10-r1:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tkerberos? ( >=virtual/krb5-0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\topenldap? ( >=net-nds/openldap-2.4.38-r1:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tmysql? ( dev-db/mysql-connector-c:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tpam? ( >=sys-libs/pam-0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tpostgres? ( dev-db/postgresql:* )\n\tsqlite? ( >=dev-db/sqlite-3.8.2:3[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tssl? ( >=dev-libs/openssl-1.0.1h-r2:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] ) '
  54. declare DESCRIPTION="The Cyrus SASL (Simple Authentication and Security Layer)"
  55. declare -x DIROPTIONS="-m0755"
  56. declare -x EAPI="8"
  57. declare -x ELIBC="glibc"
  58. declare -x ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
  59. declare -- EPOCHREALTIME="1734816667.227889"
  60. declare -- EPOCHSECONDS="1734816667"
  61. declare -x EXEOPTIONS="-m0755"
  62. declare -x FCFLAGS="-O2 -pipe -std=gnu17"
  63. 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}\""
  64. declare -x FFLAGS="-O2 -pipe -std=gnu17"
  65. declare -x FFTOOLS=""
  66. declare -x GCC_SPECS=""
  67. declare -- GNUCONFIG_AUTO_DEPEND="no"
  68. declare -- GNUCONFIG_DEPEND="sys-devel/gnuconfig"
  69. declare -x GPG_VERIFY_GROUP_DROP="nogroup"
  70. declare -x GPG_VERIFY_USER_DROP="nobody"
  71. declare -x GPSD_PROTOCOLS=""
  72. declare -x GRUB_PLATFORMS=""
  73. declare -x GUILE_SINGLE_TARGET=""
  74. declare -x GUILE_TARGETS=""
  75. declare HOMEPAGE="https://www.cyrusimap.org/sasl/"
  76. declare IDEPEND=""
  77. declare -x INHERITED=" gnuconfig toolchain-funcs multilib libtool autotools edos2unix flag-o-matic out-of-source-utils multibuild multilib-build multilib-minimal pam db-use systemd tmpfiles"
  78. declare -x INPUT_DEVICES=""
  79. declare -x INSOPTIONS="-m0644"
  80. declare IUSE="authdaemond berkdb gdbm kerberos ldapdb openldap mysql pam postgres sample selinux sqlite srp ssl static-libs urandom abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_s390_32 abi_s390_64"
  81. declare -x IUSE_EFFECTIVE="abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-linux arm arm64 arm64-macos authdaemond berkdb elibc_Darwin elibc_SunOS elibc_bionic elibc_glibc elibc_mingw elibc_musl gdbm hppa kerberos kernel_Darwin kernel_SunOS kernel_linux ldapdb loong m68k mips mysql openldap pam postgres ppc ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack riscv s390 sample selinux sparc sqlite srp ssl static-libs urandom x64-macos x64-solaris x86 x86-linux"
  82. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest prefix-stack"
  83. declare -x KERNEL="linux"
  84. declare -x KERNEL_ABI="amd64"
  85. declare -x KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ~ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
  86. declare -x L10N=""
  87. declare -x LANG="en_AU.utf8"
  88. declare -x LCD_DEVICES=""
  89. declare -x LC_COLLATE="C"
  90. declare -x LC_MESSAGES="C"
  91. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
  92. declare -x LDFLAGS_amd64="-m elf_x86_64"
  93. declare -x LDFLAGS_default
  94. declare -x LDFLAGS_x32="-m elf32_x86_64"
  95. declare -x LDFLAGS_x86="-m elf_i386"
  96. declare -x LEX="flex"
  97. declare -x LIBDIR_amd64="lib64"
  98. declare -x LIBDIR_default="lib"
  99. declare -x LIBDIR_x32="libx32"
  100. declare -x LIBDIR_x86="lib"
  101. declare -x LIBOPTIONS="-m0644"
  102. declare -x LIBREOFFICE_EXTENSIONS=""
  103. declare -x LICENSE="BSD-with-attribution"
  104. declare -x LLVM_SLOT=""
  105. declare -x LLVM_TARGETS=""
  106. declare -x LUA_SINGLE_TARGET=""
  107. declare -x LUA_TARGETS=""
  108. declare -x MAKEOPTS="-j5"
  109. declare -x MANPAGER="manpager"
  110. declare -x MULTILIB_ABIS="amd64 x86"
  111. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  112. 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"
  113. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  114. declare -- MULTILIB_USEDEP="abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?"
  115. declare -a MULTILIB_WRAPPED_HEADERS=([0]="/usr/include/sasl/md5global.h")
  116. declare -- MY_PATCH_VER="cyrus-sasl-2.1.28-r4-patches"
  117. declare -x NGINX_MODULES_HTTP=""
  118. declare -x NGINX_MODULES_MAIL=""
  119. declare -x NGINX_MODULES_STREAM=""
  120. declare -x OFFICE_IMPLEMENTATION=""
  121. declare -x OPENMPI_FABRICS=""
  122. declare -x OPENMPI_OFED_FEATURES=""
  123. declare -x OPENMPI_RM=""
  124. declare -a PATCHES=([0]="/var/tmp/portage/dev-libs/cyrus-sasl-2.1.28-r5/work/cyrus-sasl-2.1.28-r4-patches/")
  125. declare -x PATH="/usr/lib/portage/python3.12/ebuild-helpers/xattr:/usr/lib/portage/python3.12/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/19/bin:/usr/lib/llvm/18/bin"
  126. declare PDEPEND=""
  127. declare -x PERL_FEATURES=""
  128. declare -x PHP_TARGETS=""
  129. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  130. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  131. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  132. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/cyrus-sasl-2.1.28-r5/html")
  133. declare -a PORTAGE_DOSTRIP=([0]="/")
  134. declare -a PORTAGE_DOSTRIP_SKIP=()
  135. declare -x PORTAGE_REPO_REVISIONS="{\"gentoo\": \"748d62a710387f50a59103179c4b0d0796cb3ef5\"}"
  136. declare -x POSTGRES_TARGETS=""
  137. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc"
  138. declare -x PROFILE_23_USRTYPE="split-usr"
  139. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL"
  140. declare -- PROPERTIES=""
  141. declare -x PYTHONDONTWRITEBYTECODE="1"
  142. declare -x PYTHON_SINGLE_TARGET=""
  143. declare -x PYTHON_TARGETS=""
  144. declare -x QEMU_SOFTMMU_TARGETS=""
  145. declare -x QEMU_USER_TARGETS=""
  146. declare RDEPEND=$'net-mail/mailbase\n\tvirtual/libcrypt:=\n\tauthdaemond? ( || ( net-mail/courier-imap mail-mta/courier ) )\n\tberkdb? ( >=sys-libs/db-4.8.30-r1:4.8[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tgdbm? ( >=sys-libs/gdbm-1.10-r1:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tkerberos? ( >=virtual/krb5-0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\topenldap? ( >=net-nds/openldap-2.4.38-r1:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tmysql? ( dev-db/mysql-connector-c:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tpam? ( >=sys-libs/pam-0-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tpostgres? ( dev-db/postgresql:* )\n\tsqlite? ( >=dev-db/sqlite-3.8.2:3[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tssl? ( >=dev-libs/openssl-1.0.1h-r2:0=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?] )\n\tselinux? ( sec-policy/selinux-sasl ) virtual/tmpfiles'
  147. declare REPOSITORY
  148. declare REQUIRED_USE="ldapdb? ( openldap ) "
  149. declare RESTRICT=""
  150. 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}\""
  151. declare -x RUBY_TARGETS=""
  152. declare -x S="/var/tmp/portage/dev-libs/cyrus-sasl-2.1.28-r5/work/cyrus-sasl-2.1.28"
  153. declare -x SANDBOX_DEBUG="0"
  154. declare -x SANDBOX_DENY=""
  155. declare -x SANDBOX_METHOD="any"
  156. declare -x SANDBOX_PREDICT="/var/tmp/portage/dev-libs/cyrus-sasl-2.1.28-r5/homedir:/dev/crypto:/var/cache/man:/var/cache/fontconfig"
  157. declare -x SANDBOX_READ="/:/var/tmp/portage"
  158. declare -x SANDBOX_VERBOSE="1"
  159. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp/:/var/tmp/portage:/var/tmp/portage/dev-libs/cyrus-sasl-2.1.28-r5/homedir/.bash_history"
  160. declare -x SANE_BACKENDS=""
  161. declare -- SASLAUTHD_CONF_VER="2.1.26"
  162. declare -x SHELL="/bin/bash"
  163. declare -x SHELL_SETS_TITLE="0"
  164. declare -x SLOT="2"
  165. declare -i SRANDOM="2945356026"
  166. declare SRC_URI="https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.28/cyrus-sasl-2.1.28.tar.gz https://dev.gentoo.org/~grobian/distfiles/cyrus-sasl-2.1.28-r4-patches.tar.xz"
  167. declare -x SYMLINK_LIB="no"
  168. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  169. declare -x USE="abi_x86_64 amd64 berkdb elibc_glibc kernel_linux pam ssl"
  170. declare -x USERLAND="GNU"
  171. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL"
  172. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  173. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-linux arm arm64 arm64-macos hppa loong m68k mips ppc ppc64 ppc64-linux ppc-macos riscv s390 sparc x64-macos x64-solaris x86 x86-linux"
  174. declare -x USE_EXPAND_VALUES_ELIBC="bionic Darwin glibc mingw musl SunOS"
  175. declare -x USE_EXPAND_VALUES_KERNEL="Darwin linux SunOS"
  176. declare -x UWSGI_PLUGINS=""
  177. declare -x VIDEO_CARDS=""
  178. declare -x VOICEMAIL_STORAGE=""
  179. declare -x WANT_AUTOCONF="2.72"
  180. declare -x WANT_AUTOMAKE="1.16"
  181. declare -x WANT_LIBTOOL="latest"
  182. declare -x XTABLES_ADDONS=""
  183. declare -- _AUTOTOOLS_AUTO_DEPEND="yes"
  184. declare -- _AUTOTOOLS_ECLASS="1"
  185. declare -- _FLAG_O_MATIC_ECLASS="1"
  186. declare -- _GNUCONFIG_CLASS="1"
  187. declare -a _LATEST_AUTOCONF=([0]="2.72-r1:2.72" [1]="2.71-r6:2.71")
  188. declare -a _LATEST_AUTOMAKE=([0]="1.17-r1:1.17" [1]="1.16.5:1.16")
  189. declare -- _LIBTOOL_ECLASS="1"
  190. declare -- _MULTIBUILD_ECLASS="1"
  191. declare -- _MULTILIB_BUILD_ECLASS="1"
  192. declare -- _MULTILIB_ECLASS="1"
  193. 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_s390_32:s390" [7]="abi_s390_64:s390x")
  194. declare -- _MULTILIB_MINIMAL_ECLASS="1"
  195. declare -- _OUT_OF_SOURCE_UTILS_ECLASS="1"
  196. declare -- _PAM_ECLASS="1"
  197. declare -- _SYSTEMD_ECLASS="1"
  198. declare -- _TMPFILES_ECLASS="1"
  199. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  200. declare -x __E_DESTTREE="/usr"
  201. declare -x __E_DOCDESTTREE=""
  202. declare -x __E_EXEDESTTREE=""
  203. declare -x __E_INSDESTTREE=""
  204. declare -- _libtool_atom=">=dev-build/libtool-2.4.7-r3"
  205. declare -x ac_cv_c_undeclared_builtin_options="none needed"
  206. declare -x enable_year2038="no"
  207. declare -x gl_cv_compiler_check_decl_option="-Werror=implicit-function-declaration"
  208. declare -x gl_cv_func_getcwd_path_max="yes"
  209. __eapi6_src_install ()
  210. {
  211. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  212. emake DESTDIR="${D}" install;
  213. fi;
  214. einstalldocs
  215. }
  216. __eapi6_src_prepare ()
  217. {
  218. if ___is_indexed_array_var PATCHES; then
  219. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  220. else
  221. if [[ -n ${PATCHES} ]]; then
  222. eapply ${PATCHES};
  223. fi;
  224. fi;
  225. eapply_user
  226. }
  227. __eapi7_ver_compare ()
  228. {
  229. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  230. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  231. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  232. an=${BASH_REMATCH[1]};
  233. al=${BASH_REMATCH[3]};
  234. as=${BASH_REMATCH[4]};
  235. ar=${BASH_REMATCH[7]};
  236. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  237. bn=${BASH_REMATCH[1]};
  238. bl=${BASH_REMATCH[3]};
  239. bs=${BASH_REMATCH[4]};
  240. br=${BASH_REMATCH[7]};
  241. __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  242. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  243. an=${an#*.};
  244. bn=${bn#*.};
  245. a=${an%%.*};
  246. b=${bn%%.*};
  247. if [[ ${a} == 0* || ${b} == 0* ]]; then
  248. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  249. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  250. [[ ${a} > ${b} ]] && return 3;
  251. [[ ${a} < ${b} ]] && return 1;
  252. else
  253. __eapi7_ver_compare_int "${a}" "${b}" || return;
  254. fi;
  255. done;
  256. [[ ${an} == *.* ]] && return 3;
  257. [[ ${bn} == *.* ]] && return 1;
  258. [[ ${al} > ${bl} ]] && return 3;
  259. [[ ${al} < ${bl} ]] && return 1;
  260. as=${as#_}${as:+_};
  261. bs=${bs#_}${bs:+_};
  262. while [[ -n ${as} && -n ${bs} ]]; do
  263. a=${as%%_*};
  264. b=${bs%%_*};
  265. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  266. __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  267. else
  268. [[ ${a%%[0-9]*} == p ]] && return 3;
  269. [[ ${b%%[0-9]*} == p ]] && return 1;
  270. [[ ${a} > ${b} ]] && return 3 || return 1;
  271. fi;
  272. as=${as#*_};
  273. bs=${bs#*_};
  274. done;
  275. if [[ -n ${as} ]]; then
  276. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  277. else
  278. if [[ -n ${bs} ]]; then
  279. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  280. fi;
  281. fi;
  282. __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  283. return 2
  284. }
  285. __eapi7_ver_compare_int ()
  286. {
  287. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  288. if [[ ${d} -gt 0 ]]; then
  289. printf -v b "%0${d}d%s" 0 "${b}";
  290. else
  291. if [[ ${d} -lt 0 ]]; then
  292. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  293. fi;
  294. fi;
  295. [[ ${a} > ${b} ]] && return 3;
  296. [[ ${a} == "${b}" ]]
  297. }
  298. __eapi7_ver_parse_range ()
  299. {
  300. local range=${1};
  301. local max=${2};
  302. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  303. start=${range%-*};
  304. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  305. if [[ -n ${end} ]]; then
  306. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  307. [[ ${end} -le ${max} ]] || end=${max};
  308. else
  309. end=${max};
  310. fi
  311. }
  312. __eapi7_ver_split ()
  313. {
  314. local v=${1} LC_ALL=C;
  315. comp=();
  316. local s c;
  317. while [[ -n ${v} ]]; do
  318. s=${v%%[a-zA-Z0-9]*};
  319. v=${v:${#s}};
  320. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  321. v=${v:${#c}};
  322. comp+=("${s}" "${c}");
  323. done
  324. }
  325. __eapi8_src_prepare ()
  326. {
  327. local f;
  328. if ___is_indexed_array_var PATCHES; then
  329. [[ ${#PATCHES[@]} -gt 0 ]] && eapply -- "${PATCHES[@]}";
  330. else
  331. if [[ -n ${PATCHES} ]]; then
  332. eapply -- ${PATCHES};
  333. fi;
  334. fi;
  335. eapply_user
  336. }
  337. _at_uses_autoheader ()
  338. {
  339. _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  340. }
  341. _at_uses_automake ()
  342. {
  343. _at_uses_pkg AM_INIT_AUTOMAKE
  344. }
  345. _at_uses_gettext ()
  346. {
  347. _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  348. }
  349. _at_uses_glibgettext ()
  350. {
  351. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  352. }
  353. _at_uses_gnomedoc ()
  354. {
  355. _at_uses_pkg GNOME_DOC_INIT
  356. }
  357. _at_uses_gtkdoc ()
  358. {
  359. _at_uses_pkg GTK_DOC_CHECK
  360. }
  361. _at_uses_intltool ()
  362. {
  363. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  364. }
  365. _at_uses_libltdl ()
  366. {
  367. _at_uses_pkg LT_CONFIG_LTDL_DIR
  368. }
  369. _at_uses_libtool ()
  370. {
  371. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  372. }
  373. _at_uses_pkg ()
  374. {
  375. if [[ -n $(autotools_check_macro "$@") ]]; then
  376. return 0;
  377. else
  378. local macro args=();
  379. for macro in "$@";
  380. do
  381. args+=(-e "^[[:space:]]*${macro}\>");
  382. done;
  383. grep -E -q "${args[@]}" configure.??;
  384. fi
  385. }
  386. _automake_version ()
  387. {
  388. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  389. }
  390. _autotools_m4dir_include ()
  391. {
  392. local x include_opts flag;
  393. [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  394. for x in "$@";
  395. do
  396. case ${x} in
  397. -${flag})
  398.  
  399. ;;
  400. *)
  401. [[ ! -d ${x} ]] && ewarn "${ECLASS}: '${x}' does not exist";
  402. include_opts+=" -${flag} ${x}"
  403. ;;
  404. esac;
  405. done;
  406. echo ${include_opts}
  407. }
  408. _clang_fullversion ()
  409. {
  410. local ver="$1";
  411. shift;
  412. set -- $($(tc-getCPP "$@") -E -P - <<< "__clang_major__ __clang_minor__ __clang_patchlevel__");
  413. eval echo "${ver}"
  414. }
  415. _eapply_get_files ()
  416. {
  417. local LC_ALL=POSIX;
  418. local prev_shopt=$(shopt -p nullglob);
  419. shopt -s nullglob;
  420. local f;
  421. for f in "${1}"/*;
  422. do
  423. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  424. files+=("${f}");
  425. fi;
  426. done;
  427. ${prev_shopt}
  428. }
  429. _eapply_patch ()
  430. {
  431. local f=${1};
  432. local prefix=${2};
  433. ebegin "${prefix:-Applying }${f##*/}";
  434. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  435. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  436. all_opts+=(-s -F0);
  437. fi;
  438. ${patch_cmd} "${all_opts[@]}" < "${f}";
  439. failed=${?};
  440. if ! eend "${failed}"; then
  441. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  442. fi
  443. }
  444. _elibtoolize ()
  445. {
  446. local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  447. if [[ ${1} == "--auto-ltdl" ]]; then
  448. shift;
  449. _at_uses_libltdl && set -- "$@" --ltdl;
  450. fi;
  451. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  452. autotools_run_tool ${LIBTOOLIZE} "$@"
  453. }
  454. _filter-hardened ()
  455. {
  456. local f;
  457. for f in "$@";
  458. do
  459. case "${f}" in
  460. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  461. if ! gcc-specs-pie && ! tc-enables-pie; then
  462. continue;
  463. fi;
  464. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  465. if test-flags -nopie > /dev/null; then
  466. append-flags -nopie;
  467. else
  468. append-flags -no-pie;
  469. fi;
  470. fi
  471. ;;
  472. -fstack-protector | -fstack-protector-strong)
  473. if ! gcc-specs-ssp && ! tc-enables-ssp && ! tc-enables-ssp-strong; then
  474. continue;
  475. fi;
  476. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  477. ;;
  478. -fstack-protector-all)
  479. if ! gcc-specs-ssp-to-all && ! tc-enables-ssp-all; then
  480. continue;
  481. fi;
  482. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  483. ;;
  484. -fno-strict-overflow)
  485. gcc-specs-nostrict || continue;
  486. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  487. ;;
  488. -D_GLIBCXX_ASSERTIONS | -D_LIBCPP_ENABLE_ASSERTIONS | -D_LIBCPP_ENABLE_HARDENED_MODE)
  489. tc-enables-cxx-assertions || continue;
  490. append-cppflags -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -U_LIBCPP_ENABLE_HARDENED_MODE
  491. ;;
  492. -D_FORTIFY_SOURCE=*)
  493. tc-enables-fortify-source || continue;
  494. append-cppflags -U_FORTIFY_SOURCE
  495. ;;
  496. esac;
  497. done
  498. }
  499. _filter-var ()
  500. {
  501. local f x var=$1 new=();
  502. shift;
  503. for f in ${!var};
  504. do
  505. for x in "$@";
  506. do
  507. [[ ${f} == ${x} ]] && continue 2;
  508. done;
  509. new+=("${f}");
  510. done;
  511. export ${var}="${new[*]}"
  512. }
  513. _gcc-install-dir ()
  514. {
  515. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  516. }
  517. _gcc-specs-directive_raw ()
  518. {
  519. local cc=$(tc-getCC);
  520. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  521. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  522. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  523. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  524. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  525. { spec=spec $0 }
  526. END { print spec }';
  527. return 0
  528. }
  529. _gcc-specs-exists ()
  530. {
  531. [[ -f $(_gcc-install-dir)/$1 ]]
  532. }
  533. _gcc_fullversion ()
  534. {
  535. local ver="$1";
  536. shift;
  537. set -- $($(tc-getCPP "$@") -E -P - <<< "__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  538. eval echo "${ver}"
  539. }
  540. _is_flagq ()
  541. {
  542. local x var="$1[*]";
  543. for x in ${!var};
  544. do
  545. [[ ${x} == $2 ]] && return 0;
  546. done;
  547. return 1
  548. }
  549. _multibuild_run ()
  550. {
  551. local i=1;
  552. while [[ ${!i} == _* ]]; do
  553. (( i += 1 ));
  554. done;
  555. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  556. "${@}"
  557. }
  558. _multilib_multibuild_wrapper ()
  559. {
  560. debug-print-function ${FUNCNAME} "$@";
  561. local ABI=${MULTIBUILD_VARIANT#*.};
  562. local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  563. multilib_toolchain_setup "${ABI}";
  564. readonly ABI;
  565. "${@}"
  566. }
  567. _pam_flag_disabled ()
  568. {
  569. in_iuse pam && ! use pam
  570. }
  571. _setup-allowed-flags ()
  572. {
  573. ALLOWED_FLAGS=(-pipe -O '-O[123szg]' '-mcpu=*' '-march=*' '-mtune=*' '-mfpmath=*' -flto '-flto=*' -fno-lto '-fstack-protector*' -fstack-clash-protection '-fcf-protection=*' -fbounds-check -fbounds-checking -fno-PIE -fno-pie -nopie -no-pie -fharden-compares -fharden-conditional-branches -fharden-control-flow-redundancy -fno-harden-control-flow-redundancy -fhardcfr-skip-leaf -fhardcfr-check-exceptions -fhardcfr-check-returning-calls '-fhardcfr-check-noreturn-calls=*' '-mindirect-branch=*' -mindirect-branch-register '-mfunction-return=*' -mretpoline '-mharden-sls=*' '-mbranch-protection=*' -fno-unit-at-a-time -fno-strict-overflow '-fsanitize*' '-fno-sanitize*' -g '-g[0-9]' -ggdb '-ggdb[0-9]' -gdwarf '-gdwarf-*' -gstabs -gstabs+ -gz -glldb '-fdebug-default-version=*' -fno-diagnostics-color '-fmessage-length=*' -fno-ident -fpermissive -frecord-gcc-switches -frecord-command-line '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld=*');
  574. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*' -mno-omit-leaf-frame-pointer);
  575. ALLOWED_FLAGS+=('-mregparm=*' -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float '-mfpu=*' -mieee -mieee-with-inexact '-mschedule=*' -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 '-mabi=*' -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 '-mcmodel=*' -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' '-mfloat-abi=*' '-mtls-dialect=*' -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 -mfix-r10000 -mno-fix-r10000 '-mr10k-cache-barrier=*' -mthumb -marm -ffixed-x18 -mstrict-align -mvector-strict-align -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha -mevex512 -mno-evex512);
  576. ALLOWED_FLAGS+=(-mstackrealign '-mpreferred-stack-boundary=*' '-mincoming-stack-boundary=*');
  577. ALLOWED_FLAGS+=('--unwindlib=*' '--rtlib=*' '--stdlib=*')
  578. }
  579. _systemd_get_dir ()
  580. {
  581. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <variable-name> <fallback-directory>";
  582. local variable=${1} fallback=${2} d;
  583. local -x PKG_CONFIG_FDO_SYSROOT_RULES=1;
  584. if $(tc-getPKG_CONFIG) --exists systemd; then
  585. d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die;
  586. else
  587. d="${EPREFIX}${fallback}";
  588. fi;
  589. echo "${d}"
  590. }
  591. _systemd_unprefix ()
  592. {
  593. local d=$("${@}");
  594. echo "${d#"${EPREFIX}"}"
  595. }
  596. _tc-getPROG ()
  597. {
  598. local tuple=$1;
  599. local v var vars=$2;
  600. local prog=($3);
  601. var=${vars%% *};
  602. for v in ${vars};
  603. do
  604. if [[ -n ${!v} ]]; then
  605. export ${var}="${!v}";
  606. echo "${!v}";
  607. return 0;
  608. fi;
  609. done;
  610. local search=;
  611. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  612. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  613. [[ -n ${search} ]] && prog[0]=${search##*/};
  614. export ${var}="${prog[*]}";
  615. echo "${!var}"
  616. }
  617. _tc-has-openmp ()
  618. {
  619. local base="${T}/test-tc-openmp";
  620. cat <<-EOF > "${base}.c"
  621. #include <omp.h>
  622. int main(void) {
  623. int nthreads, tid, ret = 0;
  624. #pragma omp parallel private(nthreads, tid)
  625. {
  626. tid = omp_get_thread_num();
  627. nthreads = omp_get_num_threads();
  628. ret += tid + nthreads;
  629. }
  630. return ret;
  631. }
  632. EOF
  633.  
  634. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null;
  635. local ret=$?;
  636. rm -f "${base}"*;
  637. return ${ret}
  638. }
  639. _test-flag-PROG ()
  640. {
  641. local comp=$1;
  642. local lang=$2;
  643. shift 2;
  644. if [[ -z ${comp} ]]; then
  645. return 1;
  646. fi;
  647. if [[ -z $1 ]]; then
  648. return 1;
  649. fi;
  650. comp=($(tc-get${comp}));
  651. if ! type -p ${comp[0]} > /dev/null; then
  652. return 1;
  653. fi;
  654. local in_src in_ext cmdline_extra=();
  655. case "${lang}" in
  656. c)
  657. in_ext='c';
  658. in_src='int main(void) { return 0; }';
  659. cmdline_extra+=(-xc -c)
  660. ;;
  661. c++)
  662. in_ext='cc';
  663. in_src='int main(void) { return 0; }';
  664. cmdline_extra+=(-xc++ -c)
  665. ;;
  666. f77)
  667. in_ext='f';
  668. in_src=' end';
  669. cmdline_extra+=(-xf77 -c)
  670. ;;
  671. f95)
  672. in_ext='f90';
  673. in_src='end';
  674. cmdline_extra+=(-xf95 -c)
  675. ;;
  676. c+ld)
  677. in_ext='c';
  678. in_src='int main(void) { return 0; }';
  679. if is-ldflagq -fuse-ld=*; then
  680. fuse_ld_value=$(get-flag -fuse-ld=*);
  681. cmdline_extra+=(${fuse_ld_value});
  682. fi;
  683. cmdline_extra+=(-xc)
  684. ;;
  685. esac;
  686. local test_in=${T}/test-flag.${in_ext};
  687. local test_out=${T}/test-flag.exe;
  688. printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'";
  689. local cmdline=("${comp[@]}" -Werror "$@" "${cmdline_extra[@]}" "${test_in}" -o "${test_out}");
  690. "${cmdline[@]}" &> /dev/null
  691. }
  692. _test-flags-PROG ()
  693. {
  694. local comp=$1;
  695. local flags=();
  696. local x;
  697. shift;
  698. [[ -z ${comp} ]] && return 1;
  699. while (( $# )); do
  700. case "$1" in
  701. --param | -B)
  702. if test-flag-${comp} "$1" "$2"; then
  703. flags+=("$1" "$2");
  704. fi;
  705. shift 2
  706. ;;
  707. *)
  708. if test-flag-${comp} "$1"; then
  709. flags+=("$1");
  710. fi;
  711. shift 1
  712. ;;
  713. esac;
  714. done;
  715. echo "${flags[*]}";
  716. [[ ${#flags[@]} -gt 0 ]]
  717. }
  718. all-flag-vars ()
  719. {
  720. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  721. }
  722. append-atomic-flags ()
  723. {
  724. test-flags-CCLD "-latomic" &> /dev/null || return;
  725. append-libs "-Wl,--push-state,--as-needed,-latomic,--pop-state"
  726. }
  727. append-cflags ()
  728. {
  729. [[ $# -eq 0 ]] && return 0;
  730. export CFLAGS+=" $*";
  731. return 0
  732. }
  733. append-cppflags ()
  734. {
  735. [[ $# -eq 0 ]] && return 0;
  736. export CPPFLAGS+=" $*";
  737. return 0
  738. }
  739. append-cxxflags ()
  740. {
  741. [[ $# -eq 0 ]] && return 0;
  742. export CXXFLAGS+=" $*";
  743. return 0
  744. }
  745. append-fflags ()
  746. {
  747. [[ $# -eq 0 ]] && return 0;
  748. export FFLAGS+=" $*";
  749. export FCFLAGS+=" $*";
  750. return 0
  751. }
  752. append-flags ()
  753. {
  754. [[ $# -eq 0 ]] && return 0;
  755. case " $* " in
  756. *' '-[DIU]*)
  757. eqawarn 'Please use append-cppflags for preprocessor flags'
  758. ;;
  759. *' '-L* | *' '-Wl,*)
  760. eqawarn 'Please use append-ldflags for linker flags'
  761. ;;
  762. esac;
  763. append-cflags "$@";
  764. append-cxxflags "$@";
  765. append-fflags "$@";
  766. return 0
  767. }
  768. append-ldflags ()
  769. {
  770. [[ $# -eq 0 ]] && return 0;
  771. local flag;
  772. for flag in "$@";
  773. do
  774. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  775. done;
  776. export LDFLAGS="${LDFLAGS} $*";
  777. return 0
  778. }
  779. append-lfs-flags ()
  780. {
  781. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  782. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  783. }
  784. append-libs ()
  785. {
  786. [[ $# -eq 0 ]] && return 0;
  787. local flag;
  788. for flag in "$@";
  789. do
  790. if [[ -z "${flag// }" ]]; then
  791. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  792. continue;
  793. fi;
  794. case $flag in
  795. -[lL]*)
  796. export LIBS="${LIBS} ${flag}"
  797. ;;
  798. -*)
  799. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  800. export LIBS="${LIBS} ${flag}"
  801. ;;
  802. *)
  803. export LIBS="${LIBS} -l${flag}"
  804. ;;
  805. esac;
  806. done;
  807. return 0
  808. }
  809. autotools_check_macro ()
  810. {
  811. [[ -f configure.ac || -f configure.in ]] || return 0;
  812. local trace_file=".__autoconf_trace_data";
  813. if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  814. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  815. fi;
  816. local macro args=();
  817. for macro in "$@";
  818. do
  819. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  820. args+=(-e ":${macro}:");
  821. done;
  822. grep "${args[@]}" ${trace_file}
  823. }
  824. autotools_check_macro_val ()
  825. {
  826. local macro scan_out;
  827. for macro in "$@";
  828. do
  829. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  830. if (match($0, macro ":(.*)$", res))
  831. print res[1]
  832. }' | uniq;
  833. done;
  834. return 0
  835. }
  836. autotools_env_setup ()
  837. {
  838. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  839. local pv;
  840. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  841. do
  842. has_version -b "=dev-build/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break;
  843. done;
  844. if use prefix && [[ ! -x "${BROOT}"/usr/bin/automake ]]; then
  845. [[ ${WANT_AUTOMAKE} == "latest" ]] && ewarn "Ignoring missing automake during Prefix bootstrap! Tried ${_LATEST_AUTOMAKE[*]}";
  846. else
  847. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  848. fi;
  849. fi;
  850. if [[ ${WANT_AUTOCONF} == "latest" ]]; then
  851. local pv;
  852. for pv in ${_LATEST_AUTOCONF[@]/#*:};
  853. do
  854. has_version -b "=dev-build/autoconf-${pv}*" && export WANT_AUTOCONF="${pv}" && break;
  855. done;
  856. if use prefix && [[ ! -x "${BROOT}"/usr/bin/autoconf ]]; then
  857. [[ ${WANT_AUTOCONF} == "latest" ]] && ewarn "Ignoring missing autoconf during Prefix bootstrap! Tried ${_LATEST_AUTOCONF[*]}";
  858. else
  859. [[ ${WANT_AUTOCONF} == "latest" ]] && die "Cannot find the latest autoconf! Tried ${_LATEST_AUTOCONF[*]}";
  860. fi;
  861. fi
  862. }
  863. autotools_m4dir_include ()
  864. {
  865. _autotools_m4dir_include ${AT_M4DIR}
  866. }
  867. autotools_m4sysdir_include ()
  868. {
  869. local paths=($(eval echo ${AT_SYS_M4DIR}));
  870. _autotools_m4dir_include "${paths[@]}"
  871. }
  872. autotools_run_tool ()
  873. {
  874. local autofail=true m4flags=false missing_ok=false return_output=false;
  875. while [[ -n ${1} ]]; do
  876. case ${1} in
  877. --at-no-fail)
  878. autofail=false
  879. ;;
  880. --at-m4flags)
  881. m4flags=true
  882. ;;
  883. --at-missing)
  884. missing_ok=true
  885. ;;
  886. --at-output)
  887. return_output=true
  888. ;;
  889. *)
  890. break
  891. ;;
  892. esac;
  893. shift;
  894. done;
  895. if [[ ${EBUILD_PHASE_FUNC} != "src_prepare" ]]; then
  896. eqawarn "Running '${1}' in ${EBUILD_PHASE_FUNC} phase";
  897. fi;
  898. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  899. einfo "Skipping '$*' because '${1}' not installed";
  900. return 0;
  901. fi;
  902. autotools_env_setup;
  903. local STDERR_TARGET="${T}/${1##*/}.out";
  904. if [[ -e ${STDERR_TARGET} ]]; then
  905. local i=1;
  906. while :; do
  907. STDERR_TARGET="${T}/${1##*/}-${i}.out";
  908. [[ -e ${STDERR_TARGET} ]] || break;
  909. : $(( i++ ));
  910. done;
  911. fi;
  912. if ${m4flags}; then
  913. set -- "${1}" $(autotools_m4dir_include) $(autotools_m4sysdir_include) "${@:2}";
  914. fi;
  915. if ${return_output}; then
  916. "$@";
  917. return;
  918. fi;
  919. printf "***** ${1} *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  920. ebegin "Running '$@'";
  921. "$@" >> "${STDERR_TARGET}" 2>&1;
  922. if ! eend $? && ${autofail}; then
  923. echo;
  924. eerror "Failed running '${1}'!";
  925. eerror;
  926. eerror "Include in your bug report the contents of:";
  927. eerror;
  928. eerror " ${STDERR_TARGET}";
  929. echo;
  930. die "Failed running '${1}'!";
  931. fi
  932. }
  933. clang-fullversion ()
  934. {
  935. _clang_fullversion '$1.$2.$3' "$@"
  936. }
  937. clang-major-version ()
  938. {
  939. _clang_fullversion '$1' "$@"
  940. }
  941. clang-micro-version ()
  942. {
  943. _clang_fullversion '$3' "$@"
  944. }
  945. clang-minor-version ()
  946. {
  947. _clang_fullversion '$2' "$@"
  948. }
  949. clang-version ()
  950. {
  951. _clang_fullversion '$1.$2' "$@"
  952. }
  953. cleanpamd ()
  954. {
  955. while [[ -n $1 ]]; do
  956. if ! has_version sys-libs/pam; then
  957. sed -i -e '/pam_shells\|pam_console/s:^:#:' "${ED}/etc/pam.d/$1" || die;
  958. fi;
  959. shift;
  960. done
  961. }
  962. config_rpath_update ()
  963. {
  964. local src="${BROOT}/usr/share/gettext/config.rpath";
  965. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  966. [[ $# -eq 0 ]] && return 0;
  967. einfo "Updating all config.rpath files";
  968. local dst;
  969. for dst in "$@";
  970. do
  971. einfo " ${dst}";
  972. cp "${src}" "${dst}" || die;
  973. done
  974. }
  975. db_findver ()
  976. {
  977. if [ $# -ne 1 ]; then
  978. eerror "Function db_findver needs one argument" 1>&2;
  979. eerror "args given:" 1>&2;
  980. for f in $@;
  981. do
  982. eerror " - \"$@\"" 1>&2;
  983. done;
  984. return 1;
  985. fi;
  986. PKG="$(best_version $1)";
  987. VER="$(ver_cut 1-2 "${PKG/*db-/}")";
  988. if [ -d "${ESYSROOT}"/usr/include/db$(db_ver_to_slot "$VER") ]; then
  989. echo -n "$VER";
  990. return 0;
  991. else
  992. return 1;
  993. fi
  994. }
  995. db_includedir ()
  996. {
  997. if [ $# -eq 0 ]; then
  998. VER="$(db_findver sys-libs/db)" || return 1;
  999. VER="$(db_ver_to_slot "$VER")";
  1000. echo "include version ${VER}" 1>&2;
  1001. if [ -d "${ESYSROOT}/usr/include/db${VER}" ]; then
  1002. echo -n "${ESYSROOT}/usr/include/db${VER}";
  1003. return 0;
  1004. else
  1005. eerror "sys-libs/db package requested, but headers not found" 1>&2;
  1006. return 1;
  1007. fi;
  1008. else
  1009. for x in $@;
  1010. do
  1011. if VER=$(db_findver "=sys-libs/db-${x}*") && [ -d "${ESYSROOT}/usr/include/db$(db_ver_to_slot $VER)" ]; then
  1012. echo -n "${ESYSROOT}/usr/include/db$(db_ver_to_slot $VER)";
  1013. return 0;
  1014. fi;
  1015. done;
  1016. eerror "No suitable db version found";
  1017. return 1;
  1018. fi
  1019. }
  1020. db_libname ()
  1021. {
  1022. if [ $# -eq 0 ]; then
  1023. VER="$(db_findver sys-libs/db)" || return 1;
  1024. if [ -e "${ESYSROOT}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
  1025. echo -n "db-${VER}";
  1026. return 0;
  1027. else
  1028. eerror "sys-libs/db package requested, but library not found" 1>&2;
  1029. return 1;
  1030. fi;
  1031. else
  1032. for x in $@;
  1033. do
  1034. if VER=$(db_findver "=sys-libs/db-${x}*"); then
  1035. if [ -e "${ESYSROOT}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
  1036. echo -n "db-${VER}";
  1037. return 0;
  1038. fi;
  1039. fi;
  1040. done;
  1041. eerror "No suitable db version found" 1>&2;
  1042. return 1;
  1043. fi
  1044. }
  1045. db_ver_to_slot ()
  1046. {
  1047. if [ $# -ne 1 ]; then
  1048. eerror "Function db_ver_to_slot needs one argument" 1>&2;
  1049. eerror "args given:" 1>&2;
  1050. for f in $@;
  1051. do
  1052. eerror " - \"$@\"" 1>&2;
  1053. done;
  1054. return 1;
  1055. fi;
  1056. echo -n "$1"
  1057. }
  1058. dopamd ()
  1059. {
  1060. [[ -z $1 ]] && die "dopamd requires at least one argument";
  1061. _pam_flag_disabled && return 0;
  1062. ( insinto /etc/pam.d;
  1063. insopts -m 0644;
  1064. doins "$@" );
  1065. cleanpamd "$@"
  1066. }
  1067. dopammod ()
  1068. {
  1069. [[ -z $1 ]] && die "dopammod requires at least one argument";
  1070. _pam_flag_disabled && return 0;
  1071. exeinto $(getpam_mod_dir);
  1072. doexe "$@"
  1073. }
  1074. dopamsecurity ()
  1075. {
  1076. [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments";
  1077. _pam_flag_disabled && return 0;
  1078. ( insinto /etc/security/$1;
  1079. insopts -m 0644;
  1080. doins "${@:2}" )
  1081. }
  1082. dotmpfiles ()
  1083. {
  1084. debug-print-function ${FUNCNAME} "$@";
  1085. local f;
  1086. for f in "$@";
  1087. do
  1088. if [[ ${f} != *.conf ]]; then
  1089. die "tmpfiles.d files must end with .conf";
  1090. fi;
  1091. done;
  1092. ( insopts -m 0644;
  1093. insinto /usr/lib/tmpfiles.d;
  1094. doins "$@" )
  1095. }
  1096. eaclocal ()
  1097. {
  1098. if [[ ! -f "${T}"/aclocal/dirlist ]]; then
  1099. mkdir "${T}"/aclocal || die;
  1100. cat <<-EOF > "${T}"/aclocal/dirlist ||
  1101. ${BROOT}/usr/share/aclocal
  1102. ${ESYSROOT}/usr/share/aclocal
  1103. EOF
  1104. die;
  1105. fi
  1106. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags) --system-acdir="${T}"/aclocal
  1107. }
  1108. eaclocal_amflags ()
  1109. {
  1110. local aclocal_opts amflags_file;
  1111. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  1112. do
  1113. [[ -e ${amflags_file} ]] || continue;
  1114. autotools_env_setup;
  1115. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  1116. s:[^=]*=::p; # then gobble up all escaped lines
  1117. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  1118. eval aclocal_opts=\""${aclocal_opts}"\";
  1119. break;
  1120. done;
  1121. echo ${aclocal_opts}
  1122. }
  1123. eapply ()
  1124. {
  1125. local failed patch_cmd=patch;
  1126. local -x LC_COLLATE=POSIX;
  1127. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1128. function _eapply_patch ()
  1129. {
  1130. local f=${1};
  1131. local prefix=${2};
  1132. ebegin "${prefix:-Applying }${f##*/}";
  1133. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  1134. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  1135. all_opts+=(-s -F0);
  1136. fi;
  1137. ${patch_cmd} "${all_opts[@]}" < "${f}";
  1138. failed=${?};
  1139. if ! eend "${failed}"; then
  1140. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1141. fi
  1142. };
  1143. local patch_options=() files=();
  1144. local i found_doublehyphen;
  1145. for ((i = 1; i <= ${#@}; ++i ))
  1146. do
  1147. if [[ ${@:i:1} == -- ]]; then
  1148. patch_options=("${@:1:i-1}");
  1149. files=("${@:i+1}");
  1150. found_doublehyphen=1;
  1151. break;
  1152. fi;
  1153. done;
  1154. if [[ -z ${found_doublehyphen} ]]; then
  1155. for ((i = 1; i <= ${#@}; ++i ))
  1156. do
  1157. if [[ ${@:i:1} != -* ]]; then
  1158. patch_options=("${@:1:i-1}");
  1159. files=("${@:i}");
  1160. break;
  1161. fi;
  1162. done;
  1163. for i in "${files[@]}";
  1164. do
  1165. if [[ ${i} == -* ]]; then
  1166. die "eapply: all options must be passed before non-options";
  1167. fi;
  1168. done;
  1169. fi;
  1170. if [[ ${#files[@]} -eq 0 ]]; then
  1171. die "eapply: no files specified";
  1172. fi;
  1173. local f;
  1174. for f in "${files[@]}";
  1175. do
  1176. if [[ -d ${f} ]]; then
  1177. function _eapply_get_files ()
  1178. {
  1179. local LC_ALL=POSIX;
  1180. local prev_shopt=$(shopt -p nullglob);
  1181. shopt -s nullglob;
  1182. local f;
  1183. for f in "${1}"/*;
  1184. do
  1185. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1186. files+=("${f}");
  1187. fi;
  1188. done;
  1189. ${prev_shopt}
  1190. };
  1191. local files=();
  1192. _eapply_get_files "${f}";
  1193. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1194. einfo "Applying patches from ${f} ...";
  1195. local f2;
  1196. for f2 in "${files[@]}";
  1197. do
  1198. _eapply_patch "${f2}" ' ';
  1199. [[ ${failed} -ne 0 ]] && return "${failed}";
  1200. done;
  1201. else
  1202. _eapply_patch "${f}";
  1203. [[ ${failed} -ne 0 ]] && return "${failed}";
  1204. fi;
  1205. done;
  1206. return 0
  1207. }
  1208. eapply_user ()
  1209. {
  1210. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1211. local tagfile=${T}/.portage_user_patches_applied;
  1212. [[ -f ${tagfile} ]] && return;
  1213. >> "${tagfile}";
  1214. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1215. local columns=${COLUMNS:-0};
  1216. [[ ${columns} == 0 ]] && columns=$(set -- $( ( stty size < /dev/tty ) 2> /dev/null || echo 24 80); echo $2);
  1217. (( columns > 0 )) || (( columns = 80 ));
  1218. local applied d f;
  1219. local -A _eapply_user_patches;
  1220. local prev_shopt=$(shopt -p nullglob);
  1221. shopt -s nullglob;
  1222. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1223. do
  1224. for f in "${d}"/*;
  1225. do
  1226. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1227. _eapply_user_patches[${f##*/}]=${f};
  1228. fi;
  1229. done;
  1230. done;
  1231. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1232. while read -r -d '' f; do
  1233. f=${_eapply_user_patches[${f}]};
  1234. if [[ -s ${f} ]]; then
  1235. if [[ -z ${applied} ]]; then
  1236. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++))
  1237. do
  1238. echo -n =;
  1239. done)${PORTAGE_COLOR_NORMAL}";
  1240. einfo "Applying user patches from ${basedir} ...";
  1241. fi;
  1242. eapply "${f}";
  1243. applied=1;
  1244. fi;
  1245. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" | LC_ALL=C sort -z);
  1246. fi;
  1247. ${prev_shopt};
  1248. if [[ -n ${applied} ]]; then
  1249. einfo "User patches applied.";
  1250. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++))
  1251. do
  1252. echo -n =;
  1253. done)${PORTAGE_COLOR_NORMAL}";
  1254. fi
  1255. }
  1256. eautoconf ()
  1257. {
  1258. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  1259. echo;
  1260. eerror "No configure.{ac,in} present in '${PWD}'!";
  1261. echo;
  1262. die "No configure.{ac,in} present!";
  1263. fi;
  1264. if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  1265. case ${EAPI} in
  1266. 7)
  1267. eqawarn "This package has a configure.in file which has long been deprecated. Please";
  1268. eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  1269. eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details."
  1270. ;;
  1271. *)
  1272. einfo "Moving configure.in to configure.ac (bug #426262)";
  1273. mv configure.{in,ac} || die
  1274. ;;
  1275. esac;
  1276. fi;
  1277. local _gnuconfig=$(gnuconfig_findnewest);
  1278. cp "${_gnuconfig}"/config.{guess,sub} . || die;
  1279. autotools_run_tool --at-m4flags autoconf "$@"
  1280. }
  1281. eautoheader ()
  1282. {
  1283. _at_uses_autoheader || return 0;
  1284. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  1285. }
  1286. eautomake ()
  1287. {
  1288. local extra_opts=();
  1289. local makefile_name;
  1290. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  1291. do
  1292. [[ -f ${makefile_name} ]] && break;
  1293. done;
  1294. function _automake_version ()
  1295. {
  1296. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  1297. };
  1298. if [[ -z ${makefile_name} ]]; then
  1299. _at_uses_automake || return 0;
  1300. else
  1301. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  1302. local used_automake;
  1303. local installed_automake;
  1304. installed_automake=$(WANT_AUTOMAKE= _automake_version);
  1305. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  1306. if [[ ${installed_automake} != ${used_automake} ]]; then
  1307. ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  1308. ewarn "Forcing a full rebuild of the autotools to workaround.";
  1309. eautoreconf;
  1310. return 0;
  1311. fi;
  1312. fi;
  1313. fi;
  1314. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  1315. case $(_automake_version) in
  1316. 1.4 | 1.4[.-]*)
  1317.  
  1318. ;;
  1319. *)
  1320. extra_opts+=(--force-missing)
  1321. ;;
  1322. esac;
  1323. autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  1324. }
  1325. eautopoint ()
  1326. {
  1327. autotools_run_tool autopoint "$@"
  1328. }
  1329. eautoreconf ()
  1330. {
  1331. local x g;
  1332. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  1333. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  1334. do
  1335. if [[ -d ${x} ]]; then
  1336. pushd "${x}" > /dev/null;
  1337. AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  1338. popd > /dev/null;
  1339. fi;
  1340. done;
  1341. fi;
  1342. einfo "Running eautoreconf in '${PWD}' ...";
  1343. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  1344. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  1345. 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");
  1346. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1347. do
  1348. if _at_uses_${tools[i]}; then
  1349. tools[i+1]=true;
  1350. ${tools[i+2]};
  1351. fi;
  1352. done;
  1353. local rerun_aclocal=false;
  1354. eaclocal;
  1355. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1356. do
  1357. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  1358. ${tools[i+2]};
  1359. rerun_aclocal=true;
  1360. fi;
  1361. done;
  1362. ${rerun_aclocal} && eaclocal;
  1363. if [[ ${WANT_AUTOCONF} == "2.1" ]]; then
  1364. eautoconf;
  1365. else
  1366. eautoconf --force;
  1367. fi;
  1368. if [[ ${AT_NOEAUTOHEADER} != "yes" ]]; then
  1369. if [[ ${WANT_AUTOCONF} == "2.1" ]]; then
  1370. eautoheader;
  1371. else
  1372. eautoheader --force;
  1373. fi;
  1374. fi;
  1375. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  1376. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  1377. elibtoolize --force "${PWD}";
  1378. fi;
  1379. return 0
  1380. }
  1381. econf_build ()
  1382. {
  1383. local CBUILD=${CBUILD:-${CHOST}};
  1384. function econf_env ()
  1385. {
  1386. CHOST=${CBUILD} econf "$@"
  1387. };
  1388. tc-env_build econf_env "$@"
  1389. }
  1390. edos2unix ()
  1391. {
  1392. [[ $# -eq 0 ]] && return 0;
  1393. sed -i 's/\r$//' -- "$@" || die
  1394. }
  1395. einstalldocs ()
  1396. {
  1397. ( if [[ $(declare -p DOCS 2> /dev/null) != *=* ]]; then
  1398. local d;
  1399. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1400. do
  1401. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1402. done;
  1403. else
  1404. if ___is_indexed_array_var DOCS; then
  1405. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1406. else
  1407. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1408. fi;
  1409. fi );
  1410. ( if ___is_indexed_array_var HTML_DOCS; then
  1411. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1412. else
  1413. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1414. fi )
  1415. }
  1416. elibtoolize ()
  1417. {
  1418. type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  1419. ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  1420. }
  1421. filter-flags ()
  1422. {
  1423. _filter-hardened "$@";
  1424. local v;
  1425. for v in $(all-flag-vars);
  1426. do
  1427. _filter-var ${v} "$@";
  1428. done;
  1429. return 0
  1430. }
  1431. filter-ldflags ()
  1432. {
  1433. _filter-var LDFLAGS "$@";
  1434. return 0
  1435. }
  1436. filter-lfs-flags ()
  1437. {
  1438. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1439. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64
  1440. }
  1441. filter-lto ()
  1442. {
  1443. [[ $# -ne 0 ]] && die "filter-lto takes no arguments";
  1444. filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*'
  1445. }
  1446. filter-mfpmath ()
  1447. {
  1448. local orig_mfpmath new_math prune_math;
  1449. orig_mfpmath=$(get-flag -mfpmath);
  1450. new_math=$(get-flag mfpmath);
  1451. new_math=${new_math/both/387,sse};
  1452. new_math=" ${new_math//[,+]/ } ";
  1453. prune_math="";
  1454. for prune_math in "$@";
  1455. do
  1456. new_math=${new_math/ ${prune_math} / };
  1457. done;
  1458. new_math=$(echo ${new_math});
  1459. new_math=${new_math// /,};
  1460. if [[ -z ${new_math} ]]; then
  1461. filter-flags ${orig_mfpmath};
  1462. else
  1463. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1464. fi;
  1465. return 0
  1466. }
  1467. gcc-fullversion ()
  1468. {
  1469. _gcc_fullversion '$1.$2.$3' "$@"
  1470. }
  1471. gcc-major-version ()
  1472. {
  1473. _gcc_fullversion '$1' "$@"
  1474. }
  1475. gcc-micro-version ()
  1476. {
  1477. _gcc_fullversion '$3' "$@"
  1478. }
  1479. gcc-minor-version ()
  1480. {
  1481. _gcc_fullversion '$2' "$@"
  1482. }
  1483. gcc-specs-directive ()
  1484. {
  1485. local directive subdname subdirective;
  1486. directive="$(_gcc-specs-directive_raw $1)";
  1487. while [[ ${directive} == *%\(*\)* ]]; do
  1488. subdname=${directive/*%\(};
  1489. subdname=${subdname/\)*};
  1490. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1491. directive="${directive//\%(${subdname})/${subdirective}}";
  1492. done;
  1493. echo "${directive}";
  1494. return 0
  1495. }
  1496. gcc-specs-nostrict ()
  1497. {
  1498. local directive;
  1499. directive=$(gcc-specs-directive cc1);
  1500. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1501. }
  1502. gcc-specs-now ()
  1503. {
  1504. local directive;
  1505. directive=$(gcc-specs-directive link_command);
  1506. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1507. }
  1508. gcc-specs-pie ()
  1509. {
  1510. local directive;
  1511. directive=$(gcc-specs-directive cc1);
  1512. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1513. }
  1514. gcc-specs-relro ()
  1515. {
  1516. local directive;
  1517. directive=$(gcc-specs-directive link_command);
  1518. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1519. }
  1520. gcc-specs-ssp ()
  1521. {
  1522. local directive;
  1523. directive=$(gcc-specs-directive cc1);
  1524. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1525. }
  1526. gcc-specs-ssp-to-all ()
  1527. {
  1528. local directive;
  1529. directive=$(gcc-specs-directive cc1);
  1530. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1531. }
  1532. gcc-specs-stack-check ()
  1533. {
  1534. local directive;
  1535. directive=$(gcc-specs-directive cc1);
  1536. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1537. }
  1538. gcc-version ()
  1539. {
  1540. _gcc_fullversion '$1.$2' "$@"
  1541. }
  1542. gen_usr_ldscript ()
  1543. {
  1544. ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  1545. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1546. tc-is-static-only && return;
  1547. use prefix && return;
  1548. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1549. multilib_is_native_abi || return 0;
  1550. fi;
  1551. case ${CTARGET:-${CHOST}} in
  1552. *-darwin*)
  1553.  
  1554. ;;
  1555. *-android*)
  1556. return 0
  1557. ;;
  1558. *linux*)
  1559. use prefix && return 0
  1560. ;;
  1561. *)
  1562. return 0
  1563. ;;
  1564. esac;
  1565. dodir /usr/${libdir};
  1566. if [[ $1 == "-a" ]]; then
  1567. auto=true;
  1568. shift;
  1569. dodir /${libdir};
  1570. fi;
  1571. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1572. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1573. local d="${T}/bfd-linker";
  1574. mkdir -p "${d}";
  1575. ln -sf $(type -P ${CHOST}-ld.bfd) "${d}"/ld;
  1576. flags+=(-B"${d}");
  1577. fi;
  1578. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1579. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1580. for lib in "$@";
  1581. do
  1582. local tlib;
  1583. if ${auto}; then
  1584. lib="lib${lib}${suffix}";
  1585. else
  1586. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1587. fi;
  1588. case ${CTARGET:-${CHOST}} in
  1589. *-darwin*)
  1590. if ${auto}; then
  1591. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1592. else
  1593. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1594. fi;
  1595. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1596. tlib=${tlib##*/};
  1597. if ${auto}; then
  1598. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1599. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1600. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1601. fi;
  1602. rm -f "${ED}"/${libdir}/${lib};
  1603. fi;
  1604. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1605. chmod u+w "${ED}${libdir}/${tlib}";
  1606. local nowrite=yes;
  1607. fi;
  1608. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1609. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1610. pushd "${ED}/usr/${libdir}" > /dev/null;
  1611. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1612. popd > /dev/null
  1613. ;;
  1614. *)
  1615. if ${auto}; then
  1616. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1617. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1618. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1619. if [[ ${tlib} != ${lib}* ]]; then
  1620. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1621. fi;
  1622. rm -f "${ED}"/${libdir}/${lib};
  1623. else
  1624. tlib=${lib};
  1625. fi;
  1626. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1627. /* GNU ld script
  1628. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1629. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1630. run into linking problems. This "fake" dynamic lib is a linker script that
  1631. redirects the linker to the real lib. And yes, this works in the cross-
  1632. compiling scenario as the sysroot-ed linker will prepend the real path.
  1633.  
  1634. See bug https://bugs.gentoo.org/4411 for more info.
  1635. */
  1636. ${output_format}
  1637. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1638. END_LDSCRIPT
  1639.  
  1640. ;;
  1641. esac
  1642. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1643. done
  1644. }
  1645. get-flag ()
  1646. {
  1647. [[ $# -ne 1 ]] && die "usage: <flag>";
  1648. local f var findflag="$1";
  1649. for var in $(all-flag-vars);
  1650. do
  1651. for f in ${!var};
  1652. do
  1653. if [ "${f/${findflag}}" != "${f}" ]; then
  1654. printf "%s\n" "${f/-${findflag}=}";
  1655. return 0;
  1656. fi;
  1657. done;
  1658. done;
  1659. return 1
  1660. }
  1661. get_abi_CFLAGS ()
  1662. {
  1663. get_abi_var CFLAGS "$@"
  1664. }
  1665. get_abi_CHOST ()
  1666. {
  1667. get_abi_var CHOST "$@"
  1668. }
  1669. get_abi_CTARGET ()
  1670. {
  1671. get_abi_var CTARGET "$@"
  1672. }
  1673. get_abi_FAKE_TARGETS ()
  1674. {
  1675. get_abi_var FAKE_TARGETS "$@"
  1676. }
  1677. get_abi_LDFLAGS ()
  1678. {
  1679. get_abi_var LDFLAGS "$@"
  1680. }
  1681. get_abi_LIBDIR ()
  1682. {
  1683. get_abi_var LIBDIR "$@"
  1684. }
  1685. get_abi_var ()
  1686. {
  1687. local flag=$1;
  1688. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1689. local var="${flag}_${abi}";
  1690. echo ${!var}
  1691. }
  1692. get_all_abis ()
  1693. {
  1694. local x order="" mvar dvar;
  1695. mvar="MULTILIB_ABIS";
  1696. dvar="DEFAULT_ABI";
  1697. if [[ -n $1 ]]; then
  1698. mvar="$1_${mvar}";
  1699. dvar="$1_${dvar}";
  1700. fi;
  1701. if [[ -z ${!mvar} ]]; then
  1702. echo "default";
  1703. return 0;
  1704. fi;
  1705. for x in ${!mvar};
  1706. do
  1707. if [[ ${x} != ${!dvar} ]]; then
  1708. order="${order:+${order} }${x}";
  1709. fi;
  1710. done;
  1711. order="${order:+${order} }${!dvar}";
  1712. echo ${order};
  1713. return 0
  1714. }
  1715. get_all_libdirs ()
  1716. {
  1717. local libdirs abi;
  1718. for abi in ${MULTILIB_ABIS};
  1719. do
  1720. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1721. done;
  1722. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1723. echo "${libdirs}"
  1724. }
  1725. get_exeext ()
  1726. {
  1727. case ${CHOST} in
  1728. mingw* | *-mingw*)
  1729. echo ".exe"
  1730. ;;
  1731. esac
  1732. }
  1733. get_install_abis ()
  1734. {
  1735. local x order="";
  1736. if [[ -z ${MULTILIB_ABIS} ]]; then
  1737. echo "default";
  1738. return 0;
  1739. fi;
  1740. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1741. for x in ${MULTILIB_ABIS};
  1742. do
  1743. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1744. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1745. fi;
  1746. done;
  1747. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1748. if [[ -n ${ABI_ALLOW} ]]; then
  1749. local ordera="";
  1750. for x in ${order};
  1751. do
  1752. if has ${x} ${ABI_ALLOW}; then
  1753. ordera="${ordera} ${x}";
  1754. fi;
  1755. done;
  1756. order=${ordera};
  1757. fi;
  1758. else
  1759. order=${DEFAULT_ABI};
  1760. fi;
  1761. if [[ -z ${order} ]]; then
  1762. 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.";
  1763. fi;
  1764. echo ${order};
  1765. return 0
  1766. }
  1767. get_libdir ()
  1768. {
  1769. local libdir_var="LIBDIR_${ABI}";
  1770. local libdir="lib";
  1771. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  1772. echo "${libdir}"
  1773. }
  1774. get_libname ()
  1775. {
  1776. local libname;
  1777. local ver=$1;
  1778. case ${CHOST} in
  1779. mingw* | *-mingw*)
  1780. libname="dll"
  1781. ;;
  1782. *-darwin*)
  1783. libname="dylib"
  1784. ;;
  1785. *)
  1786. libname="so"
  1787. ;;
  1788. esac;
  1789. if [[ -z $* ]]; then
  1790. echo ".${libname}";
  1791. else
  1792. for ver in "$@";
  1793. do
  1794. case ${CHOST} in
  1795. *-darwin*)
  1796. echo ".${ver}.${libname}"
  1797. ;;
  1798. *)
  1799. echo ".${libname}.${ver}"
  1800. ;;
  1801. esac;
  1802. done;
  1803. fi
  1804. }
  1805. get_modname ()
  1806. {
  1807. local modname;
  1808. local ver=$1;
  1809. case ${CHOST} in
  1810. *-darwin*)
  1811. modname="bundle"
  1812. ;;
  1813. *)
  1814. modname="so"
  1815. ;;
  1816. esac;
  1817. echo ".${modname}"
  1818. }
  1819. getpam_mod_dir ()
  1820. {
  1821. PAM_MOD_DIR=/$(get_libdir)/security;
  1822. echo ${PAM_MOD_DIR}
  1823. }
  1824. gnuconfig_do_update ()
  1825. {
  1826. local configsubs_dir target targetlist file;
  1827. [[ $# -eq 0 ]] && die "do not call gnuconfig_do_update; use gnuconfig_update";
  1828. configsubs_dir=$(gnuconfig_findnewest);
  1829. einfo "Using GNU config files from ${configsubs_dir}";
  1830. for file in "$@";
  1831. do
  1832. if [[ ! -r ${configsubs_dir}/${file} ]]; then
  1833. eerror "Can't read ${configsubs_dir}/${file}, skipping..";
  1834. continue;
  1835. fi;
  1836. targetlist=$(find "${startdir}" -name "${file}");
  1837. if [[ -n ${targetlist} ]]; then
  1838. for target in ${targetlist};
  1839. do
  1840. [[ -L ${target} ]] && rm -f "${target}";
  1841. ebegin " Updating ${target/$startdir\//}";
  1842. cp -f "${configsubs_dir}/${file}" "${target}";
  1843. eend $? || die;
  1844. done;
  1845. else
  1846. ewarn " No ${file} found in ${startdir}, skipping ...";
  1847. fi;
  1848. done;
  1849. return 0
  1850. }
  1851. gnuconfig_findnewest ()
  1852. {
  1853. local locations=("${BROOT}"/usr/share/misc/config.sub "${BROOT}"/usr/share/gnuconfig/config.sub "${BROOT}"/usr/share/automake*/config.sub "${BROOT}"/usr/share/libtool/config.sub);
  1854. grep -s '^timestamp' "${locations[@]}" | sort -r -n -t\' -k2 | sed -n '1{s,/config.sub:.*$,,;p;q}'
  1855. }
  1856. gnuconfig_update ()
  1857. {
  1858. local startdir;
  1859. if [[ $1 == /* ]]; then
  1860. startdir=$1;
  1861. shift;
  1862. else
  1863. startdir=${S};
  1864. fi;
  1865. if [[ $# -gt 0 ]]; then
  1866. gnuconfig_do_update "$@";
  1867. else
  1868. gnuconfig_do_update config.sub config.guess;
  1869. fi;
  1870. return $?
  1871. }
  1872. has_multilib_profile ()
  1873. {
  1874. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1875. }
  1876. in_iuse ()
  1877. {
  1878. local use=${1};
  1879. if [[ -z "${use}" ]]; then
  1880. echo "!!! in_iuse() called without a parameter." 1>&2;
  1881. echo "!!! in_iuse <USEFLAG>" 1>&2;
  1882. die "in_iuse() called without a parameter";
  1883. fi;
  1884. local liuse=(${IUSE_EFFECTIVE});
  1885. has "${use}" "${liuse[@]#[+-]}"
  1886. }
  1887. is-flag ()
  1888. {
  1889. is-flagq "$@" && echo true
  1890. }
  1891. is-flagq ()
  1892. {
  1893. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1894. local var;
  1895. for var in $(all-flag-vars);
  1896. do
  1897. _is_flagq ${var} "$1" && return 0;
  1898. done;
  1899. return 1
  1900. }
  1901. is-ldflag ()
  1902. {
  1903. is-ldflagq "$@" && echo true
  1904. }
  1905. is-ldflagq ()
  1906. {
  1907. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1908. _is_flagq LDFLAGS $1
  1909. }
  1910. is_final_abi ()
  1911. {
  1912. has_multilib_profile || return 0;
  1913. set -- $(get_install_abis);
  1914. local LAST_ABI=$#;
  1915. [[ ${!LAST_ABI} == ${ABI} ]]
  1916. }
  1917. multibuild_copy_sources ()
  1918. {
  1919. debug-print-function ${FUNCNAME} "$@";
  1920. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  1921. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  1922. function _multibuild_create_source_copy ()
  1923. {
  1924. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  1925. cp -p -R "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  1926. };
  1927. multibuild_foreach_variant _multibuild_create_source_copy
  1928. }
  1929. multibuild_for_best_variant ()
  1930. {
  1931. debug-print-function ${FUNCNAME} "$@";
  1932. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1933. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[-1]}");
  1934. multibuild_foreach_variant "${@}"
  1935. }
  1936. multibuild_foreach_variant ()
  1937. {
  1938. debug-print-function ${FUNCNAME} "$@";
  1939. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  1940. local bdir=${BUILD_DIR:-${S}};
  1941. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  1942. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  1943. local ret=0 lret=0 v;
  1944. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  1945. for v in "${MULTIBUILD_VARIANTS[@]}";
  1946. do
  1947. local MULTIBUILD_VARIANT=${v};
  1948. local MULTIBUILD_ID=${prev_id}${v};
  1949. local BUILD_DIR=${bdir%%/}-${v};
  1950. function _multibuild_run ()
  1951. {
  1952. local i=1;
  1953. while [[ ${!i} == _* ]]; do
  1954. (( i += 1 ));
  1955. done;
  1956. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  1957. "${@}"
  1958. };
  1959. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  1960. lret=${?};
  1961. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  1962. done;
  1963. return ${ret}
  1964. }
  1965. multibuild_merge_root ()
  1966. {
  1967. debug-print-function ${FUNCNAME} "$@";
  1968. local src=${1};
  1969. local dest=${2};
  1970. cp -a "${src}"/. "${dest}"/ || die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed";
  1971. rm -rf "${src}" || die
  1972. }
  1973. multilib-minimal_abi_src_compile ()
  1974. {
  1975. debug-print-function ${FUNCNAME} "$@";
  1976. pushd "${BUILD_DIR}" > /dev/null || die;
  1977. if declare -f multilib_src_compile > /dev/null; then
  1978. multilib_src_compile;
  1979. else
  1980. default_src_compile;
  1981. fi;
  1982. popd > /dev/null || die
  1983. }
  1984. multilib-minimal_abi_src_configure ()
  1985. {
  1986. debug-print-function ${FUNCNAME} "$@";
  1987. mkdir -p "${BUILD_DIR}" || die;
  1988. pushd "${BUILD_DIR}" > /dev/null || die;
  1989. if declare -f multilib_src_configure > /dev/null; then
  1990. multilib_src_configure;
  1991. else
  1992. default_src_configure;
  1993. fi;
  1994. popd > /dev/null || die
  1995. }
  1996. multilib-minimal_src_compile ()
  1997. {
  1998. debug-print-function ${FUNCNAME} "$@";
  1999. function multilib-minimal_abi_src_compile ()
  2000. {
  2001. debug-print-function ${FUNCNAME} "$@";
  2002. pushd "${BUILD_DIR}" > /dev/null || die;
  2003. if declare -f multilib_src_compile > /dev/null; then
  2004. multilib_src_compile;
  2005. else
  2006. default_src_compile;
  2007. fi;
  2008. popd > /dev/null || die
  2009. };
  2010. multilib_foreach_abi multilib-minimal_abi_src_compile
  2011. }
  2012. multilib-minimal_src_configure ()
  2013. {
  2014. debug-print-function ${FUNCNAME} "$@";
  2015. function multilib-minimal_abi_src_configure ()
  2016. {
  2017. debug-print-function ${FUNCNAME} "$@";
  2018. mkdir -p "${BUILD_DIR}" || die;
  2019. pushd "${BUILD_DIR}" > /dev/null || die;
  2020. if declare -f multilib_src_configure > /dev/null; then
  2021. multilib_src_configure;
  2022. else
  2023. default_src_configure;
  2024. fi;
  2025. popd > /dev/null || die
  2026. };
  2027. multilib_foreach_abi multilib-minimal_abi_src_configure
  2028. }
  2029. multilib-minimal_src_install ()
  2030. {
  2031. debug-print-function ${FUNCNAME} "$@";
  2032. function multilib-minimal_abi_src_install ()
  2033. {
  2034. debug-print-function ${FUNCNAME} "$@";
  2035. pushd "${BUILD_DIR}" > /dev/null || die;
  2036. if declare -f multilib_src_install > /dev/null; then
  2037. multilib_src_install;
  2038. else
  2039. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  2040. emake DESTDIR="${D}" install;
  2041. fi;
  2042. fi;
  2043. multilib_prepare_wrappers;
  2044. multilib_check_headers;
  2045. popd > /dev/null || die
  2046. };
  2047. multilib_foreach_abi multilib-minimal_abi_src_install;
  2048. multilib_install_wrappers;
  2049. if declare -f multilib_src_install_all > /dev/null; then
  2050. multilib_src_install_all;
  2051. else
  2052. einstalldocs;
  2053. fi
  2054. }
  2055. multilib-minimal_src_test ()
  2056. {
  2057. debug-print-function ${FUNCNAME} "$@";
  2058. function multilib-minimal_abi_src_test ()
  2059. {
  2060. debug-print-function ${FUNCNAME} "$@";
  2061. pushd "${BUILD_DIR}" > /dev/null || die;
  2062. if declare -f multilib_src_test > /dev/null; then
  2063. multilib_src_test;
  2064. else
  2065. default_src_test;
  2066. fi;
  2067. popd > /dev/null || die
  2068. };
  2069. multilib_foreach_abi multilib-minimal_abi_src_test
  2070. }
  2071. multilib_check_headers ()
  2072. {
  2073. function _multilib_header_cksum ()
  2074. {
  2075. set -o pipefail;
  2076. if [[ -d ${ED}/usr/include ]]; then
  2077. find "${ED}"/usr/include -type f -exec cksum {} + | sort -k2;
  2078. fi
  2079. };
  2080. local cksum cksum_prev;
  2081. local cksum_file=${T}/.multilib_header_cksum;
  2082. cksum=$(_multilib_header_cksum) || die;
  2083. unset -f _multilib_header_cksum;
  2084. if [[ -f ${cksum_file} ]]; then
  2085. cksum_prev=$(< "${cksum_file}") || die;
  2086. if [[ ${cksum} != ${cksum_prev} ]]; then
  2087. echo "${cksum}" > "${cksum_file}.new" || die;
  2088. eerror "Header files have changed between ABIs.";
  2089. if type -p diff &> /dev/null; then
  2090. eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  2091. else
  2092. eerror "Old checksums in: ${cksum_file}";
  2093. eerror "New checksums in: ${cksum_file}.new";
  2094. fi;
  2095. die "Header checksum mismatch, aborting.";
  2096. fi;
  2097. else
  2098. echo "${cksum}" > "${cksum_file}" || die;
  2099. fi
  2100. }
  2101. multilib_copy_sources ()
  2102. {
  2103. debug-print-function ${FUNCNAME} "$@";
  2104. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2105. multibuild_copy_sources
  2106. }
  2107. multilib_env ()
  2108. {
  2109. local CTARGET=${1:-${CTARGET}};
  2110. local cpu=${CTARGET%%*-};
  2111. if [[ ${CTARGET} = *-musl* ]]; then
  2112. : "${MULTILIB_ABIS=default}";
  2113. : "${DEFAULT_ABI=default}";
  2114. export MULTILIB_ABIS DEFAULT_ABI;
  2115. return;
  2116. fi;
  2117. case ${cpu} in
  2118. aarch64*)
  2119. export CFLAGS_arm=${CFLAGS_arm-};
  2120. case ${cpu} in
  2121. aarch64*be)
  2122. export CHOST_arm="armv8b-${CTARGET#*-}"
  2123. ;;
  2124. *)
  2125. export CHOST_arm="armv8l-${CTARGET#*-}"
  2126. ;;
  2127. esac;
  2128. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2129. export CTARGET_arm=${CHOST_arm};
  2130. export LIBDIR_arm="lib";
  2131. export CFLAGS_arm64=${CFLAGS_arm64-};
  2132. export CHOST_arm64=${CTARGET};
  2133. export CTARGET_arm64=${CHOST_arm64};
  2134. export LIBDIR_arm64="lib64";
  2135. : "${MULTILIB_ABIS=arm64}";
  2136. : "${DEFAULT_ABI=arm64}"
  2137. ;;
  2138. x86_64*)
  2139. export CFLAGS_x86=${CFLAGS_x86--m32};
  2140. export CHOST_x86=${CTARGET/x86_64/i686};
  2141. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2142. export CTARGET_x86=${CHOST_x86};
  2143. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2144. export LIBDIR_x86="lib32";
  2145. else
  2146. export LIBDIR_x86="lib";
  2147. fi;
  2148. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2149. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2150. export CTARGET_amd64=${CHOST_amd64};
  2151. export LIBDIR_amd64="lib64";
  2152. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2153. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2154. export CTARGET_x32=${CHOST_x32};
  2155. export LIBDIR_x32="libx32";
  2156. case ${CTARGET} in
  2157. *-gnux32)
  2158. : "${MULTILIB_ABIS=x32 amd64 x86}";
  2159. : "${DEFAULT_ABI=x32}"
  2160. ;;
  2161. *)
  2162. : "${MULTILIB_ABIS=amd64 x86}";
  2163. : "${DEFAULT_ABI=amd64}"
  2164. ;;
  2165. esac
  2166. ;;
  2167. loongarch64*)
  2168. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  2169. export CHOST_lp64d=${CTARGET};
  2170. export CTARGET_lp64d=${CTARGET};
  2171. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64};
  2172. : "${MULTILIB_ABIS=lp64d}";
  2173. : "${DEFAULT_ABI=lp64d}"
  2174. ;;
  2175. mips64* | mipsisa64*)
  2176. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2177. export CHOST_o32=${CTARGET/mips64/mips};
  2178. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2179. export CTARGET_o32=${CHOST_o32};
  2180. export LIBDIR_o32="lib";
  2181. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2182. export CHOST_n32=${CTARGET};
  2183. export CTARGET_n32=${CHOST_n32};
  2184. export LIBDIR_n32="lib32";
  2185. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2186. export CHOST_n64=${CTARGET};
  2187. export CTARGET_n64=${CHOST_n64};
  2188. export LIBDIR_n64="lib64";
  2189. : "${MULTILIB_ABIS=n64 n32 o32}";
  2190. : "${DEFAULT_ABI=n32}"
  2191. ;;
  2192. powerpc64*)
  2193. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2194. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2195. export CTARGET_ppc=${CHOST_ppc};
  2196. export LIBDIR_ppc="lib";
  2197. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2198. export CHOST_ppc64=${CTARGET};
  2199. export CTARGET_ppc64=${CHOST_ppc64};
  2200. export LIBDIR_ppc64="lib64";
  2201. : "${MULTILIB_ABIS=ppc64 ppc}";
  2202. : "${DEFAULT_ABI=ppc64}"
  2203. ;;
  2204. riscv64*)
  2205. : "${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32}";
  2206. : "${DEFAULT_ABI=lp64d}";
  2207. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  2208. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  2209. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib64};
  2210. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64gc};
  2211. export CHOST_lp64d=${CTARGET};
  2212. export CTARGET_lp64d=${CTARGET};
  2213. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64/lp64d};
  2214. export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac};
  2215. export CHOST_lp64=${CTARGET};
  2216. export CTARGET_lp64=${CTARGET};
  2217. export LIBDIR_lp64=${LIBDIR_lp64-lib64/lp64};
  2218. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  2219. export CHOST_ilp32d=${CTARGET/riscv64/riscv32};
  2220. export CTARGET_ilp32d=${CTARGET/riscv64/riscv32};
  2221. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  2222. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  2223. export CHOST_ilp32=${CTARGET/riscv64/riscv32};
  2224. export CTARGET_ilp32=${CTARGET/riscv64/riscv32};
  2225. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  2226. ;;
  2227. riscv32*)
  2228. : "${MULTILIB_ABIS=ilp32d ilp32}";
  2229. : "${DEFAULT_ABI=ilp32d}";
  2230. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  2231. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  2232. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib};
  2233. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  2234. export CHOST_ilp32d=${CTARGET};
  2235. export CTARGET_ilp32d=${CTARGET};
  2236. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  2237. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  2238. export CHOST_ilp32=${CTARGET};
  2239. export CTARGET_ilp32=${CTARGET};
  2240. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  2241. ;;
  2242. s390x*)
  2243. export CFLAGS_s390=${CFLAGS_s390--m31};
  2244. export CHOST_s390=${CTARGET/s390x/s390};
  2245. export CTARGET_s390=${CHOST_s390};
  2246. export LIBDIR_s390="lib";
  2247. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2248. export CHOST_s390x=${CTARGET};
  2249. export CTARGET_s390x=${CHOST_s390x};
  2250. export LIBDIR_s390x="lib64";
  2251. : "${MULTILIB_ABIS=s390x s390}";
  2252. : "${DEFAULT_ABI=s390x}"
  2253. ;;
  2254. sparc64*)
  2255. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2256. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2257. export CTARGET_sparc32=${CHOST_sparc32};
  2258. export LIBDIR_sparc32="lib";
  2259. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2260. export CHOST_sparc64=${CTARGET};
  2261. export CTARGET_sparc64=${CHOST_sparc64};
  2262. export LIBDIR_sparc64="lib64";
  2263. : "${MULTILIB_ABIS=sparc64 sparc32}";
  2264. : "${DEFAULT_ABI=sparc64}"
  2265. ;;
  2266. *)
  2267. : "${MULTILIB_ABIS=default}";
  2268. : "${DEFAULT_ABI=default}"
  2269. ;;
  2270. esac;
  2271. export MULTILIB_ABIS DEFAULT_ABI
  2272. }
  2273. multilib_foreach_abi ()
  2274. {
  2275. debug-print-function ${FUNCNAME} "$@";
  2276. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2277. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2278. }
  2279. multilib_get_enabled_abi_pairs ()
  2280. {
  2281. debug-print-function ${FUNCNAME} "$@";
  2282. local abis=($(get_all_abis));
  2283. local abi i found;
  2284. for abi in "${abis[@]}";
  2285. do
  2286. for i in "${_MULTILIB_FLAGS[@]}";
  2287. do
  2288. local m_abis=${i#*:} m_abi;
  2289. local m_flag=${i%:*};
  2290. for m_abi in ${m_abis//,/ };
  2291. do
  2292. if [[ ${m_abi} == ${abi} ]] && {
  2293. [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  2294. } && use "${m_flag}"; then
  2295. echo "${m_flag}.${abi}";
  2296. found=1;
  2297. break 2;
  2298. fi;
  2299. done;
  2300. done;
  2301. done;
  2302. if [[ ! -n ${found} ]]; then
  2303. local abi=${ABI:-${DEFAULT_ABI}};
  2304. debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  2305. debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  2306. echo ".${abi}";
  2307. fi
  2308. }
  2309. multilib_get_enabled_abis ()
  2310. {
  2311. debug-print-function ${FUNCNAME} "$@";
  2312. local pairs=($(multilib_get_enabled_abi_pairs));
  2313. echo "${pairs[@]#*.}"
  2314. }
  2315. multilib_install_wrappers ()
  2316. {
  2317. debug-print-function ${FUNCNAME} "$@";
  2318. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2319. [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  2320. local root=${1:-${ED}};
  2321. if [[ -d ${ED}/tmp/multilib-include ]]; then
  2322. multibuild_merge_root "${ED}"/tmp/multilib-include "${root}"/usr/include;
  2323. rmdir "${ED}"/tmp &> /dev/null;
  2324. fi
  2325. }
  2326. multilib_is_native_abi ()
  2327. {
  2328. debug-print-function ${FUNCNAME} "$@";
  2329. [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  2330. [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  2331. }
  2332. multilib_native_enable ()
  2333. {
  2334. if multilib_is_native_abi; then
  2335. echo "--enable-${1}${2+=${2}}";
  2336. else
  2337. echo "--disable-${1}";
  2338. fi
  2339. }
  2340. multilib_native_use ()
  2341. {
  2342. multilib_is_native_abi && use "$@"
  2343. }
  2344. multilib_native_use_enable ()
  2345. {
  2346. if multilib_is_native_abi; then
  2347. use_enable "${@}";
  2348. else
  2349. echo "--disable-${2:-${1}}";
  2350. fi
  2351. }
  2352. multilib_native_use_with ()
  2353. {
  2354. if multilib_is_native_abi; then
  2355. use_with "${@}";
  2356. else
  2357. echo "--without-${2:-${1}}";
  2358. fi
  2359. }
  2360. multilib_native_usev ()
  2361. {
  2362. multilib_is_native_abi && usev "$@"
  2363. }
  2364. multilib_native_usex ()
  2365. {
  2366. if multilib_is_native_abi; then
  2367. usex "${@}";
  2368. else
  2369. echo "${3-no}${5}";
  2370. fi
  2371. }
  2372. multilib_native_with ()
  2373. {
  2374. if multilib_is_native_abi; then
  2375. echo "--with-${1}${2+=${2}}";
  2376. else
  2377. echo "--without-${1}";
  2378. fi
  2379. }
  2380. multilib_parallel_foreach_abi ()
  2381. {
  2382. debug-print-function ${FUNCNAME} "$@";
  2383. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  2384. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  2385. }
  2386. multilib_prepare_wrappers ()
  2387. {
  2388. debug-print-function ${FUNCNAME} "$@";
  2389. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  2390. local root=${1:-${ED}};
  2391. local f;
  2392. if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  2393. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2394. do
  2395. f=${f#/};
  2396. local dir=${f%/*};
  2397. local fn=${f##*/};
  2398. ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2399. done;
  2400. return;
  2401. fi;
  2402. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  2403. do
  2404. f=${f#/};
  2405. local dir=${f%/*};
  2406. local fn=${f##*/};
  2407. if [[ -L ${root}/${f} ]]; then
  2408. local target;
  2409. target=$(readlink "${root}/${f}") || die;
  2410. local target_dir target_fn=${target##*/};
  2411. [[ ${target} == */* ]] && target_dir=${target%/*};
  2412. ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  2413. fi;
  2414. mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  2415. if multilib_is_native_abi; then
  2416. ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  2417. fi;
  2418. done;
  2419. if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  2420. if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  2421. for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  2422. do
  2423. f=${f#/};
  2424. if [[ ${f} != usr/include/* ]]; then
  2425. die "Wrapping headers outside of /usr/include is not supported at the moment.";
  2426. fi;
  2427. f=${f#usr/include};
  2428. local dir=${f%/*};
  2429. if [[ -f ${root}/usr/include${f} ]]; then
  2430. local wrapper=${ED}/tmp/multilib-include${f};
  2431. if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
  2432. dodir "/tmp/multilib-include${dir}";
  2433. cat > "${wrapper}" <<_EOF_ ||
  2434. /* This file is auto-generated by multilib-build.eclass
  2435. * as a multilib-friendly wrapper. For the original content,
  2436. * please see the files that are #included below.
  2437. */
  2438.  
  2439. #if defined(__x86_64__) /* amd64 */
  2440. # if defined(__ILP32__) /* x32 ABI */
  2441. # error "abi_x86_x32 not supported by the package."
  2442. # else /* 64-bit ABI */
  2443. # error "abi_x86_64 not supported by the package."
  2444. # endif
  2445. #elif defined(__i386__) /* plain x86 */
  2446. # error "abi_x86_32 not supported by the package."
  2447. #elif defined(__mips__)
  2448. # if(_MIPS_SIM == _ABIN32) /* n32 */
  2449. # error "abi_mips_n32 not supported by the package."
  2450. # elif(_MIPS_SIM == _ABI64) /* n64 */
  2451. # error "abi_mips_n64 not supported by the package."
  2452. # elif(_MIPS_SIM == _ABIO32) /* o32 */
  2453. # error "abi_mips_o32 not supported by the package."
  2454. # endif
  2455. #elif defined(__sparc__)
  2456. # if defined(__arch64__)
  2457. # error "abi_sparc_64 not supported by the package."
  2458. # else
  2459. # error "abi_sparc_32 not supported by the package."
  2460. # endif
  2461. #elif defined(__s390__)
  2462. # if defined(__s390x__)
  2463. # error "abi_s390_64 not supported by the package."
  2464. # else
  2465. # error "abi_s390_32 not supported by the package."
  2466. # endif
  2467. #elif defined(__powerpc__) || defined(__ppc__)
  2468. # if defined(__powerpc64__) || defined(__ppc64__)
  2469. # error "abi_ppc_64 not supported by the package."
  2470. # else
  2471. # error "abi_ppc_32 not supported by the package."
  2472. # endif
  2473. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  2474. # error "Native ABI not supported by the package."
  2475. #else
  2476. # error "No ABI matched, please report a bug to bugs.gentoo.org"
  2477. #endif
  2478. _EOF_
  2479. die;
  2480. fi
  2481. if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  2482. die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  2483. fi;
  2484. dodir "/tmp/multilib-include/${CHOST}${dir}";
  2485. mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die;
  2486. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2487. if multilib_is_native_abi; then
  2488. sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  2489. fi;
  2490. fi;
  2491. done;
  2492. fi;
  2493. fi
  2494. }
  2495. multilib_src_configure ()
  2496. {
  2497. local myeconfargs=(--enable-login --enable-ntlm --enable-auth-sasldb --disable-cmulocal --disable-krb4 --disable-macos-framework --enable-otp --without-sqlite --with-saslauthd="${EPREFIX}"/run/saslauthd --with-pwcheck="${EPREFIX}"/run/saslauthd --with-configdir="${EPREFIX}"/etc/sasl2 --with-plugindir="${EPREFIX}/usr/$(get_libdir)/sasl2" --with-dbpath="${EPREFIX}"/etc/sasl2/sasldb2 --with-sphinx-build=no $(use_with ssl openssl) $(use_with pam) $(use_with openldap ldap) $(use_enable ldapdb) $(multilib_native_use_enable sample) $(use_enable kerberos gssapi) $(multilib_native_use_with mysql mysql "${EPREFIX}/usr/$(get_libdir)") $(multilib_native_use_with postgres pgsql "${EPREFIX}/usr/$(get_libdir)/postgresql") $(use_with sqlite sqlite3 "${EPREFIX}/usr/$(get_libdir)") $(use_enable srp) $(use_enable static-libs static) $(usex authdaemond --with-authdaemond="${EPREFIX}"/var/lib/courier/authdaemon/socket '') $(usex ssl '' --without-des) $(usex urandom --with-devrandom=/dev/urandom ''));
  2498. if use sqlite || {
  2499. multilib_is_native_abi && {
  2500. use mysql || use postgres
  2501. }
  2502. }; then
  2503. myeconfargs+=(--enable-sql);
  2504. else
  2505. myeconfargs+=(--disable-sql);
  2506. fi;
  2507. if use gdbm; then
  2508. einfo "Building with GNU DB as database backend for your SASLdb";
  2509. myeconfargs+=(--with-dblib=gdbm);
  2510. else
  2511. if use berkdb; then
  2512. einfo "Building with BerkeleyDB as database backend for your SASLdb";
  2513. myeconfargs+=(--with-dblib=berkeley --with-bdb-incdir="$(db_includedir)");
  2514. else
  2515. einfo "Building without SASLdb support";
  2516. myeconfargs+=(--with-dblib=none);
  2517. fi;
  2518. fi;
  2519. ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
  2520. }
  2521. multilib_src_install ()
  2522. {
  2523. default;
  2524. if multilib_is_native_abi; then
  2525. if use sample; then
  2526. docinto sample;
  2527. dodoc "${S}"/sample/*.c;
  2528. exeinto /usr/share/doc/${P}/sample;
  2529. doexe sample/client sample/server;
  2530. fi;
  2531. dosbin saslauthd/testsaslauthd;
  2532. keepdir /etc/sasl2;
  2533. if use berkdb || use gdbm; then
  2534. einfo "Generating an empty sasldb2 ...";
  2535. tc-is-cross-compiler && {
  2536. cd "${WORKDIR}"/${P}-build || die
  2537. };
  2538. export SASL_PATH=./plugins/.libs;
  2539. ./utils/saslpasswd2 -f "${ED}"/etc/sasl2/sasldb2-empty -p login <<< p || die "Failed to generate sasldb2";
  2540. ./utils/saslpasswd2 -f "${ED}"/etc/sasl2/sasldb2-empty -d login || die "Failed to delete temp user";
  2541. fowners root:mail /etc/sasl2/sasldb2-empty;
  2542. fperms 0640 /etc/sasl2/sasldb2-empty;
  2543. fi;
  2544. fi
  2545. }
  2546. multilib_src_install_all ()
  2547. {
  2548. doman man/*;
  2549. docinto;
  2550. dodoc AUTHORS ChangeLog doc/legacy/TODO;
  2551. newdoc pwcheck/README README.pwcheck;
  2552. newdoc docsrc/sasl/release-notes/$(ver_cut 1-2)/index.rst release-notes;
  2553. edos2unix "${ED}"/usr/share/doc/${PF}/release-notes;
  2554. docinto html;
  2555. dodoc doc/html/*.html;
  2556. if use pam; then
  2557. newpamd "${FILESDIR}"/saslauthd.pam-include saslauthd;
  2558. fi;
  2559. newinitd "${FILESDIR}"/pwcheck.rc6 pwcheck;
  2560. systemd_dounit "${FILESDIR}"/pwcheck.service;
  2561. newinitd "${FILESDIR}"/saslauthd2.rc7 saslauthd;
  2562. newconfd "${FILESDIR}"/saslauthd-${SASLAUTHD_CONF_VER}.conf saslauthd;
  2563. systemd_dounit "${FILESDIR}"/saslauthd.service;
  2564. dotmpfiles "${FILESDIR}"/${PN}.conf;
  2565. if ! use static-libs && [[ $(get_modname) == .so ]]; then
  2566. find "${ED}" -name "*.la" -delete || die;
  2567. fi
  2568. }
  2569. multilib_toolchain_setup ()
  2570. {
  2571. local v vv;
  2572. export ABI=$1;
  2573. local save_restore_variables=(CBUILD CHOST AR CC CXX F77 FC LD NM OBJCOPY OBJDUMP PKG_CONFIG RANLIB READELF STRINGS STRIP PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH);
  2574. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2575. for v in "${save_restore_variables[@]}";
  2576. do
  2577. vv="_abi_saved_${v}";
  2578. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2579. unset ${vv};
  2580. done;
  2581. unset _DEFAULT_ABI_SAVED;
  2582. fi;
  2583. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2584. for v in "${save_restore_variables[@]}";
  2585. do
  2586. vv="_abi_saved_${v}";
  2587. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2588. done;
  2589. export _DEFAULT_ABI_SAVED="true";
  2590. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2591. export CBUILD=$(get_abi_CHOST $1);
  2592. fi;
  2593. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2594. export AR="$(tc-getAR)";
  2595. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2596. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2597. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2598. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2599. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2600. export NM="$(tc-getNM)";
  2601. export OBJCOPY="$(tc-getOBJCOPY)";
  2602. export OBJDUMP="$(tc-getOBJDUMP)";
  2603. export PKG_CONFIG="$(tc-getPKG_CONFIG)";
  2604. export RANLIB="$(tc-getRANLIB)";
  2605. export READELF="$(tc-getREADELF)";
  2606. export STRINGS="$(tc-getSTRINGS)";
  2607. export STRIP="$(tc-getSTRIP)";
  2608. export CHOST=$(get_abi_CHOST $1);
  2609. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2610. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2611. export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include;
  2612. export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir);
  2613. fi
  2614. }
  2615. newpamd ()
  2616. {
  2617. [[ $# -ne 2 ]] && die "newpamd requires two arguments";
  2618. _pam_flag_disabled && return 0;
  2619. ( insinto /etc/pam.d;
  2620. insopts -m 0644;
  2621. newins "$1" "$2" );
  2622. cleanpamd $2
  2623. }
  2624. newpammod ()
  2625. {
  2626. [[ $# -ne 2 ]] && die "newpammod requires two arguments";
  2627. _pam_flag_disabled && return 0;
  2628. exeinto $(getpam_mod_dir);
  2629. newexe "$1" "$2"
  2630. }
  2631. newpamsecurity ()
  2632. {
  2633. [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments";
  2634. _pam_flag_disabled && return 0;
  2635. ( insinto /etc/security/$1;
  2636. insopts -m 0644;
  2637. newins "$2" "$3" )
  2638. }
  2639. newtmpfiles ()
  2640. {
  2641. debug-print-function ${FUNCNAME} "$@";
  2642. if [[ $2 != *.conf ]]; then
  2643. die "tmpfiles.d files must end with .conf";
  2644. fi;
  2645. ( insopts -m 0644;
  2646. insinto /usr/lib/tmpfiles.d;
  2647. newins "$@" )
  2648. }
  2649. no-as-needed ()
  2650. {
  2651. [[ $# -ne 0 ]] && die "no-as-needed takes no arguments";
  2652. case $($(tc-getLD) -v 2>&1 < /dev/null) in
  2653. *GNU*)
  2654. echo "-Wl,--no-as-needed"
  2655. ;;
  2656. esac
  2657. }
  2658. number_abis ()
  2659. {
  2660. set -- `get_install_abis`;
  2661. echo $#
  2662. }
  2663. pamd_mimic ()
  2664. {
  2665. [[ $# -lt 3 ]] && die "pamd_mimic requires at least three arguments";
  2666. _pam_flag_disabled && return 0;
  2667. dodir /etc/pam.d;
  2668. local pamdfile="${ED}/etc/pam.d/$2";
  2669. echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" >> "${pamdfile}" || die;
  2670. local authlevels="auth account password session";
  2671. local mimic="\tsubstack\t\t$1";
  2672. shift;
  2673. shift;
  2674. while [[ -n $1 ]]; do
  2675. has $1 ${authlevels} || die "unknown level type";
  2676. echo -e "$1${mimic}" >> "${pamdfile}" || die;
  2677. shift;
  2678. done
  2679. }
  2680. pamd_mimic_system ()
  2681. {
  2682. [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two arguments";
  2683. pamd_mimic system-auth "$@"
  2684. }
  2685. pammod_hide_symbols ()
  2686. {
  2687. cat - > "${T}"/pam-eclass-pam_symbols.ver <<EOF
  2688. {
  2689. global: pam_sm_*;
  2690. local: *;
  2691. };
  2692. EOF
  2693.  
  2694. append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver
  2695. }
  2696. pkg_nofetch ()
  2697. {
  2698. default
  2699. }
  2700. pkg_postinst ()
  2701. {
  2702. tmpfiles_process ${PN}.conf;
  2703. if ( use berkdb || use gdbm ) && [[ ! -f ${EROOT}/etc/sasl2/sasldb2 ]]; then
  2704. cp -av "${EROOT}"/etc/sasl2/sasldb2{-empty,} || die;
  2705. fi;
  2706. if use authdaemond; then
  2707. elog "You need to add a user running a service using Courier's";
  2708. elog "authdaemon to the 'mail' group. For example, do:";
  2709. elog " gpasswd -a postfix mail";
  2710. elog "to add the 'postfix' user to the 'mail' group.";
  2711. fi;
  2712. elog "pwcheck and saslauthd home directories have moved to:";
  2713. elog " /run/saslauthd, using tmpfiles.d"
  2714. }
  2715. raw-ldflags ()
  2716. {
  2717. local x input="$@";
  2718. [[ -z ${input} ]] && input=${LDFLAGS};
  2719. set --;
  2720. for x in ${input};
  2721. do
  2722. case ${x} in
  2723. -Wl,*)
  2724. x=${x#-Wl,};
  2725. set -- "$@" ${x//,/ }
  2726. ;;
  2727. *)
  2728.  
  2729. ;;
  2730. esac;
  2731. done;
  2732. echo "$@"
  2733. }
  2734. replace-cpu-flags ()
  2735. {
  2736. local newcpu="$#";
  2737. newcpu="${!newcpu}";
  2738. while [ $# -gt 1 ]; do
  2739. replace-flags "-march=${1}" "-march=${newcpu}";
  2740. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2741. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2742. shift;
  2743. done;
  2744. return 0
  2745. }
  2746. replace-flags ()
  2747. {
  2748. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2749. local f var new;
  2750. for var in $(all-flag-vars);
  2751. do
  2752. new=();
  2753. for f in ${!var};
  2754. do
  2755. [[ ${f} == ${1} ]] && f=${2};
  2756. new+=("${f}");
  2757. done;
  2758. export ${var}="${new[*]}";
  2759. done;
  2760. return 0
  2761. }
  2762. replace-sparc64-flags ()
  2763. {
  2764. [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments";
  2765. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2766. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2767. for x in ${SPARC64_CPUS};
  2768. do
  2769. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2770. done;
  2771. else
  2772. for x in ${SPARC64_CPUS};
  2773. do
  2774. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2775. done;
  2776. fi;
  2777. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2778. for x in ${SPARC64_CPUS};
  2779. do
  2780. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2781. done;
  2782. else
  2783. for x in ${SPARC64_CPUS};
  2784. do
  2785. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2786. done;
  2787. fi;
  2788. export CFLAGS CXXFLAGS
  2789. }
  2790. run_in_build_dir ()
  2791. {
  2792. debug-print-function ${FUNCNAME} "$@";
  2793. local ret;
  2794. [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified.";
  2795. [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set.";
  2796. mkdir -p "${BUILD_DIR}" || die;
  2797. pushd "${BUILD_DIR}" > /dev/null || die;
  2798. "${@}";
  2799. ret=${?};
  2800. popd > /dev/null || die;
  2801. return ${ret}
  2802. }
  2803. setup-allowed-flags ()
  2804. {
  2805. [[ ${EAPI} == 7 ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  2806. _setup-allowed-flags "$@"
  2807. }
  2808. src_compile ()
  2809. {
  2810. multilib-minimal_src_compile;
  2811. if ( use berkdb || use gdbm ) && tc-is-cross-compiler; then
  2812. emake -C "${WORKDIR}"/${P}-build;
  2813. fi
  2814. }
  2815. src_configure ()
  2816. {
  2817. export CC_FOR_BUILD="$(tc-getBUILD_CC)";
  2818. append-flags -std=gnu17;
  2819. use srp && filter-lto;
  2820. if [[ ${CHOST} == *-solaris* ]]; then
  2821. append-cppflags -DHAVE_GETPASSPHRASE;
  2822. else
  2823. append-cppflags -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -DLDAP_DEPRECATED;
  2824. append-cppflags -D_DEFAULT_SOURCE;
  2825. fi;
  2826. multilib-minimal_src_configure;
  2827. if ( use berkdb || use gdbm ) && tc-is-cross-compiler; then
  2828. mkdir -p "${WORKDIR}"/${P}-build || die;
  2829. cd "${WORKDIR}"/${P}-build || die;
  2830. ECONF_SOURCE="${S}" econf_build --with-dblib=$(usex berkdb berkeley gdbm);
  2831. fi
  2832. }
  2833. src_install ()
  2834. {
  2835. multilib-minimal_src_install "$@"
  2836. }
  2837. src_prepare ()
  2838. {
  2839. default;
  2840. sed -i '/^sasldir =/s:=.*:= $(plugindir):' "${S}"/plugins/Makefile.{am,in} || die "sed failed";
  2841. sed -i -e 's:AC_CONFIG_MACRO_DIR:AC_CONFIG_MACRO_DIRS:g' configure.ac || die;
  2842. eautoreconf
  2843. }
  2844. src_test ()
  2845. {
  2846. multilib-minimal_src_test "$@"
  2847. }
  2848. src_unpack ()
  2849. {
  2850. default
  2851. }
  2852. strip-flags ()
  2853. {
  2854. [[ $# -ne 0 ]] && die "strip-flags takes no arguments";
  2855. local x y var;
  2856. local ALLOWED_FLAGS;
  2857. _setup-allowed-flags;
  2858. set -f;
  2859. for var in $(all-flag-vars);
  2860. do
  2861. local new=();
  2862. for x in ${!var};
  2863. do
  2864. for y in "${ALLOWED_FLAGS[@]}";
  2865. do
  2866. if [[ ${x} == ${y} ]]; then
  2867. new+=("${x}");
  2868. break;
  2869. fi;
  2870. done;
  2871. done;
  2872. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2873. new+=(-O2);
  2874. fi;
  2875. if [[ ${!var} != "${new[*]}" ]]; then
  2876. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  2877. fi;
  2878. export ${var}="${new[*]}";
  2879. done;
  2880. set +f;
  2881. return 0
  2882. }
  2883. strip-unsupported-flags ()
  2884. {
  2885. [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments";
  2886. export CFLAGS=$(test-flags-CC ${CFLAGS});
  2887. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  2888. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  2889. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  2890. export LDFLAGS=$(test-flags-CCLD ${LDFLAGS})
  2891. }
  2892. systemd_dounit ()
  2893. {
  2894. debug-print-function ${FUNCNAME} "$@";
  2895. ( insopts -m 0644;
  2896. insinto "$(_systemd_unprefix systemd_get_systemunitdir)";
  2897. doins "${@}" )
  2898. }
  2899. systemd_douserunit ()
  2900. {
  2901. debug-print-function ${FUNCNAME} "$@";
  2902. ( insopts -m 0644;
  2903. insinto "$(_systemd_unprefix systemd_get_userunitdir)";
  2904. doins "${@}" )
  2905. }
  2906. systemd_enable_ntpunit ()
  2907. {
  2908. debug-print-function ${FUNCNAME} "$@";
  2909. if [[ ${#} -lt 2 ]]; then
  2910. die "Usage: systemd_enable_ntpunit <NN-name> <service>...";
  2911. fi;
  2912. local ntpunit_name=${1};
  2913. local services=("${@:2}");
  2914. if [[ ${ntpunit_name} != [0-9][0-9]-* ]]; then
  2915. die "ntpunit.d file must be named NN-name where NN are digits.";
  2916. else
  2917. if [[ ${ntpunit_name} == *.list ]]; then
  2918. die "The .list suffix is appended implicitly to ntpunit.d name.";
  2919. fi;
  2920. fi;
  2921. local unitdir=$(systemd_get_systemunitdir);
  2922. local s;
  2923. for s in "${services[@]}";
  2924. do
  2925. if [[ ! -f "${D}${unitdir}/${s}" ]]; then
  2926. die "ntp-units.d provider ${s} not installed (yet?) in \${D}.";
  2927. fi;
  2928. echo "${s}" >> "${T}"/${ntpunit_name}.list || die;
  2929. done;
  2930. ( insopts -m 0644;
  2931. insinto "$(_systemd_unprefix systemd_get_utildir)"/ntp-units.d;
  2932. doins "${T}"/${ntpunit_name}.list );
  2933. local ret=${?};
  2934. rm "${T}"/${ntpunit_name}.list || die;
  2935. return ${ret}
  2936. }
  2937. systemd_enable_service ()
  2938. {
  2939. debug-print-function ${FUNCNAME} "$@";
  2940. [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service";
  2941. local target=${1};
  2942. local service=${2};
  2943. local ud=$(_systemd_unprefix systemd_get_systemunitdir);
  2944. local destname=${service##*/};
  2945. dodir "${ud}"/"${target}".wants && dosym ../"${service}" "${ud}"/"${target}".wants/"${destname}"
  2946. }
  2947. systemd_get_sleepdir ()
  2948. {
  2949. debug-print-function ${FUNCNAME} "$@";
  2950. _systemd_get_dir systemdsleepdir /lib/systemd/system-sleep
  2951. }
  2952. systemd_get_systemgeneratordir ()
  2953. {
  2954. debug-print-function ${FUNCNAME} "$@";
  2955. _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators
  2956. }
  2957. systemd_get_systempresetdir ()
  2958. {
  2959. debug-print-function ${FUNCNAME} "$@";
  2960. _systemd_get_dir systemdsystempresetdir /lib/systemd/system-preset
  2961. }
  2962. systemd_get_systemunitdir ()
  2963. {
  2964. debug-print-function ${FUNCNAME} "$@";
  2965. _systemd_get_dir systemdsystemunitdir /lib/systemd/system
  2966. }
  2967. systemd_get_userunitdir ()
  2968. {
  2969. debug-print-function ${FUNCNAME} "$@";
  2970. _systemd_get_dir systemduserunitdir /usr/lib/systemd/user
  2971. }
  2972. systemd_get_utildir ()
  2973. {
  2974. debug-print-function ${FUNCNAME} "$@";
  2975. _systemd_get_dir systemdutildir /lib/systemd
  2976. }
  2977. systemd_install_dropin ()
  2978. {
  2979. debug-print-function ${FUNCNAME} "$@";
  2980. local basedir;
  2981. if [[ $# -ge 1 ]] && [[ $1 == "--user" ]]; then
  2982. basedir=$(_systemd_unprefix systemd_get_userunitdir);
  2983. shift 1;
  2984. else
  2985. basedir=$(_systemd_unprefix systemd_get_systemunitdir);
  2986. fi;
  2987. local unit=${1};
  2988. local src=${2};
  2989. [[ -n ${unit} ]] || die "No unit specified";
  2990. [[ -n ${src} ]] || die "No conf file specified";
  2991. [[ ${unit} == *.d ]] && die "Unit ${unit} must not have .d suffix";
  2992. ( insopts -m 0644;
  2993. insinto "${basedir}/${unit}".d;
  2994. newins "${src}" 00gentoo.conf )
  2995. }
  2996. systemd_install_serviced ()
  2997. {
  2998. debug-print-function ${FUNCNAME} "$@";
  2999. local src=${1};
  3000. local service=${2};
  3001. [[ -n ${src} ]] || die "No file specified";
  3002. if [[ ! -n ${service} ]]; then
  3003. [[ ${src} == *.conf ]] || die "Source file needs .conf suffix";
  3004. service=${src##*/};
  3005. service=${service%.conf};
  3006. fi;
  3007. [[ ${service} == *.d ]] && die "Service must not have .d suffix";
  3008. ( insopts -m 0644;
  3009. insinto /etc/systemd/system/"${service}".d;
  3010. newins "${src}" 00gentoo.conf )
  3011. }
  3012. systemd_is_booted ()
  3013. {
  3014. debug-print-function ${FUNCNAME} "$@";
  3015. [[ -d /run/systemd/system ]];
  3016. local ret=${?};
  3017. debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}";
  3018. return ${ret}
  3019. }
  3020. systemd_newunit ()
  3021. {
  3022. debug-print-function ${FUNCNAME} "$@";
  3023. ( insopts -m 0644;
  3024. insinto "$(_systemd_unprefix systemd_get_systemunitdir)";
  3025. newins "${@}" )
  3026. }
  3027. systemd_newuserunit ()
  3028. {
  3029. debug-print-function ${FUNCNAME} "$@";
  3030. ( insopts -m 0644;
  3031. insinto "$(_systemd_unprefix systemd_get_userunitdir)";
  3032. newins "${@}" )
  3033. }
  3034. systemd_reenable ()
  3035. {
  3036. type systemctl &> /dev/null || return 0;
  3037. local x;
  3038. for x in "$@";
  3039. do
  3040. if systemctl --quiet --root="${ROOT:-/}" is-enabled "${x}"; then
  3041. systemctl --root="${ROOT:-/}" reenable "${x}";
  3042. fi;
  3043. done
  3044. }
  3045. systemd_update_catalog ()
  3046. {
  3047. debug-print-function ${FUNCNAME} "$@";
  3048. [[ ${EBUILD_PHASE} == post* ]] || die "${FUNCNAME} disallowed during ${EBUILD_PHASE_FUNC:-${EBUILD_PHASE}}";
  3049. local journalctl=${EPREFIX}/usr/bin/journalctl;
  3050. if [[ -x ${journalctl} ]]; then
  3051. ebegin "Updating systemd journal catalogs";
  3052. journalctl --update-catalog;
  3053. eend $?;
  3054. else
  3055. debug-print "${FUNCNAME}: journalctl not found.";
  3056. fi
  3057. }
  3058. tc-arch ()
  3059. {
  3060. tc-ninja_magic_to_arch portage "$@"
  3061. }
  3062. tc-arch-kernel ()
  3063. {
  3064. tc-ninja_magic_to_arch kern "$@"
  3065. }
  3066. tc-check-min_ver ()
  3067. {
  3068. function do_check ()
  3069. {
  3070. debug-print "Compiler version check for ${1}";
  3071. debug-print "Detected: ${2}";
  3072. debug-print "Required: ${3}";
  3073. if ver_test ${2} -lt ${3}; then
  3074. eerror "Your current compiler is too old for this package!";
  3075. die "Active compiler is too old for this package (found ${1} ${2}).";
  3076. fi
  3077. };
  3078. case ${1} in
  3079. gcc)
  3080. tc-is-gcc || return;
  3081. do_check GCC $(gcc-version) ${2}
  3082. ;;
  3083. clang)
  3084. tc-is-clang || return;
  3085. do_check Clang $(clang-version) ${2}
  3086. ;;
  3087. *)
  3088. eerror "Unknown first parameter for ${FUNCNAME} - must be gcc or clang";
  3089. die "${FUNCNAME}: Parameter ${1} unknown"
  3090. ;;
  3091. esac
  3092. }
  3093. tc-check-openmp ()
  3094. {
  3095. if ! _tc-has-openmp; then
  3096. eerror "Your current compiler does not support OpenMP!";
  3097. if tc-is-gcc; then
  3098. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  3099. else
  3100. if tc-is-clang; then
  3101. eerror "OpenMP support in llvm-core/clang is provided by llvm-runtimes/openmp.";
  3102. fi;
  3103. fi;
  3104. die "Active compiler does not have required support for OpenMP";
  3105. fi
  3106. }
  3107. tc-cpp-is-true ()
  3108. {
  3109. local CONDITION=${1};
  3110. shift;
  3111. $(tc-getTARGET_CPP) "${@}" -P - <<-EOF > /dev/null 2>&1
  3112. #if ${CONDITION}
  3113. true
  3114. #else
  3115. #error false
  3116. #endif
  3117. EOF
  3118.  
  3119. }
  3120. tc-detect-is-softfloat ()
  3121. {
  3122. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  3123. case ${CTARGET:-${CHOST}} in
  3124. *-newlib | *-elf | *-eabi | arm64-apple-darwin*)
  3125. return 1
  3126. ;;
  3127. arm*)
  3128. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  3129. echo "no";
  3130. else
  3131. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  3132. echo "yes";
  3133. else
  3134. echo "softfp";
  3135. fi;
  3136. fi;
  3137. return 0
  3138. ;;
  3139. *)
  3140. return 1
  3141. ;;
  3142. esac
  3143. }
  3144. tc-enables-cxx-assertions ()
  3145. {
  3146. tc-cpp-is-true "defined(_GLIBCXX_ASSERTIONS) || defined(_LIBCPP_ENABLE_ASSERTIONS) || defined(_LIBCPP_ENABLE_HARDENED_MODE)" ${CPPFLAGS} ${CXXFLAGS}
  3147. }
  3148. tc-enables-fortify-source ()
  3149. {
  3150. tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3151. }
  3152. tc-enables-pie ()
  3153. {
  3154. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3155. }
  3156. tc-enables-ssp ()
  3157. {
  3158. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3159. }
  3160. tc-enables-ssp-all ()
  3161. {
  3162. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3163. }
  3164. tc-enables-ssp-strong ()
  3165. {
  3166. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  3167. }
  3168. tc-endian ()
  3169. {
  3170. local host=$1;
  3171. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3172. host=${host%%-*};
  3173. case ${host} in
  3174. aarch64*be)
  3175. echo big
  3176. ;;
  3177. aarch64)
  3178. echo little
  3179. ;;
  3180. alpha*)
  3181. echo little
  3182. ;;
  3183. arc*b*)
  3184. echo big
  3185. ;;
  3186. arc*)
  3187. echo little
  3188. ;;
  3189. arm*b*)
  3190. echo big
  3191. ;;
  3192. arm*)
  3193. echo little
  3194. ;;
  3195. cris*)
  3196. echo little
  3197. ;;
  3198. hppa*)
  3199. echo big
  3200. ;;
  3201. i?86*)
  3202. echo little
  3203. ;;
  3204. ia64*)
  3205. echo little
  3206. ;;
  3207. loongarch*)
  3208. echo little
  3209. ;;
  3210. m68*)
  3211. echo big
  3212. ;;
  3213. mips*l*)
  3214. echo little
  3215. ;;
  3216. mips*)
  3217. echo big
  3218. ;;
  3219. powerpc*le)
  3220. echo little
  3221. ;;
  3222. powerpc*)
  3223. echo big
  3224. ;;
  3225. riscv*)
  3226. echo little
  3227. ;;
  3228. s390*)
  3229. echo big
  3230. ;;
  3231. sh*b*)
  3232. echo big
  3233. ;;
  3234. sh*)
  3235. echo little
  3236. ;;
  3237. sparc*)
  3238. echo big
  3239. ;;
  3240. x86_64*)
  3241. echo little
  3242. ;;
  3243. *)
  3244. echo wtf
  3245. ;;
  3246. esac
  3247. }
  3248. tc-env_build ()
  3249. {
  3250. tc-export_build_env;
  3251. 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) READELF=$(tc-getBUILD_READELF) "$@"
  3252. }
  3253. tc-export ()
  3254. {
  3255. local var;
  3256. for var in "$@";
  3257. do
  3258. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3259. "tc-get${var}" > /dev/null;
  3260. done
  3261. }
  3262. tc-export_build_env ()
  3263. {
  3264. tc-export "$@";
  3265. if tc-is-cross-compiler; then
  3266. : "${BUILD_CFLAGS:=-O1 -pipe}";
  3267. : "${BUILD_CXXFLAGS:=-O1 -pipe}";
  3268. : "${BUILD_CPPFLAGS:= }";
  3269. : "${BUILD_LDFLAGS:= }";
  3270. else
  3271. : "${BUILD_CFLAGS:=${CFLAGS}}";
  3272. : "${BUILD_CXXFLAGS:=${CXXFLAGS}}";
  3273. : "${BUILD_CPPFLAGS:=${CPPFLAGS}}";
  3274. : "${BUILD_LDFLAGS:=${LDFLAGS}}";
  3275. fi;
  3276. export BUILD_{C,CXX,CPP,LD}FLAGS;
  3277. local v;
  3278. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  3279. do
  3280. export ${v#BUILD_}_FOR_BUILD="${!v}";
  3281. done
  3282. }
  3283. tc-get-build-ptr-size ()
  3284. {
  3285. $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CBUILD pointer size"
  3286. }
  3287. tc-get-c-rtlib ()
  3288. {
  3289. local res=$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name 2> /dev/null);
  3290. case ${res} in
  3291. *libclang_rt*)
  3292. echo compiler-rt
  3293. ;;
  3294. *libgcc*)
  3295. echo libgcc
  3296. ;;
  3297. *)
  3298. return 1
  3299. ;;
  3300. esac;
  3301. return 0
  3302. }
  3303. tc-get-compiler-type ()
  3304. {
  3305. local code='
  3306. #if defined(__PATHSCALE__)
  3307. HAVE_PATHCC
  3308. #elif defined(__clang__)
  3309. HAVE_CLANG
  3310. #elif defined(__GNUC__)
  3311. HAVE_GCC
  3312. #endif
  3313. ';
  3314. local res=$($(tc-getCPP "$@") -E -P - <<< "${code}");
  3315. case ${res} in
  3316. *HAVE_PATHCC*)
  3317. echo pathcc
  3318. ;;
  3319. *HAVE_CLANG*)
  3320. echo clang
  3321. ;;
  3322. *HAVE_GCC*)
  3323. echo gcc
  3324. ;;
  3325. *)
  3326. echo unknown
  3327. ;;
  3328. esac
  3329. }
  3330. tc-get-cxx-stdlib ()
  3331. {
  3332. local code='#include <ciso646>
  3333.  
  3334. #if defined(_LIBCPP_VERSION)
  3335. HAVE_LIBCXX
  3336. #elif defined(__GLIBCXX__)
  3337. HAVE_LIBSTDCPP
  3338. #endif
  3339. ';
  3340. local res=$($(tc-getCXX) ${CPPFLAGS} ${CXXFLAGS} -x c++ -E -P - <<< "${code}" 2> /dev/null);
  3341. case ${res} in
  3342. *HAVE_LIBCXX*)
  3343. echo libc++
  3344. ;;
  3345. *HAVE_LIBSTDCPP*)
  3346. echo libstdc++
  3347. ;;
  3348. *)
  3349. return 1
  3350. ;;
  3351. esac;
  3352. return 0
  3353. }
  3354. tc-get-ptr-size ()
  3355. {
  3356. $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CHOST pointer size"
  3357. }
  3358. tc-getAR ()
  3359. {
  3360. tc-getPROG AR ar "$@"
  3361. }
  3362. tc-getAS ()
  3363. {
  3364. tc-getPROG AS as "$@"
  3365. }
  3366. tc-getBUILD_AR ()
  3367. {
  3368. tc-getBUILD_PROG AR ar "$@"
  3369. }
  3370. tc-getBUILD_AS ()
  3371. {
  3372. tc-getBUILD_PROG AS as "$@"
  3373. }
  3374. tc-getBUILD_CC ()
  3375. {
  3376. tc-getBUILD_PROG CC gcc "$@"
  3377. }
  3378. tc-getBUILD_CPP ()
  3379. {
  3380. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  3381. }
  3382. tc-getBUILD_CXX ()
  3383. {
  3384. tc-getBUILD_PROG CXX g++ "$@"
  3385. }
  3386. tc-getBUILD_LD ()
  3387. {
  3388. tc-getBUILD_PROG LD ld "$@"
  3389. }
  3390. tc-getBUILD_NM ()
  3391. {
  3392. tc-getBUILD_PROG NM nm "$@"
  3393. }
  3394. tc-getBUILD_OBJCOPY ()
  3395. {
  3396. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3397. }
  3398. tc-getBUILD_PKG_CONFIG ()
  3399. {
  3400. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3401. }
  3402. tc-getBUILD_PROG ()
  3403. {
  3404. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  3405. tc-is-cross-compiler || vars+=" $1";
  3406. _tc-getPROG CBUILD "${vars}" "${@:2}"
  3407. }
  3408. tc-getBUILD_RANLIB ()
  3409. {
  3410. tc-getBUILD_PROG RANLIB ranlib "$@"
  3411. }
  3412. tc-getBUILD_READELF ()
  3413. {
  3414. tc-getBUILD_PROG READELF readelf "$@"
  3415. }
  3416. tc-getBUILD_STRINGS ()
  3417. {
  3418. tc-getBUILD_PROG STRINGS strings "$@"
  3419. }
  3420. tc-getBUILD_STRIP ()
  3421. {
  3422. tc-getBUILD_PROG STRIP strip "$@"
  3423. }
  3424. tc-getCC ()
  3425. {
  3426. tc-getPROG CC gcc "$@"
  3427. }
  3428. tc-getCPP ()
  3429. {
  3430. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  3431. }
  3432. tc-getCXX ()
  3433. {
  3434. tc-getPROG CXX g++ "$@"
  3435. }
  3436. tc-getDLLWRAP ()
  3437. {
  3438. tc-getPROG DLLWRAP dllwrap "$@"
  3439. }
  3440. tc-getF77 ()
  3441. {
  3442. tc-getPROG F77 gfortran "$@"
  3443. }
  3444. tc-getFC ()
  3445. {
  3446. tc-getPROG FC gfortran "$@"
  3447. }
  3448. tc-getGCJ ()
  3449. {
  3450. tc-getPROG GCJ gcj "$@"
  3451. }
  3452. tc-getGO ()
  3453. {
  3454. tc-getPROG GO gccgo "$@"
  3455. }
  3456. tc-getLD ()
  3457. {
  3458. tc-getPROG LD ld "$@"
  3459. }
  3460. tc-getNM ()
  3461. {
  3462. tc-getPROG NM nm "$@"
  3463. }
  3464. tc-getOBJCOPY ()
  3465. {
  3466. tc-getPROG OBJCOPY objcopy "$@"
  3467. }
  3468. tc-getOBJDUMP ()
  3469. {
  3470. tc-getPROG OBJDUMP objdump "$@"
  3471. }
  3472. tc-getPKG_CONFIG ()
  3473. {
  3474. tc-getPROG PKG_CONFIG pkg-config "$@"
  3475. }
  3476. tc-getPROG ()
  3477. {
  3478. _tc-getPROG CHOST "$@"
  3479. }
  3480. tc-getRANLIB ()
  3481. {
  3482. tc-getPROG RANLIB ranlib "$@"
  3483. }
  3484. tc-getRC ()
  3485. {
  3486. tc-getPROG RC windres "$@"
  3487. }
  3488. tc-getREADELF ()
  3489. {
  3490. tc-getPROG READELF readelf "$@"
  3491. }
  3492. tc-getSTRINGS ()
  3493. {
  3494. tc-getPROG STRINGS strings "$@"
  3495. }
  3496. tc-getSTRIP ()
  3497. {
  3498. tc-getPROG STRIP strip "$@"
  3499. }
  3500. tc-getTARGET_CPP ()
  3501. {
  3502. if [[ -n ${CTARGET} ]]; then
  3503. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  3504. else
  3505. tc-getCPP "$@";
  3506. fi
  3507. }
  3508. tc-has-64bit-time_t ()
  3509. {
  3510. $(tc-getCC) ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &> /dev/null
  3511. #include <sys/types.h>
  3512. int test[sizeof(time_t) >= 8 ? 1 : -1];
  3513. EOF
  3514.  
  3515. return $?
  3516. }
  3517. tc-has-tls ()
  3518. {
  3519. local base="${T}/test-tc-tls";
  3520. cat <<-EOF > "${base}.c"
  3521. int foo(int *i) {
  3522. static __thread int j = 0;
  3523. return *i ? j : *i;
  3524. }
  3525. EOF
  3526.  
  3527. local flags;
  3528. case $1 in
  3529. -s)
  3530. flags="-S"
  3531. ;;
  3532. -c)
  3533. flags="-c"
  3534. ;;
  3535. -l)
  3536.  
  3537. ;;
  3538. -*)
  3539. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3540. ;;
  3541. esac;
  3542. case "${CHOST}" in
  3543. *-darwin*)
  3544. : ${flags:=-dynamiclib}
  3545. ;;
  3546. *)
  3547. : ${flags:=-fPIC -shared -Wl,-z,defs}
  3548. ;;
  3549. esac;
  3550. [[ $1 == -* ]] && shift;
  3551. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null;
  3552. local ret=$?;
  3553. rm -f "${base}"*;
  3554. return ${ret}
  3555. }
  3556. tc-is-clang ()
  3557. {
  3558. [[ $(tc-get-compiler-type) == clang ]]
  3559. }
  3560. tc-is-cross-compiler ()
  3561. {
  3562. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  3563. }
  3564. tc-is-gcc ()
  3565. {
  3566. [[ $(tc-get-compiler-type) == gcc ]]
  3567. }
  3568. tc-is-lto ()
  3569. {
  3570. local f="${T}/test-lto.o";
  3571. local ret=1;
  3572. case $(tc-get-compiler-type) in
  3573. clang)
  3574. $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  3575. llvm-bcanalyzer "${f}" &> /dev/null && ret=0
  3576. ;;
  3577. gcc)
  3578. $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  3579. [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && ret=0
  3580. ;;
  3581. esac;
  3582. rm -f "${f}" || die;
  3583. return "${ret}"
  3584. }
  3585. tc-is-softfloat ()
  3586. {
  3587. tc-detect-is-softfloat || tc-tuple-is-softfloat
  3588. }
  3589. tc-is-static-only ()
  3590. {
  3591. local host=${CTARGET:-${CHOST}};
  3592. [[ ${host} == *-mint* ]]
  3593. }
  3594. tc-ld-disable-gold ()
  3595. {
  3596. tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
  3597. }
  3598. tc-ld-force-bfd ()
  3599. {
  3600. if tc-ld-is-bfd "$@"; then
  3601. return;
  3602. fi;
  3603. ewarn "Forcing usage of the BFD linker";
  3604. local ld=$(unset LD; tc-getLD "$@");
  3605. local bfd_ld="${ld}.bfd";
  3606. local path_ld=$(type -P "${bfd_ld}" 2> /dev/null);
  3607. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  3608. if tc-is-gcc || tc-is-clang; then
  3609. export CFLAGS="${CFLAGS} -fuse-ld=bfd";
  3610. export CXXFLAGS="${CXXFLAGS} -fuse-ld=bfd";
  3611. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3612. fi
  3613. }
  3614. tc-ld-is-bfd ()
  3615. {
  3616. local out;
  3617. local -x LC_ALL=C;
  3618. out=$($(tc-getLD "$@") --version 2>&1);
  3619. if [[ ${out} != "GNU ld"* ]]; then
  3620. return 1;
  3621. fi;
  3622. local base="${T}/test-tc-linker";
  3623. cat <<-EOF > "${base}.c"
  3624. int main(void) { return 0; }
  3625. EOF
  3626.  
  3627. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3628. rm -f "${base}"*;
  3629. if [[ ! ${out} =~ .*^"GNU ld".* ]]; then
  3630. return 1;
  3631. fi;
  3632. return 0
  3633. }
  3634. tc-ld-is-gold ()
  3635. {
  3636. local out;
  3637. local -x LC_ALL=C;
  3638. out=$($(tc-getLD "$@") --version 2>&1);
  3639. if [[ ${out} == *"GNU gold"* ]]; then
  3640. return 0;
  3641. fi;
  3642. local base="${T}/test-tc-linker";
  3643. cat <<-EOF > "${base}.c"
  3644. int main(void) { return 0; }
  3645. EOF
  3646.  
  3647. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3648. rm -f "${base}"*;
  3649. if [[ ${out} == *"GNU gold"* ]]; then
  3650. return 0;
  3651. fi;
  3652. return 1
  3653. }
  3654. tc-ld-is-lld ()
  3655. {
  3656. local out;
  3657. local -x LC_ALL=C;
  3658. out=$($(tc-getLD "$@") --version 2>&1);
  3659. if [[ ${out} == *"LLD"* ]]; then
  3660. return 0;
  3661. fi;
  3662. local base="${T}/test-tc-linker";
  3663. cat <<-EOF > "${base}.c"
  3664. int main(void) { return 0; }
  3665. EOF
  3666.  
  3667. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3668. rm -f "${base}"*;
  3669. if [[ ${out} == *"LLD"* ]]; then
  3670. return 0;
  3671. fi;
  3672. return 1
  3673. }
  3674. tc-ld-is-mold ()
  3675. {
  3676. local out;
  3677. local -x LC_ALL=C;
  3678. out=$($(tc-getLD "$@") --version 2>&1);
  3679. if [[ ${out} == *"mold"* ]]; then
  3680. return 0;
  3681. fi;
  3682. local base="${T}/test-tc-linker";
  3683. cat <<-EOF > "${base}.c"
  3684. int main(void) { return 0; }
  3685. EOF
  3686.  
  3687. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3688. rm -f "${base}"*;
  3689. if [[ ${out} == *"mold"* ]]; then
  3690. return 0;
  3691. fi;
  3692. return 1
  3693. }
  3694. tc-ninja_magic_to_arch ()
  3695. {
  3696. function _tc_echo_kernel_alias ()
  3697. {
  3698. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3699. };
  3700. local type=$1;
  3701. local host=$2;
  3702. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3703. case ${host} in
  3704. arm64*)
  3705. echo arm64
  3706. ;;
  3707. aarch64*)
  3708. echo arm64
  3709. ;;
  3710. alpha*)
  3711. echo alpha
  3712. ;;
  3713. arc*)
  3714. echo arc
  3715. ;;
  3716. arm*)
  3717. echo arm
  3718. ;;
  3719. avr*)
  3720. _tc_echo_kernel_alias avr32 avr
  3721. ;;
  3722. bfin*)
  3723. _tc_echo_kernel_alias blackfin bfin
  3724. ;;
  3725. c6x*)
  3726. echo c6x
  3727. ;;
  3728. cris*)
  3729. echo cris
  3730. ;;
  3731. frv*)
  3732. echo frv
  3733. ;;
  3734. hexagon*)
  3735. echo hexagon
  3736. ;;
  3737. hppa*)
  3738. _tc_echo_kernel_alias parisc hppa
  3739. ;;
  3740. i?86*)
  3741. echo x86
  3742. ;;
  3743. ia64*)
  3744. echo ia64
  3745. ;;
  3746. loongarch*)
  3747. _tc_echo_kernel_alias loongarch loong
  3748. ;;
  3749. m68*)
  3750. echo m68k
  3751. ;;
  3752. metag*)
  3753. echo metag
  3754. ;;
  3755. microblaze*)
  3756. echo microblaze
  3757. ;;
  3758. mips*)
  3759. echo mips
  3760. ;;
  3761. nios2*)
  3762. echo nios2
  3763. ;;
  3764. nios*)
  3765. echo nios
  3766. ;;
  3767. or1k* | or32*)
  3768. echo openrisc
  3769. ;;
  3770. powerpc*)
  3771. if [[ ${type} == "kern" ]]; then
  3772. echo powerpc;
  3773. else
  3774. if [[ ${host} == powerpc64* ]]; then
  3775. echo ppc64;
  3776. else
  3777. echo ppc;
  3778. fi;
  3779. fi
  3780. ;;
  3781. riscv*)
  3782. echo riscv
  3783. ;;
  3784. s390*)
  3785. echo s390
  3786. ;;
  3787. score*)
  3788. echo score
  3789. ;;
  3790. sh64*)
  3791. _tc_echo_kernel_alias sh64 sh
  3792. ;;
  3793. sh*)
  3794. echo sh
  3795. ;;
  3796. sparc64*)
  3797. _tc_echo_kernel_alias sparc64 sparc
  3798. ;;
  3799. sparc*)
  3800. [[ ${PROFILE_ARCH} == "sparc64" ]] && _tc_echo_kernel_alias sparc64 sparc || echo sparc
  3801. ;;
  3802. tile*)
  3803. echo tile
  3804. ;;
  3805. vax*)
  3806. echo vax
  3807. ;;
  3808. x86_64*)
  3809. if [[ ${type} == "kern" ]]; then
  3810. echo x86;
  3811. else
  3812. echo amd64;
  3813. fi
  3814. ;;
  3815. xtensa*)
  3816. echo xtensa
  3817. ;;
  3818. *)
  3819. echo unknown
  3820. ;;
  3821. esac
  3822. }
  3823. tc-stack-grows-down ()
  3824. {
  3825. case ${ARCH} in
  3826. hppa | metag)
  3827. return 1
  3828. ;;
  3829. esac;
  3830. return 0
  3831. }
  3832. tc-tuple-is-softfloat ()
  3833. {
  3834. local CTARGET=${CTARGET:-${CHOST}};
  3835. case ${CTARGET//_/-} in
  3836. bfin* | h8300*)
  3837. echo "only"
  3838. ;;
  3839. *-softfloat-*)
  3840. echo "yes"
  3841. ;;
  3842. *-softfp-*)
  3843. echo "softfp"
  3844. ;;
  3845. arm*-hardfloat-* | arm*eabihf)
  3846. echo "no"
  3847. ;;
  3848. *-newlib | *-elf | *-eabi)
  3849. echo "no"
  3850. ;;
  3851. arm64-apple-darwin*)
  3852. echo "no"
  3853. ;;
  3854. arm*)
  3855. echo "yes"
  3856. ;;
  3857. *)
  3858. echo "no"
  3859. ;;
  3860. esac
  3861. }
  3862. test-compile ()
  3863. {
  3864. local lang=$1;
  3865. local code=$2;
  3866. shift 2;
  3867. [[ -z "${lang}" ]] && return 1;
  3868. [[ -z "${code}" ]] && return 1;
  3869. local compiler filename_in filename_out args=() libs=();
  3870. case "${lang}" in
  3871. c)
  3872. compiler="$(tc-getCC)";
  3873. filename_in="${T}/test.c";
  3874. filename_out="${T}/test.o";
  3875. args+=(${CFLAGS[@]} -xc -c)
  3876. ;;
  3877. c++)
  3878. compiler="$(tc-getCXX)";
  3879. filename_in="${T}/test.cc";
  3880. filename_out="${T}/test.o";
  3881. args+=(${CXXFLAGS[@]} -xc++ -c)
  3882. ;;
  3883. f77)
  3884. compiler="$(tc-getF77)";
  3885. filename_in="${T}/test.f";
  3886. filename_out="${T}/test.o";
  3887. args+=(${FFFLAGS[@]} -xf77 -c)
  3888. ;;
  3889. f95)
  3890. compiler="$(tc-getFC)";
  3891. filename_in="${T}/test.f90";
  3892. filename_out="${T}/test.o";
  3893. args+=(${FCFLAGS[@]} -xf95 -c)
  3894. ;;
  3895. c+ld)
  3896. compiler="$(tc-getCC)";
  3897. filename_in="${T}/test.c";
  3898. filename_out="${T}/test.exe";
  3899. args+=(${CFLAGS[@]} ${LDFLAGS[@]} -xc);
  3900. libs+=(${LIBS[@]})
  3901. ;;
  3902. c+++ld)
  3903. compiler="$(tc-getCXX)";
  3904. filename_in="${T}/test.cc";
  3905. filename_out="${T}/test.exe";
  3906. args+=(${CXXFLAGS[@]} ${LDFLAGS[@]} -xc++);
  3907. libs+=(${LIBS[@]})
  3908. ;;
  3909. f77+ld)
  3910. compiler="$(tc-getF77)";
  3911. filename_in="${T}/test.f";
  3912. filename_out="${T}/test.exe";
  3913. args+=(${FFLAGS[@]} ${LDFLAGS[@]} -xf77);
  3914. libs+=(${LIBS[@]})
  3915. ;;
  3916. f95+ld)
  3917. compiler="$(tc-getFC)";
  3918. filename_in="${T}/test.f90";
  3919. filename_out="${T}/test.exe";
  3920. args+=(${FCFLAGS[@]} ${LDFLAGS[@]} -xf95);
  3921. libs+=(${LIBS[@]})
  3922. ;;
  3923. *)
  3924. die "Unknown compiled language ${lang}"
  3925. ;;
  3926. esac;
  3927. printf "%s\n" "${code}" > "${filename_in}" || die "Failed to create '${test_in}'";
  3928. "${compiler}" ${args[@]} "${filename_in}" -o "${filename_out}" ${libs[@]} &> /dev/null
  3929. }
  3930. test-flag-CC ()
  3931. {
  3932. _test-flag-PROG CC c "$@"
  3933. }
  3934. test-flag-CCLD ()
  3935. {
  3936. _test-flag-PROG CC c+ld "$@"
  3937. }
  3938. test-flag-CXX ()
  3939. {
  3940. _test-flag-PROG CXX c++ "$@"
  3941. }
  3942. test-flag-F77 ()
  3943. {
  3944. _test-flag-PROG F77 f77 "$@"
  3945. }
  3946. test-flag-FC ()
  3947. {
  3948. _test-flag-PROG FC f95 "$@"
  3949. }
  3950. test-flag-PROG ()
  3951. {
  3952. [[ ${EAPI} == 7 ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  3953. _test-flag-PROG "$@"
  3954. }
  3955. test-flags ()
  3956. {
  3957. test-flags-CC "$@"
  3958. }
  3959. test-flags-CC ()
  3960. {
  3961. _test-flags-PROG CC "$@"
  3962. }
  3963. test-flags-CCLD ()
  3964. {
  3965. _test-flags-PROG CCLD "$@"
  3966. }
  3967. test-flags-CXX ()
  3968. {
  3969. _test-flags-PROG CXX "$@"
  3970. }
  3971. test-flags-F77 ()
  3972. {
  3973. _test-flags-PROG F77 "$@"
  3974. }
  3975. test-flags-FC ()
  3976. {
  3977. _test-flags-PROG FC "$@"
  3978. }
  3979. test-flags-PROG ()
  3980. {
  3981. [[ ${EAPI} == 7 ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  3982. _test-flags-PROG "$@"
  3983. }
  3984. test_version_info ()
  3985. {
  3986. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  3987. return 0;
  3988. else
  3989. return 1;
  3990. fi
  3991. }
  3992. tmpfiles_process ()
  3993. {
  3994. debug-print-function ${FUNCNAME} "$@";
  3995. [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst";
  3996. [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename";
  3997. if [[ ${ROOT:-/} != / ]]; then
  3998. ewarn "Warning: tmpfiles.d not processed on ROOT != /. If you do not use";
  3999. ewarn "a service manager supporting tmpfiles.d, you need to run";
  4000. ewarn "the following command after booting (or chroot-ing with all";
  4001. ewarn "appropriate filesystems mounted) into the ROOT:";
  4002. ewarn;
  4003. ewarn " tmpfiles --create";
  4004. ewarn;
  4005. ewarn "Failure to do so may result in missing runtime directories";
  4006. ewarn "and failures to run programs or start services.";
  4007. return;
  4008. fi;
  4009. if type systemd-tmpfiles &> /dev/null; then
  4010. systemd-tmpfiles --create "$@";
  4011. else
  4012. if type tmpfiles &> /dev/null; then
  4013. tmpfiles --create "$@";
  4014. fi;
  4015. fi;
  4016. if [[ $? -ne 0 ]]; then
  4017. ewarn "The tmpfiles processor exited with a non-zero exit code";
  4018. fi
  4019. }
  4020. ver_cut ()
  4021. {
  4022. local range=${1};
  4023. local v=${2:-${PV}};
  4024. local start end;
  4025. local -a comp;
  4026. __eapi7_ver_split "${v}";
  4027. local max=$((${#comp[@]}/2));
  4028. __eapi7_ver_parse_range "${range}" "${max}";
  4029. local IFS=;
  4030. if [[ ${start} -gt 0 ]]; then
  4031. start=$(( start*2 - 1 ));
  4032. fi;
  4033. echo "${comp[*]:start:end*2-start}"
  4034. }
  4035. ver_rs ()
  4036. {
  4037. local v;
  4038. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  4039. local start end i;
  4040. local -a comp;
  4041. __eapi7_ver_split "${v}";
  4042. local max=$((${#comp[@]}/2 - 1));
  4043. while [[ ${#} -ge 2 ]]; do
  4044. __eapi7_ver_parse_range "${1}" "${max}";
  4045. for ((i = start*2; i <= end*2; i+=2 ))
  4046. do
  4047. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  4048. comp[i]=${2};
  4049. done;
  4050. shift 2;
  4051. done;
  4052. local IFS=;
  4053. echo "${comp[*]}"
  4054. }
  4055. ver_test ()
  4056. {
  4057. local va op vb;
  4058. if [[ $# -eq 3 ]]; then
  4059. va=${1};
  4060. shift;
  4061. else
  4062. va=${PVR};
  4063. fi;
  4064. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  4065. op=${1};
  4066. vb=${2};
  4067. case ${op} in
  4068. -eq | -ne | -lt | -le | -gt | -ge)
  4069.  
  4070. ;;
  4071. *)
  4072. die "${FUNCNAME}: invalid operator: ${op}"
  4073. ;;
  4074. esac;
  4075. __eapi7_ver_compare "${va}" "${vb}";
  4076. test $? "${op}" 2
  4077. }
  4078.  
Add Comment
Please, Sign In to add comment