spacepaste

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