spacepaste

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