spacepaste

  1.  
  2. declare -x ABI="amd64"
  3. declare -x ABI_X86="64"
  4. declare -x ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci"
  5. declare -x 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 -x BOOTSTRAP_USE="cxx unicode internal-glib python_targets_python3_4 python_targets_python2_7 multilib"
  8. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
  9. declare -x CBUILD="x86_64-pc-linux-gnu"
  10. declare -x CC="x86_64-pc-linux-gnu-gcc"
  11. declare -x CFLAGS="-march=native -O2 -pipe"
  12. declare -x CFLAGS_amd64="-m64"
  13. declare -x CFLAGS_default
  14. declare -x CFLAGS_x32="-mx32"
  15. declare -x CFLAGS_x86="-m32"
  16. declare -x CHOST="x86_64-pc-linux-gnu"
  17. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  18. declare -x CHOST_default="x86_64-pc-linux-gnu"
  19. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  20. declare -x CHOST_x86="i686-pc-linux-gnu"
  21. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  22. declare -x CPPFLAGS=" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
  23. declare -x CPU_FLAGS_X86="mmx sse sse2"
  24. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  25. declare -x CXXFLAGS="-march=native -O2 -pipe"
  26. declare -- DEB_PV="1.5-6"
  27. declare -x DEFAULT_ABI="amd64"
  28. declare -x DEFINED_PHASES=" configure install prepare"
  29. declare DEPEND=""
  30. declare DESCRIPTION="Standard log daemons"
  31. declare -x DESTTREE="/usr"
  32. declare -x DIROPTIONS="-m0755"
  33. declare -x EAPI="4"
  34. declare -x ELIBC="glibc"
  35. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  36. declare -- EPATCH_EXCLUDE=""
  37. declare -- EPATCH_FORCE="no"
  38. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  39. declare -- EPATCH_N_APPLIED_PATCHES="7"
  40. declare -- EPATCH_OPTS=""
  41. declare -- EPATCH_SINGLE_MSG=""
  42. declare -- EPATCH_SOURCE="/var/tmp/portage/app-admin/sysklogd-1.5.1/work/patch"
  43. declare -- EPATCH_SUFFIX="patch.bz2"
  44. declare -- EPATCH_USER_SOURCE="/etc/portage/patches"
  45. declare -x EXEOPTIONS="-m0755"
  46. declare -x FCFLAGS="-O2 -pipe"
  47. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  48. declare -x FFLAGS="-O2 -pipe"
  49. declare -x GCC_SPECS=""
  50. declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx"
  51. declare -x GRUB_PLATFORMS=""
  52. declare -x GSETTINGS_BACKEND="dconf"
  53. declare HDEPEND=""
  54. declare HOMEPAGE="http://www.infodrom.org/projects/sysklogd/"
  55. declare -x INHERITED=" estack epatch toolchain-funcs multilib ltprune eutils flag-o-matic"
  56. declare -x INPUT_DEVICES="libinput"
  57. declare -x INSDESTTREE=""
  58. declare -x INSOPTIONS="-m0644"
  59. declare IUSE="logrotate "
  60. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-chain prefix-guest"
  61. declare -x KERNEL="linux"
  62. declare -x KERNEL_ABI="amd64"
  63. declare -x KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86"
  64. declare -x LANG="en_US.utf8"
  65. declare -x LCD_DEVICES=""
  66. declare -x LC_MESSAGES="C"
  67. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  68. declare -x LDFLAGS_amd64="-m elf_x86_64"
  69. declare -x LDFLAGS_default
  70. declare -x LDFLAGS_x32="-m elf32_x86_64"
  71. declare -x LDFLAGS_x86="-m elf_i386"
  72. declare -x LIBDIR_amd64="lib64"
  73. declare -x LIBDIR_default="lib"
  74. declare -x LIBDIR_x32="libx32"
  75. declare -x LIBDIR_x86="lib32"
  76. declare -x LIBOPTIONS="-m0644"
  77. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  78. declare -x LICENSE="BSD"
  79. declare -x MAKEOPTS="-j4"
  80. declare -x MANPAGER="manpager"
  81. declare -x MULTILIB_ABIS="amd64 x86"
  82. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  83. 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"
  84. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  85. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  86. declare -x OFFICE_IMPLEMENTATION="libreoffice"
  87. declare -x OPENGL_PROFILE="xorg-x11"
  88. declare -x PATH="/usr/lib/portage/python3.4/ebuild-helpers/xattr:/usr/lib/portage/python3.4/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/5.4.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  89. declare PDEPEND=""
  90. declare -x PHP_TARGETS=""
  91. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  92. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  93. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  94. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  95. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/sysklogd-1.5.1/html")'
  96. declare -x POSTGRES_TARGETS=""
  97. 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"
  98. declare -x PROPERTIES=""
  99. declare -x PROVIDE=""
  100. declare -x PYTHONDONTWRITEBYTECODE="1"
  101. declare -x PYTHON_SINGLE_TARGET=""
  102. declare -x PYTHON_TARGETS=""
  103. declare -x QT_GRAPHICSSYSTEM="raster"
  104. declare RDEPEND="dev-lang/perl
  105. sys-apps/debianutils "
  106. declare REPOSITORY
  107. declare REQUIRED_USE=""
  108. declare -x RESTRICT="test"
  109. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  110. declare -x RUBY_TARGETS=""
  111. declare -x S="/var/tmp/portage/app-admin/sysklogd-1.5.1/work/sysklogd-1.5.1"
  112. declare -x SANDBOX_DEBUG="0"
  113. declare -x SANDBOX_DENY=""
  114. declare -x SANDBOX_PREDICT="/var/tmp/portage/app-admin/sysklogd-1.5.1/homedir:/dev/crypto:/var/cache/fontconfig"
  115. declare -x SANDBOX_READ="/:/var/tmp"
  116. declare -x SANDBOX_VERBOSE="1"
  117. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/lib/cf:/usr/lib/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/app-admin/sysklogd-1.5.1/homedir/.bash_history"
  118. declare -- SHELL="/bin/bash"
  119. declare -x SLOT="0"
  120. declare SRC_URI="http://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.1.tar.gz
  121. mirror://debian/pool/main/s/sysklogd/sysklogd_1.5-6.diff.gz"
  122. declare -x SYMLINK_LIB="yes"
  123. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  124. declare -x USE="abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU"
  125. declare -x USERLAND="GNU"
  126. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  127. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  128. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 hppa ia64 m68k m68k-mint mips nios2 ppc ppc64 ppc64-linux ppc-aix ppc-macos riscv s390 sh sparc sparc64-solaris sparc-fbsd sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  129. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  130. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  131. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  132. declare -x VIDEO_CARDS=""
  133. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  134. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  135. 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"
  136. declare -- _EPATCH_ECLASS="1"
  137. declare -- _ESTACK_ECLASS="1"
  138. declare -- _EUTILS_ECLASS="1"
  139. declare -x _E_DOCDESTTREE_=""
  140. declare -x _E_EXEDESTTREE_=""
  141. declare -- _FLAG_O_MATIC_ECLASS="1"
  142. declare -- _LTPRUNE_ECLASS="1"
  143. declare -- _MULTILIB_ECLASS="1"
  144. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  145. declare -- phase_func
  146. __eapi6_src_install ()
  147. {
  148. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  149. emake DESTDIR="${D}" install;
  150. fi;
  151. einstalldocs
  152. }
  153. __eapi6_src_prepare ()
  154. {
  155. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  156. [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}";
  157. else
  158. if [[ -n ${PATCHES} ]]; then
  159. eapply ${PATCHES};
  160. fi;
  161. fi;
  162. eapply_user
  163. }
  164. _clang_fullversion ()
  165. {
  166. local ver="$1";
  167. shift;
  168. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  169. eval echo "$ver"
  170. }
  171. _epatch_draw_line ()
  172. {
  173. [[ -z $1 ]] && set "$(printf "%65s" '')";
  174. echo "${1//?/=}"
  175. }
  176. _eutils_eprefix_init ()
  177. {
  178. has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
  179. }
  180. _filter-hardened ()
  181. {
  182. local f;
  183. for f in "$@";
  184. do
  185. case "${f}" in
  186. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  187. gcc-specs-pie || continue;
  188. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  189. if test-flags -nopie > /dev/null; then
  190. append-flags -nopie;
  191. else
  192. append-flags -no-pie;
  193. fi;
  194. fi
  195. ;;
  196. -fstack-protector)
  197. gcc-specs-ssp || continue;
  198. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  199. ;;
  200. -fstack-protector-all)
  201. gcc-specs-ssp-to-all || continue;
  202. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  203. ;;
  204. -fno-strict-overflow)
  205. gcc-specs-nostrict || continue;
  206. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  207. ;;
  208. esac;
  209. done
  210. }
  211. _filter-var ()
  212. {
  213. local f x var=$1 new=();
  214. shift;
  215. for f in ${!var};
  216. do
  217. for x in "$@";
  218. do
  219. [[ ${f} == ${x} ]] && continue 2;
  220. done;
  221. new+=("${f}");
  222. done;
  223. export ${var}="${new[*]}"
  224. }
  225. _gcc-install-dir ()
  226. {
  227. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  228. }
  229. _gcc-specs-directive_raw ()
  230. {
  231. local cc=$(tc-getCC);
  232. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  233. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  234. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  235. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  236. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  237. { spec=spec $0 }
  238. END { print spec }';
  239. return 0
  240. }
  241. _gcc-specs-exists ()
  242. {
  243. [[ -f $(_gcc-install-dir)/$1 ]]
  244. }
  245. _gcc_fullversion ()
  246. {
  247. local ver="$1";
  248. shift;
  249. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  250. eval echo "$ver"
  251. }
  252. _iconins ()
  253. {
  254. ( local funcname=$1;
  255. shift;
  256. local size dir;
  257. local context=apps;
  258. local theme=hicolor;
  259. while [[ $# -gt 0 ]]; do
  260. case $1 in
  261. -s | --size)
  262. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  263. size=${2%%x*};
  264. else
  265. size=${2};
  266. fi;
  267. case ${size} in
  268. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  269. size=${size}x${size}
  270. ;;
  271. scalable)
  272. ;;
  273. *)
  274. eerror "${size} is an unsupported icon size!";
  275. exit 1
  276. ;;
  277. esac;
  278. shift 2
  279. ;;
  280. -t | --theme)
  281. theme=${2};
  282. shift 2
  283. ;;
  284. -c | --context)
  285. context=${2};
  286. shift 2
  287. ;;
  288. *)
  289. if [[ -z ${size} ]]; then
  290. insinto /usr/share/pixmaps;
  291. else
  292. insinto /usr/share/icons/${theme}/${size}/${context};
  293. fi;
  294. if [[ ${funcname} == doicon ]]; then
  295. if [[ -f $1 ]]; then
  296. doins "${1}";
  297. else
  298. if [[ -d $1 ]]; then
  299. shopt -s nullglob;
  300. doins "${1}"/*.{png,svg};
  301. shopt -u nullglob;
  302. else
  303. eerror "${1} is not a valid file/directory!";
  304. exit 1;
  305. fi;
  306. fi;
  307. else
  308. break;
  309. fi;
  310. shift 1
  311. ;;
  312. esac;
  313. done;
  314. if [[ ${funcname} == newicon ]]; then
  315. newins "$@";
  316. fi ) || die
  317. }
  318. _is_flagq ()
  319. {
  320. local x var="$1[*]";
  321. for x in ${!var};
  322. do
  323. [[ ${x} == $2 ]] && return 0;
  324. done;
  325. return 1
  326. }
  327. _tc-getPROG ()
  328. {
  329. local tuple=$1;
  330. local v var vars=$2;
  331. local prog=($3);
  332. var=${vars%% *};
  333. for v in ${vars};
  334. do
  335. if [[ -n ${!v} ]]; then
  336. export ${var}="${!v}";
  337. echo "${!v}";
  338. return 0;
  339. fi;
  340. done;
  341. local search=;
  342. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  343. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  344. [[ -n ${search} ]] && prog[0]=${search##*/};
  345. export ${var}="${prog[*]}";
  346. echo "${!var}"
  347. }
  348. all-flag-vars ()
  349. {
  350. echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  351. }
  352. append-cflags ()
  353. {
  354. [[ $# -eq 0 ]] && return 0;
  355. export CFLAGS+=" $*";
  356. return 0
  357. }
  358. append-cppflags ()
  359. {
  360. [[ $# -eq 0 ]] && return 0;
  361. export CPPFLAGS+=" $*";
  362. return 0
  363. }
  364. append-cxxflags ()
  365. {
  366. [[ $# -eq 0 ]] && return 0;
  367. export CXXFLAGS+=" $*";
  368. return 0
  369. }
  370. append-fflags ()
  371. {
  372. [[ $# -eq 0 ]] && return 0;
  373. export FFLAGS+=" $*";
  374. export FCFLAGS+=" $*";
  375. return 0
  376. }
  377. append-flags ()
  378. {
  379. [[ $# -eq 0 ]] && return 0;
  380. case " $* " in
  381. *' '-[DIU]*)
  382. eqawarn 'please use append-cppflags for preprocessor flags'
  383. ;;
  384. *' '-L* | *' '-Wl,*)
  385. eqawarn 'please use append-ldflags for linker flags'
  386. ;;
  387. esac;
  388. append-cflags "$@";
  389. append-cxxflags "$@";
  390. append-fflags "$@";
  391. return 0
  392. }
  393. append-ldflags ()
  394. {
  395. [[ $# -eq 0 ]] && return 0;
  396. local flag;
  397. for flag in "$@";
  398. do
  399. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  400. done;
  401. export LDFLAGS="${LDFLAGS} $*";
  402. return 0
  403. }
  404. append-lfs-flags ()
  405. {
  406. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  407. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  408. }
  409. append-libs ()
  410. {
  411. [[ $# -eq 0 ]] && return 0;
  412. local flag;
  413. for flag in "$@";
  414. do
  415. if [[ -z "${flag// }" ]]; then
  416. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  417. continue;
  418. fi;
  419. case $flag in
  420. -[lL]*)
  421. export LIBS="${LIBS} ${flag}"
  422. ;;
  423. -*)
  424. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  425. export LIBS="${LIBS} ${flag}"
  426. ;;
  427. *)
  428. export LIBS="${LIBS} -l${flag}"
  429. ;;
  430. esac;
  431. done;
  432. return 0
  433. }
  434. built_with_use ()
  435. {
  436. _eutils_eprefix_init;
  437. local hidden="no";
  438. if [[ $1 == "--hidden" ]]; then
  439. hidden="yes";
  440. shift;
  441. fi;
  442. local missing_action="die";
  443. if [[ $1 == "--missing" ]]; then
  444. missing_action=$2;
  445. shift;
  446. shift;
  447. case ${missing_action} in
  448. true | false | die)
  449. ;;
  450. *)
  451. die "unknown action '${missing_action}'"
  452. ;;
  453. esac;
  454. fi;
  455. local opt=$1;
  456. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  457. local PKG=$(best_version $1);
  458. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  459. shift;
  460. local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE;
  461. local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE;
  462. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  463. case ${missing_action} in
  464. true)
  465. return 0
  466. ;;
  467. false)
  468. return 1
  469. ;;
  470. die)
  471. die "Unable to determine what USE flags $PKG was built with"
  472. ;;
  473. esac;
  474. fi;
  475. if [[ ${hidden} == "no" ]]; then
  476. local IUSE_BUILT=($(<"${IUSEFILE}"));
  477. local expand;
  478. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  479. do
  480. if [[ $1 == ${expand}_* ]]; then
  481. expand="";
  482. break;
  483. fi;
  484. done;
  485. if [[ -n ${expand} ]]; then
  486. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  487. case ${missing_action} in
  488. true)
  489. return 0
  490. ;;
  491. false)
  492. return 1
  493. ;;
  494. die)
  495. die "$PKG does not actually support the $1 USE flag!"
  496. ;;
  497. esac;
  498. fi;
  499. fi;
  500. fi;
  501. local USE_BUILT=$(<${USEFILE});
  502. while [[ $# -gt 0 ]]; do
  503. if [[ ${opt} = "-o" ]]; then
  504. has $1 ${USE_BUILT} && return 0;
  505. else
  506. has $1 ${USE_BUILT} || return 1;
  507. fi;
  508. shift;
  509. done;
  510. [[ ${opt} = "-a" ]]
  511. }
  512. check_license ()
  513. {
  514. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  515. }
  516. clang-fullversion ()
  517. {
  518. _clang_fullversion '$1.$2.$3' "$@"
  519. }
  520. clang-major-version ()
  521. {
  522. _clang_fullversion '$1' "$@"
  523. }
  524. clang-micro-version ()
  525. {
  526. _clang_fullversion '$3' "$@"
  527. }
  528. clang-minor-version ()
  529. {
  530. _clang_fullversion '$2' "$@"
  531. }
  532. clang-version ()
  533. {
  534. _clang_fullversion '$1.$2' "$@"
  535. }
  536. doicon ()
  537. {
  538. _iconins ${FUNCNAME} "$@"
  539. }
  540. domenu ()
  541. {
  542. ( local i j ret=0;
  543. insinto /usr/share/applications;
  544. for i in "$@";
  545. do
  546. if [[ -f ${i} ]]; then
  547. doins "${i}";
  548. ((ret+=$?));
  549. else
  550. if [[ -d ${i} ]]; then
  551. for j in "${i}"/*.desktop;
  552. do
  553. doins "${j}";
  554. ((ret+=$?));
  555. done;
  556. else
  557. ((++ret));
  558. fi;
  559. fi;
  560. done;
  561. exit ${ret} )
  562. }
  563. ebeep ()
  564. {
  565. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  566. }
  567. econf_build ()
  568. {
  569. local CBUILD=${CBUILD:-${CHOST}};
  570. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  571. }
  572. ecvs_clean ()
  573. {
  574. [[ $# -eq 0 ]] && set -- .;
  575. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  576. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  577. }
  578. edos2unix ()
  579. {
  580. [[ $# -eq 0 ]] && return 0;
  581. sed -i 's/\r$//' -- "$@" || die
  582. }
  583. egit_clean ()
  584. {
  585. [[ $# -eq 0 ]] && set -- .;
  586. find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
  587. }
  588. einstalldocs ()
  589. {
  590. debug-print-function ${FUNCNAME} "${@}";
  591. local dodoc_opts=-r;
  592. has ${EAPI} 0 1 2 3 && dodoc_opts=;
  593. if ! declare -p DOCS &> /dev/null; then
  594. local d;
  595. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  596. do
  597. if [[ -s ${d} ]]; then
  598. dodoc "${d}" || die;
  599. fi;
  600. done;
  601. else
  602. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  603. if [[ -n ${DOCS[@]} ]]; then
  604. dodoc ${dodoc_opts} "${DOCS[@]}" || die;
  605. fi;
  606. else
  607. if [[ -n ${DOCS} ]]; then
  608. dodoc ${dodoc_opts} ${DOCS} || die;
  609. fi;
  610. fi;
  611. fi;
  612. if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  613. if [[ -n ${HTML_DOCS[@]} ]]; then
  614. dohtml -r "${HTML_DOCS[@]}" || die;
  615. fi;
  616. else
  617. if [[ -n ${HTML_DOCS} ]]; then
  618. dohtml -r ${HTML_DOCS} || die;
  619. fi;
  620. fi;
  621. return 0
  622. }
  623. emktemp ()
  624. {
  625. local exe="touch";
  626. [[ $1 == -d ]] && exe="mkdir" && shift;
  627. local topdir=$1;
  628. if [[ -z ${topdir} ]]; then
  629. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  630. fi;
  631. if ! type -P mktemp > /dev/null; then
  632. local tmp=/;
  633. while [[ -e ${tmp} ]]; do
  634. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  635. done;
  636. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  637. echo "${tmp}";
  638. else
  639. if [[ ${exe} == "touch" ]]; then
  640. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  641. else
  642. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  643. fi;
  644. fi
  645. }
  646. epatch ()
  647. {
  648. function _epatch_draw_line ()
  649. {
  650. [[ -z $1 ]] && set "$(printf "%65s" '')";
  651. echo "${1//?/=}"
  652. };
  653. unset P4CONFIG P4PORT P4USER;
  654. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  655. while [[ $# -gt 0 ]]; do
  656. case $1 in
  657. -*)
  658. EPATCH_OPTS+=("$1")
  659. ;;
  660. *)
  661. break
  662. ;;
  663. esac;
  664. shift;
  665. done;
  666. if [[ $# -gt 1 ]]; then
  667. local m;
  668. for m in "$@";
  669. do
  670. epatch "${m}";
  671. done;
  672. return 0;
  673. fi;
  674. local SINGLE_PATCH="no";
  675. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  676. if [[ -f $1 ]]; then
  677. SINGLE_PATCH="yes";
  678. set -- "$1";
  679. local EPATCH_SUFFIX=$1;
  680. else
  681. if [[ -d $1 ]]; then
  682. evar_push_set LC_COLLATE C;
  683. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  684. evar_pop;
  685. else
  686. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  687. epatch "${EPATCH_SOURCE}/$1";
  688. return $?;
  689. else
  690. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  691. echo;
  692. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  693. eerror;
  694. eerror " ${EPATCH_SOURCE}";
  695. eerror " ( ${EPATCH_SOURCE##*/} )";
  696. echo;
  697. die "Cannot find \$EPATCH_SOURCE!";
  698. fi;
  699. fi;
  700. fi;
  701. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  702. local PIPE_CMD;
  703. case ${EPATCH_SUFFIX##*\.} in
  704. xz)
  705. PIPE_CMD="xz -dc"
  706. ;;
  707. lzma)
  708. PIPE_CMD="lzma -dc"
  709. ;;
  710. bz2)
  711. PIPE_CMD="bzip2 -dc"
  712. ;;
  713. gz | Z | z)
  714. PIPE_CMD="gzip -dc"
  715. ;;
  716. ZIP | zip)
  717. PIPE_CMD="unzip -p"
  718. ;;
  719. *)
  720. ;;
  721. esac;
  722. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  723. local x;
  724. for x in "$@";
  725. do
  726. [[ ! -f ${x} ]] && continue;
  727. local patchname=${x##*/};
  728. local a=${patchname#*_};
  729. a=${a%%_*};
  730. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  731. continue;
  732. fi;
  733. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  734. eshopts_push -o noglob;
  735. local ex;
  736. for ex in ${EPATCH_EXCLUDE};
  737. do
  738. if [[ ${patchname} == ${ex} ]]; then
  739. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  740. eshopts_pop;
  741. continue 2;
  742. fi;
  743. done;
  744. for ex in ${EPATCH_USER_EXCLUDE};
  745. do
  746. if [[ ${patchname} == ${ex} ]]; then
  747. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  748. eshopts_pop;
  749. continue 2;
  750. fi;
  751. done;
  752. eshopts_pop;
  753. fi;
  754. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  755. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  756. einfo "${EPATCH_SINGLE_MSG}";
  757. else
  758. einfo "Applying ${patchname} ...";
  759. fi;
  760. else
  761. einfo " ${patchname} ...";
  762. fi;
  763. local patch="patch";
  764. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  765. local STDERR_TARGET="${T}/${patchname}.out";
  766. if [[ -e ${STDERR_TARGET} ]]; then
  767. STDERR_TARGET="${T}/${patchname}-$$.out";
  768. fi;
  769. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  770. local count=0;
  771. local PATCH_TARGET;
  772. if [[ -n ${PIPE_CMD} ]]; then
  773. PATCH_TARGET="${T}/$$.patch";
  774. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  775. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  776. echo;
  777. eerror "Could not extract patch!";
  778. count=5;
  779. break;
  780. fi;
  781. else
  782. PATCH_TARGET=${x};
  783. fi;
  784. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  785. if [[ -n ${abs_paths} ]]; then
  786. count=1;
  787. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  788. fi;
  789. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  790. if [[ -n ${rel_paths} ]]; then
  791. echo;
  792. eerror "Rejected Patch: ${patchname} !";
  793. eerror " ( ${PATCH_TARGET} )";
  794. eerror;
  795. eerror "Your patch uses relative paths '../':";
  796. eerror "${rel_paths}";
  797. echo;
  798. die "you need to fix the relative paths in patch";
  799. fi;
  800. local patch_cmd;
  801. while [[ ${count} -lt 5 ]]; do
  802. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  803. ( _epatch_draw_line "***** ${patchname} *****";
  804. echo;
  805. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  806. echo;
  807. _epatch_draw_line "***** ${patchname} *****";
  808. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  809. ret=$?;
  810. echo;
  811. echo "patch program exited with status ${ret}";
  812. exit ${ret} ) >> "${STDERR_TARGET}";
  813. if [ $? -eq 0 ]; then
  814. ( _epatch_draw_line "***** ${patchname} *****";
  815. echo;
  816. echo "ACTUALLY APPLYING ${patchname} ...";
  817. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  818. echo;
  819. _epatch_draw_line "***** ${patchname} *****";
  820. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  821. ret=$?;
  822. echo;
  823. echo "patch program exited with status ${ret}";
  824. exit ${ret} ) >> "${STDERR_TARGET}";
  825. if [ $? -ne 0 ]; then
  826. echo;
  827. eerror "A dry-run of patch command succeeded, but actually";
  828. eerror "applying the patch failed!";
  829. count=5;
  830. fi;
  831. break;
  832. fi;
  833. : $(( count++ ));
  834. done;
  835. (( EPATCH_N_APPLIED_PATCHES++ ));
  836. if [[ -n ${PIPE_CMD} ]]; then
  837. rm -f "${PATCH_TARGET}";
  838. fi;
  839. if [[ ${count} -ge 5 ]]; then
  840. echo;
  841. eerror "Failed Patch: ${patchname} !";
  842. eerror " ( ${PATCH_TARGET} )";
  843. eerror;
  844. eerror "Include in your bugreport the contents of:";
  845. eerror;
  846. eerror " ${STDERR_TARGET}";
  847. echo;
  848. die "Failed Patch: ${patchname}!";
  849. fi;
  850. rm -f "${STDERR_TARGET}";
  851. cat >> "${T}/epatch.log" <<-EOF
  852. PATCH: ${x}
  853. CMD: ${patch_cmd}
  854. PWD: ${PWD}
  855. EOF
  856. eend 0;
  857. done;
  858. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  859. :
  860. }
  861. epatch_user ()
  862. {
  863. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  864. local applied="${T}/epatch_user.log";
  865. [[ -e ${applied} ]] && return 2;
  866. local EPATCH_SOURCE check;
  867. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}};
  868. do
  869. EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CTARGET}/${check};
  870. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CHOST}/${check};
  871. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${check};
  872. if [[ -d ${EPATCH_SOURCE} ]]; then
  873. local old_n_applied_patches=${EPATCH_N_APPLIED_PATCHES:-0};
  874. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  875. echo "${EPATCH_SOURCE}" > "${applied}";
  876. if [[ ${old_n_applied_patches} -lt ${EPATCH_N_APPLIED_PATCHES} ]]; then
  877. has epatch_user_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" epatch_user_death_notice";
  878. fi;
  879. return 0;
  880. fi;
  881. done;
  882. echo "none" > "${applied}";
  883. return 1
  884. }
  885. epatch_user_death_notice ()
  886. {
  887. ewarn "!!! User patches were applied to this build!"
  888. }
  889. epause ()
  890. {
  891. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  892. }
  893. eshopts_pop ()
  894. {
  895. local s;
  896. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  897. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  898. }
  899. eshopts_push ()
  900. {
  901. if [[ $1 == -[su] ]]; then
  902. estack_push eshopts "$(shopt -p)";
  903. [[ $# -eq 0 ]] && return 0;
  904. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  905. else
  906. estack_push eshopts "$(shopt -p -o)";
  907. [[ $# -eq 0 ]] && return 0;
  908. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  909. fi
  910. }
  911. estack_pop ()
  912. {
  913. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  914. local _estack_name="_ESTACK_$1_";
  915. shift;
  916. local _estack_retvar=$1;
  917. shift;
  918. eval local _estack_i=\${#${_estack_name}\[@\]};
  919. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  920. if [[ -n ${_estack_retvar} ]]; then
  921. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  922. fi;
  923. eval unset \"${_estack_name}\[${_estack_i}\]\"
  924. }
  925. estack_push ()
  926. {
  927. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  928. local stack_name="_ESTACK_$1_";
  929. shift;
  930. eval ${stack_name}+=\( \"\$@\" \)
  931. }
  932. esvn_clean ()
  933. {
  934. [[ $# -eq 0 ]] && set -- .;
  935. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  936. }
  937. eumask_pop ()
  938. {
  939. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  940. local s;
  941. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  942. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  943. }
  944. eumask_push ()
  945. {
  946. estack_push eumask "$(umask)";
  947. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  948. }
  949. evar_pop ()
  950. {
  951. local cnt=${1:-bad};
  952. case $# in
  953. 0)
  954. cnt=1
  955. ;;
  956. 1)
  957. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  958. ;;
  959. *)
  960. die "${FUNCNAME}: only accepts one arg: $*"
  961. ;;
  962. esac;
  963. local var val;
  964. while (( cnt-- )); do
  965. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  966. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  967. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  968. done
  969. }
  970. evar_push ()
  971. {
  972. local var val;
  973. for var in "$@";
  974. do
  975. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  976. estack_push evar "${var}" "${val}";
  977. done
  978. }
  979. evar_push_set ()
  980. {
  981. local var=$1;
  982. evar_push ${var};
  983. case $# in
  984. 1)
  985. unset ${var}
  986. ;;
  987. 2)
  988. printf -v "${var}" '%s' "$2"
  989. ;;
  990. *)
  991. die "${FUNCNAME}: incorrect # of args: $*"
  992. ;;
  993. esac
  994. }
  995. filter-flags ()
  996. {
  997. _filter-hardened "$@";
  998. local v;
  999. for v in $(all-flag-vars);
  1000. do
  1001. _filter-var ${v} "$@";
  1002. done;
  1003. return 0
  1004. }
  1005. filter-ldflags ()
  1006. {
  1007. _filter-var LDFLAGS "$@";
  1008. return 0
  1009. }
  1010. filter-lfs-flags ()
  1011. {
  1012. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1013. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1014. }
  1015. filter-mfpmath ()
  1016. {
  1017. local orig_mfpmath new_math prune_math;
  1018. orig_mfpmath=$(get-flag -mfpmath);
  1019. new_math=$(get-flag mfpmath);
  1020. new_math=${new_math/both/387,sse};
  1021. new_math=" ${new_math//[,+]/ } ";
  1022. prune_math="";
  1023. for prune_math in "$@";
  1024. do
  1025. new_math=${new_math/ ${prune_math} / };
  1026. done;
  1027. new_math=$(echo ${new_math});
  1028. new_math=${new_math// /,};
  1029. if [[ -z ${new_math} ]]; then
  1030. filter-flags ${orig_mfpmath};
  1031. else
  1032. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1033. fi;
  1034. return 0
  1035. }
  1036. gcc-fullversion ()
  1037. {
  1038. _gcc_fullversion '$1.$2.$3' "$@"
  1039. }
  1040. gcc-major-version ()
  1041. {
  1042. _gcc_fullversion '$1' "$@"
  1043. }
  1044. gcc-micro-version ()
  1045. {
  1046. _gcc_fullversion '$3' "$@"
  1047. }
  1048. gcc-minor-version ()
  1049. {
  1050. _gcc_fullversion '$2' "$@"
  1051. }
  1052. gcc-specs-directive ()
  1053. {
  1054. local directive subdname subdirective;
  1055. directive="$(_gcc-specs-directive_raw $1)";
  1056. while [[ ${directive} == *%\(*\)* ]]; do
  1057. subdname=${directive/*%\(};
  1058. subdname=${subdname/\)*};
  1059. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1060. directive="${directive//\%(${subdname})/${subdirective}}";
  1061. done;
  1062. echo "${directive}";
  1063. return 0
  1064. }
  1065. gcc-specs-nostrict ()
  1066. {
  1067. local directive;
  1068. directive=$(gcc-specs-directive cc1);
  1069. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1070. }
  1071. gcc-specs-now ()
  1072. {
  1073. local directive;
  1074. directive=$(gcc-specs-directive link_command);
  1075. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1076. }
  1077. gcc-specs-pie ()
  1078. {
  1079. local directive;
  1080. directive=$(gcc-specs-directive cc1);
  1081. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1082. }
  1083. gcc-specs-relro ()
  1084. {
  1085. local directive;
  1086. directive=$(gcc-specs-directive link_command);
  1087. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1088. }
  1089. gcc-specs-ssp ()
  1090. {
  1091. local directive;
  1092. directive=$(gcc-specs-directive cc1);
  1093. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1094. }
  1095. gcc-specs-ssp-to-all ()
  1096. {
  1097. local directive;
  1098. directive=$(gcc-specs-directive cc1);
  1099. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1100. }
  1101. gcc-specs-stack-check ()
  1102. {
  1103. local directive;
  1104. directive=$(gcc-specs-directive cc1);
  1105. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1106. }
  1107. gcc-version ()
  1108. {
  1109. _gcc_fullversion '$1.$2' "$@"
  1110. }
  1111. gen_usr_ldscript ()
  1112. {
  1113. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1114. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1115. tc-is-static-only && return;
  1116. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1117. multilib_is_native_abi || return 0;
  1118. fi;
  1119. case ${CTARGET:-${CHOST}} in
  1120. *-darwin*)
  1121. ;;
  1122. *-android*)
  1123. return 0
  1124. ;;
  1125. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1126. use prefix && return 0
  1127. ;;
  1128. *)
  1129. return 0
  1130. ;;
  1131. esac;
  1132. dodir /usr/${libdir};
  1133. if [[ $1 == "-a" ]]; then
  1134. auto=true;
  1135. shift;
  1136. dodir /${libdir};
  1137. fi;
  1138. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1139. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1140. local d="${T}/bfd-linker";
  1141. mkdir -p "${d}";
  1142. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1143. flags+=(-B"${d}");
  1144. fi;
  1145. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1146. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1147. for lib in "$@";
  1148. do
  1149. local tlib;
  1150. if ${auto}; then
  1151. lib="lib${lib}${suffix}";
  1152. else
  1153. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1154. fi;
  1155. case ${CTARGET:-${CHOST}} in
  1156. *-darwin*)
  1157. if ${auto}; then
  1158. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1159. else
  1160. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1161. fi;
  1162. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1163. tlib=${tlib##*/};
  1164. if ${auto}; then
  1165. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1166. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1167. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1168. fi;
  1169. rm -f "${ED}"/${libdir}/${lib};
  1170. fi;
  1171. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1172. chmod u+w "${ED}${libdir}/${tlib}";
  1173. local nowrite=yes;
  1174. fi;
  1175. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1176. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1177. pushd "${ED}/usr/${libdir}" > /dev/null;
  1178. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1179. popd > /dev/null
  1180. ;;
  1181. *)
  1182. if ${auto}; then
  1183. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1184. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1185. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1186. if [[ ${tlib} != ${lib}* ]]; then
  1187. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1188. fi;
  1189. rm -f "${ED}"/${libdir}/${lib};
  1190. else
  1191. tlib=${lib};
  1192. fi;
  1193. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1194. /* GNU ld script
  1195. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1196. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1197. run into linking problems. This "fake" dynamic lib is a linker script that
  1198. redirects the linker to the real lib. And yes, this works in the cross-
  1199. compiling scenario as the sysroot-ed linker will prepend the real path.
  1200. See bug https://bugs.gentoo.org/4411 for more info.
  1201. */
  1202. ${output_format}
  1203. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1204. END_LDSCRIPT
  1205. ;;
  1206. esac
  1207. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1208. done
  1209. }
  1210. get-flag ()
  1211. {
  1212. local f var findflag="$1";
  1213. for var in $(all-flag-vars);
  1214. do
  1215. for f in ${!var};
  1216. do
  1217. if [ "${f/${findflag}}" != "${f}" ]; then
  1218. printf "%s\n" "${f/-${findflag}=}";
  1219. return 0;
  1220. fi;
  1221. done;
  1222. done;
  1223. return 1
  1224. }
  1225. get_abi_CFLAGS ()
  1226. {
  1227. get_abi_var CFLAGS "$@"
  1228. }
  1229. get_abi_CHOST ()
  1230. {
  1231. get_abi_var CHOST "$@"
  1232. }
  1233. get_abi_CTARGET ()
  1234. {
  1235. get_abi_var CTARGET "$@"
  1236. }
  1237. get_abi_FAKE_TARGETS ()
  1238. {
  1239. get_abi_var FAKE_TARGETS "$@"
  1240. }
  1241. get_abi_LDFLAGS ()
  1242. {
  1243. get_abi_var LDFLAGS "$@"
  1244. }
  1245. get_abi_LIBDIR ()
  1246. {
  1247. get_abi_var LIBDIR "$@"
  1248. }
  1249. get_abi_var ()
  1250. {
  1251. local flag=$1;
  1252. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1253. local var="${flag}_${abi}";
  1254. echo ${!var}
  1255. }
  1256. get_all_abis ()
  1257. {
  1258. local x order="" mvar dvar;
  1259. mvar="MULTILIB_ABIS";
  1260. dvar="DEFAULT_ABI";
  1261. if [[ -n $1 ]]; then
  1262. mvar="$1_${mvar}";
  1263. dvar="$1_${dvar}";
  1264. fi;
  1265. if [[ -z ${!mvar} ]]; then
  1266. echo "default";
  1267. return 0;
  1268. fi;
  1269. for x in ${!mvar};
  1270. do
  1271. if [[ ${x} != ${!dvar} ]]; then
  1272. order="${order:+${order} }${x}";
  1273. fi;
  1274. done;
  1275. order="${order:+${order} }${!dvar}";
  1276. echo ${order};
  1277. return 0
  1278. }
  1279. get_all_libdirs ()
  1280. {
  1281. local libdirs abi;
  1282. for abi in ${MULTILIB_ABIS};
  1283. do
  1284. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1285. done;
  1286. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1287. echo "${libdirs}"
  1288. }
  1289. get_exeext ()
  1290. {
  1291. case ${CHOST} in
  1292. *-cygwin* | mingw* | *-mingw*)
  1293. echo ".exe"
  1294. ;;
  1295. esac
  1296. }
  1297. get_install_abis ()
  1298. {
  1299. local x order="";
  1300. if [[ -z ${MULTILIB_ABIS} ]]; then
  1301. echo "default";
  1302. return 0;
  1303. fi;
  1304. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1305. for x in ${MULTILIB_ABIS};
  1306. do
  1307. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1308. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1309. fi;
  1310. done;
  1311. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1312. if [[ -n ${ABI_ALLOW} ]]; then
  1313. local ordera="";
  1314. for x in ${order};
  1315. do
  1316. if has ${x} ${ABI_ALLOW}; then
  1317. ordera="${ordera} ${x}";
  1318. fi;
  1319. done;
  1320. order=${ordera};
  1321. fi;
  1322. else
  1323. order=${DEFAULT_ABI};
  1324. fi;
  1325. if [[ -z ${order} ]]; then
  1326. 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.";
  1327. fi;
  1328. echo ${order};
  1329. return 0
  1330. }
  1331. get_libdir ()
  1332. {
  1333. local CONF_LIBDIR;
  1334. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1335. echo ${CONF_LIBDIR_OVERRIDE};
  1336. else
  1337. get_abi_LIBDIR;
  1338. fi
  1339. }
  1340. get_libname ()
  1341. {
  1342. local libname;
  1343. local ver=$1;
  1344. case ${CHOST} in
  1345. *-cygwin*)
  1346. libname="dll.a"
  1347. ;;
  1348. mingw* | *-mingw*)
  1349. libname="dll"
  1350. ;;
  1351. *-darwin*)
  1352. libname="dylib"
  1353. ;;
  1354. *-mint*)
  1355. libname="irrelevant"
  1356. ;;
  1357. hppa*-hpux*)
  1358. libname="sl"
  1359. ;;
  1360. *)
  1361. libname="so"
  1362. ;;
  1363. esac;
  1364. if [[ -z $* ]]; then
  1365. echo ".${libname}";
  1366. else
  1367. for ver in "$@";
  1368. do
  1369. case ${CHOST} in
  1370. *-cygwin*)
  1371. echo ".${ver}.${libname}"
  1372. ;;
  1373. *-darwin*)
  1374. echo ".${ver}.${libname}"
  1375. ;;
  1376. *-mint*)
  1377. echo ".${libname}"
  1378. ;;
  1379. *)
  1380. echo ".${libname}.${ver}"
  1381. ;;
  1382. esac;
  1383. done;
  1384. fi
  1385. }
  1386. get_modname ()
  1387. {
  1388. local modname;
  1389. local ver=$1;
  1390. case ${CHOST} in
  1391. *-darwin*)
  1392. modname="bundle"
  1393. ;;
  1394. *)
  1395. modname="so"
  1396. ;;
  1397. esac;
  1398. echo ".${modname}"
  1399. }
  1400. has_m32 ()
  1401. {
  1402. die "${FUNCNAME}: don't use this anymore"
  1403. }
  1404. has_m64 ()
  1405. {
  1406. die "${FUNCNAME}: don't use this anymore"
  1407. }
  1408. has_multilib_profile ()
  1409. {
  1410. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1411. }
  1412. in_iuse ()
  1413. {
  1414. debug-print-function ${FUNCNAME} "${@}";
  1415. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  1416. local flag=${1};
  1417. local liuse=(${IUSE});
  1418. has "${flag}" "${liuse[@]#[+-]}"
  1419. }
  1420. is-flag ()
  1421. {
  1422. is-flagq "$@" && echo true
  1423. }
  1424. is-flagq ()
  1425. {
  1426. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1427. local var;
  1428. for var in $(all-flag-vars);
  1429. do
  1430. _is_flagq ${var} "$1" && return 0;
  1431. done;
  1432. return 1
  1433. }
  1434. is-ldflag ()
  1435. {
  1436. is-ldflagq "$@" && echo true
  1437. }
  1438. is-ldflagq ()
  1439. {
  1440. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1441. _is_flagq LDFLAGS $1
  1442. }
  1443. is_final_abi ()
  1444. {
  1445. has_multilib_profile || return 0;
  1446. set -- $(get_install_abis);
  1447. local LAST_ABI=$#;
  1448. [[ ${!LAST_ABI} == ${ABI} ]]
  1449. }
  1450. isdigit ()
  1451. {
  1452. local d;
  1453. for d in "$@";
  1454. do
  1455. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  1456. done;
  1457. return 0
  1458. }
  1459. make_desktop_entry ()
  1460. {
  1461. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  1462. local exec=${1};
  1463. local name=${2:-${PN}};
  1464. local icon=${3:-${PN}};
  1465. local type=${4};
  1466. local fields=${5};
  1467. if [[ -z ${type} ]]; then
  1468. local catmaj=${CATEGORY%%-*};
  1469. local catmin=${CATEGORY##*-};
  1470. case ${catmaj} in
  1471. app)
  1472. case ${catmin} in
  1473. accessibility)
  1474. type="Utility;Accessibility"
  1475. ;;
  1476. admin)
  1477. type=System
  1478. ;;
  1479. antivirus)
  1480. type=System
  1481. ;;
  1482. arch)
  1483. type="Utility;Archiving"
  1484. ;;
  1485. backup)
  1486. type="Utility;Archiving"
  1487. ;;
  1488. cdr)
  1489. type="AudioVideo;DiscBurning"
  1490. ;;
  1491. dicts)
  1492. type="Office;Dictionary"
  1493. ;;
  1494. doc)
  1495. type=Documentation
  1496. ;;
  1497. editors)
  1498. type="Utility;TextEditor"
  1499. ;;
  1500. emacs)
  1501. type="Development;TextEditor"
  1502. ;;
  1503. emulation)
  1504. type="System;Emulator"
  1505. ;;
  1506. laptop)
  1507. type="Settings;HardwareSettings"
  1508. ;;
  1509. office)
  1510. type=Office
  1511. ;;
  1512. pda)
  1513. type="Office;PDA"
  1514. ;;
  1515. vim)
  1516. type="Development;TextEditor"
  1517. ;;
  1518. xemacs)
  1519. type="Development;TextEditor"
  1520. ;;
  1521. esac
  1522. ;;
  1523. dev)
  1524. type="Development"
  1525. ;;
  1526. games)
  1527. case ${catmin} in
  1528. action | fps)
  1529. type=ActionGame
  1530. ;;
  1531. arcade)
  1532. type=ArcadeGame
  1533. ;;
  1534. board)
  1535. type=BoardGame
  1536. ;;
  1537. emulation)
  1538. type=Emulator
  1539. ;;
  1540. kids)
  1541. type=KidsGame
  1542. ;;
  1543. puzzle)
  1544. type=LogicGame
  1545. ;;
  1546. roguelike)
  1547. type=RolePlaying
  1548. ;;
  1549. rpg)
  1550. type=RolePlaying
  1551. ;;
  1552. simulation)
  1553. type=Simulation
  1554. ;;
  1555. sports)
  1556. type=SportsGame
  1557. ;;
  1558. strategy)
  1559. type=StrategyGame
  1560. ;;
  1561. esac;
  1562. type="Game;${type}"
  1563. ;;
  1564. gnome)
  1565. type="Gnome;GTK"
  1566. ;;
  1567. kde)
  1568. type="KDE;Qt"
  1569. ;;
  1570. mail)
  1571. type="Network;Email"
  1572. ;;
  1573. media)
  1574. case ${catmin} in
  1575. gfx)
  1576. type=Graphics
  1577. ;;
  1578. *)
  1579. case ${catmin} in
  1580. radio)
  1581. type=Tuner
  1582. ;;
  1583. sound)
  1584. type=Audio
  1585. ;;
  1586. tv)
  1587. type=TV
  1588. ;;
  1589. video)
  1590. type=Video
  1591. ;;
  1592. esac;
  1593. type="AudioVideo;${type}"
  1594. ;;
  1595. esac
  1596. ;;
  1597. net)
  1598. case ${catmin} in
  1599. dialup)
  1600. type=Dialup
  1601. ;;
  1602. ftp)
  1603. type=FileTransfer
  1604. ;;
  1605. im)
  1606. type=InstantMessaging
  1607. ;;
  1608. irc)
  1609. type=IRCClient
  1610. ;;
  1611. mail)
  1612. type=Email
  1613. ;;
  1614. news)
  1615. type=News
  1616. ;;
  1617. nntp)
  1618. type=News
  1619. ;;
  1620. p2p)
  1621. type=FileTransfer
  1622. ;;
  1623. voip)
  1624. type=Telephony
  1625. ;;
  1626. esac;
  1627. type="Network;${type}"
  1628. ;;
  1629. sci)
  1630. case ${catmin} in
  1631. astro*)
  1632. type=Astronomy
  1633. ;;
  1634. bio*)
  1635. type=Biology
  1636. ;;
  1637. calc*)
  1638. type=Calculator
  1639. ;;
  1640. chem*)
  1641. type=Chemistry
  1642. ;;
  1643. elec*)
  1644. type=Electronics
  1645. ;;
  1646. geo*)
  1647. type=Geology
  1648. ;;
  1649. math*)
  1650. type=Math
  1651. ;;
  1652. physics)
  1653. type=Physics
  1654. ;;
  1655. visual*)
  1656. type=DataVisualization
  1657. ;;
  1658. esac;
  1659. type="Education;Science;${type}"
  1660. ;;
  1661. sys)
  1662. type="System"
  1663. ;;
  1664. www)
  1665. case ${catmin} in
  1666. client)
  1667. type=WebBrowser
  1668. ;;
  1669. esac;
  1670. type="Network;${type}"
  1671. ;;
  1672. *)
  1673. type=
  1674. ;;
  1675. esac;
  1676. fi;
  1677. local slot=${SLOT%/*};
  1678. if [[ ${slot} == "0" ]]; then
  1679. local desktop_name="${PN}";
  1680. else
  1681. local desktop_name="${PN}-${slot}";
  1682. fi;
  1683. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  1684. type=${type%;}${type:+;};
  1685. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  1686. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  1687. ewarn "allowed in .desktop files if the value is not an absolute path.";
  1688. icon=${icon%.*};
  1689. fi;
  1690. cat > "${desktop}" <<-EOF
  1691. [Desktop Entry]
  1692. Name=${name}
  1693. Type=Application
  1694. Comment=${DESCRIPTION}
  1695. Exec=${exec}
  1696. TryExec=${exec%% *}
  1697. Icon=${icon}
  1698. Categories=${type}
  1699. EOF
  1700. if [[ ${fields:-=} != *=* ]]; then
  1701. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  1702. fields="Path=${fields}";
  1703. fi;
  1704. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  1705. ( insinto /usr/share/applications;
  1706. doins "${desktop}" ) || die "installing desktop file failed"
  1707. }
  1708. make_session_desktop ()
  1709. {
  1710. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  1711. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  1712. local title=$1;
  1713. local command=$2;
  1714. local desktop=${T}/${wm:-${PN}}.desktop;
  1715. shift 2;
  1716. cat > "${desktop}" <<-EOF
  1717. [Desktop Entry]
  1718. Name=${title}
  1719. Comment=This session logs you into ${title}
  1720. Exec=${command} $*
  1721. TryExec=${command}
  1722. Type=XSession
  1723. EOF
  1724. ( insinto /usr/share/xsessions;
  1725. doins "${desktop}" )
  1726. }
  1727. make_wrapper ()
  1728. {
  1729. _eutils_eprefix_init;
  1730. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  1731. local tmpwrapper=$(emktemp);
  1732. ( echo '#!/bin/sh';
  1733. [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}";
  1734. if [[ -n ${libdir} ]]; then
  1735. local var;
  1736. if [[ ${CHOST} == *-darwin* ]]; then
  1737. var=DYLD_LIBRARY_PATH;
  1738. else
  1739. var=LD_LIBRARY_PATH;
  1740. fi;
  1741. cat <<-EOF
  1742. if [ "\${${var}+set}" = "set" ] ; then
  1743. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  1744. else
  1745. export ${var}="${EPREFIX}${libdir}"
  1746. fi
  1747. EOF
  1748. fi
  1749. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  1750. chmod go+rx "${tmpwrapper}";
  1751. if [[ -n ${path} ]]; then
  1752. ( exeinto "${path}";
  1753. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  1754. else
  1755. newbin "${tmpwrapper}" "${wrapper}" || die;
  1756. fi
  1757. }
  1758. multilib_env ()
  1759. {
  1760. local CTARGET=${1:-${CTARGET}};
  1761. local cpu=${CTARGET%%*-};
  1762. case ${cpu} in
  1763. aarch64*)
  1764. export CFLAGS_arm=${CFLAGS_arm-};
  1765. case ${cpu} in
  1766. aarch64*be)
  1767. export CHOST_arm="armv8b-${CTARGET#*-}"
  1768. ;;
  1769. *)
  1770. export CHOST_arm="armv8l-${CTARGET#*-}"
  1771. ;;
  1772. esac;
  1773. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1774. export CTARGET_arm=${CHOST_arm};
  1775. export LIBDIR_arm="lib";
  1776. export CFLAGS_arm64=${CFLAGS_arm64-};
  1777. export CHOST_arm64=${CTARGET};
  1778. export CTARGET_arm64=${CHOST_arm64};
  1779. export LIBDIR_arm64="lib64";
  1780. : ${MULTILIB_ABIS=arm64};
  1781. : ${DEFAULT_ABI=arm64}
  1782. ;;
  1783. x86_64*)
  1784. export CFLAGS_x86=${CFLAGS_x86--m32};
  1785. export CHOST_x86=${CTARGET/x86_64/i686};
  1786. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1787. export CTARGET_x86=${CHOST_x86};
  1788. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1789. export LIBDIR_x86="lib32";
  1790. else
  1791. export LIBDIR_x86="lib";
  1792. fi;
  1793. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1794. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1795. export CTARGET_amd64=${CHOST_amd64};
  1796. export LIBDIR_amd64="lib64";
  1797. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1798. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1799. export CTARGET_x32=${CHOST_x32};
  1800. export LIBDIR_x32="libx32";
  1801. case ${CTARGET} in
  1802. *-gnux32)
  1803. : ${MULTILIB_ABIS=x32 amd64 x86};
  1804. : ${DEFAULT_ABI=x32}
  1805. ;;
  1806. *)
  1807. : ${MULTILIB_ABIS=amd64 x86};
  1808. : ${DEFAULT_ABI=amd64}
  1809. ;;
  1810. esac
  1811. ;;
  1812. mips64*)
  1813. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1814. export CHOST_o32=${CTARGET/mips64/mips};
  1815. export CTARGET_o32=${CHOST_o32};
  1816. export LIBDIR_o32="lib";
  1817. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1818. export CHOST_n32=${CTARGET};
  1819. export CTARGET_n32=${CHOST_n32};
  1820. export LIBDIR_n32="lib32";
  1821. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1822. export CHOST_n64=${CTARGET};
  1823. export CTARGET_n64=${CHOST_n64};
  1824. export LIBDIR_n64="lib64";
  1825. : ${MULTILIB_ABIS=n64 n32 o32};
  1826. : ${DEFAULT_ABI=n32}
  1827. ;;
  1828. powerpc64*)
  1829. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1830. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1831. export CTARGET_ppc=${CHOST_ppc};
  1832. export LIBDIR_ppc="lib";
  1833. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1834. export CHOST_ppc64=${CTARGET};
  1835. export CTARGET_ppc64=${CHOST_ppc64};
  1836. export LIBDIR_ppc64="lib64";
  1837. : ${MULTILIB_ABIS=ppc64 ppc};
  1838. : ${DEFAULT_ABI=ppc64}
  1839. ;;
  1840. s390x*)
  1841. export CFLAGS_s390=${CFLAGS_s390--m31};
  1842. export CHOST_s390=${CTARGET/s390x/s390};
  1843. export CTARGET_s390=${CHOST_s390};
  1844. export LIBDIR_s390="lib";
  1845. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1846. export CHOST_s390x=${CTARGET};
  1847. export CTARGET_s390x=${CHOST_s390x};
  1848. export LIBDIR_s390x="lib64";
  1849. : ${MULTILIB_ABIS=s390x s390};
  1850. : ${DEFAULT_ABI=s390x}
  1851. ;;
  1852. sparc64*)
  1853. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1854. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1855. export CTARGET_sparc32=${CHOST_sparc32};
  1856. export LIBDIR_sparc32="lib";
  1857. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1858. export CHOST_sparc64=${CTARGET};
  1859. export CTARGET_sparc64=${CHOST_sparc64};
  1860. export LIBDIR_sparc64="lib64";
  1861. : ${MULTILIB_ABIS=sparc64 sparc32};
  1862. : ${DEFAULT_ABI=sparc64}
  1863. ;;
  1864. *)
  1865. : ${MULTILIB_ABIS=default};
  1866. : ${DEFAULT_ABI=default}
  1867. ;;
  1868. esac;
  1869. export MULTILIB_ABIS DEFAULT_ABI
  1870. }
  1871. multilib_toolchain_setup ()
  1872. {
  1873. local v vv;
  1874. export ABI=$1;
  1875. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  1876. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1877. do
  1878. vv="_abi_saved_${v}";
  1879. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  1880. unset ${vv};
  1881. done;
  1882. unset _DEFAULT_ABI_SAVED;
  1883. fi;
  1884. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  1885. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1886. do
  1887. vv="_abi_saved_${v}";
  1888. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  1889. done;
  1890. export _DEFAULT_ABI_SAVED="true";
  1891. if [[ ${CBUILD} == "${CHOST}" ]]; then
  1892. export CBUILD=$(get_abi_CHOST $1);
  1893. fi;
  1894. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  1895. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  1896. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  1897. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  1898. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  1899. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  1900. export CHOST=$(get_abi_CHOST $1);
  1901. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  1902. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  1903. fi
  1904. }
  1905. newicon ()
  1906. {
  1907. _iconins ${FUNCNAME} "$@"
  1908. }
  1909. newmenu ()
  1910. {
  1911. ( insinto /usr/share/applications;
  1912. newins "$@" )
  1913. }
  1914. no-as-needed ()
  1915. {
  1916. case $($(tc-getLD) -v 2>&1 </dev/null) in
  1917. *GNU*)
  1918. echo "-Wl,--no-as-needed"
  1919. ;;
  1920. esac
  1921. }
  1922. number_abis ()
  1923. {
  1924. set -- `get_install_abis`;
  1925. echo $#
  1926. }
  1927. optfeature ()
  1928. {
  1929. debug-print-function ${FUNCNAME} "$@";
  1930. local i j msg;
  1931. local desc=$1;
  1932. local flag=0;
  1933. shift;
  1934. for i in "$@";
  1935. do
  1936. for j in ${i};
  1937. do
  1938. if has_version "${j}"; then
  1939. flag=1;
  1940. else
  1941. flag=0;
  1942. break;
  1943. fi;
  1944. done;
  1945. if [[ ${flag} -eq 1 ]]; then
  1946. break;
  1947. fi;
  1948. done;
  1949. if [[ ${flag} -eq 0 ]]; then
  1950. for i in "$@";
  1951. do
  1952. msg=" ";
  1953. for j in ${i};
  1954. do
  1955. msg+=" ${j} and";
  1956. done;
  1957. msg="${msg:0: -4} for ${desc}";
  1958. elog "${msg}";
  1959. done;
  1960. fi
  1961. }
  1962. path_exists ()
  1963. {
  1964. local opt=$1;
  1965. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  1966. [[ $# -eq 0 ]] && return 1;
  1967. local p r=0;
  1968. for p in "$@";
  1969. do
  1970. [[ -e ${p} ]];
  1971. : $(( r += $? ));
  1972. done;
  1973. case ${opt} in
  1974. -a)
  1975. return $(( r != 0 ))
  1976. ;;
  1977. -o)
  1978. return $(( r == $# ))
  1979. ;;
  1980. esac
  1981. }
  1982. pkg_nofetch ()
  1983. {
  1984. default
  1985. }
  1986. preserve_old_lib ()
  1987. {
  1988. _eutils_eprefix_init;
  1989. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  1990. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  1991. die "Invalid preserve_old_lib() usage";
  1992. fi;
  1993. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  1994. has preserve-libs ${FEATURES} && return 0;
  1995. local lib dir;
  1996. for lib in "$@";
  1997. do
  1998. [[ -e ${EROOT}/${lib} ]] || continue;
  1999. dir=${lib%/*};
  2000. dodir ${dir} || die "dodir ${dir} failed";
  2001. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  2002. touch "${ED}"/${lib};
  2003. done
  2004. }
  2005. preserve_old_lib_notify ()
  2006. {
  2007. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2008. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2009. die "Invalid preserve_old_lib_notify() usage";
  2010. fi;
  2011. has preserve-libs ${FEATURES} && return 0;
  2012. _eutils_eprefix_init;
  2013. local lib notice=0;
  2014. for lib in "$@";
  2015. do
  2016. [[ -e ${EROOT}/${lib} ]] || continue;
  2017. if [[ ${notice} -eq 0 ]]; then
  2018. notice=1;
  2019. ewarn "Old versions of installed libraries were detected on your system.";
  2020. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2021. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2022. ewarn "in order to remove these old dependencies. If you do not have this";
  2023. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2024. ewarn;
  2025. fi;
  2026. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2027. done
  2028. }
  2029. prune_libtool_files ()
  2030. {
  2031. debug-print-function ${FUNCNAME} "$@";
  2032. local removing_all removing_modules opt;
  2033. for opt in "$@";
  2034. do
  2035. case "${opt}" in
  2036. --all)
  2037. removing_all=1;
  2038. removing_modules=1
  2039. ;;
  2040. --modules)
  2041. removing_modules=1
  2042. ;;
  2043. *)
  2044. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2045. ;;
  2046. esac;
  2047. done;
  2048. local f;
  2049. local queue=();
  2050. while IFS= read -r -d '' f; do
  2051. local archivefile=${f/%.la/.a};
  2052. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  2053. continue;
  2054. fi;
  2055. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2056. local reason= pkgconfig_scanned=;
  2057. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  2058. if [[ ${snotlink} == yes ]]; then
  2059. if [[ -f ${archivefile} ]]; then
  2060. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2061. queue+=("${archivefile}");
  2062. fi;
  2063. if [[ -n ${removing_modules} ]]; then
  2064. reason='module';
  2065. fi;
  2066. else
  2067. if [[ -n ${removing_all} ]]; then
  2068. reason='requested';
  2069. else
  2070. if [[ ! -f ${archivefile} ]]; then
  2071. reason='no static archive';
  2072. else
  2073. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2074. reason='no libs & flags';
  2075. else
  2076. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2077. local pc_libs=();
  2078. if [[ ! -n ${removing_all} ]]; then
  2079. local pc;
  2080. local tf=${T}/prune-lt-files.pc;
  2081. local pkgconf=$(tc-getPKG_CONFIG);
  2082. while IFS= read -r -d '' pc; do
  2083. local arg libs;
  2084. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  2085. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2086. libs=$(${pkgconf} --libs "${tf}");
  2087. else
  2088. libs=$(sed -ne 's/^Libs://p' "${pc}");
  2089. fi;
  2090. for arg in ${libs};
  2091. do
  2092. if [[ ${arg} == -l* ]]; then
  2093. if [[ ${arg} == '*$*' ]]; then
  2094. eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2095. eerror "(arg: ${arg})";
  2096. eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2097. die "${FUNCNAME}: unsubstituted variable found in .pc";
  2098. fi;
  2099. pc_libs+=(lib${arg#-l}.la);
  2100. fi;
  2101. done;
  2102. done < <(find "${D}" -type f -name '*.pc' -print0);
  2103. rm -f "${tf}";
  2104. fi;
  2105. pkgconfig_scanned=1;
  2106. fi;
  2107. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2108. fi;
  2109. fi;
  2110. fi;
  2111. fi;
  2112. if [[ -n ${reason} ]]; then
  2113. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2114. queue+=("${f}");
  2115. fi;
  2116. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2117. if [[ -n ${queue[@]} ]]; then
  2118. rm -f "${queue[@]}";
  2119. fi
  2120. }
  2121. raw-ldflags ()
  2122. {
  2123. local x input="$@";
  2124. [[ -z ${input} ]] && input=${LDFLAGS};
  2125. set --;
  2126. for x in ${input};
  2127. do
  2128. case ${x} in
  2129. -Wl,*)
  2130. x=${x#-Wl,};
  2131. set -- "$@" ${x//,/ }
  2132. ;;
  2133. *)
  2134. ;;
  2135. esac;
  2136. done;
  2137. echo "$@"
  2138. }
  2139. replace-cpu-flags ()
  2140. {
  2141. local newcpu="$#";
  2142. newcpu="${!newcpu}";
  2143. while [ $# -gt 1 ]; do
  2144. replace-flags "-march=${1}" "-march=${newcpu}";
  2145. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2146. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2147. shift;
  2148. done;
  2149. return 0
  2150. }
  2151. replace-flags ()
  2152. {
  2153. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2154. local f var new;
  2155. for var in $(all-flag-vars);
  2156. do
  2157. new=();
  2158. for f in ${!var};
  2159. do
  2160. [[ ${f} == ${1} ]] && f=${2};
  2161. new+=("${f}");
  2162. done;
  2163. export ${var}="${new[*]}";
  2164. done;
  2165. return 0
  2166. }
  2167. replace-sparc64-flags ()
  2168. {
  2169. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2170. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2171. for x in ${SPARC64_CPUS};
  2172. do
  2173. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2174. done;
  2175. else
  2176. for x in ${SPARC64_CPUS};
  2177. do
  2178. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2179. done;
  2180. fi;
  2181. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2182. for x in ${SPARC64_CPUS};
  2183. do
  2184. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2185. done;
  2186. else
  2187. for x in ${SPARC64_CPUS};
  2188. do
  2189. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2190. done;
  2191. fi;
  2192. export CFLAGS CXXFLAGS
  2193. }
  2194. setup-allowed-flags ()
  2195. {
  2196. ALLOWED_FLAGS=(-pipe -O '-O[12sg]' -mcpu -march -mtune '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check -fbounds-check -fbounds-checking -fno-strict-overflow -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*');
  2197. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  2198. ALLOWED_FLAGS+=(-mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi -mfix-r10000 -mno-fix-r10000 -mthumb -marm -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha)
  2199. }
  2200. src_compile ()
  2201. {
  2202. default
  2203. }
  2204. src_configure ()
  2205. {
  2206. append-lfs-flags;
  2207. tc-export CC
  2208. }
  2209. src_install ()
  2210. {
  2211. dosbin syslogd klogd debian/syslog-facility debian/syslogd-listfiles;
  2212. doman *.[1-9] debian/syslogd-listfiles.8;
  2213. insinto /etc;
  2214. doins debian/syslog.conf;
  2215. if use logrotate; then
  2216. insinto /etc/logrotate.d;
  2217. newins "${FILESDIR}"/sysklogd.logrotate sysklogd;
  2218. else
  2219. exeinto /etc/cron.daily;
  2220. newexe debian/cron.daily syslog;
  2221. exeinto /etc/cron.weekly;
  2222. newexe debian/cron.weekly syslog;
  2223. fi;
  2224. dodoc ANNOUNCE CHANGES NEWS README.1st README.linux;
  2225. newinitd "${FILESDIR}"/sysklogd.rc7 sysklogd;
  2226. newconfd "${FILESDIR}"/sysklogd.confd sysklogd
  2227. }
  2228. src_prepare ()
  2229. {
  2230. epatch "${WORKDIR}"/${PN}_${DEB_PV}.diff;
  2231. epatch "${FILESDIR}"/${PN}-1.5-debian-cron.patch;
  2232. epatch "${FILESDIR}"/${PN}-1.5-build.patch;
  2233. epatch "${FILESDIR}"/${PN}-1.4.2-caen-owl-syslogd-bind.diff;
  2234. epatch "${FILESDIR}"/${PN}-1.4.2-caen-owl-syslogd-drop-root.diff;
  2235. epatch "${FILESDIR}"/${PN}-1.4.2-caen-owl-klogd-drop-root.diff;
  2236. epatch "${FILESDIR}"/${PN}-1.5-syslog-func-collision.patch
  2237. }
  2238. src_test ()
  2239. {
  2240. default
  2241. }
  2242. src_unpack ()
  2243. {
  2244. default
  2245. }
  2246. strip-flags ()
  2247. {
  2248. local x y var;
  2249. local ALLOWED_FLAGS;
  2250. setup-allowed-flags;
  2251. set -f;
  2252. for var in $(all-flag-vars);
  2253. do
  2254. local new=();
  2255. for x in ${!var};
  2256. do
  2257. local flag=${x%%=*};
  2258. for y in "${ALLOWED_FLAGS[@]}";
  2259. do
  2260. if [[ -z ${flag%%${y}} ]]; then
  2261. new+=("${x}");
  2262. break;
  2263. fi;
  2264. done;
  2265. done;
  2266. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2267. new+=(-O2);
  2268. fi;
  2269. if [[ ${!var} != "${new[*]}" ]]; then
  2270. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  2271. fi;
  2272. export ${var}="${new[*]}";
  2273. done;
  2274. set +f;
  2275. return 0
  2276. }
  2277. strip-linguas ()
  2278. {
  2279. local ls newls nols;
  2280. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2281. local op=$1;
  2282. shift;
  2283. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2284. shift;
  2285. local d f;
  2286. for d in "$@";
  2287. do
  2288. if [[ ${op} == "-u" ]]; then
  2289. newls=${ls};
  2290. else
  2291. newls="";
  2292. fi;
  2293. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2294. do
  2295. if [[ ${op} == "-i" ]]; then
  2296. has ${f} ${ls} && newls="${newls} ${f}";
  2297. else
  2298. has ${f} ${ls} || newls="${newls} ${f}";
  2299. fi;
  2300. done;
  2301. ls=${newls};
  2302. done;
  2303. else
  2304. ls="$@";
  2305. fi;
  2306. nols="";
  2307. newls="";
  2308. for f in ${LINGUAS};
  2309. do
  2310. if has ${f} ${ls}; then
  2311. newls="${newls} ${f}";
  2312. else
  2313. nols="${nols} ${f}";
  2314. fi;
  2315. done;
  2316. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2317. export LINGUAS=${newls:1}
  2318. }
  2319. strip-unsupported-flags ()
  2320. {
  2321. export CFLAGS=$(test-flags-CC ${CFLAGS});
  2322. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  2323. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  2324. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  2325. export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  2326. }
  2327. tc-arch ()
  2328. {
  2329. tc-ninja_magic_to_arch portage "$@"
  2330. }
  2331. tc-arch-kernel ()
  2332. {
  2333. tc-ninja_magic_to_arch kern "$@"
  2334. }
  2335. tc-check-openmp ()
  2336. {
  2337. if ! tc-has-openmp; then
  2338. eerror "Your current compiler does not support OpenMP!";
  2339. if tc-is-gcc; then
  2340. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  2341. else
  2342. if tc-is-clang; then
  2343. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  2344. fi;
  2345. fi;
  2346. die "Active compiler does not have required support for OpenMP";
  2347. fi
  2348. }
  2349. tc-enables-pie ()
  2350. {
  2351. local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
  2352. #if defined(__PIE__)
  2353. true
  2354. #endif
  2355. EOF
  2356. )";
  2357. [[ ${ret} == true ]]
  2358. }
  2359. tc-enables-ssp ()
  2360. {
  2361. local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
  2362. #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)
  2363. true
  2364. #endif
  2365. EOF
  2366. )";
  2367. [[ ${ret} == true ]]
  2368. }
  2369. tc-enables-ssp-all ()
  2370. {
  2371. local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
  2372. #if defined(__SSP_ALL__)
  2373. true
  2374. #endif
  2375. EOF
  2376. )";
  2377. [[ ${ret} == true ]]
  2378. }
  2379. tc-enables-ssp-strong ()
  2380. {
  2381. local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
  2382. #if defined(__SSP_STRONG__) || defined(__SSP_ALL__)
  2383. true
  2384. #endif
  2385. EOF
  2386. )";
  2387. [[ ${ret} == true ]]
  2388. }
  2389. tc-endian ()
  2390. {
  2391. local host=$1;
  2392. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2393. host=${host%%-*};
  2394. case ${host} in
  2395. aarch64*be)
  2396. echo big
  2397. ;;
  2398. aarch64)
  2399. echo little
  2400. ;;
  2401. alpha*)
  2402. echo little
  2403. ;;
  2404. arm*b*)
  2405. echo big
  2406. ;;
  2407. arm*)
  2408. echo little
  2409. ;;
  2410. cris*)
  2411. echo little
  2412. ;;
  2413. hppa*)
  2414. echo big
  2415. ;;
  2416. i?86*)
  2417. echo little
  2418. ;;
  2419. ia64*)
  2420. echo little
  2421. ;;
  2422. m68*)
  2423. echo big
  2424. ;;
  2425. mips*l*)
  2426. echo little
  2427. ;;
  2428. mips*)
  2429. echo big
  2430. ;;
  2431. powerpc*le)
  2432. echo little
  2433. ;;
  2434. powerpc*)
  2435. echo big
  2436. ;;
  2437. s390*)
  2438. echo big
  2439. ;;
  2440. sh*b*)
  2441. echo big
  2442. ;;
  2443. sh*)
  2444. echo little
  2445. ;;
  2446. sparc*)
  2447. echo big
  2448. ;;
  2449. x86_64*)
  2450. echo little
  2451. ;;
  2452. *)
  2453. echo wtf
  2454. ;;
  2455. esac
  2456. }
  2457. tc-env_build ()
  2458. {
  2459. tc-export_build_env;
  2460. 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) "$@"
  2461. }
  2462. tc-export ()
  2463. {
  2464. local var;
  2465. for var in "$@";
  2466. do
  2467. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2468. "tc-get${var}" > /dev/null;
  2469. done
  2470. }
  2471. tc-export_build_env ()
  2472. {
  2473. tc-export "$@";
  2474. : ${BUILD_CFLAGS:=-O1 -pipe};
  2475. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2476. : ${BUILD_CPPFLAGS:= };
  2477. : ${BUILD_LDFLAGS:= };
  2478. export BUILD_{C,CXX,CPP,LD}FLAGS;
  2479. local v;
  2480. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  2481. do
  2482. export ${v#BUILD_}_FOR_BUILD="${!v}";
  2483. done
  2484. }
  2485. tc-get-compiler-type ()
  2486. {
  2487. local code='
  2488. #if defined(__PATHSCALE__)
  2489. HAVE_PATHCC
  2490. #elif defined(__clang__)
  2491. HAVE_CLANG
  2492. #elif defined(__GNUC__)
  2493. HAVE_GCC
  2494. #endif
  2495. ';
  2496. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  2497. case ${res} in
  2498. *HAVE_PATHCC*)
  2499. echo pathcc
  2500. ;;
  2501. *HAVE_CLANG*)
  2502. echo clang
  2503. ;;
  2504. *HAVE_GCC*)
  2505. echo gcc
  2506. ;;
  2507. *)
  2508. echo unknown
  2509. ;;
  2510. esac
  2511. }
  2512. tc-getAR ()
  2513. {
  2514. tc-getPROG AR ar "$@"
  2515. }
  2516. tc-getAS ()
  2517. {
  2518. tc-getPROG AS as "$@"
  2519. }
  2520. tc-getBUILD_AR ()
  2521. {
  2522. tc-getBUILD_PROG AR ar "$@"
  2523. }
  2524. tc-getBUILD_AS ()
  2525. {
  2526. tc-getBUILD_PROG AS as "$@"
  2527. }
  2528. tc-getBUILD_CC ()
  2529. {
  2530. tc-getBUILD_PROG CC gcc "$@"
  2531. }
  2532. tc-getBUILD_CPP ()
  2533. {
  2534. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  2535. }
  2536. tc-getBUILD_CXX ()
  2537. {
  2538. tc-getBUILD_PROG CXX g++ "$@"
  2539. }
  2540. tc-getBUILD_LD ()
  2541. {
  2542. tc-getBUILD_PROG LD ld "$@"
  2543. }
  2544. tc-getBUILD_NM ()
  2545. {
  2546. tc-getBUILD_PROG NM nm "$@"
  2547. }
  2548. tc-getBUILD_OBJCOPY ()
  2549. {
  2550. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2551. }
  2552. tc-getBUILD_PKG_CONFIG ()
  2553. {
  2554. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2555. }
  2556. tc-getBUILD_PROG ()
  2557. {
  2558. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  2559. }
  2560. tc-getBUILD_RANLIB ()
  2561. {
  2562. tc-getBUILD_PROG RANLIB ranlib "$@"
  2563. }
  2564. tc-getBUILD_STRIP ()
  2565. {
  2566. tc-getBUILD_PROG STRIP strip "$@"
  2567. }
  2568. tc-getCC ()
  2569. {
  2570. tc-getPROG CC gcc "$@"
  2571. }
  2572. tc-getCPP ()
  2573. {
  2574. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  2575. }
  2576. tc-getCXX ()
  2577. {
  2578. tc-getPROG CXX g++ "$@"
  2579. }
  2580. tc-getDLLWRAP ()
  2581. {
  2582. tc-getPROG DLLWRAP dllwrap "$@"
  2583. }
  2584. tc-getF77 ()
  2585. {
  2586. tc-getPROG F77 gfortran "$@"
  2587. }
  2588. tc-getFC ()
  2589. {
  2590. tc-getPROG FC gfortran "$@"
  2591. }
  2592. tc-getGCJ ()
  2593. {
  2594. tc-getPROG GCJ gcj "$@"
  2595. }
  2596. tc-getGO ()
  2597. {
  2598. tc-getPROG GO gccgo "$@"
  2599. }
  2600. tc-getLD ()
  2601. {
  2602. tc-getPROG LD ld "$@"
  2603. }
  2604. tc-getNM ()
  2605. {
  2606. tc-getPROG NM nm "$@"
  2607. }
  2608. tc-getOBJCOPY ()
  2609. {
  2610. tc-getPROG OBJCOPY objcopy "$@"
  2611. }
  2612. tc-getOBJDUMP ()
  2613. {
  2614. tc-getPROG OBJDUMP objdump "$@"
  2615. }
  2616. tc-getPKG_CONFIG ()
  2617. {
  2618. tc-getPROG PKG_CONFIG pkg-config "$@"
  2619. }
  2620. tc-getPROG ()
  2621. {
  2622. _tc-getPROG CHOST "$@"
  2623. }
  2624. tc-getRANLIB ()
  2625. {
  2626. tc-getPROG RANLIB ranlib "$@"
  2627. }
  2628. tc-getRC ()
  2629. {
  2630. tc-getPROG RC windres "$@"
  2631. }
  2632. tc-getSTRIP ()
  2633. {
  2634. tc-getPROG STRIP strip "$@"
  2635. }
  2636. tc-has-openmp ()
  2637. {
  2638. local base="${T}/test-tc-openmp";
  2639. cat > "${base}.c" <<-EOF
  2640. #include <omp.h>
  2641. int main() {
  2642. int nthreads, tid, ret = 0;
  2643. #pragma omp parallel private(nthreads, tid)
  2644. {
  2645. tid = omp_get_thread_num();
  2646. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  2647. }
  2648. return ret;
  2649. }
  2650. EOF
  2651. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  2652. local ret=$?;
  2653. rm -f "${base}"*;
  2654. return ${ret}
  2655. }
  2656. tc-has-tls ()
  2657. {
  2658. local base="${T}/test-tc-tls";
  2659. cat > "${base}.c" <<-EOF
  2660. int foo(int *i) {
  2661. static __thread int j = 0;
  2662. return *i ? j : *i;
  2663. }
  2664. EOF
  2665. local flags;
  2666. case $1 in
  2667. -s)
  2668. flags="-S"
  2669. ;;
  2670. -c)
  2671. flags="-c"
  2672. ;;
  2673. -l)
  2674. ;;
  2675. -*)
  2676. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  2677. ;;
  2678. esac;
  2679. : ${flags:=-fPIC -shared -Wl,-z,defs};
  2680. [[ $1 == -* ]] && shift;
  2681. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  2682. local ret=$?;
  2683. rm -f "${base}"*;
  2684. return ${ret}
  2685. }
  2686. tc-is-clang ()
  2687. {
  2688. [[ $(tc-get-compiler-type) == clang ]]
  2689. }
  2690. tc-is-cross-compiler ()
  2691. {
  2692. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  2693. }
  2694. tc-is-gcc ()
  2695. {
  2696. [[ $(tc-get-compiler-type) == gcc ]]
  2697. }
  2698. tc-is-softfloat ()
  2699. {
  2700. local CTARGET=${CTARGET:-${CHOST}};
  2701. case ${CTARGET} in
  2702. bfin* | h8300*)
  2703. echo "only"
  2704. ;;
  2705. *)
  2706. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  2707. echo "yes";
  2708. else
  2709. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  2710. echo "softfp";
  2711. else
  2712. echo "no";
  2713. fi;
  2714. fi
  2715. ;;
  2716. esac
  2717. }
  2718. tc-is-static-only ()
  2719. {
  2720. local host=${CTARGET:-${CHOST}};
  2721. [[ ${host} == *-mint* ]]
  2722. }
  2723. tc-ld-disable-gold ()
  2724. {
  2725. if ! tc-ld-is-gold "$@"; then
  2726. return;
  2727. fi;
  2728. ewarn "Forcing usage of the BFD linker instead of GOLD";
  2729. local ld=$(tc-getLD "$@");
  2730. local bfd_ld="${ld%% *}.bfd";
  2731. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  2732. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  2733. local major=$(gcc-major-version "$@");
  2734. local minor=$(gcc-minor-version "$@");
  2735. if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]]; then
  2736. if [[ -e ${path_ld} ]]; then
  2737. local d="${T}/bfd-linker";
  2738. mkdir -p "${d}";
  2739. ln -sf "${path_ld}" "${d}"/ld;
  2740. export LDFLAGS="${LDFLAGS} -B${d}";
  2741. else
  2742. die "unable to locate a BFD linker to bypass gold";
  2743. fi;
  2744. else
  2745. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  2746. fi
  2747. }
  2748. tc-ld-is-gold ()
  2749. {
  2750. local out;
  2751. out=$($(tc-getLD "$@") --version 2>&1);
  2752. if [[ ${out} == *"GNU gold"* ]]; then
  2753. return 0;
  2754. fi;
  2755. local base="${T}/test-tc-gold";
  2756. cat > "${base}.c" <<-EOF
  2757. int main() { return 0; }
  2758. EOF
  2759. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  2760. rm -f "${base}"*;
  2761. if [[ ${out} == *"GNU gold"* ]]; then
  2762. return 0;
  2763. fi;
  2764. return 1
  2765. }
  2766. tc-ninja_magic_to_arch ()
  2767. {
  2768. function ninj ()
  2769. {
  2770. [[ ${type} == "kern" ]] && echo $1 || echo $2
  2771. };
  2772. local type=$1;
  2773. local host=$2;
  2774. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2775. case ${host} in
  2776. aarch64*)
  2777. echo arm64
  2778. ;;
  2779. alpha*)
  2780. echo alpha
  2781. ;;
  2782. arm*)
  2783. echo arm
  2784. ;;
  2785. avr*)
  2786. ninj avr32 avr
  2787. ;;
  2788. bfin*)
  2789. ninj blackfin bfin
  2790. ;;
  2791. c6x*)
  2792. echo c6x
  2793. ;;
  2794. cris*)
  2795. echo cris
  2796. ;;
  2797. frv*)
  2798. echo frv
  2799. ;;
  2800. hexagon*)
  2801. echo hexagon
  2802. ;;
  2803. hppa*)
  2804. ninj parisc hppa
  2805. ;;
  2806. i?86*)
  2807. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  2808. echo i386;
  2809. else
  2810. echo x86;
  2811. fi
  2812. ;;
  2813. ia64*)
  2814. echo ia64
  2815. ;;
  2816. m68*)
  2817. echo m68k
  2818. ;;
  2819. metag*)
  2820. echo metag
  2821. ;;
  2822. microblaze*)
  2823. echo microblaze
  2824. ;;
  2825. mips*)
  2826. echo mips
  2827. ;;
  2828. nios2*)
  2829. echo nios2
  2830. ;;
  2831. nios*)
  2832. echo nios
  2833. ;;
  2834. or1k | or32*)
  2835. echo openrisc
  2836. ;;
  2837. powerpc*)
  2838. if [[ ${type} == "kern" ]]; then
  2839. echo powerpc;
  2840. else
  2841. if [[ ${host} == powerpc64* ]]; then
  2842. echo ppc64;
  2843. else
  2844. echo ppc;
  2845. fi;
  2846. fi
  2847. ;;
  2848. riscv*)
  2849. echo riscv
  2850. ;;
  2851. s390*)
  2852. echo s390
  2853. ;;
  2854. score*)
  2855. echo score
  2856. ;;
  2857. sh64*)
  2858. ninj sh64 sh
  2859. ;;
  2860. sh*)
  2861. echo sh
  2862. ;;
  2863. sparc64*)
  2864. ninj sparc64 sparc
  2865. ;;
  2866. sparc*)
  2867. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  2868. ;;
  2869. tile*)
  2870. echo tile
  2871. ;;
  2872. vax*)
  2873. echo vax
  2874. ;;
  2875. x86_64*freebsd*)
  2876. echo amd64
  2877. ;;
  2878. x86_64*)
  2879. if [[ ${type} == "kern" ]]; then
  2880. echo x86;
  2881. else
  2882. echo amd64;
  2883. fi
  2884. ;;
  2885. xtensa*)
  2886. echo xtensa
  2887. ;;
  2888. *)
  2889. echo unknown
  2890. ;;
  2891. esac
  2892. }
  2893. tc-stack-grows-down ()
  2894. {
  2895. case ${ARCH} in
  2896. hppa | metag)
  2897. return 1
  2898. ;;
  2899. esac;
  2900. return 0
  2901. }
  2902. test-flag-CC ()
  2903. {
  2904. test-flag-PROG "CC" c "$1"
  2905. }
  2906. test-flag-CXX ()
  2907. {
  2908. test-flag-PROG "CXX" c++ "$1"
  2909. }
  2910. test-flag-F77 ()
  2911. {
  2912. test-flag-PROG "F77" f77 "$1"
  2913. }
  2914. test-flag-FC ()
  2915. {
  2916. test-flag-PROG "FC" f95 "$1"
  2917. }
  2918. test-flag-PROG ()
  2919. {
  2920. local comp=$1;
  2921. local lang=$2;
  2922. local flag=$3;
  2923. [[ -z ${comp} || -z ${flag} ]] && return 1;
  2924. local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  2925. if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  2926. cmdline+=("${flag}" -x${lang} -);
  2927. else
  2928. cmdline+=("${flag}" -c -o /dev/null /dev/null);
  2929. fi;
  2930. if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  2931. cmdline+=(-Qunused-arguments);
  2932. "${cmdline[@]}" < /dev/null &> /dev/null;
  2933. fi
  2934. }
  2935. test-flags ()
  2936. {
  2937. test-flags-CC "$@"
  2938. }
  2939. test-flags-CC ()
  2940. {
  2941. test-flags-PROG "CC" "$@"
  2942. }
  2943. test-flags-CXX ()
  2944. {
  2945. test-flags-PROG "CXX" "$@"
  2946. }
  2947. test-flags-F77 ()
  2948. {
  2949. test-flags-PROG "F77" "$@"
  2950. }
  2951. test-flags-FC ()
  2952. {
  2953. test-flags-PROG "FC" "$@"
  2954. }
  2955. test-flags-PROG ()
  2956. {
  2957. local comp=$1;
  2958. local flags=();
  2959. local x;
  2960. shift;
  2961. [[ -z ${comp} ]] && return 1;
  2962. for x in "$@";
  2963. do
  2964. test-flag-${comp} "${x}" && flags+=("${x}");
  2965. done;
  2966. echo "${flags[*]}";
  2967. [[ ${#flags[@]} -gt 0 ]]
  2968. }
  2969. test_version_info ()
  2970. {
  2971. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  2972. return 0;
  2973. else
  2974. return 1;
  2975. fi
  2976. }
  2977. use_if_iuse ()
  2978. {
  2979. in_iuse $1 || return 1;
  2980. use $1
  2981. }
  2982. usex ()
  2983. {
  2984. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  2985. }
  2986. validate_desktop_entries ()
  2987. {
  2988. eqawarn "validate_desktop_entries is deprecated and should be not be used.";
  2989. eqawarn ".desktop file validation is done implicitly by Portage now.";
  2990. _eutils_eprefix_init;
  2991. if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]]; then
  2992. einfo "Checking desktop entry validity";
  2993. local directories="";
  2994. for d in /usr/share/applications $@;
  2995. do
  2996. [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}";
  2997. done;
  2998. if [[ -n ${directories} ]]; then
  2999. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  3000. do
  3001. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  3002. [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:};
  3003. done;
  3004. fi;
  3005. echo "";
  3006. else
  3007. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  3008. fi
  3009. }
  3010.