spacepaste

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