Advertisement
theluckyone17

/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/temp/environment

Aug 21st, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 175.44 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 32"
  5. declare -x ADA_TARGET=""
  6. declare -x ALSA_CARDS=""
  7. declare -x AMDGPU_TARGETS=""
  8. declare -x ANT_HOME="/usr/share/ant"
  9. declare -x APACHE2_MODULES=""
  10. declare -x APACHE2_MPMS=""
  11. declare -x ARCH="amd64"
  12. declare BDEPEND="
  13. dev-util/gdbus-codegen
  14. dev-util/glib-utils
  15. gtk-doc? (
  16. dev-util/gtk-doc
  17. app-text/docbook-xml-dtd:4.1.2
  18. )
  19. >=sys-devel/gettext-0.17
  20. virtual/pkgconfig
  21. introspection? (
  22. || ( ( dev-lang/python:3.11 dev-python/pygobject:3[python_targets_python3_11(-)] ) ( dev-lang/python:3.10 dev-python/pygobject:3[python_targets_python3_10(-)] ) )
  23. dev-lang/perl
  24. dev-libs/libxslt
  25. )
  26. vala? ( || ( dev-lang/vala:0.56 ) )
  27. test? (
  28. >=dev-libs/jansson-2.7
  29. || ( ( dev-lang/python:3.11
  30. dev-python/dbus-python[python_targets_python3_11(-)]
  31. dev-python/pygobject:3[python_targets_python3_11(-)] ) ( dev-lang/python:3.10
  32. dev-python/dbus-python[python_targets_python3_10(-)]
  33. dev-python/pygobject:3[python_targets_python3_10(-)] ) )
  34. )
  35. app-arch/xz-utils >=dev-util/meson-0.62.2
  36. >=dev-util/ninja-1.8.2
  37. dev-util/meson-format-array
  38. virtual/pkgconfig virtual/pkgconfig test? (
  39. x11-base/xorg-server[xvfb]
  40. x11-apps/xhost
  41. )"
  42. declare -x BINPKG_FORMAT="xpak"
  43. declare -x BINPKG_GPG_SIGNING_BASE_COMMAND="/usr/bin/flock /run/lock/portage-binpkg-gpg.lock /usr/bin/gpg --sign --armor [PORTAGE_CONFIG]"
  44. declare -x BINPKG_GPG_SIGNING_DIGEST="SHA512"
  45. declare -x BINPKG_GPG_VERIFY_BASE_COMMAND="/usr/bin/gpg --verify --batch --no-tty --no-auto-check-trustdb --status-fd 2 [PORTAGE_CONFIG] [SIGNATURE]"
  46. declare -x BINPKG_GPG_VERIFY_GPG_HOME="/etc/portage/gnupg"
  47. declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr xml python_targets_python3_11 python_single_target_python3_11 multilib"
  48. declare -x CALLIGRA_FEATURES=""
  49. declare -x CAMERAS=""
  50. declare -x CBUILD="x86_64-pc-linux-gnu"
  51. declare -x CFLAGS="-march=skylake -O2 -pipe"
  52. declare -x CFLAGS_amd64="-m64"
  53. declare -x CFLAGS_default
  54. declare -x CFLAGS_x32="-mx32"
  55. declare -x CFLAGS_x86="-m32 -mfpmath=sse"
  56. declare -- CHECKCONFIG_DONOTHING=""
  57. declare -x CHOST="x86_64-pc-linux-gnu"
  58. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  59. declare -x CHOST_default="x86_64-pc-linux-gnu"
  60. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  61. declare -x CHOST_x86="i686-pc-linux-gnu"
  62. declare -x COLLECTD_PLUGINS=""
  63. declare -- COMMON_DEPEND="
  64. sys-apps/util-linux[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  65. elogind? ( >=sys-auth/elogind-219 )
  66. >=virtual/libudev-175:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  67. sys-apps/dbus
  68. net-libs/libndp
  69. systemd? ( >=sys-apps/systemd-209:0= )
  70. >=dev-libs/glib-2.40:2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  71. introspection? ( >=dev-libs/gobject-introspection-0.10.3:= )
  72. selinux? (
  73. sec-policy/selinux-networkmanager
  74. sys-libs/libselinux
  75. )
  76. audit? ( sys-process/audit )
  77. teamd? (
  78. >=dev-libs/jansson-2.7:=
  79. >=net-misc/libteam-1.9
  80. )
  81. policykit? ( >=sys-auth/polkit-0.106 )
  82. nss? (
  83. dev-libs/nspr[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  84. >=dev-libs/nss-3.11[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  85. )
  86. gnutls? (
  87. >=net-libs/gnutls-2.12:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  88. )
  89. ppp? ( >=net-dialup/ppp-2.4.5:=[ipv6(+)] )
  90. modemmanager? (
  91. net-misc/mobile-broadband-provider-info
  92. >=net-misc/modemmanager-0.7.991:0=
  93. )
  94. bluetooth? ( >=net-wireless/bluez-5:= )
  95. ofono? ( net-misc/ofono )
  96. dhclient? ( >=net-misc/dhcp-4[client] )
  97. dhcpcd? ( >=net-misc/dhcpcd-9.3.3 )
  98. ovs? ( >=dev-libs/jansson-2.7:= )
  99. resolvconf? ( virtual/resolvconf )
  100. connection-sharing? (
  101. net-dns/dnsmasq[dbus,dhcp]
  102. iptables? ( net-firewall/iptables )
  103. nftables? ( net-firewall/nftables )
  104. )
  105. psl? ( net-libs/libpsl )
  106. concheck? ( net-misc/curl )
  107. tools? (
  108. >=dev-libs/newt-0.52.15
  109. libedit? ( dev-libs/libedit )
  110. !libedit? ( sys-libs/readline:= )
  111. )
  112. "
  113. declare -x COMMON_FLAGS="-march=skylake -O2 -pipe"
  114. declare -x CPU_FLAGS_ARM=""
  115. declare -x CPU_FLAGS_PPC=""
  116. declare -x CPU_FLAGS_X86=""
  117. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  118. declare -x CURL_SSL=""
  119. declare -x CXXFLAGS="-march=skylake -O2 -pipe"
  120. declare -x DEFAULT_ABI="amd64"
  121. declare -x DEFINED_PHASES=" compile configure install postinst postrm prepare setup test"
  122. declare DEPEND="
  123. sys-apps/util-linux[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  124. elogind? ( >=sys-auth/elogind-219 )
  125. >=virtual/libudev-175:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  126. sys-apps/dbus
  127. net-libs/libndp
  128. systemd? ( >=sys-apps/systemd-209:0= )
  129. >=dev-libs/glib-2.40:2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  130. introspection? ( >=dev-libs/gobject-introspection-0.10.3:= )
  131. selinux? (
  132. sec-policy/selinux-networkmanager
  133. sys-libs/libselinux
  134. )
  135. audit? ( sys-process/audit )
  136. teamd? (
  137. >=dev-libs/jansson-2.7:=
  138. >=net-misc/libteam-1.9
  139. )
  140. policykit? ( >=sys-auth/polkit-0.106 )
  141. nss? (
  142. dev-libs/nspr[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  143. >=dev-libs/nss-3.11[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  144. )
  145. gnutls? (
  146. >=net-libs/gnutls-2.12:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  147. )
  148. ppp? ( >=net-dialup/ppp-2.4.5:=[ipv6(+)] )
  149. modemmanager? (
  150. net-misc/mobile-broadband-provider-info
  151. >=net-misc/modemmanager-0.7.991:0=
  152. )
  153. bluetooth? ( >=net-wireless/bluez-5:= )
  154. ofono? ( net-misc/ofono )
  155. dhclient? ( >=net-misc/dhcp-4[client] )
  156. dhcpcd? ( >=net-misc/dhcpcd-9.3.3 )
  157. ovs? ( >=dev-libs/jansson-2.7:= )
  158. resolvconf? ( virtual/resolvconf )
  159. connection-sharing? (
  160. net-dns/dnsmasq[dbus,dhcp]
  161. iptables? ( net-firewall/iptables )
  162. nftables? ( net-firewall/nftables )
  163. )
  164. psl? ( net-libs/libpsl )
  165. concheck? ( net-misc/curl )
  166. tools? (
  167. >=dev-libs/newt-0.52.15
  168. libedit? ( dev-libs/libedit )
  169. !libedit? ( sys-libs/readline:= )
  170. )
  171.  
  172. >=sys-kernel/linux-headers-3.18
  173. net-libs/libndp[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  174. ppp? ( elibc_musl? ( net-libs/ppp-defs ) )
  175. "
  176. declare DESCRIPTION="A set of co-operative tools that make networking simple and straightforward"
  177. declare -x DIROPTIONS="-m0755"
  178. declare -- DOC_CONTENTS="To modify system network connections without needing to enter the
  179. root password, add your user account to the 'plugdev' group."
  180. declare -x EAPI="8"
  181. declare -x ELIBC="glibc"
  182. declare -- EMESON_BUILDTYPE="plain"
  183. 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"
  184. declare -- EPOCHREALTIME="1692637369.150769"
  185. declare -- EPOCHSECONDS="1692637369"
  186. declare -x EPYTHON="python3.11"
  187. declare -x EXEOPTIONS="-m0755"
  188. declare -x FCFLAGS="-march=skylake -O2 -pipe"
  189. 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}\""
  190. declare -x FFLAGS="-march=skylake -O2 -pipe"
  191. declare -x FFTOOLS=""
  192. declare -x GCC_SPECS=""
  193. declare -- GNOME_ORG_MODULE="NetworkManager"
  194. declare -- GNOME_ORG_PV="1.42.6"
  195. declare -- GNOME_ORG_RELEASE="1.42"
  196. declare -- GNOME_TARBALL_SUFFIX="xz"
  197. declare -x GPG_VERIFY_GROUP_DROP="nogroup"
  198. declare -x GPG_VERIFY_USER_DROP="nobody"
  199. declare -x GPSD_PROTOCOLS=""
  200. declare -x GRUB_PLATFORMS=""
  201. declare -x GSETTINGS_BACKEND="dconf"
  202. declare HOMEPAGE="https://wiki.gnome.org/Projects/NetworkManager"
  203. declare IDEPEND=""
  204. declare -x INHERITED=" gnome.org toolchain-funcs multilib linux-info multiprocessing ninja-utils python-utils-r1 meson out-of-source-utils multibuild multilib-build multilib-minimal meson-multilib python-any-r1 readme.gentoo-r1 systemd udev flag-o-matic vala virtualx"
  205. declare -x INPUT_DEVICES=""
  206. declare -x INSOPTIONS="-m0644"
  207. declare IUSE="audit bluetooth +concheck connection-sharing debug dhclient dhcpcd elogind gnutls +gtk-doc +introspection iptables iwd psl libedit lto +nss nftables +modemmanager ofono ovs policykit +ppp resolvconf selinux syslog systemd teamd test +tools vala +wext +wifi abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_s390_32 abi_s390_64 test"
  208. 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 audit bluetooth concheck connection-sharing debug dhclient dhcpcd elibc_Darwin elibc_SunOS elibc_bionic elibc_glibc elibc_mingw elibc_musl elogind gnutls gtk-doc hppa ia64 introspection iptables iwd kernel_Darwin kernel_SunOS kernel_linux libedit loong lto m68k mips modemmanager nftables nss ofono ovs policykit ppc ppc-macos ppc64 ppc64-linux ppp prefix prefix-guest prefix-stack psl resolvconf riscv s390 selinux sparc syslog systemd teamd test tools vala wext wifi x64-macos x64-solaris x86 x86-linux"
  209. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest prefix-stack"
  210. declare -x KERNEL="linux"
  211. declare -x KERNEL_ABI="amd64"
  212. declare -- KERNEL_DIR="/usr/src/linux"
  213. declare -- KERNEL_MAKEFILE=""
  214. declare -x KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~loong ppc ppc64 ~riscv ~sparc x86"
  215. declare -x L10N=""
  216. declare -x LANG="en_US.utf8"
  217. declare -x LCD_DEVICES=""
  218. declare -x LC_COLLATE="C"
  219. declare -x LC_MESSAGES="C.utf8"
  220. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  221. declare -x LDFLAGS_amd64="-m elf_x86_64"
  222. declare -x LDFLAGS_default
  223. declare -x LDFLAGS_x32="-m elf32_x86_64"
  224. declare -x LDFLAGS_x86="-m elf_i386"
  225. declare -x LEX="flex"
  226. declare -x LIBDIR_amd64="lib64"
  227. declare -x LIBDIR_default="lib"
  228. declare -x LIBDIR_x32="libx32"
  229. declare -x LIBDIR_x86="lib"
  230. declare -x LIBOPTIONS="-m0644"
  231. declare -x LIBREOFFICE_EXTENSIONS=""
  232. declare -x LICENSE="GPL-2+ LGPL-2.1+"
  233. declare -x LLVM_TARGETS=""
  234. declare -x LUA_SINGLE_TARGET=""
  235. declare -x LUA_TARGETS=""
  236. declare -x MAIL="/var/mail/root"
  237. declare -x MAKEOPTS="-j8"
  238. declare -x MANPAGER="manpager"
  239. declare -- MESON_VERBOSE="ON"
  240. declare -x MONKEYD_PLUGINS=""
  241. declare -x MULTILIB_ABIS="amd64 x86"
  242. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  243. 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"
  244. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  245. 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(-)?"
  246. declare -x NGINX_MODULES_HTTP=""
  247. declare -x NGINX_MODULES_MAIL=""
  248. declare -x NGINX_MODULES_STREAM=""
  249. declare -- NINJA="ninja"
  250. declare -- NINJA_DEPEND=">=dev-util/ninja-1.8.2"
  251. declare -- NINJA_VERBOSE="ON"
  252. declare -x NPM_CONFIG_GLOBALCONFIG="/etc/npm/npmrc"
  253. declare -x OFFICE_IMPLEMENTATION=""
  254. declare -x OPENMPI_FABRICS=""
  255. declare -x OPENMPI_OFED_FEATURES=""
  256. declare -x OPENMPI_RM=""
  257. declare -a PATCHES=([0]="/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/distdir/networkmanager-ppp-2.5.0.patch")
  258. declare -x PATH="/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/temp/python3.11/bin:/usr/lib/portage/python3.11/ebuild-helpers/xattr:/usr/lib/portage/python3.11/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/16/bin:/usr/lib/llvm/15/bin"
  259. declare PDEPEND=""
  260. declare -x PHP_TARGETS=""
  261. declare -x PKG_CONFIG_PATH="/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/temp/python3.11/pkgconfig"
  262. declare -x PORTAGE_COMPRESSION_COMMAND="zstd -T8"
  263. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  264. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  265. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/networkmanager-1.42.6-r1/html")
  266. declare -a PORTAGE_DOSTRIP=([0]="/")
  267. declare -a PORTAGE_DOSTRIP_SKIP=()
  268. declare -x POSTGRES_TARGETS=""
  269. 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"
  270. declare -- PROPERTIES=""
  271. declare -x PYTHON="/usr/bin/python3.11"
  272. declare -x PYTHONDONTWRITEBYTECODE="1"
  273. declare -a PYTHON_COMPAT=([0]="python3_9" [1]="python3_10" [2]="python3_11")
  274. declare -- PYTHON_DEPS="|| ( dev-lang/python:3.11 dev-lang/python:3.10 )"
  275. declare -- PYTHON_REQUIRED_USE="I-DO-NOT-EXIST-IN-PYTHON-ANY-R1"
  276. declare -x PYTHON_SINGLE_TARGET=""
  277. declare -x PYTHON_TARGETS=""
  278. declare -x QEMU_SOFTMMU_TARGETS=""
  279. declare -x QEMU_USER_TARGETS=""
  280. declare RDEPEND="
  281. sys-apps/util-linux[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  282. elogind? ( >=sys-auth/elogind-219 )
  283. >=virtual/libudev-175:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  284. sys-apps/dbus
  285. net-libs/libndp
  286. systemd? ( >=sys-apps/systemd-209:0= )
  287. >=dev-libs/glib-2.40:2[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  288. introspection? ( >=dev-libs/gobject-introspection-0.10.3:= )
  289. selinux? (
  290. sec-policy/selinux-networkmanager
  291. sys-libs/libselinux
  292. )
  293. audit? ( sys-process/audit )
  294. teamd? (
  295. >=dev-libs/jansson-2.7:=
  296. >=net-misc/libteam-1.9
  297. )
  298. policykit? ( >=sys-auth/polkit-0.106 )
  299. nss? (
  300. dev-libs/nspr[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  301. >=dev-libs/nss-3.11[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  302. )
  303. gnutls? (
  304. >=net-libs/gnutls-2.12:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?]
  305. )
  306. ppp? ( >=net-dialup/ppp-2.4.5:=[ipv6(+)] )
  307. modemmanager? (
  308. net-misc/mobile-broadband-provider-info
  309. >=net-misc/modemmanager-0.7.991:0=
  310. )
  311. bluetooth? ( >=net-wireless/bluez-5:= )
  312. ofono? ( net-misc/ofono )
  313. dhclient? ( >=net-misc/dhcp-4[client] )
  314. dhcpcd? ( >=net-misc/dhcpcd-9.3.3 )
  315. ovs? ( >=dev-libs/jansson-2.7:= )
  316. resolvconf? ( virtual/resolvconf )
  317. connection-sharing? (
  318. net-dns/dnsmasq[dbus,dhcp]
  319. iptables? ( net-firewall/iptables )
  320. nftables? ( net-firewall/nftables )
  321. )
  322. psl? ( net-libs/libpsl )
  323. concheck? ( net-misc/curl )
  324. tools? (
  325. >=dev-libs/newt-0.52.15
  326. libedit? ( dev-libs/libedit )
  327. !libedit? ( sys-libs/readline:= )
  328. )
  329.  
  330. acct-group/plugdev
  331. || (
  332. net-misc/iputils[arping(+)]
  333. net-analyzer/arping
  334. )
  335. wifi? (
  336. !iwd? ( >=net-wireless/wpa_supplicant-0.7.3-r3[dbus] )
  337. iwd? ( net-wireless/iwd )
  338. )
  339. "
  340. declare -- README_GENTOO_SUFFIX=""
  341. declare REPOSITORY
  342. declare REQUIRED_USE="
  343. bluetooth? ( modemmanager )
  344. connection-sharing? ( || ( iptables nftables ) )
  345. gtk-doc? ( introspection )
  346. iwd? ( wifi )
  347. vala? ( introspection )
  348. wext? ( wifi )
  349. ^^ ( gnutls nss )
  350. ?? ( elogind systemd )
  351. ?? ( dhclient dhcpcd )
  352. ?? ( syslog systemd )
  353. "
  354. declare RESTRICT="test"
  355. 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}\""
  356. declare -x ROS_MESSAGES=""
  357. declare -x RUBY_TARGETS=""
  358. declare -x S="/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/work/NetworkManager-1.42.6"
  359. declare -x SANDBOX_DEBUG="0"
  360. declare -x SANDBOX_DENY=""
  361. declare -x SANDBOX_METHOD="any"
  362. declare -x SANDBOX_PREDICT="/var/tmp/portage/net-misc/networkmanager-1.42.6-r1/homedir:/dev/crypto:/var/cache/man:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  363. declare -x SANDBOX_READ="/:/var/tmp/portage"
  364. declare -x SANDBOX_VERBOSE="1"
  365. 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/net-misc/networkmanager-1.42.6-r1/homedir/.bash_history"
  366. declare -x SANE_BACKENDS=""
  367. declare -x SHELL="/bin/bash"
  368. declare -- SKIP_KERNEL_CHECK=""
  369. declare -x SLOT="0"
  370. declare -i SRANDOM="2911664079"
  371. declare SRC_URI="mirror://gnome/sources/NetworkManager/1.42/NetworkManager-1.42.6.tar.xz https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/commit/5df19f5b26c5921a401e63fb329e844a02d6b1f2.patch -> networkmanager-ppp-2.5.0.patch"
  372. declare -x SUDO_COMMAND="/usr/bin/emerge -avuDN world"
  373. declare -x SUDO_GID="1000"
  374. declare -x SUDO_UID="1000"
  375. declare -x SUDO_USER="noel"
  376. declare -x SYMLINK_LIB="no"
  377. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  378. declare -x USE="abi_x86_32 abi_x86_64 amd64 bluetooth concheck elibc_glibc elogind gtk-doc introspection kernel_linux modemmanager nss policykit ppp tools wext wifi"
  379. declare -x USERLAND="GNU"
  380. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL"
  381. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  382. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-linux arm arm64 arm64-macos hppa ia64 loong m68k mips ppc ppc64 ppc64-linux ppc-macos riscv s390 sparc x64-macos x64-solaris x86 x86-linux"
  383. declare -x USE_EXPAND_VALUES_ELIBC="bionic Darwin glibc mingw musl SunOS"
  384. declare -x USE_EXPAND_VALUES_KERNEL="Darwin linux SunOS"
  385. declare -x UWSGI_PLUGINS=""
  386. declare -- VALA_MAX_API_VERSION="0.56"
  387. declare -- VALA_MIN_API_VERSION="0.56"
  388. declare -x VIDEO_CARDS=""
  389. declare -- VIRTUALX_DEPEND="
  390. x11-base/xorg-server[xvfb]
  391. x11-apps/xhost
  392. "
  393. declare -- VIRTUALX_REQUIRED="test"
  394. declare -x VOICEMAIL_STORAGE=""
  395. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  396. declare -x XDG_CURRENT_DESKTOP="KDE"
  397. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  398. declare -x XTABLES_ADDONS=""
  399. declare -- _FLAG_O_MATIC_ECLASS="1"
  400. declare -- _GNOME_ORG_ECLASS="1"
  401. declare -- _LINUX_CONFIG_EXISTS_DONE=""
  402. declare -- _LINUX_INFO_ECLASS="1"
  403. declare -- _MESON_ECLASS="1"
  404. declare -- _MESON_MULTILIB_ECLASS="1"
  405. declare -- _MULTIBUILD_ECLASS="1"
  406. declare -- _MULTILIB_BUILD_ECLASS="1"
  407. declare -- _MULTILIB_ECLASS="1"
  408. 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")
  409. declare -- _MULTILIB_MINIMAL_ECLASS="1"
  410. declare -- _MULTIPROCESSING_ECLASS="1"
  411. declare -- _NINJA_UTILS_ECLASS="1"
  412. declare -- _OUT_OF_SOURCE_UTILS_ECLASS="1"
  413. declare -a _PYTHON_ALL_IMPLS=([0]="pypy3" [1]="python3_10" [2]="python3_11" [3]="python3_12")
  414. declare -- _PYTHON_ANY_R1_ECLASS="1"
  415. declare -a _PYTHON_HISTORICAL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy1_8" [3]="pypy1_9" [4]="pypy2_0" [5]="python2_5" [6]="python2_6" [7]="python2_7" [8]="python3_1" [9]="python3_2" [10]="python3_3" [11]="python3_4" [12]="python3_5" [13]="python3_6" [14]="python3_7" [15]="python3_8" [16]="python3_9")
  416. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python3_10" [1]="python3_11")
  417. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="pypy3" [1]="python3_12")
  418. declare -- _PYTHON_UTILS_R1_ECLASS="1"
  419. declare -- _README_GENTOO_ECLASS="1"
  420. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  421. declare -- _UDEV_ECLASS="1"
  422. declare -- _VALA_ECLASS="1"
  423. declare -- _VIRTUALX_ECLASS="1"
  424. declare -x __E_DESTTREE="/usr"
  425. declare -x __E_DOCDESTTREE=""
  426. declare -x __E_EXEDESTTREE=""
  427. declare -x __E_INSDESTTREE=""
  428. declare -x ac_cv_c_undeclared_builtin_options="none needed"
  429. declare -x enable_year2038="no"
  430. declare -- get_version_warning_done=""
  431. declare -x gl_cv_compiler_check_decl_option="-Werror=implicit-function-declaration"
  432. __eapi6_src_install ()
  433. {
  434. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  435. emake DESTDIR="${D}" install;
  436. fi;
  437. einstalldocs
  438. }
  439. __eapi6_src_prepare ()
  440. {
  441. if ___is_indexed_array_var PATCHES; then
  442. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  443. else
  444. if [[ -n ${PATCHES} ]]; then
  445. eapply ${PATCHES};
  446. fi;
  447. fi;
  448. eapply_user
  449. }
  450. __eapi7_ver_compare ()
  451. {
  452. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  453. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  454. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  455. an=${BASH_REMATCH[1]};
  456. al=${BASH_REMATCH[3]};
  457. as=${BASH_REMATCH[4]};
  458. ar=${BASH_REMATCH[7]};
  459. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  460. bn=${BASH_REMATCH[1]};
  461. bl=${BASH_REMATCH[3]};
  462. bs=${BASH_REMATCH[4]};
  463. br=${BASH_REMATCH[7]};
  464. __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  465. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  466. an=${an#*.};
  467. bn=${bn#*.};
  468. a=${an%%.*};
  469. b=${bn%%.*};
  470. if [[ ${a} == 0* || ${b} == 0* ]]; then
  471. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  472. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  473. [[ ${a} > ${b} ]] && return 3;
  474. [[ ${a} < ${b} ]] && return 1;
  475. else
  476. __eapi7_ver_compare_int "${a}" "${b}" || return;
  477. fi;
  478. done;
  479. [[ ${an} == *.* ]] && return 3;
  480. [[ ${bn} == *.* ]] && return 1;
  481. [[ ${al} > ${bl} ]] && return 3;
  482. [[ ${al} < ${bl} ]] && return 1;
  483. as=${as#_}${as:+_};
  484. bs=${bs#_}${bs:+_};
  485. while [[ -n ${as} && -n ${bs} ]]; do
  486. a=${as%%_*};
  487. b=${bs%%_*};
  488. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  489. __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  490. else
  491. [[ ${a%%[0-9]*} == p ]] && return 3;
  492. [[ ${b%%[0-9]*} == p ]] && return 1;
  493. [[ ${a} > ${b} ]] && return 3 || return 1;
  494. fi;
  495. as=${as#*_};
  496. bs=${bs#*_};
  497. done;
  498. if [[ -n ${as} ]]; then
  499. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  500. else
  501. if [[ -n ${bs} ]]; then
  502. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  503. fi;
  504. fi;
  505. __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  506. return 2
  507. }
  508. __eapi7_ver_compare_int ()
  509. {
  510. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  511. if [[ ${d} -gt 0 ]]; then
  512. printf -v b "%0${d}d%s" 0 "${b}";
  513. else
  514. if [[ ${d} -lt 0 ]]; then
  515. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  516. fi;
  517. fi;
  518. [[ ${a} > ${b} ]] && return 3;
  519. [[ ${a} == "${b}" ]]
  520. }
  521. __eapi7_ver_parse_range ()
  522. {
  523. local range=${1};
  524. local max=${2};
  525. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  526. start=${range%-*};
  527. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  528. if [[ -n ${end} ]]; then
  529. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  530. [[ ${end} -le ${max} ]] || end=${max};
  531. else
  532. end=${max};
  533. fi
  534. }
  535. __eapi7_ver_split ()
  536. {
  537. local v=${1} LC_ALL=C;
  538. comp=();
  539. local s c;
  540. while [[ -n ${v} ]]; do
  541. s=${v%%[a-zA-Z0-9]*};
  542. v=${v:${#s}};
  543. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  544. v=${v:${#c}};
  545. comp+=("${s}" "${c}");
  546. done
  547. }
  548. __eapi8_src_prepare ()
  549. {
  550. local f;
  551. if ___is_indexed_array_var PATCHES; then
  552. [[ ${#PATCHES[@]} -gt 0 ]] && eapply -- "${PATCHES[@]}";
  553. else
  554. if [[ -n ${PATCHES} ]]; then
  555. eapply -- ${PATCHES};
  556. fi;
  557. fi;
  558. eapply_user
  559. }
  560. _clang_fullversion ()
  561. {
  562. local ver="$1";
  563. shift;
  564. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  565. eval echo "${ver}"
  566. }
  567. _eapply_patch ()
  568. {
  569. local f=${1};
  570. local prefix=${2};
  571. ebegin "${prefix:-Applying }${f##*/}";
  572. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  573. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  574. all_opts+=(-s -F0);
  575. fi;
  576. ${patch_cmd} "${all_opts[@]}" < "${f}";
  577. failed=${?};
  578. if ! eend "${failed}"; then
  579. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  580. fi
  581. }
  582. _filter-hardened ()
  583. {
  584. local f;
  585. for f in "$@";
  586. do
  587. case "${f}" in
  588. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  589. if ! gcc-specs-pie && ! tc-enables-pie; then
  590. continue;
  591. fi;
  592. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  593. if test-flags -nopie > /dev/null; then
  594. append-flags -nopie;
  595. else
  596. append-flags -no-pie;
  597. fi;
  598. fi
  599. ;;
  600. -fstack-protector | -fstack-protector-strong)
  601. if ! gcc-specs-ssp && ! tc-enables-ssp && ! tc-enables-ssp-strong; then
  602. continue;
  603. fi;
  604. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  605. ;;
  606. -fstack-protector-all)
  607. if ! gcc-specs-ssp-to-all && ! tc-enables-ssp-all; then
  608. continue;
  609. fi;
  610. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  611. ;;
  612. -fno-strict-overflow)
  613. gcc-specs-nostrict || continue;
  614. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  615. ;;
  616. -D_GLIBCXX_ASSERTIONS | -D_LIBCPP_ENABLE_ASSERTIONS | -D_LIBCPP_ENABLE_HARDENED_MODE)
  617. tc-enables-cxx-assertions || continue;
  618. append-cppflags -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -U_LIBCPP_ENABLE_HARDENED_MODE
  619. ;;
  620. -D_FORTIFY_SOURCE=*)
  621. tc-enables-fortify-source || continue;
  622. append-cppflags -U_FORTIFY_SOURCE
  623. ;;
  624. esac;
  625. done
  626. }
  627. _filter-var ()
  628. {
  629. local f x var=$1 new=();
  630. shift;
  631. for f in ${!var};
  632. do
  633. for x in "$@";
  634. do
  635. [[ ${f} == ${x} ]] && continue 2;
  636. done;
  637. new+=("${f}");
  638. done;
  639. export ${var}="${new[*]}"
  640. }
  641. _gcc-install-dir ()
  642. {
  643. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  644. }
  645. _gcc-specs-directive_raw ()
  646. {
  647. local cc=$(tc-getCC);
  648. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  649. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  650. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  651. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  652. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  653. { spec=spec $0 }
  654. END { print spec }';
  655. return 0
  656. }
  657. _gcc-specs-exists ()
  658. {
  659. [[ -f $(_gcc-install-dir)/$1 ]]
  660. }
  661. _gcc_fullversion ()
  662. {
  663. local ver="$1";
  664. shift;
  665. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  666. eval echo "${ver}"
  667. }
  668. _is_flagq ()
  669. {
  670. local x var="$1[*]";
  671. for x in ${!var};
  672. do
  673. [[ ${x} == $2 ]] && return 0;
  674. done;
  675. return 1
  676. }
  677. _meson_create_cross_file ()
  678. {
  679. local system cpu_family cpu;
  680. _meson_get_machine_info "${CHOST}";
  681. local fn=${T}/meson.${CHOST}.${ABI}.ini;
  682. cat > "${fn}" <<-EOF
  683. [binaries]
  684. ar = $(_meson_env_array "$(tc-getAR)")
  685. c = $(_meson_env_array "$(tc-getCC)")
  686. cpp = $(_meson_env_array "$(tc-getCXX)")
  687. fortran = $(_meson_env_array "$(tc-getFC)")
  688. llvm-config = '$(tc-getPROG LLVM_CONFIG llvm-config)'
  689. nm = $(_meson_env_array "$(tc-getNM)")
  690. objc = $(_meson_env_array "$(tc-getPROG OBJC cc)")
  691. objcopy = $(_meson_env_array "$(tc-getOBJCOPY)")
  692. objcpp = $(_meson_env_array "$(tc-getPROG OBJCXX c++)")
  693. pkgconfig = '$(tc-getPKG_CONFIG)'
  694. strip = $(_meson_env_array "$(tc-getSTRIP)")
  695. windres = $(_meson_env_array "$(tc-getRC)")
  696.  
  697. [built-in options]
  698. c_args = $(_meson_env_array "${CFLAGS} ${CPPFLAGS}")
  699. c_link_args = $(_meson_env_array "${CFLAGS} ${LDFLAGS}")
  700. cpp_args = $(_meson_env_array "${CXXFLAGS} ${CPPFLAGS}")
  701. cpp_link_args = $(_meson_env_array "${CXXFLAGS} ${LDFLAGS}")
  702. fortran_args = $(_meson_env_array "${FCFLAGS}")
  703. fortran_link_args = $(_meson_env_array "${FCFLAGS} ${LDFLAGS}")
  704. objc_args = $(_meson_env_array "${OBJCFLAGS} ${CPPFLAGS}")
  705. objc_link_args = $(_meson_env_array "${OBJCFLAGS} ${LDFLAGS}")
  706. objcpp_args = $(_meson_env_array "${OBJCXXFLAGS} ${CPPFLAGS}")
  707. objcpp_link_args = $(_meson_env_array "${OBJCXXFLAGS} ${LDFLAGS}")
  708.  
  709. [properties]
  710. needs_exe_wrapper = true
  711. sys_root = '${SYSROOT}'
  712. pkg_config_libdir = '${PKG_CONFIG_LIBDIR:-${EPREFIX}/usr/$(get_libdir)/pkgconfig}'
  713.  
  714. [host_machine]
  715. system = '${system}'
  716. cpu_family = '${cpu_family}'
  717. cpu = '${cpu}'
  718. endian = '$(tc-endian "${CHOST}")'
  719. EOF
  720.  
  721. echo "${fn}"
  722. }
  723. _meson_create_native_file ()
  724. {
  725. local system cpu_family cpu;
  726. _meson_get_machine_info "${CBUILD}";
  727. local fn=${T}/meson.${CBUILD}.${ABI}.ini;
  728. cat > "${fn}" <<-EOF
  729. [binaries]
  730. ar = $(_meson_env_array "$(tc-getBUILD_AR)")
  731. c = $(_meson_env_array "$(tc-getBUILD_CC)")
  732. cpp = $(_meson_env_array "$(tc-getBUILD_CXX)")
  733. fortran = $(_meson_env_array "$(tc-getBUILD_PROG FC gfortran)")
  734. llvm-config = '$(tc-getBUILD_PROG LLVM_CONFIG llvm-config)'
  735. nm = $(_meson_env_array "$(tc-getBUILD_NM)")
  736. objc = $(_meson_env_array "$(tc-getBUILD_PROG OBJC cc)")
  737. objcopy = $(_meson_env_array "$(tc-getBUILD_OBJCOPY)")
  738. objcpp = $(_meson_env_array "$(tc-getBUILD_PROG OBJCXX c++)")
  739. pkgconfig = '$(tc-getBUILD_PKG_CONFIG)'
  740. strip = $(_meson_env_array "$(tc-getBUILD_STRIP)")
  741. windres = $(_meson_env_array "$(tc-getBUILD_PROG RC windres)")
  742.  
  743. [built-in options]
  744. c_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_CPPFLAGS}")
  745. c_link_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_LDFLAGS}")
  746. cpp_args = $(_meson_env_array "${BUILD_CXXFLAGS} ${BUILD_CPPFLAGS}")
  747. cpp_link_args = $(_meson_env_array "${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}")
  748. fortran_args = $(_meson_env_array "${BUILD_FCFLAGS}")
  749. fortran_link_args = $(_meson_env_array "${BUILD_FCFLAGS} ${BUILD_LDFLAGS}")
  750. objc_args = $(_meson_env_array "${BUILD_OBJCFLAGS} ${BUILD_CPPFLAGS}")
  751. objc_link_args = $(_meson_env_array "${BUILD_OBJCFLAGS} ${BUILD_LDFLAGS}")
  752. objcpp_args = $(_meson_env_array "${BUILD_OBJCXXFLAGS} ${BUILD_CPPFLAGS}")
  753. objcpp_link_args = $(_meson_env_array "${BUILD_OBJCXXFLAGS} ${BUILD_LDFLAGS}")
  754.  
  755. [properties]
  756. needs_exe_wrapper = false
  757. pkg_config_libdir = '${BUILD_PKG_CONFIG_LIBDIR:-${EPREFIX}/usr/$(get_libdir)/pkgconfig}'
  758.  
  759. [build_machine]
  760. system = '${system}'
  761. cpu_family = '${cpu_family}'
  762. cpu = '${cpu}'
  763. endian = '$(tc-endian "${CBUILD}")'
  764. EOF
  765.  
  766. echo "${fn}"
  767. }
  768. _meson_env_array ()
  769. {
  770. meson-format-array "$@"
  771. }
  772. _meson_get_machine_info ()
  773. {
  774. local tuple=$1;
  775. case ${tuple} in
  776. *-darwin*)
  777. system=darwin
  778. ;;
  779. *-linux*)
  780. system=linux
  781. ;;
  782. mingw* | *-mingw*)
  783. system=windows
  784. ;;
  785. *-solaris*)
  786. system=sunos
  787. ;;
  788. esac;
  789. cpu_family=$(tc-arch "${tuple}");
  790. case ${cpu_family} in
  791. amd64)
  792. cpu_family=x86_64
  793. ;;
  794. arm64)
  795. cpu_family=aarch64
  796. ;;
  797. riscv)
  798. case ${tuple} in
  799. riscv32*)
  800. cpu_family=riscv32
  801. ;;
  802. riscv64*)
  803. cpu_family=riscv64
  804. ;;
  805. esac
  806. ;;
  807. esac;
  808. cpu=${tuple%%-*}
  809. }
  810. _multilib_multibuild_wrapper ()
  811. {
  812. debug-print-function ${FUNCNAME} "$@";
  813. local ABI=${MULTIBUILD_VARIANT#*.};
  814. local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*};
  815. multilib_toolchain_setup "${ABI}";
  816. readonly ABI;
  817. "${@}"
  818. }
  819. _python_check_EPYTHON ()
  820. {
  821. if [[ -z ${EPYTHON} ]]; then
  822. die "EPYTHON unset, invalid call context";
  823. fi
  824. }
  825. _python_check_locale_sanity ()
  826. {
  827. local -x LC_ALL=${1};
  828. local IFS=;
  829. local lc=({a..z});
  830. local uc=({A..Z});
  831. local input="${lc[*]}${uc[*]}";
  832. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  833. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  834. }
  835. _python_check_occluded_packages ()
  836. {
  837. debug-print-function ${FUNCNAME} "${@}";
  838. [[ ! -n ${PYTHON_EXPERIMENTAL_QA} ]] && return;
  839. [[ -z ${BUILD_DIR} || ! -d ${BUILD_DIR}/install ]] && return;
  840. local sitedir="${BUILD_DIR}/install$(python_get_sitedir)";
  841. [[ ${sitedir} -ef . ]] && return;
  842. local f fn diff l;
  843. for f in "${sitedir}"/*/;
  844. do
  845. f=${f%/};
  846. fn=${f##*/};
  847. [[ ${fn} == *.dist-info || ${fn} == *.egg-info ]] && continue;
  848. if [[ -d ${fn} ]]; then
  849. diff=$(
  850. comm -1 -3 <(
  851. find "${fn}" -type f -not -path '*/__pycache__/*' |
  852. sort
  853. assert
  854. ) <(
  855. cd "${sitedir}" &&
  856. find "${fn}" -type f -not -path '*/__pycache__/*' |
  857. sort
  858. assert
  859. )
  860. );
  861. if [[ -n ${diff} ]]; then
  862. eqawarn "The directory ${fn} occludes package installed for ${EPYTHON}.";
  863. eqawarn "The installed package includes additional files:";
  864. eqawarn;
  865. while IFS= read -r l; do
  866. eqawarn " ${l}";
  867. done <<< "${diff}";
  868. eqawarn;
  869. if [[ ! -n ${_PYTHON_WARNED_OCCLUDED_PACKAGES} ]]; then
  870. eqawarn "For more information on occluded packages, please see:";
  871. eqawarn "https://projects.gentoo.org/python/guide/test.html#importerrors-for-c-extensions";
  872. _PYTHON_WARNED_OCCLUDED_PACKAGES=1;
  873. fi;
  874. fi;
  875. fi;
  876. done
  877. }
  878. _python_export ()
  879. {
  880. debug-print-function ${FUNCNAME} "${@}";
  881. local impl var;
  882. case "${1}" in
  883. python* | jython*)
  884. impl=${1/_/.};
  885. shift
  886. ;;
  887. pypy | pypy3)
  888. impl=${1};
  889. shift
  890. ;;
  891. *)
  892. impl=${EPYTHON};
  893. if [[ -z ${impl} ]]; then
  894. die "_python_export called without a python implementation and EPYTHON is unset";
  895. fi
  896. ;;
  897. esac;
  898. debug-print "${FUNCNAME}: implementation: ${impl}";
  899. for var in "$@";
  900. do
  901. case "${var}" in
  902. EPYTHON)
  903. export EPYTHON=${impl};
  904. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  905. ;;
  906. PYTHON)
  907. export PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl};
  908. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  909. ;;
  910. PYTHON_SITEDIR)
  911. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  912. PYTHON_SITEDIR=$(
  913. "${PYTHON}" - <<-EOF || die
  914. import sysconfig
  915. print(sysconfig.get_path("purelib"))
  916. EOF
  917. );
  918. PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"};
  919. export PYTHON_SITEDIR;
  920. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  921. ;;
  922. PYTHON_INCLUDEDIR)
  923. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  924. PYTHON_INCLUDEDIR=$(
  925. "${PYTHON}" - <<-EOF || die
  926. import sysconfig
  927. print(sysconfig.get_path("platinclude"))
  928. EOF
  929. );
  930. PYTHON_INCLUDEDIR=${ESYSROOT}${PYTHON_INCLUDEDIR#"${BROOT-${EPREFIX}}"};
  931. export PYTHON_INCLUDEDIR;
  932. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  933. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  934. die "${impl} does not install any header files!";
  935. fi
  936. ;;
  937. PYTHON_LIBPATH)
  938. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  939. PYTHON_LIBPATH=$(
  940. "${PYTHON}" - <<-EOF || die
  941. import os.path, sysconfig
  942. print(
  943. os.path.join(
  944. sysconfig.get_config_var("LIBDIR"),
  945. sysconfig.get_config_var("LDLIBRARY"))
  946. if sysconfig.get_config_var("LDLIBRARY")
  947. else "")
  948. EOF
  949. );
  950. export PYTHON_LIBPATH;
  951. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  952. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  953. die "${impl} lacks a (usable) dynamic library";
  954. fi
  955. ;;
  956. PYTHON_CFLAGS)
  957. local val;
  958. case "${impl}" in
  959. python*)
  960. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  961. ;;
  962. *)
  963. die "${impl}: obtaining ${var} not supported"
  964. ;;
  965. esac;
  966. export PYTHON_CFLAGS=${val};
  967. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  968. ;;
  969. PYTHON_LIBS)
  970. local val;
  971. case "${impl}" in
  972. python*)
  973. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}-embed) || die
  974. ;;
  975. *)
  976. die "${impl}: obtaining ${var} not supported"
  977. ;;
  978. esac;
  979. export PYTHON_LIBS=${val};
  980. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  981. ;;
  982. PYTHON_CONFIG)
  983. local flags val;
  984. case "${impl}" in
  985. python*)
  986. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  987. flags=$(
  988. "${PYTHON}" - <<-EOF || die
  989. import sysconfig
  990. print(sysconfig.get_config_var("ABIFLAGS")
  991. or "")
  992. EOF
  993. );
  994. val=${PYTHON}${flags}-config
  995. ;;
  996. *)
  997. die "${impl}: obtaining ${var} not supported"
  998. ;;
  999. esac;
  1000. export PYTHON_CONFIG=${val};
  1001. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  1002. ;;
  1003. PYTHON_PKG_DEP)
  1004. local d;
  1005. case ${impl} in
  1006. python*)
  1007. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  1008. ;;
  1009. pypy3)
  1010. PYTHON_PKG_DEP="dev-python/${impl}:="
  1011. ;;
  1012. *)
  1013. die "Invalid implementation: ${impl}"
  1014. ;;
  1015. esac;
  1016. if [[ -n ${PYTHON_REQ_USE} ]]; then
  1017. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  1018. fi;
  1019. export PYTHON_PKG_DEP;
  1020. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  1021. ;;
  1022. PYTHON_SCRIPTDIR)
  1023. local dir;
  1024. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  1025. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  1026. ;;
  1027. *)
  1028. die "_python_export: unknown variable ${var}"
  1029. ;;
  1030. esac;
  1031. done
  1032. }
  1033. _python_impl_matches ()
  1034. {
  1035. [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter";
  1036. [[ ${#} -eq 1 ]] && return 0;
  1037. local impl=${1/./_} pattern;
  1038. shift;
  1039. for pattern in "$@";
  1040. do
  1041. case ${pattern} in
  1042. -2 | python2* | pypy)
  1043. if [[ ${EAPI} != 7 ]]; then
  1044. eerror;
  1045. eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  1046. eerror "${FUNCNAME[1]} calls.";
  1047. die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  1048. fi
  1049. ;;
  1050. -3)
  1051. if [[ ${EAPI} != 7 ]]; then
  1052. eerror;
  1053. eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  1054. eerror "${FUNCNAME[1]} calls.";
  1055. die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  1056. fi;
  1057. return 0
  1058. ;;
  1059. 3.10)
  1060. [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] && return 0
  1061. ;;
  1062. 3.8 | 3.9 | 3.1[1-2])
  1063. [[ ${impl} == python${pattern/./_} ]] && return 0
  1064. ;;
  1065. *)
  1066. [[ ${impl} == ${pattern/./_} ]] && return 0
  1067. ;;
  1068. esac;
  1069. done;
  1070. return 1
  1071. }
  1072. _python_run_check_deps ()
  1073. {
  1074. debug-print-function ${FUNCNAME} "${@}";
  1075. local impl=${1};
  1076. einfo "Checking whether ${impl} is suitable ...";
  1077. local PYTHON_PKG_DEP;
  1078. _python_export "${impl}" PYTHON_PKG_DEP;
  1079. ebegin " ${PYTHON_PKG_DEP}";
  1080. has_version -b "${PYTHON_PKG_DEP}";
  1081. eend ${?} || return 1;
  1082. declare -f python_check_deps > /dev/null || return 0;
  1083. local PYTHON_USEDEP="python_targets_${impl}(-)";
  1084. local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)";
  1085. ebegin " python_check_deps";
  1086. python_check_deps;
  1087. eend ${?}
  1088. }
  1089. _python_set_impls ()
  1090. {
  1091. local i;
  1092. if [[ ${BASH_VERSINFO[0]} -ge 5 ]]; then
  1093. [[ ${PYTHON_COMPAT@a} == *a* ]];
  1094. else
  1095. [[ $(declare -p PYTHON_COMPAT) == "declare -a"* ]];
  1096. fi;
  1097. if [[ ${?} -ne 0 ]]; then
  1098. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  1099. die 'PYTHON_COMPAT not declared.';
  1100. else
  1101. die 'PYTHON_COMPAT must be an array.';
  1102. fi;
  1103. fi;
  1104. local obsolete=();
  1105. if [[ ! -n ${PYTHON_COMPAT_NO_STRICT} ]]; then
  1106. for i in "${PYTHON_COMPAT[@]}";
  1107. do
  1108. case ${i} in
  1109. pypy3 | python3_9 | python3_1[0-2])
  1110.  
  1111. ;;
  1112. jython2_7 | pypy | pypy1_[89] | pypy2_0 | python2_[5-7] | python3_[1-9])
  1113. obsolete+=("${i}")
  1114. ;;
  1115. *)
  1116. if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}"; then
  1117. die "Mis-synced patterns in _python_set_impls: missing ${i}";
  1118. else
  1119. die "Invalid implementation in PYTHON_COMPAT: ${i}";
  1120. fi
  1121. ;;
  1122. esac;
  1123. done;
  1124. fi;
  1125. if [[ -n ${obsolete[@]} && ${EBUILD_PHASE} == setup ]]; then
  1126. if [[ $(head -n 1 "${EBUILD}" 2>/dev/null) == *2022* ]]; then
  1127. eqawarn "Please clean PYTHON_COMPAT of obsolete implementations:";
  1128. eqawarn " ${obsolete[*]}";
  1129. fi;
  1130. fi;
  1131. local supp=() unsupp=();
  1132. for i in "${_PYTHON_ALL_IMPLS[@]}";
  1133. do
  1134. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  1135. supp+=("${i}");
  1136. else
  1137. unsupp+=("${i}");
  1138. fi;
  1139. done;
  1140. if [[ ! -n ${supp[@]} ]]; then
  1141. die "No supported implementation in PYTHON_COMPAT.";
  1142. fi;
  1143. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  1144. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  1145. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  1146. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  1147. eerror "Now : ${supp[*]}";
  1148. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  1149. fi;
  1150. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  1151. eerror "Unsupported impls changed between inherits!";
  1152. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  1153. eerror "Now : ${unsupp[*]}";
  1154. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  1155. fi;
  1156. else
  1157. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  1158. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  1159. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  1160. fi
  1161. }
  1162. _python_verify_patterns ()
  1163. {
  1164. debug-print-function ${FUNCNAME} "${@}";
  1165. local impl pattern;
  1166. for pattern in "$@";
  1167. do
  1168. case ${pattern} in
  1169. -[23] | 3.[89] | 3.1[012])
  1170. continue
  1171. ;;
  1172. esac;
  1173. for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}";
  1174. do
  1175. [[ ${impl} == ${pattern/./_} ]] && continue 2;
  1176. done;
  1177. die "Invalid implementation pattern: ${pattern}";
  1178. done
  1179. }
  1180. _python_wrapper_setup ()
  1181. {
  1182. debug-print-function ${FUNCNAME} "${@}";
  1183. local workdir=${1:-${T}/${EPYTHON}};
  1184. local impl=${2:-${EPYTHON}};
  1185. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  1186. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  1187. if [[ ! -x ${workdir}/bin/python ]]; then
  1188. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  1189. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  1190. rm -f "${workdir}"/bin/2to3 || die;
  1191. rm -f "${workdir}"/pkgconfig/python{2,3}{,-embed}.pc || die;
  1192. local EPYTHON PYTHON;
  1193. _python_export "${impl}" EPYTHON PYTHON;
  1194. cat > "${workdir}/bin/python" <<-_EOF_ ||
  1195. #!/bin/sh
  1196. exec "${PYTHON}" "\${@}"
  1197. _EOF_
  1198. die
  1199. cp "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  1200. chmod +x "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  1201. local nonsupp=(python2 python2-config);
  1202. if [[ ${EPYTHON} == python* ]]; then
  1203. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  1204. #!/bin/sh
  1205. exec "${PYTHON}-config" "\${@}"
  1206. _EOF_
  1207. die
  1208. cp "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  1209. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  1210. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  1211. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python3.pc || die;
  1212. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}-embed.pc "${workdir}"/pkgconfig/python3-embed.pc || die;
  1213. else
  1214. nonsupp+=(2to3 python-config python3-config);
  1215. fi;
  1216. local x;
  1217. for x in "${nonsupp[@]}";
  1218. do
  1219. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  1220. #!/bin/sh
  1221. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  1222. exit 127
  1223. _EOF_
  1224. die
  1225. chmod +x "${workdir}"/bin/${x} || die;
  1226. done;
  1227. fi;
  1228. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  1229. PATH=${workdir}/bin${PATH:+:${PATH}};
  1230. fi;
  1231. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  1232. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  1233. fi;
  1234. export PATH PKG_CONFIG_PATH
  1235. }
  1236. _setup-allowed-flags ()
  1237. {
  1238. ALLOWED_FLAGS=(-pipe -O '-O[123szg]' '-mcpu=*' '-march=*' '-mtune=*' -flto '-flto=*' -fno-lto '-fstack-protector*' -fstack-clash-protection '-fcf-protection=*' -fbounds-check -fbounds-checking -fno-PIE -fno-pie -nopie -no-pie '-mindirect-branch=*' -mindirect-branch-register '-mfunction-return=*' -mretpoline -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 -fno-diagnostics-color '-fmessage-length=*' -fno-ident -fpermissive -frecord-gcc-switches -frecord-command-line '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld=*');
  1239. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  1240. ALLOWED_FLAGS+=('-mregparm=*' -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float '-mfpu=*' -mieee -mieee-with-inexact '-mschedule=*' -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 '-mabi=*' -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 '-mcmodel=*' -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' '-mfloat-abi=*' -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 -mfix-rm7000 -mno-fix-rm7000 -mfix-r10000 -mno-fix-r10000 '-mr10k-cache-barrier=*' -mthumb -marm -ffixed-x18 -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);
  1241. ALLOWED_FLAGS+=(-mstackrealign)
  1242. }
  1243. _systemd_get_dir ()
  1244. {
  1245. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <variable-name> <fallback-directory>";
  1246. local variable=${1} fallback=${2} d;
  1247. local -x PKG_CONFIG_FDO_SYSROOT_RULES=1;
  1248. if $(tc-getPKG_CONFIG) --exists systemd; then
  1249. d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die;
  1250. else
  1251. d="${EPREFIX}${fallback}";
  1252. fi;
  1253. echo "${d}"
  1254. }
  1255. _systemd_unprefix ()
  1256. {
  1257. local d=$("${@}");
  1258. echo "${d#"${EPREFIX}"}"
  1259. }
  1260. _tc-getPROG ()
  1261. {
  1262. local tuple=$1;
  1263. local v var vars=$2;
  1264. local prog=($3);
  1265. var=${vars%% *};
  1266. for v in ${vars};
  1267. do
  1268. if [[ -n ${!v} ]]; then
  1269. export ${var}="${!v}";
  1270. echo "${!v}";
  1271. return 0;
  1272. fi;
  1273. done;
  1274. local search=;
  1275. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  1276. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  1277. [[ -n ${search} ]] && prog[0]=${search##*/};
  1278. export ${var}="${prog[*]}";
  1279. echo "${!var}"
  1280. }
  1281. _tc-has-openmp ()
  1282. {
  1283. local base="${T}/test-tc-openmp";
  1284. cat <<-EOF > "${base}.c"
  1285. #include <omp.h>
  1286. int main(void) {
  1287. int nthreads, tid, ret = 0;
  1288. #pragma omp parallel private(nthreads, tid)
  1289. {
  1290. tid = omp_get_thread_num();
  1291. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  1292. }
  1293. return ret;
  1294. }
  1295. EOF
  1296.  
  1297. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  1298. local ret=$?;
  1299. rm -f "${base}"*;
  1300. return ${ret}
  1301. }
  1302. _test-flag-PROG ()
  1303. {
  1304. local comp=$1;
  1305. local lang=$2;
  1306. shift 2;
  1307. if [[ -z ${comp} ]]; then
  1308. return 1;
  1309. fi;
  1310. if [[ -z $1 ]]; then
  1311. return 1;
  1312. fi;
  1313. comp=($(tc-get${comp}));
  1314. if ! type -p ${comp[0]} > /dev/null; then
  1315. return 1;
  1316. fi;
  1317. local in_src in_ext cmdline_extra=();
  1318. case "${lang}" in
  1319. c)
  1320. in_ext='c';
  1321. in_src='int main(void) { return 0; }';
  1322. cmdline_extra+=(-xc -c)
  1323. ;;
  1324. c++)
  1325. in_ext='cc';
  1326. in_src='int main(void) { return 0; }';
  1327. cmdline_extra+=(-xc++ -c)
  1328. ;;
  1329. f77)
  1330. in_ext='f';
  1331. in_src=' end';
  1332. cmdline_extra+=(-xf77 -c)
  1333. ;;
  1334. f95)
  1335. in_ext='f90';
  1336. in_src='end';
  1337. cmdline_extra+=(-xf95 -c)
  1338. ;;
  1339. c+ld)
  1340. in_ext='c';
  1341. in_src='int main(void) { return 0; }';
  1342. if is-ldflagq -fuse-ld=*; then
  1343. fuse_ld_value=$(get-flag -fuse-ld=*);
  1344. cmdline_extra+=(${fuse_ld_value});
  1345. fi;
  1346. cmdline_extra+=(-xc)
  1347. ;;
  1348. esac;
  1349. local test_in=${T}/test-flag.${in_ext};
  1350. local test_out=${T}/test-flag.exe;
  1351. printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'";
  1352. local cmdline=("${comp[@]}" -Werror "$@" "${cmdline_extra[@]}" "${test_in}" -o "${test_out}");
  1353. "${cmdline[@]}" &> /dev/null
  1354. }
  1355. _test-flags-PROG ()
  1356. {
  1357. local comp=$1;
  1358. local flags=();
  1359. local x;
  1360. shift;
  1361. [[ -z ${comp} ]] && return 1;
  1362. while (( $# )); do
  1363. case "$1" in
  1364. --param | -B)
  1365. if test-flag-${comp} "$1" "$2"; then
  1366. flags+=("$1" "$2");
  1367. fi;
  1368. shift 2
  1369. ;;
  1370. *)
  1371. if test-flag-${comp} "$1"; then
  1372. flags+=("$1");
  1373. fi;
  1374. shift 1
  1375. ;;
  1376. esac;
  1377. done;
  1378. echo "${flags[*]}";
  1379. [[ ${#flags[@]} -gt 0 ]]
  1380. }
  1381. _udev_get_udevdir ()
  1382. {
  1383. local -x PKG_CONFIG_FDO_SYSROOT_RULES=1;
  1384. if $($(tc-getPKG_CONFIG) --exists udev); then
  1385. local udevdir="$($(tc-getPKG_CONFIG) --variable=udevdir udev)";
  1386. echo "${udevdir#${EPREFIX}}";
  1387. else
  1388. echo /lib/udev;
  1389. fi
  1390. }
  1391. _vala_use_depend ()
  1392. {
  1393. local u="" vala_use;
  1394. if [[ -n ${VALA_USE_DEPEND} ]]; then
  1395. for vala_use in ${VALA_USE_DEPEND};
  1396. do
  1397. case ${vala_use} in
  1398. vapigen)
  1399. u="${u},${vala_use}(+)"
  1400. ;;
  1401. valadoc)
  1402. u="${u},${vala_use}(-)"
  1403. ;;
  1404. esac;
  1405. done;
  1406. u="[${u#,}]";
  1407. fi;
  1408. echo -n "${u}"
  1409. }
  1410. all-flag-vars ()
  1411. {
  1412. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  1413. }
  1414. append-atomic-flags ()
  1415. {
  1416. local code;
  1417. read -r -d '' code <<-EOF
  1418. int main(void)
  1419. {
  1420. return 0;
  1421. }
  1422. EOF
  1423.  
  1424. test-compile "c+ld" "${code}" || return;
  1425. local bytesizes;
  1426. [[ "${#}" == "0" ]] && bytesizes=("1" "2" "4" "8") || bytesizes="${@}";
  1427. for bytesize in ${bytesizes[@]};
  1428. do
  1429. read -r -d '' code <<-EOF
  1430. #include <stdint.h>
  1431. int main(void)
  1432. {
  1433. uint$((${bytesize} * 8))_t a = 0;
  1434. __atomic_add_fetch(&a, 3, __ATOMIC_RELAXED);
  1435. __atomic_compare_exchange_n(&a, &a, 2, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  1436. return 0;
  1437. }
  1438. EOF
  1439.  
  1440. test-compile "c+ld" "${code}" && continue
  1441. test-flags-CCLD "-latomic" &> /dev/null || die "-latomic is required but not supported by $(tc-getCC)";
  1442. append-libs "-latomic";
  1443. test-compile "c+ld" "${code}" || die "libatomic does not include an implementation of ${bytesize}-byte atomics for this toolchain";
  1444. return;
  1445. done
  1446. }
  1447. append-cflags ()
  1448. {
  1449. [[ $# -eq 0 ]] && return 0;
  1450. export CFLAGS+=" $*";
  1451. return 0
  1452. }
  1453. append-cppflags ()
  1454. {
  1455. [[ $# -eq 0 ]] && return 0;
  1456. export CPPFLAGS+=" $*";
  1457. return 0
  1458. }
  1459. append-cxxflags ()
  1460. {
  1461. [[ $# -eq 0 ]] && return 0;
  1462. export CXXFLAGS+=" $*";
  1463. return 0
  1464. }
  1465. append-fflags ()
  1466. {
  1467. [[ $# -eq 0 ]] && return 0;
  1468. export FFLAGS+=" $*";
  1469. export FCFLAGS+=" $*";
  1470. return 0
  1471. }
  1472. append-flags ()
  1473. {
  1474. [[ $# -eq 0 ]] && return 0;
  1475. case " $* " in
  1476. *' '-[DIU]*)
  1477. eqawarn 'Please use append-cppflags for preprocessor flags'
  1478. ;;
  1479. *' '-L* | *' '-Wl,*)
  1480. eqawarn 'Please use append-ldflags for linker flags'
  1481. ;;
  1482. esac;
  1483. append-cflags "$@";
  1484. append-cxxflags "$@";
  1485. append-fflags "$@";
  1486. return 0
  1487. }
  1488. append-ldflags ()
  1489. {
  1490. [[ $# -eq 0 ]] && return 0;
  1491. local flag;
  1492. for flag in "$@";
  1493. do
  1494. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1495. done;
  1496. export LDFLAGS="${LDFLAGS} $*";
  1497. return 0
  1498. }
  1499. append-lfs-flags ()
  1500. {
  1501. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1502. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1503. }
  1504. append-libs ()
  1505. {
  1506. [[ $# -eq 0 ]] && return 0;
  1507. local flag;
  1508. for flag in "$@";
  1509. do
  1510. if [[ -z "${flag// }" ]]; then
  1511. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1512. continue;
  1513. fi;
  1514. case $flag in
  1515. -[lL]*)
  1516. export LIBS="${LIBS} ${flag}"
  1517. ;;
  1518. -*)
  1519. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1520. export LIBS="${LIBS} ${flag}"
  1521. ;;
  1522. *)
  1523. export LIBS="${LIBS} -l${flag}"
  1524. ;;
  1525. esac;
  1526. done;
  1527. return 0
  1528. }
  1529. build_sphinx ()
  1530. {
  1531. debug-print-function ${FUNCNAME} "${@}";
  1532. [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes 1 arg: <directory>";
  1533. local dir=${1};
  1534. sed -i -e 's:^intersphinx_mapping:disabled_&:' "${dir}"/conf.py || die;
  1535. local command=("${EPYTHON}" -m sphinx.cmd.build);
  1536. if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2> /dev/null; then
  1537. command=(sphinx-build);
  1538. fi;
  1539. command+=(-b html -d "${dir}"/_build/doctrees "${dir}" "${dir}"/_build/html);
  1540. echo "${command[@]}" 1>&2;
  1541. "${command[@]}" || die;
  1542. HTML_DOCS+=("${dir}/_build/html/.")
  1543. }
  1544. check_extra_config ()
  1545. {
  1546. use kernel_linux || return;
  1547. local config negate die error reworkmodulenames;
  1548. local soft_errors_count=0 hard_errors_count=0 config_required=0;
  1549. local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  1550. linux-info_get_any_version;
  1551. for config in ${CONFIG_CHECK};
  1552. do
  1553. if [[ "${config:0:1}" != "~" ]]; then
  1554. config_required=1;
  1555. break;
  1556. fi;
  1557. done;
  1558. if [[ ${config_required} == 0 ]]; then
  1559. if ! linux_config_exists; then
  1560. ewarn "Unable to check for the following kernel config options due";
  1561. ewarn "to absence of any configured kernel sources or compiled";
  1562. ewarn "config:";
  1563. for config in ${CONFIG_CHECK};
  1564. do
  1565. config=${config#\~};
  1566. config=${config#\!};
  1567. local_error="ERROR_${config}";
  1568. msg="${!local_error}";
  1569. if [[ -z ${msg} ]]; then
  1570. local_error="WARNING_${config}";
  1571. msg="${!local_error}";
  1572. fi;
  1573. ewarn " - ${config}${msg:+ - }${msg}";
  1574. done;
  1575. ewarn "You're on your own to make sure they are set if needed.";
  1576. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1577. return 0;
  1578. fi;
  1579. else
  1580. if ! linux_config_exists; then
  1581. qeerror "Could not find a neither a usable .config in the kernel source directory";
  1582. qeerror "nor a /proc/config.gz file,";
  1583. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  1584. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  1585. qeerror "it points to the necessary object directory so that it might find .config";
  1586. qeerror "or have a properly configured kernel to produce a config.gz file. (CONFIG_IKCONFIG).";
  1587. die "Kernel not configured; no .config found in ${KV_OUT_DIR} or /proc/config.gz found";
  1588. fi;
  1589. fi;
  1590. ebegin "Checking for suitable kernel configuration options";
  1591. for config in ${CONFIG_CHECK};
  1592. do
  1593. die=1;
  1594. error=0;
  1595. negate=0;
  1596. reworkmodulenames=0;
  1597. if [[ ${config:0:1} == "~" ]]; then
  1598. die=0;
  1599. config=${config:1};
  1600. else
  1601. if [[ ${config:0:1} == "@" ]]; then
  1602. die=0;
  1603. reworkmodulenames=1;
  1604. config=${config:1};
  1605. fi;
  1606. fi;
  1607. if [[ ${config:0:1} == "!" ]]; then
  1608. negate=1;
  1609. config=${config:1};
  1610. fi;
  1611. if [[ ${negate} == 1 ]]; then
  1612. linux_chkconfig_present ${config} && error=2;
  1613. else
  1614. if [[ ${reworkmodulenames} == 1 ]]; then
  1615. local temp_config="${config//*:}" i n;
  1616. config="${config//:*}";
  1617. if linux_chkconfig_present ${config}; then
  1618. for i in ${MODULE_NAMES};
  1619. do
  1620. n="${i//${temp_config}}";
  1621. [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  1622. done;
  1623. error=2;
  1624. fi;
  1625. else
  1626. linux_chkconfig_present ${config} || error=1;
  1627. fi;
  1628. fi;
  1629. if [[ ${error} -gt 0 ]]; then
  1630. local report_func="eerror" local_error;
  1631. local_error="ERROR_${config}";
  1632. local_error="${!local_error}";
  1633. if [[ -z "${local_error}" ]]; then
  1634. local_error="${config}_ERROR";
  1635. local_error="${!local_error}";
  1636. fi;
  1637. if [[ ${die} == 0 && -z "${local_error}" ]]; then
  1638. local_error="WARNING_${config}";
  1639. local_error="${!local_error}";
  1640. if [[ -n "${local_error}" ]]; then
  1641. report_func="ewarn";
  1642. fi;
  1643. fi;
  1644. if [[ -z "${local_error}" ]]; then
  1645. [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  1646. local_error="CONFIG_${config}:\t ${local_error}";
  1647. fi;
  1648. if [[ ${die} == 0 ]]; then
  1649. ${report_func} " ${local_error}";
  1650. soft_errors_count=$[soft_errors_count + 1];
  1651. else
  1652. ${report_func} " ${local_error}";
  1653. hard_errors_count=$[hard_errors_count + 1];
  1654. fi;
  1655. fi;
  1656. done;
  1657. if [[ ${hard_errors_count} -gt 0 ]]; then
  1658. eend 1;
  1659. eerror "Please check to make sure these options are set correctly.";
  1660. eerror "Failure to do so may cause unexpected problems.";
  1661. eerror "Once you have satisfied these options, please try merging";
  1662. eerror "this package again.";
  1663. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1664. die "Incorrect kernel configuration options";
  1665. else
  1666. if [[ ${soft_errors_count} -gt 0 ]]; then
  1667. eend 1;
  1668. ewarn "Please check to make sure these options are set correctly.";
  1669. ewarn "Failure to do so may cause unexpected problems.";
  1670. else
  1671. eend 0;
  1672. fi;
  1673. fi;
  1674. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  1675. }
  1676. check_kernel_built ()
  1677. {
  1678. if ! use kernel_linux; then
  1679. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1680. fi;
  1681. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  1682. require_configured_kernel;
  1683. local versionh_path;
  1684. if kernel_is -ge 3 7; then
  1685. versionh_path="include/generated/uapi/linux/version.h";
  1686. else
  1687. versionh_path="include/linux/version.h";
  1688. fi;
  1689. if [[ ! -f "${KV_OUT_DIR}/${versionh_path}" ]]; then
  1690. eerror "These sources have not yet been prepared.";
  1691. eerror "We cannot build against an unprepared tree.";
  1692. eerror "To resolve this, please type the following:";
  1693. eerror;
  1694. eerror "# cd ${KV_DIR}";
  1695. eerror "# make oldconfig";
  1696. eerror "# make modules_prepare";
  1697. eerror;
  1698. eerror "Then please try merging this module again.";
  1699. die "Kernel sources need compiling first";
  1700. fi
  1701. }
  1702. check_modules_supported ()
  1703. {
  1704. if ! use kernel_linux; then
  1705. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1706. fi;
  1707. require_configured_kernel;
  1708. if ! linux_chkconfig_builtin "MODULES"; then
  1709. eerror "These sources do not support loading external modules.";
  1710. eerror "to be able to use this module please enable \"Loadable modules support\"";
  1711. eerror "in your kernel, recompile and then try merging this module again.";
  1712. die "No support for external modules in ${KV_FULL} config";
  1713. fi
  1714. }
  1715. check_zlibinflate ()
  1716. {
  1717. if ! use kernel_linux; then
  1718. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1719. fi;
  1720. require_configured_kernel;
  1721. local INFLATE;
  1722. local DEFLATE;
  1723. einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  1724. ebegin "checking ZLIB_INFLATE";
  1725. linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  1726. eend $? || die;
  1727. ebegin "checking ZLIB_DEFLATE";
  1728. linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  1729. eend $? || die;
  1730. local LINENO_START;
  1731. local LINENO_END;
  1732. local SYMBOLS;
  1733. local x;
  1734. LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  1735. LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  1736. (( LINENO_AMOUNT = ${LINENO_END} - ${LINENO_START} ));
  1737. (( LINENO_END = ${LINENO_END} - 1 ));
  1738. SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  1739. for x in ${SYMBOLS};
  1740. do
  1741. if [[ "${!x}" = "y" ]]; then
  1742. einfo "${x} ensures zlib is linked into your kernel - excellent";
  1743. return 0;
  1744. fi;
  1745. done;
  1746. eerror;
  1747. eerror "This kernel module requires ZLIB library support.";
  1748. eerror "You have enabled zlib support in your kernel, but haven't enabled";
  1749. eerror "enabled any option that will ensure that zlib is linked into your";
  1750. eerror "kernel.";
  1751. eerror;
  1752. eerror "Please ensure that you enable at least one of these options:";
  1753. eerror;
  1754. for x in ${SYMBOLS};
  1755. do
  1756. eerror " * $x";
  1757. done;
  1758. eerror;
  1759. eerror "Please remember to recompile and install your kernel, and reboot";
  1760. eerror "into your new kernel before attempting to load this kernel module.";
  1761. die "Kernel doesn't include zlib support"
  1762. }
  1763. clang-fullversion ()
  1764. {
  1765. _clang_fullversion '$1.$2.$3' "$@"
  1766. }
  1767. clang-major-version ()
  1768. {
  1769. _clang_fullversion '$1' "$@"
  1770. }
  1771. clang-micro-version ()
  1772. {
  1773. _clang_fullversion '$3' "$@"
  1774. }
  1775. clang-minor-version ()
  1776. {
  1777. _clang_fullversion '$2' "$@"
  1778. }
  1779. clang-version ()
  1780. {
  1781. _clang_fullversion '$1.$2' "$@"
  1782. }
  1783. eapply ()
  1784. {
  1785. local failed patch_cmd=patch;
  1786. local -x LC_COLLATE=POSIX;
  1787. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1788. function _eapply_patch ()
  1789. {
  1790. local f=${1};
  1791. local prefix=${2};
  1792. ebegin "${prefix:-Applying }${f##*/}";
  1793. local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  1794. if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  1795. all_opts+=(-s -F0);
  1796. fi;
  1797. ${patch_cmd} "${all_opts[@]}" < "${f}";
  1798. failed=${?};
  1799. if ! eend "${failed}"; then
  1800. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1801. fi
  1802. };
  1803. local patch_options=() files=();
  1804. local i found_doublehyphen;
  1805. for ((i = 1; i <= ${#@}; ++i ))
  1806. do
  1807. if [[ ${@:i:1} == -- ]]; then
  1808. patch_options=("${@:1:i-1}");
  1809. files=("${@:i+1}");
  1810. found_doublehyphen=1;
  1811. break;
  1812. fi;
  1813. done;
  1814. if [[ -z ${found_doublehyphen} ]]; then
  1815. for ((i = 1; i <= ${#@}; ++i ))
  1816. do
  1817. if [[ ${@:i:1} != -* ]]; then
  1818. patch_options=("${@:1:i-1}");
  1819. files=("${@:i}");
  1820. break;
  1821. fi;
  1822. done;
  1823. for i in "${files[@]}";
  1824. do
  1825. if [[ ${i} == -* ]]; then
  1826. die "eapply: all options must be passed before non-options";
  1827. fi;
  1828. done;
  1829. fi;
  1830. if [[ ${#files[@]} -eq 0 ]]; then
  1831. die "eapply: no files specified";
  1832. fi;
  1833. local f;
  1834. for f in "${files[@]}";
  1835. do
  1836. if [[ -d ${f} ]]; then
  1837. function _eapply_get_files ()
  1838. {
  1839. local LC_ALL=POSIX;
  1840. local prev_shopt=$(shopt -p nullglob);
  1841. shopt -s nullglob;
  1842. local f;
  1843. for f in "${1}"/*;
  1844. do
  1845. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1846. files+=("${f}");
  1847. fi;
  1848. done;
  1849. ${prev_shopt}
  1850. };
  1851. local files=();
  1852. _eapply_get_files "${f}";
  1853. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1854. einfo "Applying patches from ${f} ...";
  1855. local f2;
  1856. for f2 in "${files[@]}";
  1857. do
  1858. _eapply_patch "${f2}" ' ';
  1859. [[ ${failed} -ne 0 ]] && return "${failed}";
  1860. done;
  1861. else
  1862. _eapply_patch "${f}";
  1863. [[ ${failed} -ne 0 ]] && return "${failed}";
  1864. fi;
  1865. done;
  1866. return 0
  1867. }
  1868. eapply_user ()
  1869. {
  1870. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1871. local tagfile=${T}/.portage_user_patches_applied;
  1872. [[ -f ${tagfile} ]] && return;
  1873. >> "${tagfile}";
  1874. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1875. local columns=${COLUMNS:-0};
  1876. [[ ${columns} == 0 ]] && columns=$(set -- $( ( stty size </dev/tty ) 2>/dev/null || echo 24 80 ) ; echo $2);
  1877. (( columns > 0 )) || (( columns = 80 ));
  1878. local applied d f;
  1879. local -A _eapply_user_patches;
  1880. local prev_shopt=$(shopt -p nullglob);
  1881. shopt -s nullglob;
  1882. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1883. do
  1884. for f in "${d}"/*;
  1885. do
  1886. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1887. _eapply_user_patches[${f##*/}]=${f};
  1888. fi;
  1889. done;
  1890. done;
  1891. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1892. while read -r -d '' f; do
  1893. f=${_eapply_user_patches[${f}]};
  1894. if [[ -s ${f} ]]; then
  1895. if [[ -z ${applied} ]]; then
  1896. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++)); do echo -n =; done)${PORTAGE_COLOR_NORMAL}";
  1897. einfo "Applying user patches from ${basedir} ...";
  1898. fi;
  1899. eapply "${f}";
  1900. applied=1;
  1901. fi;
  1902. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1903. LC_ALL=C sort -z);
  1904. fi;
  1905. ${prev_shopt};
  1906. if [[ -n ${applied} ]]; then
  1907. einfo "User patches applied.";
  1908. einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++)); do echo -n =; done)${PORTAGE_COLOR_NORMAL}";
  1909. fi
  1910. }
  1911. econf_build ()
  1912. {
  1913. local CBUILD=${CBUILD:-${CHOST}};
  1914. function econf_env ()
  1915. {
  1916. CHOST=${CBUILD} econf "$@"
  1917. };
  1918. tc-env_build econf_env "$@"
  1919. }
  1920. einstalldocs ()
  1921. {
  1922. ( if [[ $(declare -p DOCS 2>/dev/null) != *=* ]]; then
  1923. local d;
  1924. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1925. do
  1926. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1927. done;
  1928. else
  1929. if ___is_indexed_array_var DOCS; then
  1930. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1931. else
  1932. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1933. fi;
  1934. fi );
  1935. ( if ___is_indexed_array_var HTML_DOCS; then
  1936. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1937. else
  1938. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1939. fi )
  1940. }
  1941. eninja ()
  1942. {
  1943. [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}";
  1944. local v;
  1945. case "${NINJA_VERBOSE}" in
  1946. OFF)
  1947.  
  1948. ;;
  1949. *)
  1950. v="-v"
  1951. ;;
  1952. esac;
  1953. set -- "${NINJA}" ${v} $(get_NINJAOPTS) "$@";
  1954. echo "$@" 1>&2;
  1955. "$@" || die -n "${*} failed"
  1956. }
  1957. epytest ()
  1958. {
  1959. debug-print-function ${FUNCNAME} "${@}";
  1960. _python_check_EPYTHON;
  1961. _python_check_occluded_packages;
  1962. local color;
  1963. case ${NOCOLOR} in
  1964. true | yes)
  1965. color=no
  1966. ;;
  1967. *)
  1968. color=yes
  1969. ;;
  1970. esac;
  1971. local args=(-vv -ra -l -Wdefault "--color=${color}" -o console_output_style=count -p no:cov -p no:flake8 -p no:flakes -p no:pylint -p no:markdown -p no:sugar -p no:xvfb -p no:tavern);
  1972. local x;
  1973. for x in "${EPYTEST_DESELECT[@]}";
  1974. do
  1975. args+=(--deselect "${x}");
  1976. done;
  1977. for x in "${EPYTEST_IGNORE[@]}";
  1978. do
  1979. args+=(--ignore "${x}");
  1980. done;
  1981. set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}";
  1982. echo "${@}" 1>&2;
  1983. "${@}" || die -n "pytest failed with ${EPYTHON}";
  1984. local ret=${?};
  1985. rm -rf .hypothesis .pytest_cache || die;
  1986. if [[ -n ${BUILD_DIR} && -d ${BUILD_DIR} ]]; then
  1987. find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die;
  1988. fi;
  1989. return ${ret}
  1990. }
  1991. eunittest ()
  1992. {
  1993. debug-print-function ${FUNCNAME} "${@}";
  1994. _python_check_EPYTHON;
  1995. _python_check_occluded_packages;
  1996. local runner=unittest;
  1997. if _python_impl_matches "${EPYTHON}" 3.{9..11}; then
  1998. runner=unittest_or_fail;
  1999. fi;
  2000. set -- "${EPYTHON}" -m "${runner}" discover -v "${@}";
  2001. echo "${@}" 1>&2;
  2002. "${@}" || die -n "Tests failed with ${EPYTHON}";
  2003. return ${?}
  2004. }
  2005. filter-flags ()
  2006. {
  2007. _filter-hardened "$@";
  2008. local v;
  2009. for v in $(all-flag-vars);
  2010. do
  2011. _filter-var ${v} "$@";
  2012. done;
  2013. return 0
  2014. }
  2015. filter-ldflags ()
  2016. {
  2017. _filter-var LDFLAGS "$@";
  2018. return 0
  2019. }
  2020. filter-lfs-flags ()
  2021. {
  2022. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2023. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64
  2024. }
  2025. filter-lto ()
  2026. {
  2027. [[ $# -ne 0 ]] && die "filter-lto takes no arguments";
  2028. filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*'
  2029. }
  2030. filter-mfpmath ()
  2031. {
  2032. local orig_mfpmath new_math prune_math;
  2033. orig_mfpmath=$(get-flag -mfpmath);
  2034. new_math=$(get-flag mfpmath);
  2035. new_math=${new_math/both/387,sse};
  2036. new_math=" ${new_math//[,+]/ } ";
  2037. prune_math="";
  2038. for prune_math in "$@";
  2039. do
  2040. new_math=${new_math/ ${prune_math} / };
  2041. done;
  2042. new_math=$(echo ${new_math});
  2043. new_math=${new_math// /,};
  2044. if [[ -z ${new_math} ]]; then
  2045. filter-flags ${orig_mfpmath};
  2046. else
  2047. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2048. fi;
  2049. return 0
  2050. }
  2051. gcc-fullversion ()
  2052. {
  2053. _gcc_fullversion '$1.$2.$3' "$@"
  2054. }
  2055. gcc-major-version ()
  2056. {
  2057. _gcc_fullversion '$1' "$@"
  2058. }
  2059. gcc-micro-version ()
  2060. {
  2061. _gcc_fullversion '$3' "$@"
  2062. }
  2063. gcc-minor-version ()
  2064. {
  2065. _gcc_fullversion '$2' "$@"
  2066. }
  2067. gcc-specs-directive ()
  2068. {
  2069. local directive subdname subdirective;
  2070. directive="$(_gcc-specs-directive_raw $1)";
  2071. while [[ ${directive} == *%\(*\)* ]]; do
  2072. subdname=${directive/*%\(};
  2073. subdname=${subdname/\)*};
  2074. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2075. directive="${directive//\%(${subdname})/${subdirective}}";
  2076. done;
  2077. echo "${directive}";
  2078. return 0
  2079. }
  2080. gcc-specs-nostrict ()
  2081. {
  2082. local directive;
  2083. directive=$(gcc-specs-directive cc1);
  2084. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2085. }
  2086. gcc-specs-now ()
  2087. {
  2088. local directive;
  2089. directive=$(gcc-specs-directive link_command);
  2090. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2091. }
  2092. gcc-specs-pie ()
  2093. {
  2094. local directive;
  2095. directive=$(gcc-specs-directive cc1);
  2096. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2097. }
  2098. gcc-specs-relro ()
  2099. {
  2100. local directive;
  2101. directive=$(gcc-specs-directive link_command);
  2102. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2103. }
  2104. gcc-specs-ssp ()
  2105. {
  2106. local directive;
  2107. directive=$(gcc-specs-directive cc1);
  2108. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2109. }
  2110. gcc-specs-ssp-to-all ()
  2111. {
  2112. local directive;
  2113. directive=$(gcc-specs-directive cc1);
  2114. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2115. }
  2116. gcc-specs-stack-check ()
  2117. {
  2118. local directive;
  2119. directive=$(gcc-specs-directive cc1);
  2120. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2121. }
  2122. gcc-version ()
  2123. {
  2124. _gcc_fullversion '$1.$2' "$@"
  2125. }
  2126. gen_usr_ldscript ()
  2127. {
  2128. ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  2129. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2130. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2131. tc-is-static-only && return;
  2132. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2133. multilib_is_native_abi || return 0;
  2134. fi;
  2135. case ${CTARGET:-${CHOST}} in
  2136. *-darwin*)
  2137.  
  2138. ;;
  2139. *-android*)
  2140. return 0
  2141. ;;
  2142. *linux*)
  2143. use prefix && return 0
  2144. ;;
  2145. *)
  2146. return 0
  2147. ;;
  2148. esac;
  2149. dodir /usr/${libdir};
  2150. if [[ $1 == "-a" ]]; then
  2151. auto=true;
  2152. shift;
  2153. dodir /${libdir};
  2154. fi;
  2155. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2156. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2157. local d="${T}/bfd-linker";
  2158. mkdir -p "${d}";
  2159. ln -sf $(type -P ${CHOST}-ld.bfd) "${d}"/ld;
  2160. flags+=(-B"${d}");
  2161. fi;
  2162. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2163. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2164. for lib in "$@";
  2165. do
  2166. local tlib;
  2167. if ${auto}; then
  2168. lib="lib${lib}${suffix}";
  2169. else
  2170. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2171. fi;
  2172. case ${CTARGET:-${CHOST}} in
  2173. *-darwin*)
  2174. if ${auto}; then
  2175. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2176. else
  2177. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2178. fi;
  2179. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2180. tlib=${tlib##*/};
  2181. if ${auto}; then
  2182. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2183. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2184. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2185. fi;
  2186. rm -f "${ED}"/${libdir}/${lib};
  2187. fi;
  2188. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2189. chmod u+w "${ED}${libdir}/${tlib}";
  2190. local nowrite=yes;
  2191. fi;
  2192. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2193. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2194. pushd "${ED}/usr/${libdir}" > /dev/null;
  2195. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2196. popd > /dev/null
  2197. ;;
  2198. *)
  2199. if ${auto}; then
  2200. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2201. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2202. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2203. if [[ ${tlib} != ${lib}* ]]; then
  2204. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2205. fi;
  2206. rm -f "${ED}"/${libdir}/${lib};
  2207. else
  2208. tlib=${lib};
  2209. fi;
  2210. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2211. /* GNU ld script
  2212. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2213. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2214. run into linking problems. This "fake" dynamic lib is a linker script that
  2215. redirects the linker to the real lib. And yes, this works in the cross-
  2216. compiling scenario as the sysroot-ed linker will prepend the real path.
  2217.  
  2218. See bug https://bugs.gentoo.org/4411 for more info.
  2219. */
  2220. ${output_format}
  2221. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2222. END_LDSCRIPT
  2223.  
  2224. ;;
  2225. esac
  2226. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2227. done
  2228. }
  2229. get-flag ()
  2230. {
  2231. [[ $# -ne 1 ]] && die "usage: <flag>";
  2232. local f var findflag="$1";
  2233. for var in $(all-flag-vars);
  2234. do
  2235. for f in ${!var};
  2236. do
  2237. if [ "${f/${findflag}}" != "${f}" ]; then
  2238. printf "%s\n" "${f/-${findflag}=}";
  2239. return 0;
  2240. fi;
  2241. done;
  2242. done;
  2243. return 1
  2244. }
  2245. get_NINJAOPTS ()
  2246. {
  2247. if [[ -z ${NINJAOPTS+set} ]]; then
  2248. NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) -l$(makeopts_loadavg "${MAKEOPTS}" 0)";
  2249. fi;
  2250. echo "${NINJAOPTS}"
  2251. }
  2252. get_abi_CFLAGS ()
  2253. {
  2254. get_abi_var CFLAGS "$@"
  2255. }
  2256. get_abi_CHOST ()
  2257. {
  2258. get_abi_var CHOST "$@"
  2259. }
  2260. get_abi_CTARGET ()
  2261. {
  2262. get_abi_var CTARGET "$@"
  2263. }
  2264. get_abi_FAKE_TARGETS ()
  2265. {
  2266. get_abi_var FAKE_TARGETS "$@"
  2267. }
  2268. get_abi_LDFLAGS ()
  2269. {
  2270. get_abi_var LDFLAGS "$@"
  2271. }
  2272. get_abi_LIBDIR ()
  2273. {
  2274. get_abi_var LIBDIR "$@"
  2275. }
  2276. get_abi_var ()
  2277. {
  2278. local flag=$1;
  2279. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2280. local var="${flag}_${abi}";
  2281. echo ${!var}
  2282. }
  2283. get_all_abis ()
  2284. {
  2285. local x order="" mvar dvar;
  2286. mvar="MULTILIB_ABIS";
  2287. dvar="DEFAULT_ABI";
  2288. if [[ -n $1 ]]; then
  2289. mvar="$1_${mvar}";
  2290. dvar="$1_${dvar}";
  2291. fi;
  2292. if [[ -z ${!mvar} ]]; then
  2293. echo "default";
  2294. return 0;
  2295. fi;
  2296. for x in ${!mvar};
  2297. do
  2298. if [[ ${x} != ${!dvar} ]]; then
  2299. order="${order:+${order} }${x}";
  2300. fi;
  2301. done;
  2302. order="${order:+${order} }${!dvar}";
  2303. echo ${order};
  2304. return 0
  2305. }
  2306. get_all_libdirs ()
  2307. {
  2308. local libdirs abi;
  2309. for abi in ${MULTILIB_ABIS};
  2310. do
  2311. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2312. done;
  2313. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2314. echo "${libdirs}"
  2315. }
  2316. get_exeext ()
  2317. {
  2318. case ${CHOST} in
  2319. mingw* | *-mingw*)
  2320. echo ".exe"
  2321. ;;
  2322. esac
  2323. }
  2324. get_install_abis ()
  2325. {
  2326. local x order="";
  2327. if [[ -z ${MULTILIB_ABIS} ]]; then
  2328. echo "default";
  2329. return 0;
  2330. fi;
  2331. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2332. for x in ${MULTILIB_ABIS};
  2333. do
  2334. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2335. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2336. fi;
  2337. done;
  2338. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2339. if [[ -n ${ABI_ALLOW} ]]; then
  2340. local ordera="";
  2341. for x in ${order};
  2342. do
  2343. if has ${x} ${ABI_ALLOW}; then
  2344. ordera="${ordera} ${x}";
  2345. fi;
  2346. done;
  2347. order=${ordera};
  2348. fi;
  2349. else
  2350. order=${DEFAULT_ABI};
  2351. fi;
  2352. if [[ -z ${order} ]]; then
  2353. 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.";
  2354. fi;
  2355. echo ${order};
  2356. return 0
  2357. }
  2358. get_libdir ()
  2359. {
  2360. local libdir_var="LIBDIR_${ABI}";
  2361. local libdir="lib";
  2362. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2363. echo "${libdir}"
  2364. }
  2365. get_libname ()
  2366. {
  2367. local libname;
  2368. local ver=$1;
  2369. case ${CHOST} in
  2370. mingw* | *-mingw*)
  2371. libname="dll"
  2372. ;;
  2373. *-darwin*)
  2374. libname="dylib"
  2375. ;;
  2376. *)
  2377. libname="so"
  2378. ;;
  2379. esac;
  2380. if [[ -z $* ]]; then
  2381. echo ".${libname}";
  2382. else
  2383. for ver in "$@";
  2384. do
  2385. case ${CHOST} in
  2386. *-darwin*)
  2387. echo ".${ver}.${libname}"
  2388. ;;
  2389. *)
  2390. echo ".${libname}.${ver}"
  2391. ;;
  2392. esac;
  2393. done;
  2394. fi
  2395. }
  2396. get_makefile_extract_function ()
  2397. {
  2398. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2399. local a='' b='' mkfunc='getfilevar';
  2400. a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  2401. b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  2402. [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  2403. echo "${mkfunc}"
  2404. }
  2405. get_modname ()
  2406. {
  2407. local modname;
  2408. local ver=$1;
  2409. case ${CHOST} in
  2410. *-darwin*)
  2411. modname="bundle"
  2412. ;;
  2413. *)
  2414. modname="so"
  2415. ;;
  2416. esac;
  2417. echo ".${modname}"
  2418. }
  2419. get_nproc ()
  2420. {
  2421. local nproc;
  2422. if type -P nproc &> /dev/null; then
  2423. nproc=$(nproc);
  2424. fi;
  2425. if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  2426. nproc=$(sysctl -n hw.ncpu 2>/dev/null);
  2427. fi;
  2428. if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  2429. nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null);
  2430. fi;
  2431. if [[ -n ${nproc} ]]; then
  2432. echo "${nproc}";
  2433. else
  2434. echo "${1:-1}";
  2435. fi
  2436. }
  2437. get_running_version ()
  2438. {
  2439. if ! use kernel_linux; then
  2440. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2441. fi;
  2442. local kv=$(uname -r);
  2443. if [[ -f ${ROOT%/}/lib/modules/${kv}/source/Makefile ]]; then
  2444. KERNEL_DIR=$(readlink -f "${ROOT%/}/lib/modules/${kv}/source");
  2445. if [[ -f ${ROOT%/}/lib/modules/${kv}/build/Makefile ]]; then
  2446. KBUILD_OUTPUT=$(readlink -f "${ROOT%/}/lib/modules/${kv}/build");
  2447. fi;
  2448. get_version && return 0;
  2449. fi;
  2450. KV_FULL=${kv};
  2451. local kv_full=${KV_FULL//[-+_]*};
  2452. KV_MAJOR=$(ver_cut 1 ${kv_full});
  2453. KV_MINOR=$(ver_cut 2 ${kv_full});
  2454. KV_PATCH=$(ver_cut 3 ${kv_full});
  2455. KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}";
  2456. : "${KV_PATCH:=0}";
  2457. return 0
  2458. }
  2459. get_udevdir ()
  2460. {
  2461. debug-print-function ${FUNCNAME} "${@}";
  2462. echo "$(_udev_get_udevdir)"
  2463. }
  2464. get_version ()
  2465. {
  2466. if ! use kernel_linux; then
  2467. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2468. fi;
  2469. local tmplocal;
  2470. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2471. [[ -n "${KV_FULL}" ]] && return 0;
  2472. unset KV_DIR;
  2473. [[ -z "${get_version_warning_done}" ]] && qeinfo "Determining the location of the kernel source code";
  2474. [[ -d "${KERNEL_DIR}" ]] && KV_DIR="${KERNEL_DIR}";
  2475. if [[ -z "${KV_DIR}" ]]; then
  2476. if [[ -z "${get_version_warning_done}" ]]; then
  2477. get_version_warning_done=1;
  2478. qewarn "Unable to find kernel sources at ${KERNEL_DIR}";
  2479. if [[ "${KERNEL_DIR}" == "/usr/src/linux" ]]; then
  2480. qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  2481. qeinfo "(or the kernel you wish to build against).";
  2482. qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  2483. else
  2484. qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  2485. fi;
  2486. fi;
  2487. return 1;
  2488. fi;
  2489. if [[ -z "${KBUILD_OUTPUT}" && -L "${KERNEL_DIR}/source" ]]; then
  2490. KBUILD_OUTPUT=${KERNEL_DIR};
  2491. KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source");
  2492. KV_DIR=${KERNEL_DIR};
  2493. fi;
  2494. if [[ -z "${get_version_warning_done}" ]]; then
  2495. qeinfo "Found kernel source directory:";
  2496. qeinfo " ${KV_DIR}";
  2497. fi;
  2498. kernel_get_makefile;
  2499. if [[ ! -s ${KERNEL_MAKEFILE} ]]; then
  2500. if [[ -z "${get_version_warning_done}" ]]; then
  2501. get_version_warning_done=1;
  2502. qeerror "Could not find a Makefile in the kernel source directory.";
  2503. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  2504. fi;
  2505. return 1;
  2506. fi;
  2507. local OUTPUT_DIR=${KBUILD_OUTPUT};
  2508. if [[ -z ${OUTPUT_DIR} ]]; then
  2509. local mkfunc=$(get_makefile_extract_function "${KERNEL_MAKEFILE}");
  2510. OUTPUT_DIR=$(${mkfunc} KBUILD_OUTPUT "${KERNEL_MAKEFILE}");
  2511. fi;
  2512. KV_MAJOR=$(getfilevar VERSION "${KERNEL_MAKEFILE}");
  2513. KV_MINOR=$(getfilevar PATCHLEVEL "${KERNEL_MAKEFILE}");
  2514. KV_PATCH=$(getfilevar SUBLEVEL "${KERNEL_MAKEFILE}");
  2515. KV_EXTRA=$(getfilevar EXTRAVERSION "${KERNEL_MAKEFILE}");
  2516. if [[ -z "${KV_MAJOR}" || -z "${KV_MINOR}" || -z "${KV_PATCH}" ]]; then
  2517. if [[ -z "${get_version_warning_done}" ]]; then
  2518. get_version_warning_done=1;
  2519. qeerror "Could not detect kernel version.";
  2520. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  2521. fi;
  2522. return 1;
  2523. fi;
  2524. [[ -d "${OUTPUT_DIR}" ]] && KV_OUT_DIR="${OUTPUT_DIR}";
  2525. if [[ -n "${KV_OUT_DIR}" ]]; then
  2526. qeinfo "Found kernel object directory:";
  2527. qeinfo " ${KV_OUT_DIR}";
  2528. fi;
  2529. KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  2530. if [[ -s "${KV_OUT_DIR}"/include/config/kernel.release ]]; then
  2531. KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  2532. else
  2533. if [[ -s "${KV_OUT_DIR}"/.kernelrelease ]]; then
  2534. KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  2535. else
  2536. KV_LOCAL=;
  2537. fi;
  2538. fi;
  2539. tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  2540. if [[ "${KV_LOCAL}" = "${tmplocal}" ]]; then
  2541. KV_LOCAL=;
  2542. else
  2543. KV_LOCAL=${tmplocal};
  2544. fi;
  2545. if [[ -z ${OUTPUT_DIR} ]]; then
  2546. for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "";
  2547. do
  2548. OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build";
  2549. if [[ -e ${OUTPUT_DIR} ]]; then
  2550. break;
  2551. fi;
  2552. done;
  2553. fi;
  2554. KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  2555. qeinfo "Found sources for kernel version:";
  2556. qeinfo " ${KV_FULL}";
  2557. return 0
  2558. }
  2559. getfilevar ()
  2560. {
  2561. local ERROR basefname basedname myARCH="${ARCH}";
  2562. ERROR=0;
  2563. [[ -z "${1}" ]] && ERROR=1;
  2564. [[ ! -f "${2}" ]] && ERROR=1;
  2565. if [[ "${ERROR}" = 1 ]]; then
  2566. echo -e "\n";
  2567. eerror "getfilevar requires 2 variables, with the second a valid file.";
  2568. eerror " getfilevar <VARIABLE> <CONFIGFILE>";
  2569. else
  2570. basefname="$(basename ${2})";
  2571. basedname="$(dirname ${2})";
  2572. unset ARCH;
  2573. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | nonfatal emake -C "${basedname}" --no-print-directory M="${T}" dot-config=0 need-config= need-compiler= ${BUILD_FIXES} -s -f - 2> /dev/null;
  2574. ARCH=${myARCH};
  2575. fi
  2576. }
  2577. getfilevar_noexec ()
  2578. {
  2579. local ERROR basefname basedname mycat myARCH="${ARCH}";
  2580. ERROR=0;
  2581. mycat='cat';
  2582. [[ -z "${1}" ]] && ERROR=1;
  2583. [[ ! -f "${2}" ]] && ERROR=1;
  2584. [[ "${2%.gz}" != "${2}" ]] && mycat='zcat';
  2585. if [[ "${ERROR}" = 1 ]]; then
  2586. echo -e "\n";
  2587. eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  2588. eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  2589. else
  2590. ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  2591. s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  2592. s,[[:space:]]*\$,,g ;
  2593. p
  2594. }";
  2595. fi
  2596. }
  2597. has_multilib_profile ()
  2598. {
  2599. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2600. }
  2601. in_iuse ()
  2602. {
  2603. local use=${1};
  2604. if [[ -z "${use}" ]]; then
  2605. echo "!!! in_iuse() called without a parameter." 1>&2;
  2606. echo "!!! in_iuse <USEFLAG>" 1>&2;
  2607. die "in_iuse() called without a parameter";
  2608. fi;
  2609. local liuse=(${IUSE_EFFECTIVE});
  2610. has "${use}" "${liuse[@]#[+-]}"
  2611. }
  2612. is-flag ()
  2613. {
  2614. is-flagq "$@" && echo true
  2615. }
  2616. is-flagq ()
  2617. {
  2618. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2619. local var;
  2620. for var in $(all-flag-vars);
  2621. do
  2622. _is_flagq ${var} "$1" && return 0;
  2623. done;
  2624. return 1
  2625. }
  2626. is-ldflag ()
  2627. {
  2628. is-ldflagq "$@" && echo true
  2629. }
  2630. is-ldflagq ()
  2631. {
  2632. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2633. _is_flagq LDFLAGS $1
  2634. }
  2635. is_final_abi ()
  2636. {
  2637. has_multilib_profile || return 0;
  2638. set -- $(get_install_abis);
  2639. local LAST_ABI=$#;
  2640. [[ ${!LAST_ABI} == ${ABI} ]]
  2641. }
  2642. kernel_get_makefile ()
  2643. {
  2644. [[ -s ${KV_DIR}/GNUMakefile ]] && KERNEL_MAKEFILE="${KV_DIR}/GNUMakefile" && return;
  2645. [[ -s ${KV_DIR}/makefile ]] && KERNEL_MAKEFILE="${KV_DIR}/makefile" && return;
  2646. [[ -s ${KV_DIR}/Makefile ]] && KERNEL_MAKEFILE="${KV_DIR}/Makefile" && return
  2647. }
  2648. kernel_is ()
  2649. {
  2650. if ! use kernel_linux; then
  2651. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2652. fi;
  2653. linux-info_get_any_version;
  2654. local operator;
  2655. case ${1#-} in
  2656. lt)
  2657. operator="-lt";
  2658. shift
  2659. ;;
  2660. gt)
  2661. operator="-gt";
  2662. shift
  2663. ;;
  2664. le)
  2665. operator="-le";
  2666. shift
  2667. ;;
  2668. ge)
  2669. operator="-ge";
  2670. shift
  2671. ;;
  2672. eq)
  2673. operator="-eq";
  2674. shift
  2675. ;;
  2676. *)
  2677. operator="-eq"
  2678. ;;
  2679. esac;
  2680. [[ $# -gt 3 ]] && die "Error in ${ECLASS}_${FUNCNAME}(): too many parameters";
  2681. ver_test "${KV_MAJOR:-0}.${KV_MINOR:-0}.${KV_PATCH:-0}" "${operator}" "${1:-${KV_MAJOR:-0}}.${2:-${KV_MINOR:-0}}.${3:-${KV_PATCH:-0}}"
  2682. }
  2683. linux-info_get_any_version ()
  2684. {
  2685. if ! use kernel_linux; then
  2686. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2687. fi;
  2688. if ! get_version; then
  2689. ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  2690. if ! get_running_version; then
  2691. die "Unable to determine any Linux Kernel version, please report a bug";
  2692. fi;
  2693. fi
  2694. }
  2695. linux-info_pkg_setup ()
  2696. {
  2697. use kernel_linux || return;
  2698. linux-info_get_any_version;
  2699. [[ -n "${CONFIG_CHECK}" && -z ${CHECKCONFIG_DONOTHING} ]] && check_extra_config
  2700. }
  2701. linux_chkconfig_builtin ()
  2702. {
  2703. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2704. linux_config_qa_check linux_chkconfig_builtin;
  2705. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
  2706. }
  2707. linux_chkconfig_module ()
  2708. {
  2709. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2710. linux_config_qa_check linux_chkconfig_module;
  2711. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
  2712. }
  2713. linux_chkconfig_present ()
  2714. {
  2715. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2716. linux_config_qa_check linux_chkconfig_present;
  2717. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
  2718. }
  2719. linux_chkconfig_string ()
  2720. {
  2721. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  2722. linux_config_qa_check linux_chkconfig_string;
  2723. getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
  2724. }
  2725. linux_config_bin_exists ()
  2726. {
  2727. export _LINUX_CONFIG_EXISTS_DONE=1;
  2728. use kernel_linux && [[ -s /proc/config.gz ]]
  2729. }
  2730. linux_config_exists ()
  2731. {
  2732. linux_config_src_exists || linux_config_bin_exists
  2733. }
  2734. linux_config_path ()
  2735. {
  2736. if linux_config_src_exists; then
  2737. echo "${KV_OUT_DIR}/.config";
  2738. else
  2739. if linux_config_bin_exists; then
  2740. echo "/proc/config.gz";
  2741. else
  2742. return 1;
  2743. fi;
  2744. fi
  2745. }
  2746. linux_config_qa_check ()
  2747. {
  2748. local f="$1";
  2749. if [[ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]]; then
  2750. ewarn "QA: You called $f before any linux_config_exists!";
  2751. ewarn "QA: The return value of $f will NOT guaranteed later!";
  2752. fi;
  2753. if ! use kernel_linux; then
  2754. die "$f called on non-Linux system, please fix the ebuild";
  2755. fi
  2756. }
  2757. linux_config_src_exists ()
  2758. {
  2759. export _LINUX_CONFIG_EXISTS_DONE=1;
  2760. use kernel_linux && [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
  2761. }
  2762. makeopts_jobs ()
  2763. {
  2764. [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  2765. local jobs=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p");
  2766. echo ${jobs:-1}
  2767. }
  2768. makeopts_loadavg ()
  2769. {
  2770. [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  2771. local lavg=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+(\.[0-9]+)?)[[:space:]].*:\3:p' -e "s:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:${2:-999}:p");
  2772. echo ${lavg:-${2:-999}}
  2773. }
  2774. meson-multilib_src_compile ()
  2775. {
  2776. local _meson_args=("${@}");
  2777. multilib-minimal_src_compile
  2778. }
  2779. meson-multilib_src_configure ()
  2780. {
  2781. local _meson_args=("${@}");
  2782. multilib-minimal_src_configure
  2783. }
  2784. meson-multilib_src_install ()
  2785. {
  2786. local _meson_args=("${@}");
  2787. multilib-minimal_src_install
  2788. }
  2789. meson-multilib_src_test ()
  2790. {
  2791. local _meson_args=("${@}");
  2792. multilib-minimal_src_test
  2793. }
  2794. meson_feature ()
  2795. {
  2796. usex "$1" "-D${2-$1}=enabled" "-D${2-$1}=disabled"
  2797. }
  2798. meson_install ()
  2799. {
  2800. debug-print-function ${FUNCNAME} "$@";
  2801. local mesoninstallargs=(-C "${BUILD_DIR}" --destdir "${D}" --no-rebuild "$@");
  2802. set -- meson install "${mesoninstallargs[@]}";
  2803. echo "$@" 1>&2;
  2804. "$@" || die "install failed"
  2805. }
  2806. meson_native_enabled ()
  2807. {
  2808. if multilib_is_native_abi; then
  2809. echo "-D${1}=enabled";
  2810. else
  2811. echo "-D${1}=disabled";
  2812. fi
  2813. }
  2814. meson_native_true ()
  2815. {
  2816. if multilib_is_native_abi; then
  2817. echo "-D${1}=true";
  2818. else
  2819. echo "-D${1}=false";
  2820. fi
  2821. }
  2822. meson_native_use_bool ()
  2823. {
  2824. multilib_native_usex "${1}" "-D${2-${1}}=true" "-D${2-${1}}=false"
  2825. }
  2826. meson_native_use_feature ()
  2827. {
  2828. multilib_native_usex "${1}" "-D${2-${1}}=enabled" "-D${2-${1}}=disabled"
  2829. }
  2830. meson_nm_native_program ()
  2831. {
  2832. multilib_native_usex "$1" "-D${2:-$1}=$3" "-D${2:-$1}=no"
  2833. }
  2834. meson_nm_program ()
  2835. {
  2836. usex "$1" "-D${2:-$1}=$3" "-D${2:-$1}=no"
  2837. }
  2838. meson_src_compile ()
  2839. {
  2840. debug-print-function ${FUNCNAME} "$@";
  2841. local mesoncompileargs=(-C "${BUILD_DIR}" --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)" --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)");
  2842. case ${MESON_VERBOSE} in
  2843. OFF)
  2844.  
  2845. ;;
  2846. *)
  2847. mesoncompileargs+=(--verbose)
  2848. ;;
  2849. esac;
  2850. mesoncompileargs+=("$@");
  2851. set -- meson compile "${mesoncompileargs[@]}";
  2852. echo "$@" 1>&2;
  2853. "$@" || die "compile failed"
  2854. }
  2855. meson_src_configure ()
  2856. {
  2857. debug-print-function ${FUNCNAME} "$@";
  2858. [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}";
  2859. local BUILD_CFLAGS=${BUILD_CFLAGS};
  2860. local BUILD_CPPFLAGS=${BUILD_CPPFLAGS};
  2861. local BUILD_CXXFLAGS=${BUILD_CXXFLAGS};
  2862. local BUILD_FCFLAGS=${BUILD_FCFLAGS};
  2863. local BUILD_OBJCFLAGS=${BUILD_OBJCFLAGS};
  2864. local BUILD_OBJCXXFLAGS=${BUILD_OBJCXXFLAGS};
  2865. local BUILD_LDFLAGS=${BUILD_LDFLAGS};
  2866. local BUILD_PKG_CONFIG_LIBDIR=${BUILD_PKG_CONFIG_LIBDIR};
  2867. local BUILD_PKG_CONFIG_PATH=${BUILD_PKG_CONFIG_PATH};
  2868. if tc-is-cross-compiler; then
  2869. : "${BUILD_CFLAGS:=-O1 -pipe}";
  2870. : "${BUILD_CXXFLAGS:=-O1 -pipe}";
  2871. : "${BUILD_FCFLAGS:=-O1 -pipe}";
  2872. : "${BUILD_OBJCFLAGS:=-O1 -pipe}";
  2873. : "${BUILD_OBJCXXFLAGS:=-O1 -pipe}";
  2874. else
  2875. : "${BUILD_CFLAGS:=${CFLAGS}}";
  2876. : "${BUILD_CPPFLAGS:=${CPPFLAGS}}";
  2877. : "${BUILD_CXXFLAGS:=${CXXFLAGS}}";
  2878. : "${BUILD_FCFLAGS:=${FCFLAGS}}";
  2879. : "${BUILD_LDFLAGS:=${LDFLAGS}}";
  2880. : "${BUILD_OBJCFLAGS:=${OBJCFLAGS}}";
  2881. : "${BUILD_OBJCXXFLAGS:=${OBJCXXFLAGS}}";
  2882. : "${BUILD_PKG_CONFIG_LIBDIR:=${PKG_CONFIG_LIBDIR}}";
  2883. : "${BUILD_PKG_CONFIG_PATH:=${PKG_CONFIG_PATH}}";
  2884. fi;
  2885. local mesonargs=(meson setup --libdir "$(get_libdir)" --localstatedir "${EPREFIX}/var/lib" --prefix "${EPREFIX}/usr" --sysconfdir "${EPREFIX}/etc" --wrap-mode nodownload --build.pkg-config-path "${BUILD_PKG_CONFIG_PATH}${BUILD_PKG_CONFIG_PATH:+:}${EPREFIX}/usr/share/pkgconfig" --pkg-config-path "${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}${EPREFIX}/usr/share/pkgconfig" --native-file "$(_meson_create_native_file)" -Db_pch=false -Dwerror=false);
  2886. if [[ -n ${EMESON_BUILDTYPE} ]]; then
  2887. mesonargs+=(--buildtype "${EMESON_BUILDTYPE}");
  2888. fi;
  2889. if tc-is-cross-compiler; then
  2890. mesonargs+=(--cross-file "$(_meson_create_cross_file)");
  2891. fi;
  2892. BUILD_DIR="${BUILD_DIR:-${WORKDIR}/${P}-build}";
  2893. eval "local -a MYMESONARGS=( ${MYMESONARGS} )";
  2894. mesonargs+=("${emesonargs[@]}" "$@" "${MYMESONARGS[@]}" "${EMESON_SOURCE:-${S}}" "${BUILD_DIR}");
  2895. tc-export NM;
  2896. tc-getPROG READELF readelf > /dev/null;
  2897. python_export_utf8_locale;
  2898. local -x BOOST_INCLUDEDIR="${BOOST_INCLUDEDIR-${EPREFIX}/usr/include}";
  2899. local -x BOOST_LIBRARYDIR="${BOOST_LIBRARYDIR-${EPREFIX}/usr/$(get_libdir)}";
  2900. ( export -n {C,CPP,CXX,F,OBJC,OBJCXX,LD}FLAGS PKG_CONFIG_{LIBDIR,PATH};
  2901. echo "${mesonargs[@]}" 1>&2;
  2902. "${mesonargs[@]}" ) || die
  2903. }
  2904. meson_src_install ()
  2905. {
  2906. debug-print-function ${FUNCNAME} "$@";
  2907. meson_install "$@";
  2908. einstalldocs
  2909. }
  2910. meson_src_test ()
  2911. {
  2912. debug-print-function ${FUNCNAME} "$@";
  2913. local mesontestargs=(--print-errorlogs -C "${BUILD_DIR}" --num-processes "$(makeopts_jobs "${MAKEOPTS}")" "$@");
  2914. set -- meson test "${mesontestargs[@]}";
  2915. echo "$@" 1>&2;
  2916. "$@" || die "tests failed"
  2917. }
  2918. meson_use ()
  2919. {
  2920. usex "$1" "-D${2-$1}=true" "-D${2-$1}=false"
  2921. }
  2922. multibuild_copy_sources ()
  2923. {
  2924. debug-print-function ${FUNCNAME} "${@}";
  2925. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  2926. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  2927. function _multibuild_create_source_copy ()
  2928. {
  2929. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  2930. cp -p -R "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  2931. };
  2932. multibuild_foreach_variant _multibuild_create_source_copy
  2933. }
  2934. multibuild_for_best_variant ()
  2935. {
  2936. debug-print-function ${FUNCNAME} "${@}";
  2937. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2938. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[-1]}");
  2939. multibuild_foreach_variant "${@}"
  2940. }
  2941. multibuild_foreach_variant ()
  2942. {
  2943. debug-print-function ${FUNCNAME} "${@}";
  2944. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2945. local bdir=${BUILD_DIR:-${S}};
  2946. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  2947. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  2948. local ret=0 lret=0 v;
  2949. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  2950. for v in "${MULTIBUILD_VARIANTS[@]}";
  2951. do
  2952. local MULTIBUILD_VARIANT=${v};
  2953. local MULTIBUILD_ID=${prev_id}${v};
  2954. local BUILD_DIR=${bdir%%/}-${v};
  2955. function _multibuild_run ()
  2956. {
  2957. local i=1;
  2958. while [[ ${!i} == _* ]]; do
  2959. (( i += 1 ));
  2960. done;
  2961. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  2962. "${@}"
  2963. };
  2964. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  2965. lret=${?};
  2966. done;
  2967. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  2968. return ${ret}
  2969. }
  2970. multibuild_merge_root ()
  2971. {
  2972. debug-print-function ${FUNCNAME} "${@}";
  2973. local src=${1};
  2974. local dest=${2};
  2975. cp -a "${src}"/. "${dest}"/ || die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed";
  2976. rm -rf "${src}" || die
  2977. }
  2978. multilib-minimal_src_compile ()
  2979. {
  2980. debug-print-function ${FUNCNAME} "$@";
  2981. function multilib-minimal_abi_src_compile ()
  2982. {
  2983. debug-print-function ${FUNCNAME} "$@";
  2984. pushd "${BUILD_DIR}" > /dev/null || die;
  2985. if declare -f multilib_src_compile > /dev/null; then
  2986. multilib_src_compile;
  2987. else
  2988. default_src_compile;
  2989. fi;
  2990. popd > /dev/null || die
  2991. };
  2992. multilib_foreach_abi multilib-minimal_abi_src_compile
  2993. }
  2994. multilib-minimal_src_configure ()
  2995. {
  2996. debug-print-function ${FUNCNAME} "$@";
  2997. function multilib-minimal_abi_src_configure ()
  2998. {
  2999. debug-print-function ${FUNCNAME} "$@";
  3000. mkdir -p "${BUILD_DIR}" || die;
  3001. pushd "${BUILD_DIR}" > /dev/null || die;
  3002. if declare -f multilib_src_configure > /dev/null; then
  3003. multilib_src_configure;
  3004. else
  3005. default_src_configure;
  3006. fi;
  3007. popd > /dev/null || die
  3008. };
  3009. multilib_foreach_abi multilib-minimal_abi_src_configure
  3010. }
  3011. multilib-minimal_src_install ()
  3012. {
  3013. debug-print-function ${FUNCNAME} "$@";
  3014. function multilib-minimal_abi_src_install ()
  3015. {
  3016. debug-print-function ${FUNCNAME} "$@";
  3017. pushd "${BUILD_DIR}" > /dev/null || die;
  3018. if declare -f multilib_src_install > /dev/null; then
  3019. multilib_src_install;
  3020. else
  3021. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  3022. emake DESTDIR="${D}" install;
  3023. fi;
  3024. fi;
  3025. multilib_prepare_wrappers;
  3026. multilib_check_headers;
  3027. popd > /dev/null || die
  3028. };
  3029. multilib_foreach_abi multilib-minimal_abi_src_install;
  3030. multilib_install_wrappers;
  3031. if declare -f multilib_src_install_all > /dev/null; then
  3032. multilib_src_install_all;
  3033. else
  3034. einstalldocs;
  3035. fi
  3036. }
  3037. multilib-minimal_src_test ()
  3038. {
  3039. debug-print-function ${FUNCNAME} "$@";
  3040. function multilib-minimal_abi_src_test ()
  3041. {
  3042. debug-print-function ${FUNCNAME} "$@";
  3043. pushd "${BUILD_DIR}" > /dev/null || die;
  3044. if declare -f multilib_src_test > /dev/null; then
  3045. multilib_src_test;
  3046. else
  3047. default_src_test;
  3048. fi;
  3049. popd > /dev/null || die
  3050. };
  3051. multilib_foreach_abi multilib-minimal_abi_src_test
  3052. }
  3053. multilib_check_headers ()
  3054. {
  3055. function _multilib_header_cksum ()
  3056. {
  3057. set -o pipefail;
  3058. if [[ -d ${ED%/}/usr/include ]]; then
  3059. find "${ED%/}"/usr/include -type f -exec cksum {} + | sort -k2;
  3060. fi
  3061. };
  3062. local cksum cksum_prev;
  3063. local cksum_file=${T}/.multilib_header_cksum;
  3064. cksum=$(_multilib_header_cksum) || die;
  3065. unset -f _multilib_header_cksum;
  3066. if [[ -f ${cksum_file} ]]; then
  3067. cksum_prev=$(< "${cksum_file}") || die;
  3068. if [[ ${cksum} != ${cksum_prev} ]]; then
  3069. echo "${cksum}" > "${cksum_file}.new" || die;
  3070. eerror "Header files have changed between ABIs.";
  3071. if type -p diff &> /dev/null; then
  3072. eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")";
  3073. else
  3074. eerror "Old checksums in: ${cksum_file}";
  3075. eerror "New checksums in: ${cksum_file}.new";
  3076. fi;
  3077. die "Header checksum mismatch, aborting.";
  3078. fi;
  3079. else
  3080. echo "${cksum}" > "${cksum_file}" || die;
  3081. fi
  3082. }
  3083. multilib_copy_sources ()
  3084. {
  3085. debug-print-function ${FUNCNAME} "$@";
  3086. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  3087. multibuild_copy_sources
  3088. }
  3089. multilib_env ()
  3090. {
  3091. local CTARGET=${1:-${CTARGET}};
  3092. local cpu=${CTARGET%%*-};
  3093. if [[ ${CTARGET} = *-musl* ]]; then
  3094. : "${MULTILIB_ABIS=default}";
  3095. : "${DEFAULT_ABI=default}";
  3096. export MULTILIB_ABIS DEFAULT_ABI;
  3097. return;
  3098. fi;
  3099. case ${cpu} in
  3100. aarch64*)
  3101. export CFLAGS_arm=${CFLAGS_arm-};
  3102. case ${cpu} in
  3103. aarch64*be)
  3104. export CHOST_arm="armv8b-${CTARGET#*-}"
  3105. ;;
  3106. *)
  3107. export CHOST_arm="armv8l-${CTARGET#*-}"
  3108. ;;
  3109. esac;
  3110. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  3111. export CTARGET_arm=${CHOST_arm};
  3112. export LIBDIR_arm="lib";
  3113. export CFLAGS_arm64=${CFLAGS_arm64-};
  3114. export CHOST_arm64=${CTARGET};
  3115. export CTARGET_arm64=${CHOST_arm64};
  3116. export LIBDIR_arm64="lib64";
  3117. : "${MULTILIB_ABIS=arm64}";
  3118. : "${DEFAULT_ABI=arm64}"
  3119. ;;
  3120. x86_64*)
  3121. export CFLAGS_x86=${CFLAGS_x86--m32};
  3122. export CHOST_x86=${CTARGET/x86_64/i686};
  3123. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  3124. export CTARGET_x86=${CHOST_x86};
  3125. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  3126. export LIBDIR_x86="lib32";
  3127. else
  3128. export LIBDIR_x86="lib";
  3129. fi;
  3130. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  3131. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  3132. export CTARGET_amd64=${CHOST_amd64};
  3133. export LIBDIR_amd64="lib64";
  3134. export CFLAGS_x32=${CFLAGS_x32--mx32};
  3135. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  3136. export CTARGET_x32=${CHOST_x32};
  3137. export LIBDIR_x32="libx32";
  3138. case ${CTARGET} in
  3139. *-gnux32)
  3140. : "${MULTILIB_ABIS=x32 amd64 x86}";
  3141. : "${DEFAULT_ABI=x32}"
  3142. ;;
  3143. *)
  3144. : "${MULTILIB_ABIS=amd64 x86}";
  3145. : "${DEFAULT_ABI=amd64}"
  3146. ;;
  3147. esac
  3148. ;;
  3149. loongarch64*)
  3150. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  3151. export CHOST_lp64d=${CTARGET};
  3152. export CTARGET_lp64d=${CTARGET};
  3153. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64};
  3154. : "${MULTILIB_ABIS=lp64d}";
  3155. : "${DEFAULT_ABI=lp64d}"
  3156. ;;
  3157. mips64* | mipsisa64*)
  3158. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3159. export CHOST_o32=${CTARGET/mips64/mips};
  3160. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  3161. export CTARGET_o32=${CHOST_o32};
  3162. export LIBDIR_o32="lib";
  3163. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3164. export CHOST_n32=${CTARGET};
  3165. export CTARGET_n32=${CHOST_n32};
  3166. export LIBDIR_n32="lib32";
  3167. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3168. export CHOST_n64=${CTARGET};
  3169. export CTARGET_n64=${CHOST_n64};
  3170. export LIBDIR_n64="lib64";
  3171. : "${MULTILIB_ABIS=n64 n32 o32}";
  3172. : "${DEFAULT_ABI=n32}"
  3173. ;;
  3174. powerpc64*)
  3175. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3176. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3177. export CTARGET_ppc=${CHOST_ppc};
  3178. export LIBDIR_ppc="lib";
  3179. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3180. export CHOST_ppc64=${CTARGET};
  3181. export CTARGET_ppc64=${CHOST_ppc64};
  3182. export LIBDIR_ppc64="lib64";
  3183. : "${MULTILIB_ABIS=ppc64 ppc}";
  3184. : "${DEFAULT_ABI=ppc64}"
  3185. ;;
  3186. riscv64*)
  3187. : "${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32}";
  3188. : "${DEFAULT_ABI=lp64d}";
  3189. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  3190. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  3191. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib64};
  3192. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64gc};
  3193. export CHOST_lp64d=${CTARGET};
  3194. export CTARGET_lp64d=${CTARGET};
  3195. export LIBDIR_lp64d=${LIBDIR_lp64d-lib64/lp64d};
  3196. export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac};
  3197. export CHOST_lp64=${CTARGET};
  3198. export CTARGET_lp64=${CTARGET};
  3199. export LIBDIR_lp64=${LIBDIR_lp64-lib64/lp64};
  3200. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  3201. export CHOST_ilp32d=${CTARGET/riscv64/riscv32};
  3202. export CTARGET_ilp32d=${CTARGET/riscv64/riscv32};
  3203. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  3204. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  3205. export CHOST_ilp32=${CTARGET/riscv64/riscv32};
  3206. export CTARGET_ilp32=${CTARGET/riscv64/riscv32};
  3207. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  3208. ;;
  3209. riscv32*)
  3210. : "${MULTILIB_ABIS=ilp32d ilp32}";
  3211. : "${DEFAULT_ABI=ilp32d}";
  3212. local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  3213. local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  3214. export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib};
  3215. export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  3216. export CHOST_ilp32d=${CTARGET};
  3217. export CTARGET_ilp32d=${CTARGET};
  3218. export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  3219. export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  3220. export CHOST_ilp32=${CTARGET};
  3221. export CTARGET_ilp32=${CTARGET};
  3222. export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  3223. ;;
  3224. s390x*)
  3225. export CFLAGS_s390=${CFLAGS_s390--m31};
  3226. export CHOST_s390=${CTARGET/s390x/s390};
  3227. export CTARGET_s390=${CHOST_s390};
  3228. export LIBDIR_s390="lib";
  3229. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3230. export CHOST_s390x=${CTARGET};
  3231. export CTARGET_s390x=${CHOST_s390x};
  3232. export LIBDIR_s390x="lib64";
  3233. : "${MULTILIB_ABIS=s390x s390}";
  3234. : "${DEFAULT_ABI=s390x}"
  3235. ;;
  3236. sparc64*)
  3237. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  3238. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3239. export CTARGET_sparc32=${CHOST_sparc32};
  3240. export LIBDIR_sparc32="lib";
  3241. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3242. export CHOST_sparc64=${CTARGET};
  3243. export CTARGET_sparc64=${CHOST_sparc64};
  3244. export LIBDIR_sparc64="lib64";
  3245. : "${MULTILIB_ABIS=sparc64 sparc32}";
  3246. : "${DEFAULT_ABI=sparc64}"
  3247. ;;
  3248. *)
  3249. : "${MULTILIB_ABIS=default}";
  3250. : "${DEFAULT_ABI=default}"
  3251. ;;
  3252. esac;
  3253. export MULTILIB_ABIS DEFAULT_ABI
  3254. }
  3255. multilib_foreach_abi ()
  3256. {
  3257. debug-print-function ${FUNCNAME} "$@";
  3258. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  3259. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  3260. }
  3261. multilib_get_enabled_abi_pairs ()
  3262. {
  3263. debug-print-function ${FUNCNAME} "$@";
  3264. local abis=($(get_all_abis));
  3265. local abi i found;
  3266. for abi in "${abis[@]}";
  3267. do
  3268. for i in "${_MULTILIB_FLAGS[@]}";
  3269. do
  3270. local m_abis=${i#*:} m_abi;
  3271. local m_flag=${i%:*};
  3272. for m_abi in ${m_abis//,/ };
  3273. do
  3274. if [[ ${m_abi} == ${abi} ]] && {
  3275. [[ ! -n "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"
  3276. } && use "${m_flag}"; then
  3277. echo "${m_flag}.${abi}";
  3278. found=1;
  3279. break 2;
  3280. fi;
  3281. done;
  3282. done;
  3283. done;
  3284. if [[ ! -n ${found} ]]; then
  3285. local abi=${ABI:-${DEFAULT_ABI}};
  3286. debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}";
  3287. debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}";
  3288. echo ".${abi}";
  3289. fi
  3290. }
  3291. multilib_get_enabled_abis ()
  3292. {
  3293. debug-print-function ${FUNCNAME} "$@";
  3294. local pairs=($(multilib_get_enabled_abi_pairs));
  3295. echo "${pairs[@]#*.}"
  3296. }
  3297. multilib_install_wrappers ()
  3298. {
  3299. debug-print-function ${FUNCNAME} "$@";
  3300. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  3301. [[ ${COMPLETE_MULTILIB} == yes ]] && return;
  3302. local root=${1:-${ED}};
  3303. if [[ -d ${ED%/}/tmp/multilib-include ]]; then
  3304. multibuild_merge_root "${ED%/}"/tmp/multilib-include "${root}"/usr/include;
  3305. rmdir "${ED%/}"/tmp &> /dev/null;
  3306. fi
  3307. }
  3308. multilib_is_native_abi ()
  3309. {
  3310. debug-print-function ${FUNCNAME} "$@";
  3311. [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments";
  3312. [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
  3313. }
  3314. multilib_native_enable ()
  3315. {
  3316. if multilib_is_native_abi; then
  3317. echo "--enable-${1}${2+=${2}}";
  3318. else
  3319. echo "--disable-${1}";
  3320. fi
  3321. }
  3322. multilib_native_use ()
  3323. {
  3324. multilib_is_native_abi && use "$@"
  3325. }
  3326. multilib_native_use_enable ()
  3327. {
  3328. if multilib_is_native_abi; then
  3329. use_enable "${@}";
  3330. else
  3331. echo "--disable-${2:-${1}}";
  3332. fi
  3333. }
  3334. multilib_native_use_with ()
  3335. {
  3336. if multilib_is_native_abi; then
  3337. use_with "${@}";
  3338. else
  3339. echo "--without-${2:-${1}}";
  3340. fi
  3341. }
  3342. multilib_native_usev ()
  3343. {
  3344. multilib_is_native_abi && usev "$@"
  3345. }
  3346. multilib_native_usex ()
  3347. {
  3348. if multilib_is_native_abi; then
  3349. usex "${@}";
  3350. else
  3351. echo "${3-no}${5}";
  3352. fi
  3353. }
  3354. multilib_native_with ()
  3355. {
  3356. if multilib_is_native_abi; then
  3357. echo "--with-${1}${2+=${2}}";
  3358. else
  3359. echo "--without-${1}";
  3360. fi
  3361. }
  3362. multilib_parallel_foreach_abi ()
  3363. {
  3364. debug-print-function ${FUNCNAME} "$@";
  3365. local MULTIBUILD_VARIANTS=($(multilib_get_enabled_abi_pairs));
  3366. multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
  3367. }
  3368. multilib_prepare_wrappers ()
  3369. {
  3370. debug-print-function ${FUNCNAME} "$@";
  3371. [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments";
  3372. local root=${1:-${ED%/}};
  3373. local f;
  3374. if [[ ${COMPLETE_MULTILIB} == yes ]]; then
  3375. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  3376. do
  3377. f=${f#/};
  3378. local dir=${f%/*};
  3379. local fn=${f##*/};
  3380. ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die;
  3381. done;
  3382. return;
  3383. fi;
  3384. for f in "${MULTILIB_CHOST_TOOLS[@]}";
  3385. do
  3386. f=${f#/};
  3387. local dir=${f%/*};
  3388. local fn=${f##*/};
  3389. if [[ -L ${root}/${f} ]]; then
  3390. local target;
  3391. target=$(readlink "${root}/${f}") || die;
  3392. local target_dir target_fn=${target##*/};
  3393. [[ ${target} == */* ]] && target_dir=${target%/*};
  3394. ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" "${root}/${f}" || die;
  3395. fi;
  3396. mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die;
  3397. if multilib_is_native_abi; then
  3398. ln -s "${CHOST}-${fn}" "${root}/${f}" || die;
  3399. fi;
  3400. done;
  3401. if [[ -n ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
  3402. if [[ -n ${MULTILIB_ABI_FLAG} ]]; then
  3403. for f in "${MULTILIB_WRAPPED_HEADERS[@]}";
  3404. do
  3405. f=${f#/};
  3406. if [[ ${f} != usr/include/* ]]; then
  3407. die "Wrapping headers outside of /usr/include is not supported at the moment.";
  3408. fi;
  3409. f=${f#usr/include};
  3410. local dir=${f%/*};
  3411. if [[ -f ${root}/usr/include${f} ]]; then
  3412. local wrapper=${ED%/}/tmp/multilib-include${f};
  3413. if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then
  3414. dodir "/tmp/multilib-include${dir}";
  3415. cat > "${wrapper}" <<_EOF_ ||
  3416. /* This file is auto-generated by multilib-build.eclass
  3417. * as a multilib-friendly wrapper. For the original content,
  3418. * please see the files that are #included below.
  3419. */
  3420.  
  3421. #if defined(__x86_64__) /* amd64 */
  3422. # if defined(__ILP32__) /* x32 ABI */
  3423. # error "abi_x86_x32 not supported by the package."
  3424. # else /* 64-bit ABI */
  3425. # error "abi_x86_64 not supported by the package."
  3426. # endif
  3427. #elif defined(__i386__) /* plain x86 */
  3428. # error "abi_x86_32 not supported by the package."
  3429. #elif defined(__mips__)
  3430. # if(_MIPS_SIM == _ABIN32) /* n32 */
  3431. # error "abi_mips_n32 not supported by the package."
  3432. # elif(_MIPS_SIM == _ABI64) /* n64 */
  3433. # error "abi_mips_n64 not supported by the package."
  3434. # elif(_MIPS_SIM == _ABIO32) /* o32 */
  3435. # error "abi_mips_o32 not supported by the package."
  3436. # endif
  3437. #elif defined(__sparc__)
  3438. # if defined(__arch64__)
  3439. # error "abi_sparc_64 not supported by the package."
  3440. # else
  3441. # error "abi_sparc_32 not supported by the package."
  3442. # endif
  3443. #elif defined(__s390__)
  3444. # if defined(__s390x__)
  3445. # error "abi_s390_64 not supported by the package."
  3446. # else
  3447. # error "abi_s390_32 not supported by the package."
  3448. # endif
  3449. #elif defined(__powerpc__) || defined(__ppc__)
  3450. # if defined(__powerpc64__) || defined(__ppc64__)
  3451. # error "abi_ppc_64 not supported by the package."
  3452. # else
  3453. # error "abi_ppc_32 not supported by the package."
  3454. # endif
  3455. #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
  3456. # error "Native ABI not supported by the package."
  3457. #else
  3458. # error "No ABI matched, please report a bug to bugs.gentoo.org"
  3459. #endif
  3460. _EOF_
  3461. die;
  3462. fi
  3463. if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"; then
  3464. die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org.";
  3465. fi;
  3466. dodir "/tmp/multilib-include/${CHOST}${dir}";
  3467. mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die;
  3468. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  3469. if multilib_is_native_abi; then
  3470. sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" -i "${wrapper}" || die;
  3471. fi;
  3472. fi;
  3473. done;
  3474. fi;
  3475. fi
  3476. }
  3477. multilib_src_compile ()
  3478. {
  3479. meson_src_compile "${_meson_args[@]}"
  3480. }
  3481. multilib_src_configure ()
  3482. {
  3483. local emesonargs=(--localstatedir="${EPREFIX}/var" -Dsystemdsystemunitdir=$(systemd_get_systemunitdir) -Dsystem_ca_path=/etc/ssl/certs -Dudev_dir=$(get_udevdir) -Ddbus_conf_dir=/usr/share/dbus-1/system.d -Dkernel_firmware_dir=/lib/firmware -Diptables=/sbin/iptables -Dnft=/sbin/nft -Ddnsmasq=/usr/sbin/dnsmasq -Ddist_version=${PVR} $(meson_native_use_bool policykit polkit) $(meson_native_use_bool policykit config_auth_polkit_default) -Dmodify_system=true -Dpolkit_agent_helper_1=/usr/lib/polkit-1/polkit-agent-helper-1 $(meson_native_use_bool selinux) $(meson_native_use_bool systemd systemd_journal) -Dhostname_persist=gentoo -Dlibaudit=$(multilib_native_usex audit) $(meson_native_use_bool wext) $(meson_native_use_bool wifi) $(meson_native_use_bool iwd) $(meson_native_use_bool ppp) -Dpppd=/usr/sbin/pppd $(meson_native_use_bool modemmanager modem_manager) $(meson_native_use_bool ofono) $(meson_native_use_bool concheck) $(meson_native_use_bool teamd teamdctl) $(meson_native_use_bool ovs) $(meson_native_use_bool tools nmcli) $(meson_native_use_bool tools nmtui) $(meson_native_use_bool tools nm_cloud_setup) $(meson_native_use_bool bluetooth bluez5_dun) -Debpf=true -Dconfig_wifi_backend_default=$(multilib_native_usex iwd iwd default) -Dconfig_plugins_default=keyfile -Difcfg_rh=false -Difupdown=false $(meson_nm_native_program resolvconf "" /sbin/resolvconf) -Dnetconfig=no -Dconfig_dns_rc_manager_default=auto $(meson_nm_program dhclient "" /sbin/dhclient) -Ddhcpcanon=no $(meson_nm_program dhcpcd "" /sbin/dhcpcd) $(meson_native_use_bool introspection) $(meson_native_use_bool vala vapi) $(meson_native_use_bool gtk-doc docs) -Dtests=$(multilib_native_usex test) $(meson_native_true firewalld_zone) -Dmore_asserts=0 $(meson_use debug more_logging) -Dvalgrind=no -Dvalgrind_suppressions= -Dld_gc=false $(meson_native_use_bool psl libpsl) -Dqt=false $(meson_use lto b_lto));
  3484. if multilib_is_native_abi && use systemd; then
  3485. emesonargs+=(-Dsession_tracking_consolekit=false);
  3486. emesonargs+=(-Dsession_tracking=systemd);
  3487. emesonargs+=(-Dsuspend_resume=systemd);
  3488. else
  3489. if multilib_is_native_abi && use elogind; then
  3490. emesonargs+=(-Dsession_tracking_consolekit=false);
  3491. emesonargs+=(-Dsession_tracking=elogind);
  3492. emesonargs+=(-Dsuspend_resume=elogind);
  3493. else
  3494. emesonargs+=(-Dsession_tracking_consolekit=false);
  3495. emesonargs+=(-Dsession_tracking=no);
  3496. emesonargs+=(-Dsuspend_resume=auto);
  3497. fi;
  3498. fi;
  3499. if multilib_is_native_abi && use syslog; then
  3500. emesonargs+=(-Dconfig_logging_backend_default=syslog);
  3501. else
  3502. if multilib_is_native_abi && use systemd; then
  3503. emesonargs+=(-Dconfig_logging_backend_default=journal);
  3504. else
  3505. emesonargs+=(-Dconfig_logging_backend_default=default);
  3506. fi;
  3507. fi;
  3508. if multilib_is_native_abi && use dhclient; then
  3509. emesonargs+=(-Dconfig_dhcp_default=dhclient);
  3510. else
  3511. if multilib_is_native_abi && use dhcpcd; then
  3512. emesonargs+=(-Dconfig_dhcp_default=dhcpcd);
  3513. else
  3514. emesonargs+=(-Dconfig_dhcp_default=internal);
  3515. fi;
  3516. fi;
  3517. if use nss; then
  3518. emesonargs+=(-Dcrypto=nss);
  3519. else
  3520. emesonargs+=(-Dcrypto=gnutls);
  3521. fi;
  3522. if use tools; then
  3523. emesonargs+=(-Dreadline=$(usex libedit libedit libreadline));
  3524. else
  3525. emesonargs+=(-Dreadline=none);
  3526. fi;
  3527. if use ppp; then
  3528. local PPPD_VER=`best_version net-dialup/ppp`;
  3529. PPPD_VER=${PPPD_VER#*/*-};
  3530. PPPD_VER=${PPPD_VER%%[_-]*};
  3531. emesonargs+=(-Dpppd_plugin_dir=/usr/$(get_libdir)/pppd/${PPPD_VER});
  3532. fi;
  3533. meson_src_configure
  3534. }
  3535. multilib_src_install ()
  3536. {
  3537. meson_src_install;
  3538. if ! multilib_is_native_abi; then
  3539. rm -r "${ED}"/{etc,usr/{bin,lib/NetworkManager,share},var} || die;
  3540. fi
  3541. }
  3542. multilib_src_install_all ()
  3543. {
  3544. ! use systemd && readme.gentoo_create_doc;
  3545. newinitd "${FILESDIR}/init.d.NetworkManager-r2" NetworkManager;
  3546. newconfd "${FILESDIR}/conf.d.NetworkManager" NetworkManager;
  3547. keepdir /etc/NetworkManager/dispatcher.d;
  3548. exeinto /etc/NetworkManager/dispatcher.d;
  3549. newexe "${FILESDIR}/10-openrc-status-r4" 10-openrc-status;
  3550. sed -e "s:@EPREFIX@:${EPREFIX}:g" -i "${ED}/etc/NetworkManager/dispatcher.d/10-openrc-status" || die;
  3551. keepdir /etc/NetworkManager/system-connections;
  3552. chmod 0600 "${ED}"/etc/NetworkManager/system-connections/.keep*;
  3553. insinto /usr/share/polkit-1/rules.d/;
  3554. doins "${FILESDIR}"/01-org.freedesktop.NetworkManager.settings.modify.system.rules;
  3555. insinto /usr/lib/NetworkManager/conf.d;
  3556. doins "${S}"/examples/nm-conf.d/31-mac-addr-change.conf;
  3557. if use iwd; then
  3558. cat <<-EOF > "${ED}"/usr/lib/NetworkManager/conf.d/iwd.conf ||
  3559. [device]
  3560. wifi.backend=iwd
  3561. EOF
  3562. die;
  3563. fi
  3564. mv "${ED}"/usr/share/doc/{NetworkManager/examples/,${PF}} || die;
  3565. rmdir "${ED}"/usr/share/doc/NetworkManager || die;
  3566. rmdir "${ED}"/var{/lib{/NetworkManager,},} || die
  3567. }
  3568. multilib_src_test ()
  3569. {
  3570. if use test && multilib_is_native_abi; then
  3571. python_setup;
  3572. virtx meson_src_test;
  3573. fi
  3574. }
  3575. multilib_toolchain_setup ()
  3576. {
  3577. local v vv;
  3578. export ABI=$1;
  3579. 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);
  3580. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  3581. for v in "${save_restore_variables[@]}";
  3582. do
  3583. vv="_abi_saved_${v}";
  3584. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  3585. unset ${vv};
  3586. done;
  3587. unset _DEFAULT_ABI_SAVED;
  3588. fi;
  3589. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3590. for v in "${save_restore_variables[@]}";
  3591. do
  3592. vv="_abi_saved_${v}";
  3593. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  3594. done;
  3595. export _DEFAULT_ABI_SAVED="true";
  3596. if [[ ${CBUILD} == "${CHOST}" ]]; then
  3597. export CBUILD=$(get_abi_CHOST $1);
  3598. fi;
  3599. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3600. export AR="$(tc-getAR)";
  3601. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3602. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3603. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  3604. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  3605. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3606. export NM="$(tc-getNM)";
  3607. export OBJCOPY="$(tc-getOBJCOPY)";
  3608. export OBJDUMP="$(tc-getOBJDUMP)";
  3609. export PKG_CONFIG="$(tc-getPKG_CONFIG)";
  3610. export RANLIB="$(tc-getRANLIB)";
  3611. export READELF="$(tc-getREADELF)";
  3612. export STRINGS="$(tc-getSTRINGS)";
  3613. export STRIP="$(tc-getSTRIP)";
  3614. export CHOST=$(get_abi_CHOST $1);
  3615. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  3616. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  3617. export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include;
  3618. export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir);
  3619. fi
  3620. }
  3621. no-as-needed ()
  3622. {
  3623. [[ $# -ne 0 ]] && die "no-as-needed takes no arguments";
  3624. case $($(tc-getLD) -v 2>&1 </dev/null) in
  3625. *GNU*)
  3626. echo "-Wl,--no-as-needed"
  3627. ;;
  3628. esac
  3629. }
  3630. number_abis ()
  3631. {
  3632. set -- `get_install_abis`;
  3633. echo $#
  3634. }
  3635. pkg_nofetch ()
  3636. {
  3637. default
  3638. }
  3639. pkg_postinst ()
  3640. {
  3641. udev_reload;
  3642. systemd_reenable NetworkManager.service;
  3643. ! use systemd && readme.gentoo_print_elog;
  3644. if [[ -e "${EROOT}/etc/NetworkManager/nm-system-settings.conf" ]]; then
  3645. ewarn "The ${PN} system configuration file has moved to a new location.";
  3646. ewarn "You must migrate your settings from ${EROOT}/etc/NetworkManager/nm-system-settings.conf";
  3647. ewarn "to ${EROOT}/etc/NetworkManager/NetworkManager.conf";
  3648. ewarn;
  3649. ewarn "After doing so, you can remove ${EROOT}/etc/NetworkManager/nm-system-settings.conf";
  3650. fi;
  3651. if [[ -e "${EROOT}/etc/NetworkManager/NetworkManager.conf" ]]; then
  3652. if grep plugins "${EROOT}/etc/NetworkManager/NetworkManager.conf" | grep -q ifnet; then
  3653. ewarn;
  3654. ewarn "You seem to use 'ifnet' plugin in ${EROOT}/etc/NetworkManager/NetworkManager.conf";
  3655. ewarn "Since it won't be used, you will need to stop setting ifnet plugin there.";
  3656. ewarn;
  3657. fi;
  3658. fi;
  3659. if grep -r "psk-flags=1" "${EROOT}"/etc/NetworkManager/; then
  3660. ewarn "You have psk-flags=1 setting in above files, you will need to";
  3661. ewarn "either reconfigure affected networks or, at least, set the flag";
  3662. ewarn "value to '0'.";
  3663. fi;
  3664. if use dhclient || use dhcpcd; then
  3665. ewarn "You have enabled USE=dhclient and/or USE=dhcpcd, but NetworkManager since";
  3666. ewarn "version 1.20 defaults to the internal DHCP client. If the internal client";
  3667. ewarn "works for you, and you're happy with, the alternative USE flags can be";
  3668. ewarn "disabled. If you want to use dhclient or dhcpcd, then you need to tweak";
  3669. ewarn "the main.dhcp configuration option to use one of them instead of internal.";
  3670. fi
  3671. }
  3672. pkg_postrm ()
  3673. {
  3674. udev_reload
  3675. }
  3676. pkg_setup ()
  3677. {
  3678. if use connection-sharing; then
  3679. if kernel_is lt 5 1; then
  3680. CONFIG_CHECK="~NF_NAT_IPV4 ~NF_NAT_MASQUERADE_IPV4";
  3681. else
  3682. CONFIG_CHECK="~NF_NAT ~NF_NAT_MASQUERADE";
  3683. fi;
  3684. linux-info_pkg_setup;
  3685. fi;
  3686. if use introspection || use test; then
  3687. python-any-r1_pkg_setup;
  3688. fi;
  3689. if tc-is-clang && use lto; then
  3690. eerror "Clang does not support -flto-partition";
  3691. die "Please use gcc or turn off USE=lto flag when building with clang";
  3692. fi
  3693. }
  3694. python-any-r1_pkg_setup ()
  3695. {
  3696. debug-print-function ${FUNCNAME} "${@}";
  3697. [[ ${MERGE_TYPE} != binary ]] && python_setup
  3698. }
  3699. python_check_deps ()
  3700. {
  3701. if use introspection; then
  3702. python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return;
  3703. fi;
  3704. if use test; then
  3705. python_has_version "dev-python/dbus-python[${PYTHON_USEDEP}]" && python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]";
  3706. fi
  3707. }
  3708. python_doexe ()
  3709. {
  3710. debug-print-function ${FUNCNAME} "${@}";
  3711. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3712. local f;
  3713. for f in "$@";
  3714. do
  3715. python_newexe "${f}" "${f##*/}";
  3716. done
  3717. }
  3718. python_doheader ()
  3719. {
  3720. debug-print-function ${FUNCNAME} "${@}";
  3721. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3722. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3723. local includedir=$(python_get_includedir);
  3724. local d=${includedir#${EPREFIX}};
  3725. ( insopts -m 0644;
  3726. insinto "${d}";
  3727. doins -r "${@}" || return ${?} )
  3728. }
  3729. python_domodule ()
  3730. {
  3731. debug-print-function ${FUNCNAME} "${@}";
  3732. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3733. local d;
  3734. if [[ ${_PYTHON_MODULEROOT} == /* ]]; then
  3735. d=${_PYTHON_MODULEROOT};
  3736. else
  3737. local sitedir=$(python_get_sitedir);
  3738. d=${sitedir#${EPREFIX}}/${_PYTHON_MODULEROOT//.//};
  3739. fi;
  3740. if [[ ${EBUILD_PHASE} == install ]]; then
  3741. ( insopts -m 0644;
  3742. insinto "${d}";
  3743. doins -r "${@}" || return ${?} );
  3744. python_optimize "${ED%/}/${d}";
  3745. else
  3746. if [[ -n ${BUILD_DIR} ]]; then
  3747. local dest=${BUILD_DIR}/install${EPREFIX}/${d};
  3748. mkdir -p "${dest}" || die;
  3749. cp -pR "${@}" "${dest}/" || die;
  3750. ( cd "${dest}" && chmod -R a+rX "${@##*/}" ) || die;
  3751. else
  3752. die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set";
  3753. fi;
  3754. fi
  3755. }
  3756. python_doscript ()
  3757. {
  3758. debug-print-function ${FUNCNAME} "${@}";
  3759. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3760. local _PYTHON_REWRITE_SHEBANG=1;
  3761. python_doexe "${@}"
  3762. }
  3763. python_export_utf8_locale ()
  3764. {
  3765. debug-print-function ${FUNCNAME} "${@}";
  3766. type locale &> /dev/null || return 0;
  3767. if [[ $(locale charmap) != UTF-8 ]]; then
  3768. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  3769. for lang in ${locales};
  3770. do
  3771. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  3772. if _python_check_locale_sanity "${lang}"; then
  3773. export LC_CTYPE=${lang};
  3774. if [[ -n ${LC_ALL} ]]; then
  3775. export LC_NUMERIC=${LC_ALL};
  3776. export LC_TIME=${LC_ALL};
  3777. export LC_COLLATE=${LC_ALL};
  3778. export LC_MONETARY=${LC_ALL};
  3779. export LC_MESSAGES=${LC_ALL};
  3780. export LC_PAPER=${LC_ALL};
  3781. export LC_NAME=${LC_ALL};
  3782. export LC_ADDRESS=${LC_ALL};
  3783. export LC_TELEPHONE=${LC_ALL};
  3784. export LC_MEASUREMENT=${LC_ALL};
  3785. export LC_IDENTIFICATION=${LC_ALL};
  3786. export LC_ALL=;
  3787. fi;
  3788. return 0;
  3789. fi;
  3790. fi;
  3791. done;
  3792. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  3793. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  3794. ewarn "/etc/locale.gen and run locale-gen.";
  3795. return 1;
  3796. fi;
  3797. return 0
  3798. }
  3799. python_fix_shebang ()
  3800. {
  3801. debug-print-function ${FUNCNAME} "${@}";
  3802. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  3803. local force quiet;
  3804. while [[ -n ${@} ]]; do
  3805. case "${1}" in
  3806. -f | --force)
  3807. force=1;
  3808. shift
  3809. ;;
  3810. -q | --quiet)
  3811. quiet=1;
  3812. shift
  3813. ;;
  3814. --)
  3815. shift;
  3816. break
  3817. ;;
  3818. *)
  3819. break
  3820. ;;
  3821. esac;
  3822. done;
  3823. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  3824. local path f;
  3825. for path in "$@";
  3826. do
  3827. local any_fixed is_recursive;
  3828. [[ -d ${path} ]] && is_recursive=1;
  3829. while IFS= read -r -d '' f; do
  3830. local shebang i;
  3831. local error= match=;
  3832. IFS= read -r shebang < "${f}";
  3833. if [[ ${shebang} == '#!'* ]]; then
  3834. local split_shebang=();
  3835. read -r -a split_shebang <<< ${shebang#"#!"} || die;
  3836. local in_path=${split_shebang[0]};
  3837. local from='^#! *[^ ]*';
  3838. if [[ ${in_path} == */env ]]; then
  3839. in_path=${split_shebang[1]};
  3840. from+=' *[^ ]*';
  3841. fi;
  3842. case ${in_path##*/} in
  3843. "${EPYTHON}")
  3844. match=1
  3845. ;;
  3846. python | python3)
  3847. match=1
  3848. ;;
  3849. python2 | python[23].[0-9] | python3.[1-9][0-9] | pypy | pypy3 | jython[23].[0-9])
  3850. match=1;
  3851. error=1
  3852. ;;
  3853. esac;
  3854. fi;
  3855. [[ -n ${force} ]] && error=;
  3856. if [[ ! -n ${match} ]]; then
  3857. [[ -n ${is_recursive} ]] && continue;
  3858. error=1;
  3859. fi;
  3860. if [[ ! -n ${quiet} ]]; then
  3861. einfo "Fixing shebang in ${f#${D%/}}.";
  3862. fi;
  3863. if [[ ! -n ${error} ]]; then
  3864. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3865. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  3866. sed -i -e "1s@${from}@#!${EPREFIX}/usr/bin/${EPYTHON}@" "${f}" || die;
  3867. any_fixed=1;
  3868. else
  3869. eerror "The file has incompatible shebang:";
  3870. eerror " file: ${f#${D%/}}";
  3871. eerror " current shebang: ${shebang}";
  3872. eerror " requested impl: ${EPYTHON}";
  3873. die "${FUNCNAME}: conversion of incompatible shebang requested";
  3874. fi;
  3875. done < <(find -H "${path}" -type f -print0 || die);
  3876. if [[ ! -n ${any_fixed} ]]; then
  3877. eerror "QA error: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  3878. eerror "There are no Python files in specified directory.";
  3879. die "${FUNCNAME} did not match any fixable files";
  3880. fi;
  3881. done
  3882. }
  3883. python_gen_any_dep ()
  3884. {
  3885. debug-print-function ${FUNCNAME} "${@}";
  3886. local depstr=${1};
  3887. [[ -n ${depstr} ]] || die "No dependency string provided";
  3888. local i PYTHON_PKG_DEP out=;
  3889. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3890. do
  3891. local PYTHON_USEDEP="python_targets_${i}(-)";
  3892. local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)";
  3893. _python_export "${i}" PYTHON_PKG_DEP;
  3894. local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  3895. i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}};
  3896. out="( ${PYTHON_PKG_DEP%:=} ${i_depstr} ) ${out}";
  3897. done;
  3898. echo "|| ( ${out})"
  3899. }
  3900. python_get_CFLAGS ()
  3901. {
  3902. debug-print-function ${FUNCNAME} "${@}";
  3903. _python_export "${@}" PYTHON_CFLAGS;
  3904. echo "${PYTHON_CFLAGS}"
  3905. }
  3906. python_get_LIBS ()
  3907. {
  3908. debug-print-function ${FUNCNAME} "${@}";
  3909. _python_export "${@}" PYTHON_LIBS;
  3910. echo "${PYTHON_LIBS}"
  3911. }
  3912. python_get_PYTHON_CONFIG ()
  3913. {
  3914. debug-print-function ${FUNCNAME} "${@}";
  3915. _python_export "${@}" PYTHON_CONFIG;
  3916. echo "${PYTHON_CONFIG}"
  3917. }
  3918. python_get_includedir ()
  3919. {
  3920. debug-print-function ${FUNCNAME} "${@}";
  3921. _python_export "${@}" PYTHON_INCLUDEDIR;
  3922. echo "${PYTHON_INCLUDEDIR}"
  3923. }
  3924. python_get_library_path ()
  3925. {
  3926. debug-print-function ${FUNCNAME} "${@}";
  3927. _python_export "${@}" PYTHON_LIBPATH;
  3928. echo "${PYTHON_LIBPATH}"
  3929. }
  3930. python_get_scriptdir ()
  3931. {
  3932. debug-print-function ${FUNCNAME} "${@}";
  3933. _python_export "${@}" PYTHON_SCRIPTDIR;
  3934. echo "${PYTHON_SCRIPTDIR}"
  3935. }
  3936. python_get_sitedir ()
  3937. {
  3938. debug-print-function ${FUNCNAME} "${@}";
  3939. _python_export "${@}" PYTHON_SITEDIR;
  3940. echo "${PYTHON_SITEDIR}"
  3941. }
  3942. python_has_version ()
  3943. {
  3944. debug-print-function ${FUNCNAME} "${@}";
  3945. local root_arg=(-b);
  3946. case ${1} in
  3947. -b | -d | -r)
  3948. root_arg=("${1}");
  3949. shift
  3950. ;;
  3951. esac;
  3952. local pkg;
  3953. for pkg in "$@";
  3954. do
  3955. ebegin " ${pkg}";
  3956. has_version "${root_arg[@]}" "${pkg}";
  3957. eend ${?} || return;
  3958. done;
  3959. return 0
  3960. }
  3961. python_moduleinto ()
  3962. {
  3963. debug-print-function ${FUNCNAME} "${@}";
  3964. _PYTHON_MODULEROOT=${1}
  3965. }
  3966. python_newexe ()
  3967. {
  3968. debug-print-function ${FUNCNAME} "${@}";
  3969. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3970. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3971. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3972. local wrapd=${_PYTHON_SCRIPTROOT:-/usr/bin};
  3973. local f=${1};
  3974. local newfn=${2};
  3975. local scriptdir=$(python_get_scriptdir);
  3976. local d=${scriptdir#${EPREFIX}};
  3977. ( dodir "${wrapd}";
  3978. exeopts -m 0755;
  3979. exeinto "${d}";
  3980. newexe "${f}" "${newfn}" || return ${?} );
  3981. local dosym=dosym;
  3982. [[ ${EAPI} == 7 ]] && dosym=dosym8;
  3983. "${dosym}" -r /usr/lib/python-exec/python-exec2 "${wrapd}/${newfn}";
  3984. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3985. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3986. fi
  3987. }
  3988. python_newscript ()
  3989. {
  3990. debug-print-function ${FUNCNAME} "${@}";
  3991. [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3992. local _PYTHON_REWRITE_SHEBANG=1;
  3993. python_newexe "${@}"
  3994. }
  3995. python_optimize ()
  3996. {
  3997. debug-print-function ${FUNCNAME} "${@}";
  3998. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3999. local PYTHON=${PYTHON};
  4000. [[ -n ${PYTHON} ]] || _python_export PYTHON;
  4001. [[ -x ${PYTHON} ]] || die "PYTHON (${PYTHON}) is not executable";
  4002. if [[ ${#} -eq 0 ]]; then
  4003. local f;
  4004. while IFS= read -r -d '' f; do
  4005. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  4006. set -- "${D%/}${f}" "${@}";
  4007. fi;
  4008. done < <(
  4009. "${PYTHON}" - <<-EOF || die
  4010. import sys
  4011. print("".join(x + "\0" for x in sys.path))
  4012. EOF
  4013. );
  4014. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  4015. fi;
  4016. local jobs=$(makeopts_jobs);
  4017. local d;
  4018. for d in "$@";
  4019. do
  4020. local instpath=${d#${D%/}};
  4021. instpath=/${instpath##/};
  4022. einfo "Optimize Python modules for ${instpath}";
  4023. case "${EPYTHON}" in
  4024. python3.8)
  4025. "${PYTHON}" -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  4026. "${PYTHON}" -O -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  4027. "${PYTHON}" -OO -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
  4028. ;;
  4029. python* | pypy3)
  4030. "${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}"
  4031. ;;
  4032. pypy | jython2.7)
  4033. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  4034. ;;
  4035. *)
  4036. die "${FUNCNAME}: unexpected EPYTHON=${EPYTHON}"
  4037. ;;
  4038. esac;
  4039. done
  4040. }
  4041. python_scriptinto ()
  4042. {
  4043. debug-print-function ${FUNCNAME} "${@}";
  4044. _PYTHON_SCRIPTROOT=${1}
  4045. }
  4046. python_setup ()
  4047. {
  4048. debug-print-function ${FUNCNAME} "${@}";
  4049. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  4050. local impls=(${PYTHON_COMPAT_OVERRIDE});
  4051. [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-any-r1";
  4052. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  4053. ewarn "implementation will be used:";
  4054. ewarn;
  4055. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  4056. ewarn;
  4057. ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored.";
  4058. _python_export "${impls[0]}" EPYTHON PYTHON;
  4059. _python_wrapper_setup;
  4060. einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT_OVERRIDE)";
  4061. return;
  4062. fi;
  4063. local epython_impl=${EPYTHON/./_};
  4064. if [[ -n ${epython_impl} ]]; then
  4065. if ! has "${epython_impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
  4066. if ! has "${epython_impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
  4067. ewarn "Invalid EPYTHON: ${EPYTHON}";
  4068. else
  4069. einfo "EPYTHON (${EPYTHON}) not supported by the package";
  4070. fi;
  4071. else
  4072. if _python_run_check_deps "${epython_impl}"; then
  4073. _python_export EPYTHON PYTHON;
  4074. _python_wrapper_setup;
  4075. einfo "Using ${EPYTHON} to build (via EPYTHON)";
  4076. return;
  4077. fi;
  4078. fi;
  4079. fi;
  4080. local i;
  4081. for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  4082. do
  4083. local impl=${_PYTHON_SUPPORTED_IMPLS[i]};
  4084. [[ ${impl} == ${epython_impl} ]] && continue;
  4085. _python_export "${impl}" EPYTHON PYTHON;
  4086. if _python_run_check_deps "${impl}"; then
  4087. _python_wrapper_setup;
  4088. einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT iteration)";
  4089. return;
  4090. fi;
  4091. done;
  4092. eerror "No Python implementation found for the build. This is usually";
  4093. eerror "a bug in the ebuild. Please report it to bugs.gentoo.org";
  4094. eerror "along with the build log.";
  4095. echo;
  4096. die "No supported Python implementation installed."
  4097. }
  4098. qeerror ()
  4099. {
  4100. qout eerror "${@}"
  4101. }
  4102. qeinfo ()
  4103. {
  4104. qout einfo "${@}"
  4105. }
  4106. qewarn ()
  4107. {
  4108. qout ewarn "${@}"
  4109. }
  4110. qout ()
  4111. {
  4112. local outputmsg type;
  4113. type=${1};
  4114. shift;
  4115. outputmsg="${@}";
  4116. case "${EBUILD_PHASE}" in
  4117. depend)
  4118. unset outputmsg
  4119. ;;
  4120. clean)
  4121. unset outputmsg
  4122. ;;
  4123. preinst)
  4124. unset outputmsg
  4125. ;;
  4126. esac;
  4127. [[ -n "${outputmsg}" ]] && ${type} "${outputmsg}"
  4128. }
  4129. raw-ldflags ()
  4130. {
  4131. local x input="$@";
  4132. [[ -z ${input} ]] && input=${LDFLAGS};
  4133. set --;
  4134. for x in ${input};
  4135. do
  4136. case ${x} in
  4137. -Wl,*)
  4138. x=${x#-Wl,};
  4139. set -- "$@" ${x//,/ }
  4140. ;;
  4141. *)
  4142.  
  4143. ;;
  4144. esac;
  4145. done;
  4146. echo "$@"
  4147. }
  4148. readme.gentoo_create_doc ()
  4149. {
  4150. debug-print-function ${FUNCNAME} "${@}";
  4151. if [[ -n "${DOC_CONTENTS}" ]]; then
  4152. if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
  4153. echo "${DOC_CONTENTS}" > "${T}"/README.gentoo || die;
  4154. else
  4155. local saved_flags=$-;
  4156. set -f;
  4157. echo -e ${DOC_CONTENTS} | fold -s -w 70 | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo;
  4158. assert;
  4159. set +f -${saved_flags};
  4160. fi;
  4161. else
  4162. if [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
  4163. cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die;
  4164. else
  4165. if [[ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]]; then
  4166. cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die;
  4167. else
  4168. die "You are not specifying README.gentoo contents!";
  4169. fi;
  4170. fi;
  4171. fi;
  4172. ( docinto .;
  4173. dodoc "${T}"/README.gentoo ) || die;
  4174. README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
  4175. }
  4176. readme.gentoo_print_elog ()
  4177. {
  4178. debug-print-function ${FUNCNAME} "${@}";
  4179. if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
  4180. die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!";
  4181. else
  4182. if ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
  4183. echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do
  4184. elog "${ELINE}";
  4185. done;
  4186. elog "";
  4187. elog "(Note: Above message is only printed the first time package is";
  4188. elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*";
  4189. elog "for future reference)";
  4190. fi;
  4191. fi
  4192. }
  4193. replace-cpu-flags ()
  4194. {
  4195. local newcpu="$#";
  4196. newcpu="${!newcpu}";
  4197. while [ $# -gt 1 ]; do
  4198. replace-flags "-march=${1}" "-march=${newcpu}";
  4199. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  4200. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  4201. shift;
  4202. done;
  4203. return 0
  4204. }
  4205. replace-flags ()
  4206. {
  4207. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  4208. local f var new;
  4209. for var in $(all-flag-vars);
  4210. do
  4211. new=();
  4212. for f in ${!var};
  4213. do
  4214. [[ ${f} == ${1} ]] && f=${2};
  4215. new+=("${f}");
  4216. done;
  4217. export ${var}="${new[*]}";
  4218. done;
  4219. return 0
  4220. }
  4221. replace-sparc64-flags ()
  4222. {
  4223. [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments";
  4224. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  4225. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  4226. for x in ${SPARC64_CPUS};
  4227. do
  4228. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  4229. done;
  4230. else
  4231. for x in ${SPARC64_CPUS};
  4232. do
  4233. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  4234. done;
  4235. fi;
  4236. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  4237. for x in ${SPARC64_CPUS};
  4238. do
  4239. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  4240. done;
  4241. else
  4242. for x in ${SPARC64_CPUS};
  4243. do
  4244. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  4245. done;
  4246. fi;
  4247. export CFLAGS CXXFLAGS
  4248. }
  4249. require_configured_kernel ()
  4250. {
  4251. [[ -n ${SKIP_KERNEL_CHECK} ]] && return;
  4252. if ! use kernel_linux; then
  4253. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  4254. fi;
  4255. if ! linux_config_src_exists; then
  4256. qeerror "Could not find a usable .config in the kernel source directory.";
  4257. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  4258. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  4259. qeerror "it points to the necessary object directory so that it might find .config.";
  4260. die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  4261. fi;
  4262. get_version || die "Unable to determine configured kernel version"
  4263. }
  4264. run_in_build_dir ()
  4265. {
  4266. debug-print-function ${FUNCNAME} "${@}";
  4267. local ret;
  4268. [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified.";
  4269. [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set.";
  4270. mkdir -p "${BUILD_DIR}" || die;
  4271. pushd "${BUILD_DIR}" > /dev/null || die;
  4272. "${@}";
  4273. ret=${?};
  4274. popd > /dev/null || die;
  4275. return ${ret}
  4276. }
  4277. set_arch_to_kernel ()
  4278. {
  4279. export ARCH=$(tc-arch-kernel)
  4280. }
  4281. set_arch_to_pkgmgr ()
  4282. {
  4283. export ARCH=$(tc-arch)
  4284. }
  4285. setup-allowed-flags ()
  4286. {
  4287. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  4288. _setup-allowed-flags "$@"
  4289. }
  4290. src_compile ()
  4291. {
  4292. meson-multilib_src_compile "$@"
  4293. }
  4294. src_configure ()
  4295. {
  4296. meson-multilib_src_configure "$@"
  4297. }
  4298. src_install ()
  4299. {
  4300. meson-multilib_src_install "$@"
  4301. }
  4302. src_prepare ()
  4303. {
  4304. DOC_CONTENTS="To modify system network connections without needing to enter the
  4305. root password, add your user account to the 'plugdev' group.";
  4306. default;
  4307. use vala && vala_setup;
  4308. sed -i -e 's#/usr/bin/sed#/bin/sed#' data/84-nm-drivers.rules || die
  4309. }
  4310. src_test ()
  4311. {
  4312. meson-multilib_src_test "$@"
  4313. }
  4314. src_unpack ()
  4315. {
  4316. default
  4317. }
  4318. strip-flags ()
  4319. {
  4320. [[ $# -ne 0 ]] && die "strip-flags takes no arguments";
  4321. local x y var;
  4322. local ALLOWED_FLAGS;
  4323. _setup-allowed-flags;
  4324. set -f;
  4325. for var in $(all-flag-vars);
  4326. do
  4327. local new=();
  4328. for x in ${!var};
  4329. do
  4330. for y in "${ALLOWED_FLAGS[@]}";
  4331. do
  4332. if [[ ${x} == ${y} ]]; then
  4333. new+=("${x}");
  4334. break;
  4335. fi;
  4336. done;
  4337. done;
  4338. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  4339. new+=(-O2);
  4340. fi;
  4341. if [[ ${!var} != "${new[*]}" ]]; then
  4342. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  4343. fi;
  4344. export ${var}="${new[*]}";
  4345. done;
  4346. set +f;
  4347. return 0
  4348. }
  4349. strip-unsupported-flags ()
  4350. {
  4351. [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments";
  4352. export CFLAGS=$(test-flags-CC ${CFLAGS});
  4353. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  4354. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  4355. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  4356. export LDFLAGS=$(test-flags-CCLD ${LDFLAGS})
  4357. }
  4358. systemd_dounit ()
  4359. {
  4360. debug-print-function ${FUNCNAME} "${@}";
  4361. ( insopts -m 0644;
  4362. insinto "$(_systemd_unprefix systemd_get_systemunitdir)";
  4363. doins "${@}" )
  4364. }
  4365. systemd_douserunit ()
  4366. {
  4367. debug-print-function ${FUNCNAME} "${@}";
  4368. ( insopts -m 0644;
  4369. insinto "$(_systemd_unprefix systemd_get_userunitdir)";
  4370. doins "${@}" )
  4371. }
  4372. systemd_enable_ntpunit ()
  4373. {
  4374. debug-print-function ${FUNCNAME} "${@}";
  4375. if [[ ${#} -lt 2 ]]; then
  4376. die "Usage: systemd_enable_ntpunit <NN-name> <service>...";
  4377. fi;
  4378. local ntpunit_name=${1};
  4379. local services=("${@:2}");
  4380. if [[ ${ntpunit_name} != [0-9][0-9]-* ]]; then
  4381. die "ntpunit.d file must be named NN-name where NN are digits.";
  4382. else
  4383. if [[ ${ntpunit_name} == *.list ]]; then
  4384. die "The .list suffix is appended implicitly to ntpunit.d name.";
  4385. fi;
  4386. fi;
  4387. local unitdir=$(systemd_get_systemunitdir);
  4388. local s;
  4389. for s in "${services[@]}";
  4390. do
  4391. if [[ ! -f "${D}${unitdir}/${s}" ]]; then
  4392. die "ntp-units.d provider ${s} not installed (yet?) in \${D}.";
  4393. fi;
  4394. echo "${s}" >> "${T}"/${ntpunit_name}.list || die;
  4395. done;
  4396. ( insopts -m 0644;
  4397. insinto "$(_systemd_unprefix systemd_get_utildir)"/ntp-units.d;
  4398. doins "${T}"/${ntpunit_name}.list );
  4399. local ret=${?};
  4400. rm "${T}"/${ntpunit_name}.list || die;
  4401. return ${ret}
  4402. }
  4403. systemd_enable_service ()
  4404. {
  4405. debug-print-function ${FUNCNAME} "${@}";
  4406. [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service";
  4407. local target=${1};
  4408. local service=${2};
  4409. local ud=$(_systemd_unprefix systemd_get_systemunitdir);
  4410. local destname=${service##*/};
  4411. dodir "${ud}"/"${target}".wants && dosym ../"${service}" "${ud}"/"${target}".wants/"${destname}"
  4412. }
  4413. systemd_get_sleepdir ()
  4414. {
  4415. debug-print-function ${FUNCNAME} "${@}";
  4416. _systemd_get_dir systemdsleepdir /lib/systemd/system-sleep
  4417. }
  4418. systemd_get_systemgeneratordir ()
  4419. {
  4420. debug-print-function ${FUNCNAME} "${@}";
  4421. _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators
  4422. }
  4423. systemd_get_systempresetdir ()
  4424. {
  4425. debug-print-function ${FUNCNAME} "${@}";
  4426. _systemd_get_dir systemdsystempresetdir /lib/systemd/system-preset
  4427. }
  4428. systemd_get_systemunitdir ()
  4429. {
  4430. debug-print-function ${FUNCNAME} "${@}";
  4431. _systemd_get_dir systemdsystemunitdir /lib/systemd/system
  4432. }
  4433. systemd_get_unitdir ()
  4434. {
  4435. [[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI 6, use systemd_get_systemunitdir instead";
  4436. systemd_get_systemunitdir
  4437. }
  4438. systemd_get_userunitdir ()
  4439. {
  4440. debug-print-function ${FUNCNAME} "${@}";
  4441. _systemd_get_dir systemduserunitdir /usr/lib/systemd/user
  4442. }
  4443. systemd_get_utildir ()
  4444. {
  4445. debug-print-function ${FUNCNAME} "${@}";
  4446. _systemd_get_dir systemdutildir /lib/systemd
  4447. }
  4448. systemd_install_serviced ()
  4449. {
  4450. debug-print-function ${FUNCNAME} "${@}";
  4451. local src=${1};
  4452. local service=${2};
  4453. [[ -n ${src} ]] || die "No file specified";
  4454. if [[ ! -n ${service} ]]; then
  4455. [[ ${src} == *.conf ]] || die "Source file needs .conf suffix";
  4456. service=${src##*/};
  4457. service=${service%.conf};
  4458. fi;
  4459. [[ ${service} == *.d ]] && die "Service must not have .d suffix";
  4460. ( insopts -m 0644;
  4461. insinto /etc/systemd/system/"${service}".d;
  4462. newins "${src}" 00gentoo.conf )
  4463. }
  4464. systemd_is_booted ()
  4465. {
  4466. debug-print-function ${FUNCNAME} "${@}";
  4467. [[ -d /run/systemd/system ]];
  4468. local ret=${?};
  4469. debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}";
  4470. return ${ret}
  4471. }
  4472. systemd_newunit ()
  4473. {
  4474. debug-print-function ${FUNCNAME} "${@}";
  4475. ( insopts -m 0644;
  4476. insinto "$(_systemd_unprefix systemd_get_systemunitdir)";
  4477. newins "${@}" )
  4478. }
  4479. systemd_newuserunit ()
  4480. {
  4481. debug-print-function ${FUNCNAME} "${@}";
  4482. ( insopts -m 0644;
  4483. insinto "$(_systemd_unprefix systemd_get_userunitdir)";
  4484. newins "${@}" )
  4485. }
  4486. systemd_reenable ()
  4487. {
  4488. type systemctl &> /dev/null || return 0;
  4489. local x;
  4490. for x in "$@";
  4491. do
  4492. if systemctl --quiet --root="${ROOT:-/}" is-enabled "${x}"; then
  4493. systemctl --root="${ROOT:-/}" reenable "${x}";
  4494. fi;
  4495. done
  4496. }
  4497. systemd_update_catalog ()
  4498. {
  4499. debug-print-function ${FUNCNAME} "${@}";
  4500. [[ ${EBUILD_PHASE} == post* ]] || die "${FUNCNAME} disallowed during ${EBUILD_PHASE_FUNC:-${EBUILD_PHASE}}";
  4501. local journalctl=${EPREFIX}/usr/bin/journalctl;
  4502. if [[ -x ${journalctl} ]]; then
  4503. ebegin "Updating systemd journal catalogs";
  4504. journalctl --update-catalog;
  4505. eend $?;
  4506. else
  4507. debug-print "${FUNCNAME}: journalctl not found.";
  4508. fi
  4509. }
  4510. systemd_with_unitdir ()
  4511. {
  4512. [[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-${1:-systemdsystemunitdir}=\"\$(systemd_get_systemunitdir)\" instead";
  4513. debug-print-function ${FUNCNAME} "${@}";
  4514. local optname=${1:-systemdsystemunitdir};
  4515. echo --with-${optname}="$(systemd_get_systemunitdir)"
  4516. }
  4517. systemd_with_utildir ()
  4518. {
  4519. [[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-systemdutildir=\"\$(systemd_get_utildir)\" instead";
  4520. debug-print-function ${FUNCNAME} "${@}";
  4521. echo --with-systemdutildir="$(systemd_get_utildir)"
  4522. }
  4523. tc-arch ()
  4524. {
  4525. tc-ninja_magic_to_arch portage "$@"
  4526. }
  4527. tc-arch-kernel ()
  4528. {
  4529. tc-ninja_magic_to_arch kern "$@"
  4530. }
  4531. tc-check-openmp ()
  4532. {
  4533. if ! _tc-has-openmp; then
  4534. eerror "Your current compiler does not support OpenMP!";
  4535. if tc-is-gcc; then
  4536. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  4537. else
  4538. if tc-is-clang; then
  4539. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  4540. fi;
  4541. fi;
  4542. die "Active compiler does not have required support for OpenMP";
  4543. fi
  4544. }
  4545. tc-cpp-is-true ()
  4546. {
  4547. local CONDITION=${1};
  4548. shift;
  4549. $(tc-getTARGET_CPP) "${@}" -P - <<-EOF > /dev/null 2>&1
  4550. #if ${CONDITION}
  4551. true
  4552. #else
  4553. #error false
  4554. #endif
  4555. EOF
  4556.  
  4557. }
  4558. tc-detect-is-softfloat ()
  4559. {
  4560. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  4561. case ${CTARGET:-${CHOST}} in
  4562. *-newlib | *-elf | *-eabi)
  4563. return 1
  4564. ;;
  4565. arm*)
  4566. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  4567. echo "no";
  4568. else
  4569. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  4570. echo "yes";
  4571. else
  4572. echo "softfp";
  4573. fi;
  4574. fi;
  4575. return 0
  4576. ;;
  4577. *)
  4578. return 1
  4579. ;;
  4580. esac
  4581. }
  4582. tc-enables-cxx-assertions ()
  4583. {
  4584. tc-cpp-is-true "defined(_GLIBCXX_ASSERTIONS) || defined(_LIBCPP_ENABLE_ASSERTIONS) || defined(_LIBCPP_ENABLE_HARDENED_MODE)" ${CPPFLAGS} ${CXXFLAGS}
  4585. }
  4586. tc-enables-fortify-source ()
  4587. {
  4588. tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4589. }
  4590. tc-enables-pie ()
  4591. {
  4592. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4593. }
  4594. tc-enables-ssp ()
  4595. {
  4596. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4597. }
  4598. tc-enables-ssp-all ()
  4599. {
  4600. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4601. }
  4602. tc-enables-ssp-strong ()
  4603. {
  4604. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4605. }
  4606. tc-endian ()
  4607. {
  4608. local host=$1;
  4609. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4610. host=${host%%-*};
  4611. case ${host} in
  4612. aarch64*be)
  4613. echo big
  4614. ;;
  4615. aarch64)
  4616. echo little
  4617. ;;
  4618. alpha*)
  4619. echo little
  4620. ;;
  4621. arm*b*)
  4622. echo big
  4623. ;;
  4624. arm*)
  4625. echo little
  4626. ;;
  4627. cris*)
  4628. echo little
  4629. ;;
  4630. hppa*)
  4631. echo big
  4632. ;;
  4633. i?86*)
  4634. echo little
  4635. ;;
  4636. ia64*)
  4637. echo little
  4638. ;;
  4639. loongarch*)
  4640. echo little
  4641. ;;
  4642. m68*)
  4643. echo big
  4644. ;;
  4645. mips*l*)
  4646. echo little
  4647. ;;
  4648. mips*)
  4649. echo big
  4650. ;;
  4651. powerpc*le)
  4652. echo little
  4653. ;;
  4654. powerpc*)
  4655. echo big
  4656. ;;
  4657. riscv*)
  4658. echo little
  4659. ;;
  4660. s390*)
  4661. echo big
  4662. ;;
  4663. sh*b*)
  4664. echo big
  4665. ;;
  4666. sh*)
  4667. echo little
  4668. ;;
  4669. sparc*)
  4670. echo big
  4671. ;;
  4672. x86_64*)
  4673. echo little
  4674. ;;
  4675. *)
  4676. echo wtf
  4677. ;;
  4678. esac
  4679. }
  4680. tc-env_build ()
  4681. {
  4682. tc-export_build_env;
  4683. 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) "$@"
  4684. }
  4685. tc-export ()
  4686. {
  4687. local var;
  4688. for var in "$@";
  4689. do
  4690. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4691. "tc-get${var}" > /dev/null;
  4692. done
  4693. }
  4694. tc-export_build_env ()
  4695. {
  4696. tc-export "$@";
  4697. if tc-is-cross-compiler; then
  4698. : "${BUILD_CFLAGS:=-O1 -pipe}";
  4699. : "${BUILD_CXXFLAGS:=-O1 -pipe}";
  4700. : "${BUILD_CPPFLAGS:= }";
  4701. : "${BUILD_LDFLAGS:= }";
  4702. else
  4703. : "${BUILD_CFLAGS:=${CFLAGS}}";
  4704. : "${BUILD_CXXFLAGS:=${CXXFLAGS}}";
  4705. : "${BUILD_CPPFLAGS:=${CPPFLAGS}}";
  4706. : "${BUILD_LDFLAGS:=${LDFLAGS}}";
  4707. fi;
  4708. export BUILD_{C,CXX,CPP,LD}FLAGS;
  4709. local v;
  4710. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4711. do
  4712. export ${v#BUILD_}_FOR_BUILD="${!v}";
  4713. done
  4714. }
  4715. tc-get-c-rtlib ()
  4716. {
  4717. local res=$(
  4718. $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name 2>/dev/null
  4719. );
  4720. case ${res} in
  4721. *libclang_rt*)
  4722. echo compiler-rt
  4723. ;;
  4724. *libgcc*)
  4725. echo libgcc
  4726. ;;
  4727. *)
  4728. return 1
  4729. ;;
  4730. esac;
  4731. return 0
  4732. }
  4733. tc-get-compiler-type ()
  4734. {
  4735. local code='
  4736. #if defined(__PATHSCALE__)
  4737. HAVE_PATHCC
  4738. #elif defined(__clang__)
  4739. HAVE_CLANG
  4740. #elif defined(__GNUC__)
  4741. HAVE_GCC
  4742. #endif
  4743. ';
  4744. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4745. case ${res} in
  4746. *HAVE_PATHCC*)
  4747. echo pathcc
  4748. ;;
  4749. *HAVE_CLANG*)
  4750. echo clang
  4751. ;;
  4752. *HAVE_GCC*)
  4753. echo gcc
  4754. ;;
  4755. *)
  4756. echo unknown
  4757. ;;
  4758. esac
  4759. }
  4760. tc-get-cxx-stdlib ()
  4761. {
  4762. local code='#include <ciso646>
  4763.  
  4764. #if defined(_LIBCPP_VERSION)
  4765. HAVE_LIBCXX
  4766. #elif defined(__GLIBCXX__)
  4767. HAVE_LIBSTDCPP
  4768. #endif
  4769. ';
  4770. local res=$(
  4771. $(tc-getCXX) ${CPPFLAGS} ${CXXFLAGS} -x c++ -E -P - <<<"${code}" 2>/dev/null
  4772. );
  4773. case ${res} in
  4774. *HAVE_LIBCXX*)
  4775. echo libc++
  4776. ;;
  4777. *HAVE_LIBSTDCPP*)
  4778. echo libstdc++
  4779. ;;
  4780. *)
  4781. return 1
  4782. ;;
  4783. esac;
  4784. return 0
  4785. }
  4786. tc-getAR ()
  4787. {
  4788. tc-getPROG AR ar "$@"
  4789. }
  4790. tc-getAS ()
  4791. {
  4792. tc-getPROG AS as "$@"
  4793. }
  4794. tc-getBUILD_AR ()
  4795. {
  4796. tc-getBUILD_PROG AR ar "$@"
  4797. }
  4798. tc-getBUILD_AS ()
  4799. {
  4800. tc-getBUILD_PROG AS as "$@"
  4801. }
  4802. tc-getBUILD_CC ()
  4803. {
  4804. tc-getBUILD_PROG CC gcc "$@"
  4805. }
  4806. tc-getBUILD_CPP ()
  4807. {
  4808. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4809. }
  4810. tc-getBUILD_CXX ()
  4811. {
  4812. tc-getBUILD_PROG CXX g++ "$@"
  4813. }
  4814. tc-getBUILD_LD ()
  4815. {
  4816. tc-getBUILD_PROG LD ld "$@"
  4817. }
  4818. tc-getBUILD_NM ()
  4819. {
  4820. tc-getBUILD_PROG NM nm "$@"
  4821. }
  4822. tc-getBUILD_OBJCOPY ()
  4823. {
  4824. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4825. }
  4826. tc-getBUILD_PKG_CONFIG ()
  4827. {
  4828. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4829. }
  4830. tc-getBUILD_PROG ()
  4831. {
  4832. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4833. tc-is-cross-compiler || vars+=" $1";
  4834. _tc-getPROG CBUILD "${vars}" "${@:2}"
  4835. }
  4836. tc-getBUILD_RANLIB ()
  4837. {
  4838. tc-getBUILD_PROG RANLIB ranlib "$@"
  4839. }
  4840. tc-getBUILD_READELF ()
  4841. {
  4842. tc-getBUILD_PROG READELF readelf "$@"
  4843. }
  4844. tc-getBUILD_STRINGS ()
  4845. {
  4846. tc-getBUILD_PROG STRINGS strings "$@"
  4847. }
  4848. tc-getBUILD_STRIP ()
  4849. {
  4850. tc-getBUILD_PROG STRIP strip "$@"
  4851. }
  4852. tc-getCC ()
  4853. {
  4854. tc-getPROG CC gcc "$@"
  4855. }
  4856. tc-getCPP ()
  4857. {
  4858. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4859. }
  4860. tc-getCXX ()
  4861. {
  4862. tc-getPROG CXX g++ "$@"
  4863. }
  4864. tc-getDLLWRAP ()
  4865. {
  4866. tc-getPROG DLLWRAP dllwrap "$@"
  4867. }
  4868. tc-getF77 ()
  4869. {
  4870. tc-getPROG F77 gfortran "$@"
  4871. }
  4872. tc-getFC ()
  4873. {
  4874. tc-getPROG FC gfortran "$@"
  4875. }
  4876. tc-getGCJ ()
  4877. {
  4878. tc-getPROG GCJ gcj "$@"
  4879. }
  4880. tc-getGO ()
  4881. {
  4882. tc-getPROG GO gccgo "$@"
  4883. }
  4884. tc-getLD ()
  4885. {
  4886. tc-getPROG LD ld "$@"
  4887. }
  4888. tc-getNM ()
  4889. {
  4890. tc-getPROG NM nm "$@"
  4891. }
  4892. tc-getOBJCOPY ()
  4893. {
  4894. tc-getPROG OBJCOPY objcopy "$@"
  4895. }
  4896. tc-getOBJDUMP ()
  4897. {
  4898. tc-getPROG OBJDUMP objdump "$@"
  4899. }
  4900. tc-getPKG_CONFIG ()
  4901. {
  4902. tc-getPROG PKG_CONFIG pkg-config "$@"
  4903. }
  4904. tc-getPROG ()
  4905. {
  4906. _tc-getPROG CHOST "$@"
  4907. }
  4908. tc-getRANLIB ()
  4909. {
  4910. tc-getPROG RANLIB ranlib "$@"
  4911. }
  4912. tc-getRC ()
  4913. {
  4914. tc-getPROG RC windres "$@"
  4915. }
  4916. tc-getREADELF ()
  4917. {
  4918. tc-getPROG READELF readelf "$@"
  4919. }
  4920. tc-getSTRINGS ()
  4921. {
  4922. tc-getPROG STRINGS strings "$@"
  4923. }
  4924. tc-getSTRIP ()
  4925. {
  4926. tc-getPROG STRIP strip "$@"
  4927. }
  4928. tc-getTARGET_CPP ()
  4929. {
  4930. if [[ -n ${CTARGET} ]]; then
  4931. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4932. else
  4933. tc-getCPP "$@";
  4934. fi
  4935. }
  4936. tc-has-tls ()
  4937. {
  4938. local base="${T}/test-tc-tls";
  4939. cat <<-EOF > "${base}.c"
  4940. int foo(int *i) {
  4941. static __thread int j = 0;
  4942. return *i ? j : *i;
  4943. }
  4944. EOF
  4945.  
  4946. local flags;
  4947. case $1 in
  4948. -s)
  4949. flags="-S"
  4950. ;;
  4951. -c)
  4952. flags="-c"
  4953. ;;
  4954. -l)
  4955.  
  4956. ;;
  4957. -*)
  4958. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4959. ;;
  4960. esac;
  4961. : "${flags:=-fPIC -shared -Wl,-z,defs}";
  4962. [[ $1 == -* ]] && shift;
  4963. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4964. local ret=$?;
  4965. rm -f "${base}"*;
  4966. return ${ret}
  4967. }
  4968. tc-is-clang ()
  4969. {
  4970. [[ $(tc-get-compiler-type) == clang ]]
  4971. }
  4972. tc-is-cross-compiler ()
  4973. {
  4974. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4975. }
  4976. tc-is-gcc ()
  4977. {
  4978. [[ $(tc-get-compiler-type) == gcc ]]
  4979. }
  4980. tc-is-softfloat ()
  4981. {
  4982. tc-detect-is-softfloat || tc-tuple-is-softfloat
  4983. }
  4984. tc-is-static-only ()
  4985. {
  4986. local host=${CTARGET:-${CHOST}};
  4987. [[ ${host} == *-mint* ]]
  4988. }
  4989. tc-ld-disable-gold ()
  4990. {
  4991. tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
  4992. }
  4993. tc-ld-force-bfd ()
  4994. {
  4995. if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@"; then
  4996. return;
  4997. fi;
  4998. ewarn "Forcing usage of the BFD linker";
  4999. local ld=$(tc-getLD "$@");
  5000. local bfd_ld="${ld%% *}.bfd";
  5001. local path_ld=$(type -P "${bfd_ld}" 2>/dev/null);
  5002. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  5003. if tc-is-gcc || tc-is-clang; then
  5004. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  5005. fi
  5006. }
  5007. tc-ld-is-gold ()
  5008. {
  5009. local out;
  5010. local -x LC_ALL=C;
  5011. out=$($(tc-getLD "$@") --version 2>&1);
  5012. if [[ ${out} == *"GNU gold"* ]]; then
  5013. return 0;
  5014. fi;
  5015. local base="${T}/test-tc-gold";
  5016. cat <<-EOF > "${base}.c"
  5017. int main(void) { return 0; }
  5018. EOF
  5019.  
  5020. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  5021. rm -f "${base}"*;
  5022. if [[ ${out} == *"GNU gold"* ]]; then
  5023. return 0;
  5024. fi;
  5025. return 1
  5026. }
  5027. tc-ld-is-lld ()
  5028. {
  5029. local out;
  5030. local -x LC_ALL=C;
  5031. out=$($(tc-getLD "$@") --version 2>&1);
  5032. if [[ ${out} == *"LLD"* ]]; then
  5033. return 0;
  5034. fi;
  5035. local base="${T}/test-tc-lld";
  5036. cat <<-EOF > "${base}.c"
  5037. int main(void) { return 0; }
  5038. EOF
  5039.  
  5040. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  5041. rm -f "${base}"*;
  5042. if [[ ${out} == *"LLD"* ]]; then
  5043. return 0;
  5044. fi;
  5045. return 1
  5046. }
  5047. tc-ninja_magic_to_arch ()
  5048. {
  5049. function _tc_echo_kernel_alias ()
  5050. {
  5051. [[ ${type} == "kern" ]] && echo $1 || echo $2
  5052. };
  5053. local type=$1;
  5054. local host=$2;
  5055. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  5056. case ${host} in
  5057. aarch64*)
  5058. echo arm64
  5059. ;;
  5060. alpha*)
  5061. echo alpha
  5062. ;;
  5063. arm*)
  5064. echo arm
  5065. ;;
  5066. avr*)
  5067. _tc_echo_kernel_alias avr32 avr
  5068. ;;
  5069. bfin*)
  5070. _tc_echo_kernel_alias blackfin bfin
  5071. ;;
  5072. c6x*)
  5073. echo c6x
  5074. ;;
  5075. cris*)
  5076. echo cris
  5077. ;;
  5078. frv*)
  5079. echo frv
  5080. ;;
  5081. hexagon*)
  5082. echo hexagon
  5083. ;;
  5084. hppa*)
  5085. _tc_echo_kernel_alias parisc hppa
  5086. ;;
  5087. i?86*)
  5088. echo x86
  5089. ;;
  5090. ia64*)
  5091. echo ia64
  5092. ;;
  5093. loongarch*)
  5094. _tc_echo_kernel_alias loongarch loong
  5095. ;;
  5096. m68*)
  5097. echo m68k
  5098. ;;
  5099. metag*)
  5100. echo metag
  5101. ;;
  5102. microblaze*)
  5103. echo microblaze
  5104. ;;
  5105. mips*)
  5106. echo mips
  5107. ;;
  5108. nios2*)
  5109. echo nios2
  5110. ;;
  5111. nios*)
  5112. echo nios
  5113. ;;
  5114. or1k* | or32*)
  5115. echo openrisc
  5116. ;;
  5117. powerpc*)
  5118. if [[ ${type} == "kern" ]]; then
  5119. echo powerpc;
  5120. else
  5121. if [[ ${host} == powerpc64* ]]; then
  5122. echo ppc64;
  5123. else
  5124. echo ppc;
  5125. fi;
  5126. fi
  5127. ;;
  5128. riscv*)
  5129. echo riscv
  5130. ;;
  5131. s390*)
  5132. echo s390
  5133. ;;
  5134. score*)
  5135. echo score
  5136. ;;
  5137. sh64*)
  5138. _tc_echo_kernel_alias sh64 sh
  5139. ;;
  5140. sh*)
  5141. echo sh
  5142. ;;
  5143. sparc64*)
  5144. _tc_echo_kernel_alias sparc64 sparc
  5145. ;;
  5146. sparc*)
  5147. [[ ${PROFILE_ARCH} == "sparc64" ]] && _tc_echo_kernel_alias sparc64 sparc || echo sparc
  5148. ;;
  5149. tile*)
  5150. echo tile
  5151. ;;
  5152. vax*)
  5153. echo vax
  5154. ;;
  5155. x86_64*)
  5156. if [[ ${type} == "kern" ]]; then
  5157. echo x86;
  5158. else
  5159. echo amd64;
  5160. fi
  5161. ;;
  5162. xtensa*)
  5163. echo xtensa
  5164. ;;
  5165. *)
  5166. echo unknown
  5167. ;;
  5168. esac
  5169. }
  5170. tc-stack-grows-down ()
  5171. {
  5172. case ${ARCH} in
  5173. hppa | metag)
  5174. return 1
  5175. ;;
  5176. esac;
  5177. return 0
  5178. }
  5179. tc-tuple-is-softfloat ()
  5180. {
  5181. local CTARGET=${CTARGET:-${CHOST}};
  5182. case ${CTARGET//_/-} in
  5183. bfin* | h8300*)
  5184. echo "only"
  5185. ;;
  5186. *-softfloat-*)
  5187. echo "yes"
  5188. ;;
  5189. *-softfp-*)
  5190. echo "softfp"
  5191. ;;
  5192. arm*-hardfloat-* | arm*eabihf)
  5193. echo "no"
  5194. ;;
  5195. *-newlib | *-elf | *-eabi)
  5196. echo "no"
  5197. ;;
  5198. arm*)
  5199. echo "yes"
  5200. ;;
  5201. *)
  5202. echo "no"
  5203. ;;
  5204. esac
  5205. }
  5206. test-compile ()
  5207. {
  5208. local lang=$1;
  5209. local code=$2;
  5210. shift 2;
  5211. [[ -z "${lang}" ]] && return 1;
  5212. [[ -z "${code}" ]] && return 1;
  5213. local compiler filename_in filename_out args=() libs=();
  5214. case "${lang}" in
  5215. c)
  5216. compiler="$(tc-getCC)";
  5217. filename_in="${T}/test.c";
  5218. filename_out="${T}/test.o";
  5219. args+=(${CFLAGS[@]} -xc -c)
  5220. ;;
  5221. c++)
  5222. compiler="$(tc-getCXX)";
  5223. filename_in="${T}/test.cc";
  5224. filename_out="${T}/test.o";
  5225. args+=(${CXXFLAGS[@]} -xc++ -c)
  5226. ;;
  5227. f77)
  5228. compiler="$(tc-getF77)";
  5229. filename_in="${T}/test.f";
  5230. filename_out="${T}/test.o";
  5231. args+=(${FFFLAGS[@]} -xf77 -c)
  5232. ;;
  5233. f95)
  5234. compiler="$(tc-getFC)";
  5235. filename_in="${T}/test.f90";
  5236. filename_out="${T}/test.o";
  5237. args+=(${FCFLAGS[@]} -xf95 -c)
  5238. ;;
  5239. c+ld)
  5240. compiler="$(tc-getCC)";
  5241. filename_in="${T}/test.c";
  5242. filename_out="${T}/test.exe";
  5243. args+=(${CFLAGS[@]} ${LDFLAGS[@]} -xc);
  5244. libs+=(${LIBS[@]})
  5245. ;;
  5246. c+++ld)
  5247. compiler="$(tc-getCXX)";
  5248. filename_in="${T}/test.cc";
  5249. filename_out="${T}/test.exe";
  5250. args+=(${CXXFLAGS[@]} ${LDFLAGS[@]} -xc++);
  5251. libs+=(${LIBS[@]})
  5252. ;;
  5253. f77+ld)
  5254. compiler="$(tc-getF77)";
  5255. filename_in="${T}/test.f";
  5256. filename_out="${T}/test.exe";
  5257. args+=(${FFLAGS[@]} ${LDFLAGS[@]} -xf77);
  5258. libs+=(${LIBS[@]})
  5259. ;;
  5260. f95+ld)
  5261. compiler="$(tc-getFC)";
  5262. filename_in="${T}/test.f90";
  5263. filename_out="${T}/test.exe";
  5264. args+=(${FCFLAGS[@]} ${LDFLAGS[@]} -xf95);
  5265. libs+=(${LIBS[@]})
  5266. ;;
  5267. *)
  5268. die "Unknown compiled language ${lang}"
  5269. ;;
  5270. esac;
  5271. printf "%s\n" "${code}" > "${filename_in}" || die "Failed to create '${test_in}'";
  5272. "${compiler}" ${args[@]} "${filename_in}" -o "${filename_out}" ${libs[@]} &> /dev/null
  5273. }
  5274. test-flag-CC ()
  5275. {
  5276. _test-flag-PROG CC c "$@"
  5277. }
  5278. test-flag-CCLD ()
  5279. {
  5280. _test-flag-PROG CC c+ld "$@"
  5281. }
  5282. test-flag-CXX ()
  5283. {
  5284. _test-flag-PROG CXX c++ "$@"
  5285. }
  5286. test-flag-F77 ()
  5287. {
  5288. _test-flag-PROG F77 f77 "$@"
  5289. }
  5290. test-flag-FC ()
  5291. {
  5292. _test-flag-PROG FC f95 "$@"
  5293. }
  5294. test-flag-PROG ()
  5295. {
  5296. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  5297. _test-flag-PROG "$@"
  5298. }
  5299. test-flags ()
  5300. {
  5301. test-flags-CC "$@"
  5302. }
  5303. test-flags-CC ()
  5304. {
  5305. _test-flags-PROG CC "$@"
  5306. }
  5307. test-flags-CCLD ()
  5308. {
  5309. _test-flags-PROG CCLD "$@"
  5310. }
  5311. test-flags-CXX ()
  5312. {
  5313. _test-flags-PROG CXX "$@"
  5314. }
  5315. test-flags-F77 ()
  5316. {
  5317. _test-flags-PROG F77 "$@"
  5318. }
  5319. test-flags-FC ()
  5320. {
  5321. _test-flags-PROG FC "$@"
  5322. }
  5323. test-flags-PROG ()
  5324. {
  5325. [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  5326. _test-flags-PROG "$@"
  5327. }
  5328. test_version_info ()
  5329. {
  5330. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  5331. return 0;
  5332. else
  5333. return 1;
  5334. fi
  5335. }
  5336. udev_dorules ()
  5337. {
  5338. debug-print-function ${FUNCNAME} "${@}";
  5339. ( insopts -m 0644;
  5340. insinto "$(_udev_get_udevdir)"/rules.d;
  5341. doins "${@}" )
  5342. }
  5343. udev_get_udevdir ()
  5344. {
  5345. debug-print-function ${FUNCNAME} "${@}";
  5346. eerror "This ebuild should be using the get_udevdir() function instead of the deprecated udev_get_udevdir()";
  5347. die "Deprecated function call: udev_get_udevdir(), please report to (overlay) maintainers."
  5348. }
  5349. udev_newrules ()
  5350. {
  5351. debug-print-function ${FUNCNAME} "${@}";
  5352. ( insopts -m 0644;
  5353. insinto "$(_udev_get_udevdir)"/rules.d;
  5354. newins "${@}" )
  5355. }
  5356. udev_reload ()
  5357. {
  5358. if [[ -n ${ROOT%/} ]]; then
  5359. return 0;
  5360. fi;
  5361. if [[ -d ${ROOT}/run/udev ]]; then
  5362. ebegin "Running udev control --reload for reloading rules and databases";
  5363. udevadm control --reload;
  5364. eend $?;
  5365. fi
  5366. }
  5367. vala_api_versions ()
  5368. {
  5369. [[ ${VALA_MIN_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MIN_API_VERSION";
  5370. [[ ${VALA_MAX_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MAX_API_VERSION";
  5371. local minimal_supported_minor_version minor_version;
  5372. minimal_supported_minor_version="56";
  5373. for ((minor_version = ${VALA_MAX_API_VERSION#*.}; minor_version >= ${VALA_MIN_API_VERSION#*.}; minor_version = minor_version - 2))
  5374. do
  5375. if ((minor_version >= minimal_supported_minor_version)); then
  5376. echo "0.${minor_version}";
  5377. fi;
  5378. done
  5379. }
  5380. vala_best_api_version ()
  5381. {
  5382. local u v;
  5383. u=$(_vala_use_depend);
  5384. for v in $(vala_api_versions);
  5385. do
  5386. has_version -b "dev-lang/vala:${v}${u}" && echo "${v}" && return;
  5387. done
  5388. }
  5389. vala_depend ()
  5390. {
  5391. local u v;
  5392. u=$(_vala_use_depend);
  5393. echo -n "|| (";
  5394. for v in $(vala_api_versions);
  5395. do
  5396. echo -n " dev-lang/vala:${v}${u}";
  5397. done;
  5398. echo " )"
  5399. }
  5400. vala_setup ()
  5401. {
  5402. local p d valafoo version ignore_use;
  5403. while [[ -n $1 ]]; do
  5404. case $1 in
  5405. "--ignore-use")
  5406. ignore_use=1
  5407. ;;
  5408. "--vala-api-version")
  5409. shift;
  5410. version=$1;
  5411. [[ -n ${version} ]] || die "'--vala-api-version' option requires API version parameter."
  5412. ;;
  5413. esac;
  5414. shift;
  5415. done;
  5416. if [[ -z ${ignore_use} ]]; then
  5417. in_iuse vala && ! use vala && return 0;
  5418. fi;
  5419. if [[ -n ${version} ]]; then
  5420. has_version -b "dev-lang/vala:${version}" || die "No installed vala:${version}";
  5421. else
  5422. version=$(vala_best_api_version);
  5423. [[ -n ${version} ]] || die "No installed vala in $(vala_depend)";
  5424. fi;
  5425. export VALAC=$(type -P valac-${version});
  5426. valafoo=$(type -P vala-gen-introspect-${version});
  5427. [[ -n ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}";
  5428. valafoo=$(type -P vapigen-${version});
  5429. [[ -n ${valafoo} ]] && export VAPIGEN="${valafoo}";
  5430. valafoo=$(type -P valadoc-${version});
  5431. [[ -n ${valafoo} ]] && has valadoc ${VALA_USE_DEPEND} && export VALADOC="${valafoo}";
  5432. valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen";
  5433. [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}";
  5434. export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi";
  5435. mkdir -p "${T}/pkgconfig" || die "mkdir failed";
  5436. for p in libvala vapigen;
  5437. do
  5438. for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig";
  5439. do
  5440. if [[ -e ${d}/${p}-${version}.pc ]]; then
  5441. ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed";
  5442. break;
  5443. fi;
  5444. done;
  5445. done;
  5446. : "${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}";
  5447. export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}";
  5448. append-cflags $(test-flags-CC -Wno-incompatible-function-pointer-types)
  5449. }
  5450. ver_cut ()
  5451. {
  5452. local range=${1};
  5453. local v=${2:-${PV}};
  5454. local start end;
  5455. local -a comp;
  5456. __eapi7_ver_split "${v}";
  5457. local max=$((${#comp[@]}/2));
  5458. __eapi7_ver_parse_range "${range}" "${max}";
  5459. local IFS=;
  5460. if [[ ${start} -gt 0 ]]; then
  5461. start=$(( start*2 - 1 ));
  5462. fi;
  5463. echo "${comp[*]:start:end*2-start}"
  5464. }
  5465. ver_rs ()
  5466. {
  5467. local v;
  5468. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  5469. local start end i;
  5470. local -a comp;
  5471. __eapi7_ver_split "${v}";
  5472. local max=$((${#comp[@]}/2 - 1));
  5473. while [[ ${#} -ge 2 ]]; do
  5474. __eapi7_ver_parse_range "${1}" "${max}";
  5475. for ((i = start*2; i <= end*2; i+=2 ))
  5476. do
  5477. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  5478. comp[i]=${2};
  5479. done;
  5480. shift 2;
  5481. done;
  5482. local IFS=;
  5483. echo "${comp[*]}"
  5484. }
  5485. ver_test ()
  5486. {
  5487. local va op vb;
  5488. if [[ $# -eq 3 ]]; then
  5489. va=${1};
  5490. shift;
  5491. else
  5492. va=${PVR};
  5493. fi;
  5494. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  5495. op=${1};
  5496. vb=${2};
  5497. case ${op} in
  5498. -eq | -ne | -lt | -le | -gt | -ge)
  5499.  
  5500. ;;
  5501. *)
  5502. die "${FUNCNAME}: invalid operator: ${op}"
  5503. ;;
  5504. esac;
  5505. __eapi7_ver_compare "${va}" "${vb}";
  5506. test $? "${op}" 2
  5507. }
  5508. virtx ()
  5509. {
  5510. debug-print-function ${FUNCNAME} "$@";
  5511. [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument";
  5512. local i=0;
  5513. local retval=0;
  5514. local xvfbargs=(-screen 0 1280x1024x24 +extension RANDR);
  5515. debug-print "${FUNCNAME}: running Xvfb hack";
  5516. export XAUTHORITY=;
  5517. einfo "Starting Xvfb ...";
  5518. debug-print "${FUNCNAME}: Xvfb -displayfd 1 ${xvfbargs[*]}";
  5519. local logfile=${T}/Xvfb.log;
  5520. local pidfile=${T}/Xvfb.pid;
  5521. export DISPLAY=:$(
  5522. Xvfb -displayfd 1 "${xvfbargs[@]}" 2>"${logfile}" &
  5523. echo "$!" > "${pidfile}"
  5524. );
  5525. if [[ ${DISPLAY} == : ]]; then
  5526. eerror "Xvfb failed to start, reprinting error log";
  5527. cat "${logfile}";
  5528. die "Xvfb failed to start";
  5529. fi;
  5530. einfo "Xvfb started on DISPLAY=${DISPLAY}";
  5531. debug-print "${FUNCNAME}: $@";
  5532. nonfatal "$@";
  5533. retval=$?;
  5534. kill "$(<"${pidfile}")";
  5535. [[ ${retval} -ne 0 ]] && die "Failed to run '$@'";
  5536. return 0
  5537. }
  5538.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement