spacepaste

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