Advertisement
shanehou

ruby-2.0.0.environment

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