Advertisement
Guest User

environment

a guest
Mar 6th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 104.40 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_X86="64"
  3. declare -x ALSA_CARDS=""
  4. declare -x ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
  5. declare -x ANDROID_SWT="/usr/share/swt-3.7/lib"
  6. declare -x ANT_HOME="/usr/share/ant"
  7. 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"
  8. declare -x ARCH="amd64"
  9. declare -- BASE_EXPF="src_unpack src_compile src_install"
  10. declare -x BOOTSTRAP_USE="cxx unicode multilib"
  11. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump"
  12. declare -x CAMERAS="ptp2"
  13. declare -x CBUILD="x86_64-pc-linux-gnu"
  14. declare -x CFLAGS="-march=native -O2 -pipe -mno-avx"
  15. declare -x CFLAGS_amd64="-m64"
  16. declare -x CFLAGS_default
  17. declare -x CFLAGS_x32="-mx32"
  18. declare -x CFLAGS_x86="-m32"
  19. declare -x CG_COMPILER_EXE="/opt/bin/cgc"
  20. declare -x CG_INC_PATH="/opt/nvidia-cg-toolkit/include"
  21. declare -x CG_LIB_PATH="/opt/nvidia-cg-toolkit/lib"
  22. declare -x CHOST="x86_64-pc-linux-gnu"
  23. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  24. declare -x CHOST_default="x86_64-pc-linux-gnu"
  25. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  26. declare -x CHOST_x86="i686-pc-linux-gnu"
  27. declare -- CMAKE_BINARY="cmake"
  28. declare -- CMAKE_BUILD_TYPE="Gentoo"
  29. declare -- CMAKE_EXPF="src_compile src_test src_install"
  30. declare -- CMAKE_MAKEFILE_GENERATOR="emake"
  31. declare -- CMAKE_MIN_VERSION="2.8.9"
  32. declare -- CMAKE_REMOVE_MODULES="yes"
  33. declare -- CMAKE_REMOVE_MODULES_LIST="FindBLAS FindLAPACK"
  34. declare -- CMAKE_VERBOSE="ON"
  35. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  36. declare -x COLORFGBG="default;default;0"
  37. declare -x CROSSCOMPILE_OPTS=""
  38. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  39. declare -x CXXFLAGS="-march=native -O2 -pipe -mno-avx"
  40. declare -x DEFAULT_ABI="amd64"
  41. declare -x DEFINED_PHASES=" compile install test unpack"
  42. declare DEPEND=">=dev-util/cmake-2.4
  43. doc? ( app-doc/doxygen ) sys-devel/make >=dev-util/cmake-2.8.9 userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
  44. declare DESCRIPTION="A collection of libraries for robotics, including hardware drivers and algorithms."
  45. declare -x DESKTOP_STARTUP_ID="awesome/urxvt/27131-8-ro-laptop_TIME19173364"
  46. declare -x DESTTREE="/usr"
  47. declare -x DIROPTIONS="-m0755"
  48. declare -x EAPI="0"
  49. declare -x ELIBC="glibc"
  50. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  51. declare -- EPATCH_EXCLUDE=""
  52. declare -- EPATCH_FORCE="no"
  53. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  54. declare -- EPATCH_OPTS=""
  55. declare -- EPATCH_SINGLE_MSG=""
  56. declare -- EPATCH_SOURCE="/var/tmp/portage/dev-libs/gearbox-10.11/work/patch"
  57. declare -- EPATCH_SUFFIX="patch.bz2"
  58. declare -x EXEOPTIONS="-m0755"
  59. declare -x FCFLAGS="-O2 -pipe"
  60. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
  61. declare -x FFLAGS="-O2 -pipe"
  62. declare -x FLTK_DOCDIR="/usr/share/doc/fltk-1.3.0-r1/html"
  63. declare -x GAZEBO_MASTER_URI="http://localhost:11345"
  64. declare -x GAZEBO_MODEL_DATABASE_URI="http://gazebosim.org/models"
  65. declare -x GAZEBO_MODEL_PATH="/usr/local/share/models"
  66. declare -x GAZEBO_PLUGIN_PATH="/usr/local/lib/gazebo-1.4/plugins"
  67. declare -x GAZEBO_RESOURCE_PATH="/usr/local/share/gazebo-1.4:/usr/local/share/gazebo_models"
  68. declare -x GCC_SPECS=""
  69. declare -x GDK_USE_XFT="1"
  70. declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx"
  71. declare -x GRUB_PLATFORMS="efi-64"
  72. declare -x GSETTINGS_BACKEND="dconf"
  73. declare HDEPEND=""
  74. declare -x HG="/usr/bin/hg"
  75. declare HOMEPAGE="http://gearbox.sourceforge.net"
  76. declare -x HUSHLOGIN="FALSE"
  77. declare -x INHERITED=" toolchain-funcs multilib user eutils flag-o-matic base cmake-utils"
  78. declare -x INPUT_DEVICES="evdev synaptics keyboard mouse"
  79. declare -x INSDESTTREE=""
  80. declare -x INSOPTIONS="-m0644"
  81. declare IUSE="doc basic gbxadvanced gbxgarminacfr gbxserialacfr gbxsickacfr gbxsmartbatteryacfr gbxutilacfr hokuyo_aist "
  82. declare -x IUSE_IMPLICIT="prefix"
  83. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  84. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  85. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  86. declare -x KERNEL="linux"
  87. declare -x KERNEL_ABI="amd64"
  88. declare -x KEYWORDS="~x86 ~amd64"
  89. declare -x KV="3.7.10-gentoo"
  90. declare -x LANG="en_GB.UTF-8"
  91. declare -x LCD_DEVICES=""
  92. declare -x LC_COLLATE="C"
  93. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  94. declare -x LDFLAGS_amd64="-m elf_x86_64"
  95. declare -x LDFLAGS_default
  96. declare -x LDFLAGS_x32="-m elf32_x86_64"
  97. declare -x LDFLAGS_x86="-m elf_i386"
  98. declare -x LD_LIBRARY_PATH="/home/ro/nasaview-3.8.0_linux64:/usr/local/lib"
  99. declare -x LIBDIR_amd64="lib64"
  100. declare -x LIBDIR_amd64_fbsd="lib64"
  101. declare -x LIBDIR_default="lib"
  102. declare -x LIBDIR_n32="lib32"
  103. declare -x LIBDIR_n64="lib64"
  104. declare -x LIBDIR_o32="lib"
  105. declare -x LIBDIR_ppc="lib32"
  106. declare -x LIBDIR_ppc64="lib64"
  107. declare -x LIBDIR_s390="lib32"
  108. declare -x LIBDIR_s390x="lib64"
  109. declare -x LIBDIR_sparc32="lib32"
  110. declare -x LIBDIR_sparc64="lib64"
  111. declare -x LIBDIR_x32="libx32"
  112. declare -x LIBDIR_x86="lib32"
  113. declare -x LIBDIR_x86_fbsd="lib32"
  114. declare -x LIBOPTIONS="-m0644"
  115. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  116. declare -x LICENSE="GPL-2"
  117. declare -x LINGUAS="en en_GB hi"
  118. declare -x MAIL="/var/mail/ro"
  119. declare -x MAKEOPTS="-j7"
  120. declare -x MULTILIB_ABIS="amd64 x86"
  121. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  122. 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"
  123. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  124. declare -x MULTIOSDIRS="../lib64:../lib32"
  125. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  126. declare -x OGRE_RESOURCE_PATH="/usr/lib64/OGRE"
  127. declare -x OPENCL_PROFILE="intel"
  128. declare -x OPENGL_PROFILE="xorg-x11"
  129. declare -x PATH="/usr/lib64/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3:/opt/nvidia-cg-toolkit/bin"
  130. declare PDEPEND=""
  131. declare -x PHP_TARGETS=""
  132. declare -x PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
  133. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  134. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/gearbox-10.11/html")'
  135. declare -- PREFIX="/usr"
  136. declare -x PRELINK_PATH_MASK="/opt:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so:/opt/bin/skype"
  137. 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"
  138. declare -x PROPERTIES=""
  139. declare -x PROVIDE=""
  140. declare -x PYTHONDONTWRITEBYTECODE="1"
  141. declare -x PYTHONPATH="/usr/lib/portage/pym:/usr/local/lib/python2.7/site-packages:/opt/ros/fuerte/lib64/python2.7/site-packages:/usr/local/lib/python2.7/site-packages"
  142. declare -x PYTHON_SINGLE_TARGET=""
  143. declare -x PYTHON_TARGETS=""
  144. declare -x QT_GRAPHICSSYSTEM="raster"
  145. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins"
  146. declare -x RDEPEND=">=dev-util/cmake-2.4
  147. doc? ( app-doc/doxygen ) "
  148. declare REPOSITORY
  149. declare REQUIRED_USE=""
  150. declare -x RESTRICT=""
  151. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
  152. declare -x RUBYOPT="-rauto_gem"
  153. declare -x RUBY_TARGETS=""
  154. declare -x R_HOME="/usr/lib64/R"
  155. declare -x S="/var/tmp/portage/dev-libs/gearbox-10.11/work/gearbox-10.11"
  156. declare -x SANDBOX_DEBUG="0"
  157. declare -x SANDBOX_DENY=""
  158. declare -x SANDBOX_PID="20546"
  159. declare -x SANDBOX_PREDICT="/var/tmp/portage/dev-libs/gearbox-10.11/homedir:/dev/crypto:/dev/random:/var/cache/fontconfig"
  160. declare -x SANDBOX_READ="/:/var/tmp"
  161. declare -x SANDBOX_VERBOSE="1"
  162. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/dev-libs/gearbox-10.11/homedir/.bash_history"
  163. declare -x SLOT="0"
  164. declare SRC_URI="mirror://sourceforge/gearbox/gearbox-10.11.tar.gz"
  165. declare -x SYMLINK_LIB="yes"
  166. declare -x USE="abi_x86_64 amd64 basic doc elibc_glibc gbxadvanced hokuyo_aist kernel_linux multilib userland_GNU"
  167. declare -x USERLAND="GNU"
  168. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  169. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  170. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
  171. declare -x USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib NetBSD OpenBSD SunOS uclibc Winnt"
  172. declare -x USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
  173. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  174. declare -x VBOX_APP_HOME="/usr/lib64/virtualbox"
  175. declare -x VIDEO_CARDS=""
  176. declare -- WANT_CMAKE="always"
  177. declare -x WINDOWID="27262982"
  178. declare -x WINDOWPATH="7"
  179. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  180. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  181. declare -x XDG_SESSION_COOKIE="92b7a551e3ec0a07d3c9949d00000008-1362578316.594109-770491392"
  182. 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"
  183. declare -x _E_DOCDESTTREE_=""
  184. declare -x _E_EXEDESTTREE_=""
  185. declare -- ___ECLASS_ONCE_BASE="recur -_+^+_- spank"
  186. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  187. declare -- ___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
  188. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  189. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  190. declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
  191. declare -- phase_func
  192. _assert_pkg_ebuild_phase ()
  193. {
  194. case ${EBUILD_PHASE} in
  195. setup | preinst | postinst)
  196.  
  197. ;;
  198. *)
  199. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  200. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  201. eerror "Package fails at QA and at life. Please file a bug.";
  202. die "Bad package! $1 is only for use in some pkg_* functions!"
  203. ;;
  204. esac
  205. }
  206. _check_build_dir ()
  207. {
  208. : ${CMAKE_USE_DIR:=${S}};
  209. if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  210. BUILD_DIR="${CMAKE_USE_DIR}";
  211. else
  212. if [[ ! -n ${BUILD_DIR} && -n ${CMAKE_BUILD_DIR} ]]; then
  213. eqawarn "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR.";
  214. eqawarn "Please migrate the ebuild to use the new one.";
  215. _RESPECT_CMAKE_BUILD_DIR=1;
  216. fi;
  217. if [[ -n ${_RESPECT_CMAKE_BUILD_DIR} ]]; then
  218. BUILD_DIR=${CMAKE_BUILD_DIR:-${WORKDIR}/${P}_build};
  219. else
  220. : ${BUILD_DIR:=${WORKDIR}/${P}_build};
  221. fi;
  222. fi;
  223. CMAKE_BUILD_DIR=${BUILD_DIR};
  224. mkdir -p "${BUILD_DIR}";
  225. echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
  226. }
  227. _execute_optionaly ()
  228. {
  229. local phase="$1";
  230. shift;
  231. if [[ ${WANT_CMAKE} = always ]]; then
  232. enable_cmake-utils_${phase} "$@";
  233. else
  234. use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@";
  235. fi
  236. }
  237. _filter-hardened ()
  238. {
  239. local f;
  240. for f in "$@";
  241. do
  242. case "${f}" in
  243. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  244. gcc-specs-pie || continue;
  245. is-flagq -nopie || append-flags -nopie
  246. ;;
  247. -fstack-protector)
  248. gcc-specs-ssp || continue;
  249. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  250. ;;
  251. -fstack-protector-all)
  252. gcc-specs-ssp-to-all || continue;
  253. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  254. ;;
  255. -fno-strict-overflow)
  256. gcc-specs-nostrict || continue;
  257. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  258. ;;
  259. esac;
  260. done
  261. }
  262. _filter-var ()
  263. {
  264. local f x var=$1 new=();
  265. shift;
  266. for f in ${!var};
  267. do
  268. for x in "$@";
  269. do
  270. [[ ${f} == ${x} ]] && continue 2;
  271. done;
  272. new+=("${f}");
  273. done;
  274. eval export ${var}=\""${new[*]}"\"
  275. }
  276. _gcc-install-dir ()
  277. {
  278. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  279. }
  280. _gcc-specs-directive_raw ()
  281. {
  282. local cc=$(tc-getCC);
  283. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  284. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  285. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  286. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  287. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  288. { spec=spec $0 }
  289. END { print spec }';
  290. return 0
  291. }
  292. _gcc-specs-exists ()
  293. {
  294. [[ -f $(_gcc-install-dir)/$1 ]]
  295. }
  296. _gcc_fullversion ()
  297. {
  298. local ver="$1";
  299. shift;
  300. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  301. eval echo "$ver"
  302. }
  303. _generator_to_use ()
  304. {
  305. local generator_name;
  306. case ${CMAKE_MAKEFILE_GENERATOR} in
  307. ninja)
  308. generator_name="Ninja"
  309. ;;
  310. emake)
  311. generator_name="Unix Makefiles"
  312. ;;
  313. *)
  314. eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}";
  315. die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
  316. ;;
  317. esac;
  318. echo ${generator_name}
  319. }
  320. _iconins ()
  321. {
  322. ( local funcname=$1;
  323. shift;
  324. local size dir;
  325. local context=apps;
  326. local theme=hicolor;
  327. while [[ $# -gt 0 ]]; do
  328. case $1 in
  329. -s | --size)
  330. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  331. size=${2%%x*};
  332. else
  333. size=${2};
  334. fi;
  335. case ${size} in
  336. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
  337. size=${size}x${size}
  338. ;;
  339. scalable)
  340.  
  341. ;;
  342. *)
  343. eerror "${size} is an unsupported icon size!";
  344. exit 1
  345. ;;
  346. esac;
  347. shift 2
  348. ;;
  349. -t | --theme)
  350. theme=${2};
  351. shift 2
  352. ;;
  353. -c | --context)
  354. context=${2};
  355. shift 2
  356. ;;
  357. *)
  358. if [[ -z ${size} ]]; then
  359. insinto /usr/share/pixmaps;
  360. else
  361. insinto /usr/share/icons/${theme}/${size}/${context};
  362. fi;
  363. if [[ ${funcname} == doicon ]]; then
  364. if [[ -f $1 ]]; then
  365. doins "${1}";
  366. else
  367. if [[ -d $1 ]]; then
  368. shopt -s nullglob;
  369. doins "${1}"/*.{png,svg};
  370. shopt -u nullglob;
  371. else
  372. eerror "${1} is not a valid file/directory!";
  373. exit 1;
  374. fi;
  375. fi;
  376. else
  377. break;
  378. fi;
  379. shift 1
  380. ;;
  381. esac;
  382. done;
  383. if [[ ${funcname} == newicon ]]; then
  384. newins "$@";
  385. fi ) || die
  386. }
  387. _is_flagq ()
  388. {
  389. local x var;
  390. eval var=\""\${$1[*]}"\";
  391. for x in ${var};
  392. do
  393. [[ ${x} == $2 ]] && return 0;
  394. done;
  395. return 1
  396. }
  397. _modify-cmakelists ()
  398. {
  399. debug-print-function ${FUNCNAME} "$@";
  400. grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0;
  401. find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + || die "${LINENO}: failed to disable hardcoded settings";
  402. cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<-_EOF_
  403.  
  404. MESSAGE(STATUS "<<< Gentoo configuration >>>
  405. Build type \${CMAKE_BUILD_TYPE}
  406. Install path \${CMAKE_INSTALL_PREFIX}
  407. Compiler flags:
  408. C \${CMAKE_C_FLAGS}
  409. C++ \${CMAKE_CXX_FLAGS}
  410. Linker flags:
  411. Executable \${CMAKE_EXE_LINKER_FLAGS}
  412. Module \${CMAKE_MODULE_LINKER_FLAGS}
  413. Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
  414. _EOF_
  415.  
  416. }
  417. _tc-getPROG ()
  418. {
  419. local tuple=$1;
  420. local v var vars=$2;
  421. local prog=$3;
  422. var=${vars%% *};
  423. for v in ${vars};
  424. do
  425. if [[ -n ${!v} ]]; then
  426. export ${var}="${!v}";
  427. echo "${!v}";
  428. return 0;
  429. fi;
  430. done;
  431. local search=;
  432. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  433. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  434. [[ -n ${search} ]] && prog=${search##*/};
  435. export ${var}=${prog};
  436. echo "${!var}"
  437. }
  438. _use_me_now ()
  439. {
  440. debug-print-function ${FUNCNAME} "$@";
  441. local uper capitalised x;
  442. [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  443. if [[ ! -z $3 ]]; then
  444. echo "-D$1$3=$(use $2 && echo ON || echo OFF)";
  445. else
  446. uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  447. capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  448. for x in $2 $uper $capitalised;
  449. do
  450. echo "-D$1$x=$(use $2 && echo ON || echo OFF) ";
  451. done;
  452. fi
  453. }
  454. _use_me_now_inverted ()
  455. {
  456. debug-print-function ${FUNCNAME} "$@";
  457. local uper capitalised x;
  458. [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  459. if [[ ! -z $3 ]]; then
  460. echo "-D$1$3=$(use $2 && echo OFF || echo ON)";
  461. else
  462. uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  463. capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  464. for x in $2 $uper $capitalised;
  465. do
  466. echo "-D$1$x=$(use $2 && echo OFF || echo ON) ";
  467. done;
  468. fi
  469. }
  470. all-flag-vars ()
  471. {
  472. echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  473. }
  474. append-cflags ()
  475. {
  476. [[ $# -eq 0 ]] && return 0;
  477. export CFLAGS=$(test-flags-CC ${CFLAGS} "$@");
  478. return 0
  479. }
  480. append-cppflags ()
  481. {
  482. [[ $# -eq 0 ]] && return 0;
  483. export CPPFLAGS="${CPPFLAGS} $*";
  484. return 0
  485. }
  486. append-cxxflags ()
  487. {
  488. [[ $# -eq 0 ]] && return 0;
  489. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS} "$@");
  490. return 0
  491. }
  492. append-fflags ()
  493. {
  494. [[ $# -eq 0 ]] && return 0;
  495. export FFLAGS=$(test-flags-F77 ${FFLAGS} "$@");
  496. export FCFLAGS=$(test-flags-FC ${FCFLAGS} "$@");
  497. return 0
  498. }
  499. append-flags ()
  500. {
  501. [[ $# -eq 0 ]] && return 0;
  502. case " $* " in
  503. *' '-[DIU]*)
  504. eqawarn 'please use append-cppflags for preprocessor flags'
  505. ;;
  506. *' '-L* | *' '-Wl,*)
  507. eqawarn 'please use append-ldflags for linker flags'
  508. ;;
  509. esac;
  510. append-cflags "$@";
  511. append-cxxflags "$@";
  512. append-fflags "$@";
  513. return 0
  514. }
  515. append-ldflags ()
  516. {
  517. [[ $# -eq 0 ]] && return 0;
  518. local flag;
  519. for flag in "$@";
  520. do
  521. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  522. done;
  523. export LDFLAGS="${LDFLAGS} $*";
  524. return 0
  525. }
  526. append-lfs-flags ()
  527. {
  528. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  529. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  530. }
  531. append-libs ()
  532. {
  533. [[ $# -eq 0 ]] && return 0;
  534. local flag;
  535. for flag in "$@";
  536. do
  537. [[ ${flag} == -l* ]] && flag=${flag#-l};
  538. export LIBS="${LIBS} -l${flag}";
  539. done;
  540. return 0
  541. }
  542. base_src_compile ()
  543. {
  544. debug-print-function $FUNCNAME "$@";
  545. has src_configure ${BASE_EXPF} || base_src_configure;
  546. base_src_make "$@"
  547. }
  548. base_src_configure ()
  549. {
  550. debug-print-function $FUNCNAME "$@";
  551. [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
  552. }
  553. base_src_install ()
  554. {
  555. debug-print-function $FUNCNAME "$@";
  556. emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME";
  557. base_src_install_docs
  558. }
  559. base_src_install_docs ()
  560. {
  561. debug-print-function $FUNCNAME "$@";
  562. local x;
  563. pushd "${S}" > /dev/null;
  564. if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  565. for x in "${DOCS[@]}";
  566. do
  567. debug-print "$FUNCNAME: docs: creating document from ${x}";
  568. dodoc "${x}" || die "dodoc failed";
  569. done;
  570. fi;
  571. if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  572. for x in "${HTML_DOCS[@]}";
  573. do
  574. debug-print "$FUNCNAME: docs: creating html document from ${x}";
  575. dohtml -r "${x}" || die "dohtml failed";
  576. done;
  577. fi;
  578. popd > /dev/null
  579. }
  580. base_src_make ()
  581. {
  582. debug-print-function $FUNCNAME "$@";
  583. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  584. emake "$@" || die "died running emake, $FUNCNAME";
  585. fi
  586. }
  587. base_src_prepare ()
  588. {
  589. debug-print-function $FUNCNAME "$@";
  590. debug-print "$FUNCNAME: PATCHES=$PATCHES";
  591. local patches_failed=0;
  592. pushd "${S}" > /dev/null;
  593. if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  594. for x in "${PATCHES[@]}";
  595. do
  596. debug-print "$FUNCNAME: applying patch from ${x}";
  597. if [[ -d "${x}" ]]; then
  598. EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch};
  599. oldval=${EPATCH_SOURCE};
  600. EPATCH_SOURCE=${x};
  601. EPATCH_FORCE=yes;
  602. epatch;
  603. EPATCH_SOURCE=${oldval};
  604. else
  605. if [[ -f "${x}" ]]; then
  606. epatch "${x}";
  607. else
  608. ewarn "QA: File or directory \"${x}\" does not exist.";
  609. ewarn "QA: Check your PATCHES array or add missing file/directory.";
  610. patches_failed=1;
  611. fi;
  612. fi;
  613. done;
  614. [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages.";
  615. else
  616. for x in ${PATCHES};
  617. do
  618. debug-print "$FUNCNAME: patching from ${x}";
  619. epatch "${x}";
  620. done;
  621. fi;
  622. debug-print "$FUNCNAME: applying user patches";
  623. epatch_user;
  624. popd > /dev/null
  625. }
  626. base_src_unpack ()
  627. {
  628. debug-print-function $FUNCNAME "$@";
  629. pushd "${WORKDIR}" > /dev/null;
  630. if [[ $(type -t unpacker_src_unpack) == "function" ]]; then
  631. unpacker_src_unpack;
  632. else
  633. if [[ -n ${A} ]]; then
  634. unpack ${A};
  635. fi;
  636. fi;
  637. has src_prepare ${BASE_EXPF} || base_src_prepare;
  638. popd > /dev/null
  639. }
  640. built_with_use ()
  641. {
  642. local hidden="no";
  643. if [[ $1 == "--hidden" ]]; then
  644. hidden="yes";
  645. shift;
  646. fi;
  647. local missing_action="die";
  648. if [[ $1 == "--missing" ]]; then
  649. missing_action=$2;
  650. shift;
  651. shift;
  652. case ${missing_action} in
  653. true | false | die)
  654.  
  655. ;;
  656. *)
  657. die "unknown action '${missing_action}'"
  658. ;;
  659. esac;
  660. fi;
  661. local opt=$1;
  662. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  663. local PKG=$(best_version $1);
  664. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  665. shift;
  666. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  667. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  668. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  669. case ${missing_action} in
  670. true)
  671. return 0
  672. ;;
  673. false)
  674. return 1
  675. ;;
  676. die)
  677. die "Unable to determine what USE flags $PKG was built with"
  678. ;;
  679. esac;
  680. fi;
  681. if [[ ${hidden} == "no" ]]; then
  682. local IUSE_BUILT=($(<"${IUSEFILE}"));
  683. local expand;
  684. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  685. do
  686. if [[ $1 == ${expand}_* ]]; then
  687. expand="";
  688. break;
  689. fi;
  690. done;
  691. if [[ -n ${expand} ]]; then
  692. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  693. case ${missing_action} in
  694. true)
  695. return 0
  696. ;;
  697. false)
  698. return 1
  699. ;;
  700. die)
  701. die "$PKG does not actually support the $1 USE flag!"
  702. ;;
  703. esac;
  704. fi;
  705. fi;
  706. fi;
  707. local USE_BUILT=$(<${USEFILE});
  708. while [[ $# -gt 0 ]]; do
  709. if [[ ${opt} = "-o" ]]; then
  710. has $1 ${USE_BUILT} && return 0;
  711. else
  712. has $1 ${USE_BUILT} || return 1;
  713. fi;
  714. shift;
  715. done;
  716. [[ ${opt} = "-a" ]]
  717. }
  718. check_license ()
  719. {
  720. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  721. }
  722. cmake-utils_src_compile ()
  723. {
  724. _execute_optionaly "src_compile" "$@"
  725. }
  726. cmake-utils_src_configure ()
  727. {
  728. _execute_optionaly "src_configure" "$@"
  729. }
  730. cmake-utils_src_install ()
  731. {
  732. _execute_optionaly "src_install" "$@"
  733. }
  734. cmake-utils_src_make ()
  735. {
  736. debug-print-function ${FUNCNAME} "$@";
  737. _check_build_dir;
  738. pushd "${BUILD_DIR}" > /dev/null;
  739. ${CMAKE_MAKEFILE_GENERATOR}_src_make $@;
  740. popd > /dev/null
  741. }
  742. cmake-utils_src_prepare ()
  743. {
  744. _execute_optionaly "src_prepare" "$@"
  745. }
  746. cmake-utils_src_test ()
  747. {
  748. _execute_optionaly "src_test" "$@"
  749. }
  750. cmake-utils_use ()
  751. {
  752. _use_me_now "" "$@"
  753. }
  754. cmake-utils_use_build ()
  755. {
  756. _use_me_now BUILD_ "$@"
  757. }
  758. cmake-utils_use_disable ()
  759. {
  760. _use_me_now_inverted DISABLE_ "$@"
  761. }
  762. cmake-utils_use_enable ()
  763. {
  764. _use_me_now ENABLE_ "$@"
  765. }
  766. cmake-utils_use_find_package ()
  767. {
  768. _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@"
  769. }
  770. cmake-utils_use_has ()
  771. {
  772. _use_me_now HAVE_ "$@"
  773. }
  774. cmake-utils_use_no ()
  775. {
  776. _use_me_now_inverted NO_ "$@"
  777. }
  778. cmake-utils_use_use ()
  779. {
  780. _use_me_now USE_ "$@"
  781. }
  782. cmake-utils_use_want ()
  783. {
  784. _use_me_now WANT_ "$@"
  785. }
  786. cmake-utils_use_with ()
  787. {
  788. _use_me_now WITH_ "$@"
  789. }
  790. doicon ()
  791. {
  792. _iconins ${FUNCNAME} "$@"
  793. }
  794. domenu ()
  795. {
  796. ( local i j ret=0;
  797. insinto /usr/share/applications;
  798. for i in "$@";
  799. do
  800. if [[ -f ${i} ]]; then
  801. doins "${i}";
  802. ((ret+=$?));
  803. else
  804. if [[ -d ${i} ]]; then
  805. for j in "${i}"/*.desktop;
  806. do
  807. doins "${j}";
  808. ((ret+=$?));
  809. done;
  810. else
  811. ((++ret));
  812. fi;
  813. fi;
  814. done;
  815. exit ${ret} )
  816. }
  817. ebeep ()
  818. {
  819. local n;
  820. if [[ -z ${EBEEP_IGNORE} ]]; then
  821. for ((n=1 ; n <= ${1:-5} ; n++))
  822. do
  823. echo -ne "\a";
  824. sleep 0.1 &>/dev/null;
  825. sleep 0,1 &>/dev/null;
  826. echo -ne "\a";
  827. sleep 1;
  828. done;
  829. fi
  830. }
  831. econf_build ()
  832. {
  833. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  834. }
  835. ecvs_clean ()
  836. {
  837. [[ -z $* ]] && set -- .;
  838. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  839. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  840. }
  841. edos2unix ()
  842. {
  843. [[ $# -eq 0 ]] && return 0;
  844. sed -i 's/\r$//' -- "$@" || die
  845. }
  846. egetent ()
  847. {
  848. local db=$1 key=$2;
  849. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  850. case ${db} in
  851. passwd | group)
  852.  
  853. ;;
  854. *)
  855. die "sorry, database '${db}' not yet supported; file a bug"
  856. ;;
  857. esac;
  858. case ${CHOST} in
  859. *-darwin[678])
  860. case ${key} in
  861. *[!0-9]*)
  862. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  863. ;;
  864. *)
  865. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  866. ;;
  867. esac
  868. ;;
  869. *-darwin*)
  870. local mykey;
  871. case ${db} in
  872. passwd)
  873. db="Users" mykey="UniqueID"
  874. ;;
  875. group)
  876. db="Groups" mykey="PrimaryGroupID"
  877. ;;
  878. esac;
  879. case ${key} in
  880. *[!0-9]*)
  881. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  882. ;;
  883. *)
  884. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  885. ;;
  886. esac
  887. ;;
  888. *-freebsd* | *-dragonfly*)
  889. case ${db} in
  890. passwd)
  891. db="user"
  892. ;;
  893. *)
  894.  
  895. ;;
  896. esac;
  897. local opts;
  898. if [[ ${key} == [[:digit:]]* ]]; then
  899. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  900. fi;
  901. pw show ${db} ${opts} "${key}" -q
  902. ;;
  903. *-netbsd* | *-openbsd*)
  904. grep "${key}:\*:" /etc/${db}
  905. ;;
  906. *)
  907. nscd -i "${db}" 2> /dev/null;
  908. getent "${db}" "${key}"
  909. ;;
  910. esac
  911. }
  912. egethome ()
  913. {
  914. local pos;
  915. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  916. case ${CHOST} in
  917. *-darwin* | *-freebsd* | *-dragonfly*)
  918. pos=9
  919. ;;
  920. *)
  921. pos=6
  922. ;;
  923. esac;
  924. egetent passwd "$1" | cut -d: -f${pos}
  925. }
  926. egetshell ()
  927. {
  928. local pos;
  929. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  930. case ${CHOST} in
  931. *-darwin* | *-freebsd* | *-dragonfly*)
  932. pos=10
  933. ;;
  934. *)
  935. pos=7
  936. ;;
  937. esac;
  938. egetent passwd "$1" | cut -d: -f${pos}
  939. }
  940. emake_src_make ()
  941. {
  942. debug-print-function ${FUNCNAME} "$@";
  943. [[ -e Makefile ]] || die "Makefile not found. Error during configure stage.";
  944. if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
  945. emake VERBOSE=1 "$@" || die;
  946. else
  947. emake "$@" || die;
  948. fi
  949. }
  950. emktemp ()
  951. {
  952. local exe="touch";
  953. [[ $1 == -d ]] && exe="mkdir" && shift;
  954. local topdir=$1;
  955. if [[ -z ${topdir} ]]; then
  956. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  957. fi;
  958. if ! type -P mktemp > /dev/null; then
  959. local tmp=/;
  960. while [[ -e ${tmp} ]]; do
  961. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  962. done;
  963. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  964. echo "${tmp}";
  965. else
  966. if [[ ${exe} == "touch" ]]; then
  967. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  968. else
  969. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  970. fi;
  971. fi
  972. }
  973. enable_cmake-utils_src_compile ()
  974. {
  975. debug-print-function ${FUNCNAME} "$@";
  976. has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure;
  977. cmake-utils_src_make "$@"
  978. }
  979. enable_cmake-utils_src_configure ()
  980. {
  981. debug-print-function ${FUNCNAME} "$@";
  982. [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && {
  983. local name;
  984. for name in ${CMAKE_REMOVE_MODULES_LIST};
  985. do
  986. find "${S}" -name ${name}.cmake -exec rm -v {} +;
  987. done
  988. };
  989. _check_build_dir;
  990. if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]]; then
  991. eerror "Unable to locate CMakeLists.txt under:";
  992. eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"";
  993. eerror "Consider not inheriting the cmake eclass.";
  994. die "FATAL: Unable to find CMakeLists.txt";
  995. fi;
  996. _modify-cmakelists;
  997. export XDG_CONFIG_HOME="${T}";
  998. if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
  999. if ! has debug ${IUSE//+} || ! use debug; then
  1000. append-cppflags -DNDEBUG;
  1001. fi;
  1002. fi;
  1003. local build_rules=${BUILD_DIR}/gentoo_rules.cmake;
  1004. cat > "${build_rules}" <<-_EOF_
  1005. SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
  1006. SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
  1007. SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
  1008. SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
  1009. SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
  1010. SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
  1011. SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
  1012. _EOF_
  1013.  
  1014. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  1015. if [[ -n ${EPREFIX} ]]; then
  1016. cat >> "${build_rules}" <<-_EOF_
  1017. # in Prefix we need rpath and must ensure cmake gets our default linker path
  1018. # right ... except for Darwin hosts
  1019. IF (NOT APPLE)
  1020. SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1021. SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
  1022. CACHE STRING "" FORCE)
  1023.  
  1024. ELSE ()
  1025.  
  1026. SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX}" CACHE STRING ""FORCE)
  1027. SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
  1028. SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1029. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "")
  1030. SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
  1031. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
  1032. SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX}/lib" CACHE STRING "" FORCE)
  1033.  
  1034. ENDIF (NOT APPLE)
  1035. _EOF_
  1036.  
  1037. fi
  1038. local common_config=${BUILD_DIR}/gentoo_common_config.cmake;
  1039. local libdir=$(get_libdir);
  1040. cat > "${common_config}" <<-_EOF_
  1041. SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
  1042. SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
  1043. _EOF_
  1044.  
  1045. [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}";
  1046. if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
  1047. local mycmakeargs_local=(${mycmakeargs});
  1048. else
  1049. local mycmakeargs_local=("${mycmakeargs[@]}");
  1050. fi;
  1051. local cmakeargs=(--no-warn-unused-cli -C "${common_config}" -G "$(_generator_to_use)" -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}" "${mycmakeargs_local[@]}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_INSTALL_DO_STRIP=OFF -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" "${MYCMAKEARGS}");
  1052. pushd "${BUILD_DIR}" > /dev/null;
  1053. debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}";
  1054. echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}";
  1055. "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
  1056. popd > /dev/null
  1057. }
  1058. enable_cmake-utils_src_install ()
  1059. {
  1060. debug-print-function ${FUNCNAME} "$@";
  1061. _check_build_dir;
  1062. pushd "${BUILD_DIR}" > /dev/null;
  1063. DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install";
  1064. base_src_install_docs;
  1065. popd > /dev/null;
  1066. if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
  1067. dodoc ${DOCS} || die "dodoc failed";
  1068. fi;
  1069. if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
  1070. dohtml -r ${HTML_DOCS} || die "dohtml failed";
  1071. fi
  1072. }
  1073. enable_cmake-utils_src_prepare ()
  1074. {
  1075. debug-print-function ${FUNCNAME} "$@";
  1076. base_src_prepare
  1077. }
  1078. enable_cmake-utils_src_test ()
  1079. {
  1080. debug-print-function ${FUNCNAME} "$@";
  1081. _check_build_dir;
  1082. pushd "${BUILD_DIR}" > /dev/null;
  1083. [[ -e CTestTestfile.cmake ]] || {
  1084. echo "No tests found. Skipping.";
  1085. return 0
  1086. };
  1087. [[ -n ${TEST_VERBOSE} ]] && myctestargs+=(--extra-verbose --output-on-failure);
  1088. if ctest "${myctestargs[@]}" "$@"; then
  1089. einfo "Tests succeeded.";
  1090. popd > /dev/null;
  1091. return 0;
  1092. else
  1093. if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]]; then
  1094. eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:";
  1095. eerror "--START TEST LOG--------------------------------------------------------------";
  1096. cat "${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1097. eerror "--END TEST LOG----------------------------------------------------------------";
  1098. die "Tests failed.";
  1099. else
  1100. die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1101. fi;
  1102. popd > /dev/null;
  1103. return 1;
  1104. fi
  1105. }
  1106. enewgroup ()
  1107. {
  1108. _assert_pkg_ebuild_phase ${FUNCNAME};
  1109. local egroup=$1;
  1110. shift;
  1111. if [[ -z ${egroup} ]]; then
  1112. eerror "No group specified !";
  1113. die "Cannot call enewgroup without a group";
  1114. fi;
  1115. if [[ -n $(egetent group "${egroup}") ]]; then
  1116. return 0;
  1117. fi;
  1118. einfo "Adding group '${egroup}' to your system ...";
  1119. local egid=$1;
  1120. shift;
  1121. if [[ ! -z ${egid} ]]; then
  1122. if [[ ${egid} -gt 0 ]]; then
  1123. if [[ -n $(egetent group ${egid}) ]]; then
  1124. egid="next available; requested gid taken";
  1125. fi;
  1126. else
  1127. eerror "Groupid given but is not greater than 0 !";
  1128. die "${egid} is not a valid GID";
  1129. fi;
  1130. else
  1131. egid="next available";
  1132. fi;
  1133. einfo " - Groupid: ${egid}";
  1134. if [[ $# -gt 0 ]]; then
  1135. die "extra arguments no longer supported; please file a bug";
  1136. fi;
  1137. function _enewgroup_next_gid ()
  1138. {
  1139. if [[ ${egid} == *[!0-9]* ]]; then
  1140. for ((egid = 101; egid <= 999; egid++))
  1141. do
  1142. [[ -z $(egetent group ${egid}) ]] && break;
  1143. done;
  1144. fi
  1145. };
  1146. case ${CHOST} in
  1147. *-darwin*)
  1148. _enewgroup_next_gid;
  1149. dscl . create "/groups/${egroup}" gid ${egid};
  1150. dscl . create "/groups/${egroup}" passwd '*'
  1151. ;;
  1152. *-freebsd* | *-dragonfly*)
  1153. _enewgroup_next_gid;
  1154. pw groupadd "${egroup}" -g ${egid} || die
  1155. ;;
  1156. *-netbsd*)
  1157. _enewgroup_next_gid;
  1158. groupadd -g ${egid} "${egroup}" || die
  1159. ;;
  1160. *)
  1161. local opts;
  1162. if [[ ${egid} == *[!0-9]* ]]; then
  1163. opts="";
  1164. else
  1165. opts="-g ${egid}";
  1166. fi;
  1167. groupadd -r ${opts} "${egroup}" || die
  1168. ;;
  1169. esac
  1170. }
  1171. enewuser ()
  1172. {
  1173. _assert_pkg_ebuild_phase ${FUNCNAME};
  1174. local euser=$1;
  1175. shift;
  1176. if [[ -z ${euser} ]]; then
  1177. eerror "No username specified !";
  1178. die "Cannot call enewuser without a username";
  1179. fi;
  1180. if [[ -n $(egetent passwd "${euser}") ]]; then
  1181. return 0;
  1182. fi;
  1183. einfo "Adding user '${euser}' to your system ...";
  1184. local opts=();
  1185. local euid=$1;
  1186. shift;
  1187. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1188. if [[ ${euid} -gt 0 ]]; then
  1189. if [[ -n $(egetent passwd ${euid}) ]]; then
  1190. euid="next";
  1191. fi;
  1192. else
  1193. eerror "Userid given but is not greater than 0 !";
  1194. die "${euid} is not a valid UID";
  1195. fi;
  1196. else
  1197. euid="next";
  1198. fi;
  1199. if [[ ${euid} == "next" ]]; then
  1200. for ((euid = 101; euid <= 999; euid++))
  1201. do
  1202. [[ -z $(egetent passwd ${euid}) ]] && break;
  1203. done;
  1204. fi;
  1205. opts+=(-u ${euid});
  1206. einfo " - Userid: ${euid}";
  1207. local eshell=$1;
  1208. shift;
  1209. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1210. if [[ ! -e ${ROOT}${eshell} ]]; then
  1211. eerror "A shell was specified but it does not exist !";
  1212. die "${eshell} does not exist in ${ROOT}";
  1213. fi;
  1214. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1215. eerror "Do not specify ${eshell} yourself, use -1";
  1216. die "Pass '-1' as the shell parameter";
  1217. fi;
  1218. else
  1219. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1220. do
  1221. [[ -x ${ROOT}${eshell} ]] && break;
  1222. done;
  1223. if [[ ${eshell} == "/dev/null" ]]; then
  1224. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1225. case ${USERLAND} in
  1226. GNU)
  1227. eshell="/bin/false"
  1228. ;;
  1229. BSD)
  1230. eshell="/sbin/nologin"
  1231. ;;
  1232. Darwin)
  1233. eshell="/usr/sbin/nologin"
  1234. ;;
  1235. *)
  1236. die "Unable to identify the default shell for userland ${USERLAND}"
  1237. ;;
  1238. esac;
  1239. fi;
  1240. fi;
  1241. einfo " - Shell: ${eshell}";
  1242. opts+=(-s "${eshell}");
  1243. local ehome=$1;
  1244. shift;
  1245. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1246. ehome="/dev/null";
  1247. fi;
  1248. einfo " - Home: ${ehome}";
  1249. opts+=(-d "${ehome}");
  1250. local egroups=$1;
  1251. shift;
  1252. local g egroups_arr;
  1253. IFS="," read -r -a egroups_arr <<< "${egroups}";
  1254. shift;
  1255. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  1256. local defgroup exgroups;
  1257. for g in "${egroups_arr[@]}";
  1258. do
  1259. if [[ -z $(egetent group "${g}") ]]; then
  1260. eerror "You must add group ${g} to the system first";
  1261. die "${g} is not a valid GID";
  1262. fi;
  1263. if [[ -z ${defgroup} ]]; then
  1264. defgroup=${g};
  1265. else
  1266. exgroups+=",${g}";
  1267. fi;
  1268. done;
  1269. opts+=(-g "${defgroup}");
  1270. if [[ ! -z ${exgroups} ]]; then
  1271. opts+=(-G "${exgroups:1}");
  1272. fi;
  1273. fi;
  1274. einfo " - Groups: ${egroups:-(none)}";
  1275. if [[ $# -gt 0 ]]; then
  1276. die "extra arguments no longer supported; please file a bug";
  1277. else
  1278. local comment="added by portage for ${PN}";
  1279. opts+=(-c "${comment}");
  1280. einfo " - GECOS: ${comment}";
  1281. fi;
  1282. case ${CHOST} in
  1283. *-darwin*)
  1284. dscl . create "/users/${euser}" uid ${euid};
  1285. dscl . create "/users/${euser}" shell "${eshell}";
  1286. dscl . create "/users/${euser}" home "${ehome}";
  1287. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  1288. for g in "${egroups_arr[@]}";
  1289. do
  1290. dscl . merge "/groups/${g}" users "${euser}";
  1291. done
  1292. ;;
  1293. *-freebsd* | *-dragonfly*)
  1294. pw useradd "${euser}" "${opts[@]}" || die
  1295. ;;
  1296. *-netbsd*)
  1297. useradd "${opts[@]}" "${euser}" || die
  1298. ;;
  1299. *-openbsd*)
  1300. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  1301. ;;
  1302. *)
  1303. useradd -r "${opts[@]}" "${euser}" || die
  1304. ;;
  1305. esac;
  1306. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1307. einfo " - Creating ${ehome} in ${ROOT}";
  1308. mkdir -p "${ROOT}/${ehome}";
  1309. chown "${euser}" "${ROOT}/${ehome}";
  1310. chmod 755 "${ROOT}/${ehome}";
  1311. fi
  1312. }
  1313. epatch ()
  1314. {
  1315. function _epatch_draw_line ()
  1316. {
  1317. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1318. echo "${1//?/=}"
  1319. };
  1320. unset P4CONFIG P4PORT P4USER;
  1321. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1322. while [[ $# -gt 0 ]]; do
  1323. case $1 in
  1324. -*)
  1325. EPATCH_OPTS+=("$1")
  1326. ;;
  1327. *)
  1328. break
  1329. ;;
  1330. esac;
  1331. shift;
  1332. done;
  1333. if [[ $# -gt 1 ]]; then
  1334. local m;
  1335. for m in "$@";
  1336. do
  1337. epatch "${m}";
  1338. done;
  1339. return 0;
  1340. fi;
  1341. local SINGLE_PATCH="no";
  1342. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1343. if [[ -f $1 ]]; then
  1344. SINGLE_PATCH="yes";
  1345. set -- "$1";
  1346. local EPATCH_SUFFIX=$1;
  1347. else
  1348. if [[ -d $1 ]]; then
  1349. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1350. else
  1351. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1352. epatch "${EPATCH_SOURCE}/$1";
  1353. return $?;
  1354. else
  1355. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1356. echo;
  1357. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1358. eerror;
  1359. eerror " ${EPATCH_SOURCE}";
  1360. eerror " ( ${EPATCH_SOURCE##*/} )";
  1361. echo;
  1362. die "Cannot find \$EPATCH_SOURCE!";
  1363. fi;
  1364. fi;
  1365. fi;
  1366. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1367. local PIPE_CMD;
  1368. case ${EPATCH_SUFFIX##*\.} in
  1369. xz)
  1370. PIPE_CMD="xz -dc"
  1371. ;;
  1372. lzma)
  1373. PIPE_CMD="lzma -dc"
  1374. ;;
  1375. bz2)
  1376. PIPE_CMD="bzip2 -dc"
  1377. ;;
  1378. gz | Z | z)
  1379. PIPE_CMD="gzip -dc"
  1380. ;;
  1381. ZIP | zip)
  1382. PIPE_CMD="unzip -p"
  1383. ;;
  1384. *)
  1385.  
  1386. ;;
  1387. esac;
  1388. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1389. local x;
  1390. for x in "$@";
  1391. do
  1392. [[ ! -f ${x} ]] && continue;
  1393. local patchname=${x##*/};
  1394. local a=${patchname#*_};
  1395. a=${a%%_*};
  1396. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1397. continue;
  1398. fi;
  1399. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  1400. eshopts_push -o noglob;
  1401. local ex;
  1402. for ex in ${EPATCH_EXCLUDE};
  1403. do
  1404. if [[ ${patchname} == ${ex} ]]; then
  1405. eshopts_pop;
  1406. continue 2;
  1407. fi;
  1408. done;
  1409. eshopts_pop;
  1410. fi;
  1411. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1412. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1413. einfo "${EPATCH_SINGLE_MSG}";
  1414. else
  1415. einfo "Applying ${patchname} ...";
  1416. fi;
  1417. else
  1418. einfo " ${patchname} ...";
  1419. fi;
  1420. local STDERR_TARGET="${T}/${patchname}.out";
  1421. if [[ -e ${STDERR_TARGET} ]]; then
  1422. STDERR_TARGET="${T}/${patchname}-$$.out";
  1423. fi;
  1424. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  1425. local count=0;
  1426. local PATCH_TARGET;
  1427. if [[ -n ${PIPE_CMD} ]]; then
  1428. PATCH_TARGET="${T}/$$.patch";
  1429. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1430. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1431. echo;
  1432. eerror "Could not extract patch!";
  1433. count=5;
  1434. break;
  1435. fi;
  1436. else
  1437. PATCH_TARGET=${x};
  1438. fi;
  1439. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1440. if [[ -n ${abs_paths} ]]; then
  1441. count=1;
  1442. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1443. fi;
  1444. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1445. if [[ -n ${rel_paths} ]]; then
  1446. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  1447. eqawarn " In the future this will cause a failure.";
  1448. eqawarn "${rel_paths}";
  1449. fi;
  1450. local patch_cmd;
  1451. while [[ ${count} -lt 5 ]]; do
  1452. patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}";
  1453. ( _epatch_draw_line "***** ${patchname} *****";
  1454. echo;
  1455. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1456. echo;
  1457. _epatch_draw_line "***** ${patchname} *****";
  1458. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1459. ret=$?;
  1460. echo;
  1461. echo "patch program exited with status ${ret}";
  1462. exit ${ret} ) >> "${STDERR_TARGET}";
  1463. if [ $? -eq 0 ]; then
  1464. ( _epatch_draw_line "***** ${patchname} *****";
  1465. echo;
  1466. echo "ACTUALLY APPLYING ${patchname} ...";
  1467. echo;
  1468. _epatch_draw_line "***** ${patchname} *****";
  1469. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1470. ret=$?;
  1471. echo;
  1472. echo "patch program exited with status ${ret}";
  1473. exit ${ret} ) >> "${STDERR_TARGET}";
  1474. if [ $? -ne 0 ]; then
  1475. echo;
  1476. eerror "A dry-run of patch command succeeded, but actually";
  1477. eerror "applying the patch failed!";
  1478. count=5;
  1479. fi;
  1480. break;
  1481. fi;
  1482. : $(( count++ ));
  1483. done;
  1484. if [[ -n ${PIPE_CMD} ]]; then
  1485. rm -f "${PATCH_TARGET}";
  1486. fi;
  1487. if [[ ${count} -ge 5 ]]; then
  1488. echo;
  1489. eerror "Failed Patch: ${patchname} !";
  1490. eerror " ( ${PATCH_TARGET} )";
  1491. eerror;
  1492. eerror "Include in your bugreport the contents of:";
  1493. eerror;
  1494. eerror " ${STDERR_TARGET}";
  1495. echo;
  1496. die "Failed Patch: ${patchname}!";
  1497. fi;
  1498. rm -f "${STDERR_TARGET}";
  1499. cat >> "${T}/epatch.log" <<-EOF
  1500. PATCH: ${x}
  1501. CMD: ${patch_cmd}
  1502. PWD: ${PWD}
  1503.  
  1504. EOF
  1505.  
  1506. eend 0;
  1507. done;
  1508. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1509. :
  1510. }
  1511. epatch_user ()
  1512. {
  1513. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1514. local applied="${T}/epatch_user.log";
  1515. [[ -e ${applied} ]] && return 2;
  1516. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1517. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}};
  1518. do
  1519. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1520. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1521. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1522. if [[ -d ${EPATCH_SOURCE} ]]; then
  1523. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1524. echo "${EPATCH_SOURCE}" > "${applied}";
  1525. return 0;
  1526. fi;
  1527. done;
  1528. echo "none" > "${applied}";
  1529. return 1
  1530. }
  1531. epause ()
  1532. {
  1533. [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
  1534. }
  1535. epunt_cxx ()
  1536. {
  1537. local dir=$1;
  1538. [[ -z ${dir} ]] && dir=${S};
  1539. ebegin "Removing useless C++ checks";
  1540. local f any_found;
  1541. find "${dir}" -name configure | while read f; do
  1542. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null && any_found=1;
  1543. done;
  1544. if [[ -z ${any_found} ]]; then
  1545. eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt).";
  1546. fi;
  1547. eend 0
  1548. }
  1549. esethome ()
  1550. {
  1551. _assert_pkg_ebuild_phase ${FUNCNAME};
  1552. local euser=$1;
  1553. shift;
  1554. if [[ -z ${euser} ]]; then
  1555. eerror "No username specified !";
  1556. die "Cannot call esethome without a username";
  1557. fi;
  1558. if [[ -z $(egetent passwd "${euser}") ]]; then
  1559. ewarn "User does not exist, cannot set home dir -- skipping.";
  1560. return 1;
  1561. fi;
  1562. local ehome=$1;
  1563. shift;
  1564. if [[ -z ${ehome} ]]; then
  1565. eerror "No home directory specified !";
  1566. die "Cannot call esethome without a home directory or '-1'";
  1567. fi;
  1568. if [[ ${ehome} == "-1" ]]; then
  1569. ehome="/dev/null";
  1570. fi;
  1571. if [[ $(egethome "${euser}") == ${ehome} ]]; then
  1572. return 0;
  1573. fi;
  1574. einfo "Updating home for user '${euser}' ...";
  1575. einfo " - Home: ${ehome}";
  1576. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1577. einfo " - Creating ${ehome} in ${ROOT}";
  1578. mkdir -p "${ROOT}/${ehome}";
  1579. chown "${euser}" "${ROOT}/${ehome}";
  1580. chmod 755 "${ROOT}/${ehome}";
  1581. fi;
  1582. case ${CHOST} in
  1583. *-darwin*)
  1584. dscl . change "/users/${euser}" home "${ehome}"
  1585. ;;
  1586. *-freebsd* | *-dragonfly*)
  1587. pw usermod "${euser}" -d "${ehome}" && return 0;
  1588. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1589. eerror "There was an error when attempting to update the home directory for ${euser}";
  1590. eerror "Please update it manually on your system:";
  1591. eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
  1592. ;;
  1593. *)
  1594. usermod -d "${ehome}" "${euser}" && return 0;
  1595. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1596. eerror "There was an error when attempting to update the home directory for ${euser}";
  1597. eerror "Please update it manually on your system (as root):";
  1598. eerror "\t usermod -d \"${ehome}\" \"${euser}\""
  1599. ;;
  1600. esac
  1601. }
  1602. eshopts_pop ()
  1603. {
  1604. local s;
  1605. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1606. if [[ ${s} == "shopt -"* ]]; then
  1607. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1608. else
  1609. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1610. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1611. fi
  1612. }
  1613. eshopts_push ()
  1614. {
  1615. if [[ $1 == -[su] ]]; then
  1616. estack_push eshopts "$(shopt -p)";
  1617. [[ $# -eq 0 ]] && return 0;
  1618. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1619. else
  1620. estack_push eshopts $-;
  1621. [[ $# -eq 0 ]] && return 0;
  1622. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1623. fi
  1624. }
  1625. estack_pop ()
  1626. {
  1627. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1628. local __estack_name="__ESTACK_$1__";
  1629. shift;
  1630. local __estack_retvar=$1;
  1631. shift;
  1632. eval local __estack_i=\${#${__estack_name}\[@\]};
  1633. [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  1634. if [[ -n ${__estack_retvar} ]]; then
  1635. eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  1636. fi;
  1637. eval unset ${__estack_name}\[${__estack_i}\]
  1638. }
  1639. estack_push ()
  1640. {
  1641. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1642. local stack_name="__ESTACK_$1__";
  1643. shift;
  1644. eval ${stack_name}+=\( \"\$@\" \)
  1645. }
  1646. esvn_clean ()
  1647. {
  1648. [[ -z $* ]] && set -- .;
  1649. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1650. }
  1651. eumask_pop ()
  1652. {
  1653. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1654. local s;
  1655. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1656. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1657. }
  1658. eumask_push ()
  1659. {
  1660. estack_push eumask "$(umask)";
  1661. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1662. }
  1663. filter-flags ()
  1664. {
  1665. _filter-hardened "$@";
  1666. local v;
  1667. for v in $(all-flag-vars);
  1668. do
  1669. _filter-var ${v} "$@";
  1670. done;
  1671. return 0
  1672. }
  1673. filter-ldflags ()
  1674. {
  1675. _filter-var LDFLAGS "$@";
  1676. return 0
  1677. }
  1678. filter-lfs-flags ()
  1679. {
  1680. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1681. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1682. }
  1683. filter-mfpmath ()
  1684. {
  1685. local orig_mfpmath new_math prune_math;
  1686. orig_mfpmath=$(get-flag -mfpmath);
  1687. new_math=$(get-flag mfpmath);
  1688. new_math=" ${new_math//,/ } ";
  1689. prune_math="";
  1690. for prune_math in "$@";
  1691. do
  1692. new_math=${new_math/ ${prune_math} / };
  1693. done;
  1694. new_math=$(echo ${new_math});
  1695. new_math=${new_math// /,};
  1696. if [[ -z ${new_math} ]]; then
  1697. filter-flags ${orig_mfpmath};
  1698. else
  1699. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1700. fi;
  1701. return 0
  1702. }
  1703. gcc-fullversion ()
  1704. {
  1705. _gcc_fullversion '$1.$2.$3' "$@"
  1706. }
  1707. gcc-major-version ()
  1708. {
  1709. _gcc_fullversion '$1' "$@"
  1710. }
  1711. gcc-micro-version ()
  1712. {
  1713. _gcc_fullversion '$3' "$@"
  1714. }
  1715. gcc-minor-version ()
  1716. {
  1717. _gcc_fullversion '$2' "$@"
  1718. }
  1719. gcc-specs-directive ()
  1720. {
  1721. local directive subdname subdirective;
  1722. directive="$(_gcc-specs-directive_raw $1)";
  1723. while [[ ${directive} == *%\(*\)* ]]; do
  1724. subdname=${directive/*%\(};
  1725. subdname=${subdname/\)*};
  1726. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1727. directive="${directive//\%(${subdname})/${subdirective}}";
  1728. done;
  1729. echo "${directive}";
  1730. return 0
  1731. }
  1732. gcc-specs-nostrict ()
  1733. {
  1734. local directive;
  1735. directive=$(gcc-specs-directive cc1);
  1736. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1737. }
  1738. gcc-specs-now ()
  1739. {
  1740. local directive;
  1741. directive=$(gcc-specs-directive link_command);
  1742. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1743. }
  1744. gcc-specs-pie ()
  1745. {
  1746. local directive;
  1747. directive=$(gcc-specs-directive cc1);
  1748. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1749. }
  1750. gcc-specs-relro ()
  1751. {
  1752. local directive;
  1753. directive=$(gcc-specs-directive link_command);
  1754. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1755. }
  1756. gcc-specs-ssp ()
  1757. {
  1758. local directive;
  1759. directive=$(gcc-specs-directive cc1);
  1760. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1761. }
  1762. gcc-specs-ssp-to-all ()
  1763. {
  1764. local directive;
  1765. directive=$(gcc-specs-directive cc1);
  1766. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1767. }
  1768. gcc-version ()
  1769. {
  1770. _gcc_fullversion '$1.$2' "$@"
  1771. }
  1772. gen_usr_ldscript ()
  1773. {
  1774. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1775. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1776. tc-is-static-only && return;
  1777. case ${CTARGET:-${CHOST}} in
  1778. *-darwin*)
  1779.  
  1780. ;;
  1781. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1782. use prefix && return 0
  1783. ;;
  1784. *)
  1785. return 0
  1786. ;;
  1787. esac;
  1788. dodir /usr/${libdir};
  1789. if [[ $1 == "-a" ]]; then
  1790. auto=true;
  1791. shift;
  1792. dodir /${libdir};
  1793. fi;
  1794. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1795. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1796. for lib in "$@";
  1797. do
  1798. local tlib;
  1799. if ${auto}; then
  1800. lib="lib${lib}${suffix}";
  1801. else
  1802. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1803. fi;
  1804. case ${CTARGET:-${CHOST}} in
  1805. *-darwin*)
  1806. if ${auto}; then
  1807. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1808. else
  1809. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1810. fi;
  1811. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1812. tlib=${tlib##*/};
  1813. if ${auto}; then
  1814. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1815. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1816. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1817. fi;
  1818. rm -f "${ED}"/${libdir}/${lib};
  1819. fi;
  1820. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1821. chmod u+w "${ED}${libdir}/${tlib}";
  1822. local nowrite=yes;
  1823. fi;
  1824. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1825. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1826. pushd "${ED}/usr/${libdir}" > /dev/null;
  1827. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1828. popd > /dev/null
  1829. ;;
  1830. *)
  1831. if ${auto}; then
  1832. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1833. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1834. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1835. if [[ ${tlib} != ${lib}* ]]; then
  1836. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1837. fi;
  1838. rm -f "${ED}"/${libdir}/${lib};
  1839. else
  1840. tlib=${lib};
  1841. fi;
  1842. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1843. /* GNU ld script
  1844. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1845. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1846. run into linking problems. This "fake" dynamic lib is a linker script that
  1847. redirects the linker to the real lib. And yes, this works in the cross-
  1848. compiling scenario as the sysroot-ed linker will prepend the real path.
  1849.  
  1850. See bug http://bugs.gentoo.org/4411 for more info.
  1851. */
  1852. ${output_format}
  1853. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1854. END_LDSCRIPT
  1855.  
  1856. ;;
  1857. esac
  1858. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1859. done
  1860. }
  1861. get-flag ()
  1862. {
  1863. local f var findflag="$1";
  1864. for var in $(all-flag-vars);
  1865. do
  1866. for f in ${!var};
  1867. do
  1868. if [ "${f/${findflag}}" != "${f}" ]; then
  1869. printf "%s\n" "${f/-${findflag}=}";
  1870. return 0;
  1871. fi;
  1872. done;
  1873. done;
  1874. return 1
  1875. }
  1876. get_abi_CFLAGS ()
  1877. {
  1878. get_abi_var CFLAGS "$@"
  1879. }
  1880. get_abi_CHOST ()
  1881. {
  1882. get_abi_var CHOST "$@"
  1883. }
  1884. get_abi_CTARGET ()
  1885. {
  1886. get_abi_var CTARGET "$@"
  1887. }
  1888. get_abi_FAKE_TARGETS ()
  1889. {
  1890. get_abi_var FAKE_TARGETS "$@"
  1891. }
  1892. get_abi_LDFLAGS ()
  1893. {
  1894. get_abi_var LDFLAGS "$@"
  1895. }
  1896. get_abi_LIBDIR ()
  1897. {
  1898. get_abi_var LIBDIR "$@"
  1899. }
  1900. get_abi_var ()
  1901. {
  1902. local flag=$1;
  1903. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1904. local var="${flag}_${abi}";
  1905. echo ${!var}
  1906. }
  1907. get_all_abis ()
  1908. {
  1909. local x order="" mvar dvar;
  1910. mvar="MULTILIB_ABIS";
  1911. dvar="DEFAULT_ABI";
  1912. if [[ -n $1 ]]; then
  1913. mvar="$1_${mvar}";
  1914. dvar="$1_${dvar}";
  1915. fi;
  1916. if [[ -z ${!mvar} ]]; then
  1917. echo "default";
  1918. return 0;
  1919. fi;
  1920. for x in ${!mvar};
  1921. do
  1922. if [[ ${x} != ${!dvar} ]]; then
  1923. order="${order:+${order} }${x}";
  1924. fi;
  1925. done;
  1926. order="${order:+${order} }${!dvar}";
  1927. echo ${order};
  1928. return 0
  1929. }
  1930. get_all_libdirs ()
  1931. {
  1932. local libdirs abi;
  1933. for abi in ${MULTILIB_ABIS};
  1934. do
  1935. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1936. done;
  1937. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1938. echo "${libdirs}"
  1939. }
  1940. get_install_abis ()
  1941. {
  1942. local x order="";
  1943. if [[ -z ${MULTILIB_ABIS} ]]; then
  1944. echo "default";
  1945. return 0;
  1946. fi;
  1947. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1948. for x in ${MULTILIB_ABIS};
  1949. do
  1950. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1951. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1952. fi;
  1953. done;
  1954. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1955. if [[ -n ${ABI_ALLOW} ]]; then
  1956. local ordera="";
  1957. for x in ${order};
  1958. do
  1959. if has ${x} ${ABI_ALLOW}; then
  1960. ordera="${ordera} ${x}";
  1961. fi;
  1962. done;
  1963. order=${ordera};
  1964. fi;
  1965. else
  1966. order=${DEFAULT_ABI};
  1967. fi;
  1968. if [[ -z ${order} ]]; then
  1969. 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.";
  1970. fi;
  1971. echo ${order};
  1972. return 0
  1973. }
  1974. get_libdir ()
  1975. {
  1976. local CONF_LIBDIR;
  1977. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1978. echo ${CONF_LIBDIR_OVERRIDE};
  1979. else
  1980. get_abi_LIBDIR;
  1981. fi
  1982. }
  1983. get_libname ()
  1984. {
  1985. local libname;
  1986. local ver=$1;
  1987. case ${CHOST} in
  1988. *-cygwin | mingw* | *-mingw*)
  1989. libname="dll"
  1990. ;;
  1991. *-darwin*)
  1992. libname="dylib"
  1993. ;;
  1994. *-mint*)
  1995. libname="irrelevant"
  1996. ;;
  1997. hppa*-hpux*)
  1998. libname="sl"
  1999. ;;
  2000. *)
  2001. libname="so"
  2002. ;;
  2003. esac;
  2004. if [[ -z $* ]]; then
  2005. echo ".${libname}";
  2006. else
  2007. for ver in "$@";
  2008. do
  2009. case ${CHOST} in
  2010. *-darwin*)
  2011. echo ".${ver}.${libname}"
  2012. ;;
  2013. *-mint*)
  2014. echo ".${libname}"
  2015. ;;
  2016. *)
  2017. echo ".${libname}.${ver}"
  2018. ;;
  2019. esac;
  2020. done;
  2021. fi
  2022. }
  2023. get_modname ()
  2024. {
  2025. local modname;
  2026. local ver=$1;
  2027. case ${CHOST} in
  2028. *-darwin*)
  2029. modname="bundle"
  2030. ;;
  2031. *)
  2032. modname="so"
  2033. ;;
  2034. esac;
  2035. echo ".${modname}"
  2036. }
  2037. has_m32 ()
  2038. {
  2039. die "${FUNCNAME}: don't use this anymore"
  2040. }
  2041. has_m64 ()
  2042. {
  2043. eqawarn "${FUNCNAME}: don't use this anymore";
  2044. local temp="$(emktemp)";
  2045. echo "int main() { return(0); }" > "${temp}".c;
  2046. MY_CC=$(tc-getCC);
  2047. ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  2048. local ret=$?;
  2049. rm -f "${temp}".c;
  2050. [[ ${ret} != 1 ]] && return 0;
  2051. return 1
  2052. }
  2053. has_multilib_profile ()
  2054. {
  2055. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2056. }
  2057. in_iuse ()
  2058. {
  2059. debug-print-function ${FUNCNAME} "${@}";
  2060. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2061. local flag=${1};
  2062. local liuse=(${IUSE});
  2063. has "${flag}" "${liuse[@]#[+-]}"
  2064. }
  2065. is-flag ()
  2066. {
  2067. is-flagq "$@" && echo true
  2068. }
  2069. is-flagq ()
  2070. {
  2071. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2072. local var;
  2073. for var in $(all-flag-vars);
  2074. do
  2075. _is_flagq ${var} "$1" && return 0;
  2076. done;
  2077. return 1
  2078. }
  2079. is-ldflag ()
  2080. {
  2081. is-ldflagq "$@" && echo true
  2082. }
  2083. is-ldflagq ()
  2084. {
  2085. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2086. _is_flagq LDFLAGS $1
  2087. }
  2088. is_final_abi ()
  2089. {
  2090. has_multilib_profile || return 0;
  2091. set -- $(get_install_abis);
  2092. local LAST_ABI=$#;
  2093. [[ ${!LAST_ABI} == ${ABI} ]]
  2094. }
  2095. make_desktop_entry ()
  2096. {
  2097. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2098. local exec=${1};
  2099. local name=${2:-${PN}};
  2100. local icon=${3:-${PN}};
  2101. local type=${4};
  2102. local fields=${5};
  2103. if [[ -z ${type} ]]; then
  2104. local catmaj=${CATEGORY%%-*};
  2105. local catmin=${CATEGORY##*-};
  2106. case ${catmaj} in
  2107. app)
  2108. case ${catmin} in
  2109. accessibility)
  2110. type="Utility;Accessibility"
  2111. ;;
  2112. admin)
  2113. type=System
  2114. ;;
  2115. antivirus)
  2116. type=System
  2117. ;;
  2118. arch)
  2119. type="Utility;Archiving"
  2120. ;;
  2121. backup)
  2122. type="Utility;Archiving"
  2123. ;;
  2124. cdr)
  2125. type="AudioVideo;DiscBurning"
  2126. ;;
  2127. dicts)
  2128. type="Office;Dictionary"
  2129. ;;
  2130. doc)
  2131. type=Documentation
  2132. ;;
  2133. editors)
  2134. type="Utility;TextEditor"
  2135. ;;
  2136. emacs)
  2137. type="Development;TextEditor"
  2138. ;;
  2139. emulation)
  2140. type="System;Emulator"
  2141. ;;
  2142. laptop)
  2143. type="Settings;HardwareSettings"
  2144. ;;
  2145. office)
  2146. type=Office
  2147. ;;
  2148. pda)
  2149. type="Office;PDA"
  2150. ;;
  2151. vim)
  2152. type="Development;TextEditor"
  2153. ;;
  2154. xemacs)
  2155. type="Development;TextEditor"
  2156. ;;
  2157. esac
  2158. ;;
  2159. dev)
  2160. type="Development"
  2161. ;;
  2162. games)
  2163. case ${catmin} in
  2164. action | fps)
  2165. type=ActionGame
  2166. ;;
  2167. arcade)
  2168. type=ArcadeGame
  2169. ;;
  2170. board)
  2171. type=BoardGame
  2172. ;;
  2173. emulation)
  2174. type=Emulator
  2175. ;;
  2176. kids)
  2177. type=KidsGame
  2178. ;;
  2179. puzzle)
  2180. type=LogicGame
  2181. ;;
  2182. roguelike)
  2183. type=RolePlaying
  2184. ;;
  2185. rpg)
  2186. type=RolePlaying
  2187. ;;
  2188. simulation)
  2189. type=Simulation
  2190. ;;
  2191. sports)
  2192. type=SportsGame
  2193. ;;
  2194. strategy)
  2195. type=StrategyGame
  2196. ;;
  2197. esac;
  2198. type="Game;${type}"
  2199. ;;
  2200. gnome)
  2201. type="Gnome;GTK"
  2202. ;;
  2203. kde)
  2204. type="KDE;Qt"
  2205. ;;
  2206. mail)
  2207. type="Network;Email"
  2208. ;;
  2209. media)
  2210. case ${catmin} in
  2211. gfx)
  2212. type=Graphics
  2213. ;;
  2214. *)
  2215. case ${catmin} in
  2216. radio)
  2217. type=Tuner
  2218. ;;
  2219. sound)
  2220. type=Audio
  2221. ;;
  2222. tv)
  2223. type=TV
  2224. ;;
  2225. video)
  2226. type=Video
  2227. ;;
  2228. esac;
  2229. type="AudioVideo;${type}"
  2230. ;;
  2231. esac
  2232. ;;
  2233. net)
  2234. case ${catmin} in
  2235. dialup)
  2236. type=Dialup
  2237. ;;
  2238. ftp)
  2239. type=FileTransfer
  2240. ;;
  2241. im)
  2242. type=InstantMessaging
  2243. ;;
  2244. irc)
  2245. type=IRCClient
  2246. ;;
  2247. mail)
  2248. type=Email
  2249. ;;
  2250. news)
  2251. type=News
  2252. ;;
  2253. nntp)
  2254. type=News
  2255. ;;
  2256. p2p)
  2257. type=FileTransfer
  2258. ;;
  2259. voip)
  2260. type=Telephony
  2261. ;;
  2262. esac;
  2263. type="Network;${type}"
  2264. ;;
  2265. sci)
  2266. case ${catmin} in
  2267. astro*)
  2268. type=Astronomy
  2269. ;;
  2270. bio*)
  2271. type=Biology
  2272. ;;
  2273. calc*)
  2274. type=Calculator
  2275. ;;
  2276. chem*)
  2277. type=Chemistry
  2278. ;;
  2279. elec*)
  2280. type=Electronics
  2281. ;;
  2282. geo*)
  2283. type=Geology
  2284. ;;
  2285. math*)
  2286. type=Math
  2287. ;;
  2288. physics)
  2289. type=Physics
  2290. ;;
  2291. visual*)
  2292. type=DataVisualization
  2293. ;;
  2294. esac;
  2295. type="Education;Science;${type}"
  2296. ;;
  2297. sys)
  2298. type="System"
  2299. ;;
  2300. www)
  2301. case ${catmin} in
  2302. client)
  2303. type=WebBrowser
  2304. ;;
  2305. esac;
  2306. type="Network;${type}"
  2307. ;;
  2308. *)
  2309. type=
  2310. ;;
  2311. esac;
  2312. fi;
  2313. if [ "${SLOT}" == "0" ]; then
  2314. local desktop_name="${PN}";
  2315. else
  2316. local desktop_name="${PN}-${SLOT}";
  2317. fi;
  2318. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2319. type=${type%;}${type:+;};
  2320. eshopts_push -s extglob;
  2321. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2322. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2323. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2324. icon=${icon%.@(xpm|png|svg)};
  2325. fi;
  2326. eshopts_pop;
  2327. cat > "${desktop}" <<-EOF
  2328. [Desktop Entry]
  2329. Name=${name}
  2330. Type=Application
  2331. Comment=${DESCRIPTION}
  2332. Exec=${exec}
  2333. TryExec=${exec%% *}
  2334. Icon=${icon}
  2335. Categories=${type}
  2336. EOF
  2337.  
  2338. if [[ ${fields:-=} != *=* ]]; then
  2339. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2340. fields="Path=${fields}";
  2341. fi;
  2342. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  2343. ( insinto /usr/share/applications;
  2344. doins "${desktop}" ) || die "installing desktop file failed"
  2345. }
  2346. make_session_desktop ()
  2347. {
  2348. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2349. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2350. local title=$1;
  2351. local command=$2;
  2352. local desktop=${T}/${wm:-${PN}}.desktop;
  2353. shift 2;
  2354. cat > "${desktop}" <<-EOF
  2355. [Desktop Entry]
  2356. Name=${title}
  2357. Comment=This session logs you into ${title}
  2358. Exec=${command} $*
  2359. TryExec=${command}
  2360. Type=XSession
  2361. EOF
  2362.  
  2363. ( insinto /usr/share/xsessions;
  2364. doins "${desktop}" )
  2365. }
  2366. make_wrapper ()
  2367. {
  2368. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2369. local tmpwrapper=$(emktemp);
  2370. cat > "${tmpwrapper}" <<EOF
  2371. #!/bin/sh
  2372. cd "${chdir:-.}"
  2373. if [ -n "${libdir}" ] ; then
  2374. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  2375. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  2376. else
  2377. export LD_LIBRARY_PATH="${libdir}"
  2378. fi
  2379. fi
  2380. exec ${bin} "\$@"
  2381. EOF
  2382.  
  2383. chmod go+rx "${tmpwrapper}";
  2384. if [[ -n ${path} ]]; then
  2385. ( exeinto "${path}";
  2386. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2387. else
  2388. newbin "${tmpwrapper}" "${wrapper}" || die;
  2389. fi
  2390. }
  2391. multilib_env ()
  2392. {
  2393. local CTARGET=${1:-${CTARGET}};
  2394. case ${CTARGET} in
  2395. x86_64*)
  2396. export CFLAGS_x86=${CFLAGS_x86--m32};
  2397. export CHOST_x86=${CTARGET/x86_64/i686};
  2398. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2399. export CTARGET_x86=${CHOST_x86};
  2400. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2401. export LIBDIR_x86="lib32";
  2402. else
  2403. export LIBDIR_x86="lib";
  2404. fi;
  2405. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2406. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2407. export CTARGET_amd64=${CHOST_amd64};
  2408. export LIBDIR_amd64="lib64";
  2409. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2410. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2411. export CTARGET_x32=${CHOST_x32};
  2412. export LIBDIR_x32="libx32";
  2413. case ${CTARGET} in
  2414. *-gnux32)
  2415. : ${MULTILIB_ABIS=x32 amd64 x86};
  2416. : ${DEFAULT_ABI=x32}
  2417. ;;
  2418. *)
  2419. : ${MULTILIB_ABIS=amd64 x86};
  2420. : ${DEFAULT_ABI=amd64}
  2421. ;;
  2422. esac
  2423. ;;
  2424. mips64*)
  2425. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2426. export CHOST_o32=${CTARGET/mips64/mips};
  2427. export CTARGET_o32=${CHOST_o32};
  2428. export LIBDIR_o32="lib";
  2429. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2430. export CHOST_n32=${CTARGET};
  2431. export CTARGET_n32=${CHOST_n32};
  2432. export LIBDIR_n32="lib32";
  2433. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2434. export CHOST_n64=${CTARGET};
  2435. export CTARGET_n64=${CHOST_n64};
  2436. export LIBDIR_n64="lib64";
  2437. : ${MULTILIB_ABIS=n64 n32 o32};
  2438. : ${DEFAULT_ABI=n32}
  2439. ;;
  2440. powerpc64*)
  2441. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2442. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2443. export CTARGET_ppc=${CHOST_ppc};
  2444. export LIBDIR_ppc="lib";
  2445. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2446. export CHOST_ppc64=${CTARGET};
  2447. export CTARGET_ppc64=${CHOST_ppc64};
  2448. export LIBDIR_ppc64="lib64";
  2449. : ${MULTILIB_ABIS=ppc64 ppc};
  2450. : ${DEFAULT_ABI=ppc64}
  2451. ;;
  2452. s390x*)
  2453. export CFLAGS_s390=${CFLAGS_s390--m31};
  2454. export CHOST_s390=${CTARGET/s390x/s390};
  2455. export CTARGET_s390=${CHOST_s390};
  2456. export LIBDIR_s390="lib";
  2457. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2458. export CHOST_s390x=${CTARGET};
  2459. export CTARGET_s390x=${CHOST_s390x};
  2460. export LIBDIR_s390x="lib64";
  2461. : ${MULTILIB_ABIS=s390x s390};
  2462. : ${DEFAULT_ABI=s390x}
  2463. ;;
  2464. sparc64*)
  2465. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2466. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2467. export CTARGET_sparc32=${CHOST_sparc32};
  2468. export LIBDIR_sparc32="lib";
  2469. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2470. export CHOST_sparc64=${CTARGET};
  2471. export CTARGET_sparc64=${CHOST_sparc64};
  2472. export LIBDIR_sparc64="lib64";
  2473. : ${MULTILIB_ABIS=sparc64 sparc32};
  2474. : ${DEFAULT_ABI=sparc64}
  2475. ;;
  2476. *)
  2477. : ${MULTILIB_ABIS=default};
  2478. : ${DEFAULT_ABI=default}
  2479. ;;
  2480. esac;
  2481. export MULTILIB_ABIS DEFAULT_ABI
  2482. }
  2483. multilib_toolchain_setup ()
  2484. {
  2485. local v vv;
  2486. export ABI=$1;
  2487. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  2488. for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
  2489. do
  2490. vv="__abi_saved_${v}";
  2491. export ${v}="${!vv}";
  2492. unset ${vv};
  2493. done;
  2494. unset __DEFAULT_ABI_SAVED;
  2495. fi;
  2496. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2497. for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
  2498. do
  2499. export __abi_saved_${v}="${!v}";
  2500. done;
  2501. export __DEFAULT_ABI_SAVED="true";
  2502. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2503. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2504. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2505. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2506. export CHOST=$(get_abi_CHOST $1);
  2507. export CBUILD=$(get_abi_CHOST $1);
  2508. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2509. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2510. fi
  2511. }
  2512. newicon ()
  2513. {
  2514. _iconins ${FUNCNAME} "$@"
  2515. }
  2516. newmenu ()
  2517. {
  2518. ( insinto /usr/share/applications;
  2519. newins "$@" )
  2520. }
  2521. ninja_src_make ()
  2522. {
  2523. debug-print-function ${FUNCNAME} "$@";
  2524. [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage.";
  2525. if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
  2526. ninja ${MAKEOPTS} -v "$@" || die;
  2527. else
  2528. ninja "$@" || die;
  2529. fi
  2530. }
  2531. no-as-needed ()
  2532. {
  2533. case $($(tc-getLD) -v 2>&1 </dev/null) in
  2534. *GNU*)
  2535. echo "-Wl,--no-as-needed"
  2536. ;;
  2537. esac
  2538. }
  2539. number_abis ()
  2540. {
  2541. set -- `get_install_abis`;
  2542. echo $#
  2543. }
  2544. path_exists ()
  2545. {
  2546. local opt=$1;
  2547. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  2548. [[ $# -eq 0 ]] && return 1;
  2549. local p r=0;
  2550. for p in "$@";
  2551. do
  2552. [[ -e ${p} ]];
  2553. : $(( r += $? ));
  2554. done;
  2555. case ${opt} in
  2556. -a)
  2557. return $(( r != 0 ))
  2558. ;;
  2559. -o)
  2560. return $(( r == $# ))
  2561. ;;
  2562. esac
  2563. }
  2564. pkg_nofetch ()
  2565. {
  2566. __eapi0_pkg_nofetch "$@"
  2567. }
  2568. preserve_old_lib ()
  2569. {
  2570. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2571. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2572. die "Invalid preserve_old_lib() usage";
  2573. fi;
  2574. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2575. has preserve-libs ${FEATURES} && return 0;
  2576. local lib dir;
  2577. for lib in "$@";
  2578. do
  2579. [[ -e ${ROOT}/${lib} ]] || continue;
  2580. dir=${lib%/*};
  2581. dodir ${dir} || die "dodir ${dir} failed";
  2582. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  2583. touch "${D}"/${lib};
  2584. done
  2585. }
  2586. preserve_old_lib_notify ()
  2587. {
  2588. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2589. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2590. die "Invalid preserve_old_lib_notify() usage";
  2591. fi;
  2592. has preserve-libs ${FEATURES} && return 0;
  2593. local lib notice=0;
  2594. for lib in "$@";
  2595. do
  2596. [[ -e ${ROOT}/${lib} ]] || continue;
  2597. if [[ ${notice} -eq 0 ]]; then
  2598. notice=1;
  2599. ewarn "Old versions of installed libraries were detected on your system.";
  2600. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2601. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2602. ewarn "in order to remove these old dependencies. If you do not have this";
  2603. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2604. ewarn;
  2605. fi;
  2606. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2607. done
  2608. }
  2609. prune_libtool_files ()
  2610. {
  2611. debug-print-function ${FUNCNAME} "$@";
  2612. local removing_all removing_modules opt;
  2613. for opt in "$@";
  2614. do
  2615. case "${opt}" in
  2616. --all)
  2617. removing_all=1;
  2618. removing_modules=1
  2619. ;;
  2620. --modules)
  2621. removing_modules=1
  2622. ;;
  2623. *)
  2624. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2625. ;;
  2626. esac;
  2627. done;
  2628. local f;
  2629. local queue=();
  2630. while IFS= read -r -d '' f; do
  2631. local archivefile=${f/%.la/.a};
  2632. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2633. local reason pkgconfig_scanned;
  2634. if grep -q '^shouldnotlink=yes$' "${f}"; then
  2635. if [[ -f ${archivefile} ]]; then
  2636. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2637. queue+=("${archivefile}");
  2638. fi;
  2639. if [[ -n ${removing_modules} ]]; then
  2640. reason='module';
  2641. fi;
  2642. else
  2643. if [[ -n ${removing_all} ]]; then
  2644. reason='requested';
  2645. else
  2646. if [[ ! -f ${archivefile} ]]; then
  2647. reason='no static archive';
  2648. else
  2649. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2650. reason='no libs & flags';
  2651. else
  2652. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2653. local pc_libs=();
  2654. if [[ ! -n ${removing_all} ]]; then
  2655. local pc;
  2656. local tf=${T}/prune-lt-files.pc;
  2657. local pkgconf=$(tc-getPKG_CONFIG);
  2658. while IFS= read -r -d '' pc; do
  2659. local arg libs;
  2660. if ${pkgconf} --exists "${pc}" &>/dev/null; then
  2661. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2662. libs=$(${pkgconf} --libs "${tf}");
  2663. else
  2664. libs=$(sed -ne 's/^Libs://p' "${pc}");
  2665. fi;
  2666. for arg in ${libs};
  2667. do
  2668. if [[ ${arg} == -l* ]]; then
  2669. if [[ ${arg} == '*$*' ]]; then
  2670. eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2671. eqawarn "(arg: ${arg})";
  2672. eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2673. fi;
  2674. pc_libs+=(lib${arg#-l}.la);
  2675. fi;
  2676. done;
  2677. done < <(find "${D}" -type f -name '*.pc' -print0);
  2678. rm -f "${tf}";
  2679. fi;
  2680. pkgconfig_scanned=1;
  2681. fi;
  2682. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2683. fi;
  2684. fi;
  2685. fi;
  2686. fi;
  2687. if [[ -n ${reason} ]]; then
  2688. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2689. queue+=("${f}");
  2690. fi;
  2691. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2692. if [[ -n ${queue[@]} ]]; then
  2693. rm -f "${queue[@]}";
  2694. fi
  2695. }
  2696. raw-ldflags ()
  2697. {
  2698. local x input="$@";
  2699. [[ -z ${input} ]] && input=${LDFLAGS};
  2700. set --;
  2701. for x in ${input};
  2702. do
  2703. case ${x} in
  2704. -Wl,*)
  2705. x=${x#-Wl,};
  2706. set -- "$@" ${x//,/ }
  2707. ;;
  2708. *)
  2709.  
  2710. ;;
  2711. esac;
  2712. done;
  2713. echo "$@"
  2714. }
  2715. replace-cpu-flags ()
  2716. {
  2717. local newcpu="$#";
  2718. newcpu="${!newcpu}";
  2719. while [ $# -gt 1 ]; do
  2720. replace-flags "-march=${1}" "-march=${newcpu}";
  2721. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2722. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2723. shift;
  2724. done;
  2725. return 0
  2726. }
  2727. replace-flags ()
  2728. {
  2729. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2730. local f var new;
  2731. for var in $(all-flag-vars);
  2732. do
  2733. new=();
  2734. for f in ${!var};
  2735. do
  2736. [[ ${f} == ${1} ]] && f=${2};
  2737. new+=("${f}");
  2738. done;
  2739. eval export ${var}=\""${new[*]}"\";
  2740. done;
  2741. return 0
  2742. }
  2743. replace-sparc64-flags ()
  2744. {
  2745. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2746. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2747. for x in ${SPARC64_CPUS};
  2748. do
  2749. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2750. done;
  2751. else
  2752. for x in ${SPARC64_CPUS};
  2753. do
  2754. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2755. done;
  2756. fi;
  2757. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2758. for x in ${SPARC64_CPUS};
  2759. do
  2760. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2761. done;
  2762. else
  2763. for x in ${SPARC64_CPUS};
  2764. do
  2765. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2766. done;
  2767. fi;
  2768. export CFLAGS CXXFLAGS
  2769. }
  2770. setup-allowed-flags ()
  2771. {
  2772. ALLOWED_FLAGS="-pipe";
  2773. ALLOWED_FLAGS+=" -O -O1 -O2 -Os -mcpu -march -mtune";
  2774. ALLOWED_FLAGS+=" -fstack-protector -fstack-protector-all";
  2775. ALLOWED_FLAGS+=" -fbounds-checking -fno-strict-overflow";
  2776. ALLOWED_FLAGS+=" -fno-PIE -fno-pie -fno-unit-at-a-time";
  2777. ALLOWED_FLAGS+=" -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+";
  2778. ALLOWED_FLAGS+=" -fno-ident -fpermissive";
  2779. ALLOWED_FLAGS+=" -W* -w";
  2780. ALLOWED_FLAGS+=" -fno-stack-protector -fno-stack-protector-all -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer";
  2781. ALLOWED_FLAGS+=" -mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -mfloat-abi -D* -U*";
  2782. ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
  2783. ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
  2784. ALLOWED_FLAGS+=" -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt";
  2785. ALLOWED_FLAGS+=" -I* -L* -R* -Wl,*";
  2786. export ALLOWED_FLAGS;
  2787. return 0
  2788. }
  2789. src_compile ()
  2790. {
  2791. local mycmakeargs="`cmake-utils_use_enable basic LIB_BASIC` `cmake-utils_use_enable gbxadvanced LIB_GBXADVANCED` `cmake-utils_use_enable gbxgarminacfr LIB_GBXGARMINACFR` `cmake-utils_use_enable gbxserialacfr LIB_GBXSERIALACFR` `cmake-utils_use_enable gbxsickacfr LIB_GBXSICKACFR` `cmake-utils_use_enable gbxsmartbatteryacfr LIB_GBXSMARTBATTERYACFR` `cmake-utils_use_enable gbxutilacfr LIB_GBXUTILACFR` `cmake-utils_use_enable hokuyo_aist LIB_HOKUYO_AIST`";
  2792. cmake-utils_src_compile;
  2793. if use doc; then
  2794. cd doc;
  2795. doxygen doxyfile || die "Error building documentation";
  2796. fi
  2797. }
  2798. src_install ()
  2799. {
  2800. cmake-utils_src_install;
  2801. dodoc LICENSE;
  2802. use doc && dohtml -r doc/html/*
  2803. }
  2804. src_test ()
  2805. {
  2806. cmake-utils_src_test "$@"
  2807. }
  2808. src_unpack ()
  2809. {
  2810. base_src_unpack "$@"
  2811. }
  2812. strip-flags ()
  2813. {
  2814. local x y var;
  2815. setup-allowed-flags;
  2816. set -f;
  2817. for var in $(all-flag-vars);
  2818. do
  2819. local new=();
  2820. for x in ${!var};
  2821. do
  2822. local flag=${x%%=*};
  2823. for y in ${ALLOWED_FLAGS};
  2824. do
  2825. if [[ -z ${flag%%${y}} ]]; then
  2826. new+=("${x}");
  2827. break;
  2828. fi;
  2829. done;
  2830. done;
  2831. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2832. new+=(-O2);
  2833. fi;
  2834. eval export ${var}=\""${new[*]}"\";
  2835. done;
  2836. set +f;
  2837. return 0
  2838. }
  2839. strip-linguas ()
  2840. {
  2841. local ls newls nols;
  2842. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2843. local op=$1;
  2844. shift;
  2845. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2846. shift;
  2847. local d f;
  2848. for d in "$@";
  2849. do
  2850. if [[ ${op} == "-u" ]]; then
  2851. newls=${ls};
  2852. else
  2853. newls="";
  2854. fi;
  2855. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2856. do
  2857. if [[ ${op} == "-i" ]]; then
  2858. has ${f} ${ls} && newls="${newls} ${f}";
  2859. else
  2860. has ${f} ${ls} || newls="${newls} ${f}";
  2861. fi;
  2862. done;
  2863. ls=${newls};
  2864. done;
  2865. else
  2866. ls="$@";
  2867. fi;
  2868. nols="";
  2869. newls="";
  2870. for f in ${LINGUAS};
  2871. do
  2872. if has ${f} ${ls}; then
  2873. newls="${newls} ${f}";
  2874. else
  2875. nols="${nols} ${f}";
  2876. fi;
  2877. done;
  2878. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2879. export LINGUAS=${newls:1}
  2880. }
  2881. strip-unsupported-flags ()
  2882. {
  2883. export CFLAGS=$(test-flags-CC ${CFLAGS});
  2884. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  2885. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  2886. export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  2887. }
  2888. tc-arch ()
  2889. {
  2890. tc-ninja_magic_to_arch portage "$@"
  2891. }
  2892. tc-arch-kernel ()
  2893. {
  2894. tc-ninja_magic_to_arch kern "$@"
  2895. }
  2896. tc-endian ()
  2897. {
  2898. local host=$1;
  2899. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2900. host=${host%%-*};
  2901. case ${host} in
  2902. aarch64*be)
  2903. echo big
  2904. ;;
  2905. aarch64)
  2906. echo little
  2907. ;;
  2908. alpha*)
  2909. echo big
  2910. ;;
  2911. arm*b*)
  2912. echo big
  2913. ;;
  2914. arm*)
  2915. echo little
  2916. ;;
  2917. cris*)
  2918. echo little
  2919. ;;
  2920. hppa*)
  2921. echo big
  2922. ;;
  2923. i?86*)
  2924. echo little
  2925. ;;
  2926. ia64*)
  2927. echo little
  2928. ;;
  2929. m68*)
  2930. echo big
  2931. ;;
  2932. mips*l*)
  2933. echo little
  2934. ;;
  2935. mips*)
  2936. echo big
  2937. ;;
  2938. powerpc*)
  2939. echo big
  2940. ;;
  2941. s390*)
  2942. echo big
  2943. ;;
  2944. sh*b*)
  2945. echo big
  2946. ;;
  2947. sh*)
  2948. echo little
  2949. ;;
  2950. sparc*)
  2951. echo big
  2952. ;;
  2953. x86_64*)
  2954. echo little
  2955. ;;
  2956. *)
  2957. echo wtf
  2958. ;;
  2959. esac
  2960. }
  2961. tc-env_build ()
  2962. {
  2963. tc-export_build_env;
  2964. 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) "$@"
  2965. }
  2966. tc-export ()
  2967. {
  2968. local var;
  2969. for var in "$@";
  2970. do
  2971. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2972. eval tc-get${var} > /dev/null;
  2973. done
  2974. }
  2975. tc-export_build_env ()
  2976. {
  2977. tc-export "$@";
  2978. : ${BUILD_CFLAGS:=-O1 -pipe};
  2979. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2980. : ${BUILD_CPPFLAGS:=};
  2981. : ${BUILD_LDFLAGS:=};
  2982. export BUILD_{C,CXX,CPP,LD}FLAGS
  2983. }
  2984. tc-getAR ()
  2985. {
  2986. tc-getPROG AR ar "$@"
  2987. }
  2988. tc-getAS ()
  2989. {
  2990. tc-getPROG AS as "$@"
  2991. }
  2992. tc-getBUILD_AR ()
  2993. {
  2994. tc-getBUILD_PROG AR ar "$@"
  2995. }
  2996. tc-getBUILD_AS ()
  2997. {
  2998. tc-getBUILD_PROG AS as "$@"
  2999. }
  3000. tc-getBUILD_CC ()
  3001. {
  3002. tc-getBUILD_PROG CC gcc "$@"
  3003. }
  3004. tc-getBUILD_CPP ()
  3005. {
  3006. tc-getBUILD_PROG CPP cpp "$@"
  3007. }
  3008. tc-getBUILD_CXX ()
  3009. {
  3010. tc-getBUILD_PROG CXX g++ "$@"
  3011. }
  3012. tc-getBUILD_LD ()
  3013. {
  3014. tc-getBUILD_PROG LD ld "$@"
  3015. }
  3016. tc-getBUILD_NM ()
  3017. {
  3018. tc-getBUILD_PROG NM nm "$@"
  3019. }
  3020. tc-getBUILD_OBJCOPY ()
  3021. {
  3022. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3023. }
  3024. tc-getBUILD_PKG_CONFIG ()
  3025. {
  3026. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3027. }
  3028. tc-getBUILD_PROG ()
  3029. {
  3030. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  3031. }
  3032. tc-getBUILD_RANLIB ()
  3033. {
  3034. tc-getBUILD_PROG RANLIB ranlib "$@"
  3035. }
  3036. tc-getBUILD_STRIP ()
  3037. {
  3038. tc-getBUILD_PROG STRIP strip "$@"
  3039. }
  3040. tc-getCC ()
  3041. {
  3042. tc-getPROG CC gcc "$@"
  3043. }
  3044. tc-getCPP ()
  3045. {
  3046. tc-getPROG CPP cpp "$@"
  3047. }
  3048. tc-getCXX ()
  3049. {
  3050. tc-getPROG CXX g++ "$@"
  3051. }
  3052. tc-getDLLWRAP ()
  3053. {
  3054. tc-getPROG DLLWRAP dllwrap "$@"
  3055. }
  3056. tc-getF77 ()
  3057. {
  3058. tc-getPROG F77 gfortran "$@"
  3059. }
  3060. tc-getFC ()
  3061. {
  3062. tc-getPROG FC gfortran "$@"
  3063. }
  3064. tc-getGCJ ()
  3065. {
  3066. tc-getPROG GCJ gcj "$@"
  3067. }
  3068. tc-getLD ()
  3069. {
  3070. tc-getPROG LD ld "$@"
  3071. }
  3072. tc-getNM ()
  3073. {
  3074. tc-getPROG NM nm "$@"
  3075. }
  3076. tc-getOBJCOPY ()
  3077. {
  3078. tc-getPROG OBJCOPY objcopy "$@"
  3079. }
  3080. tc-getPKG_CONFIG ()
  3081. {
  3082. tc-getPROG PKG_CONFIG pkg-config "$@"
  3083. }
  3084. tc-getPROG ()
  3085. {
  3086. _tc-getPROG CHOST "$@"
  3087. }
  3088. tc-getRANLIB ()
  3089. {
  3090. tc-getPROG RANLIB ranlib "$@"
  3091. }
  3092. tc-getRC ()
  3093. {
  3094. tc-getPROG RC windres "$@"
  3095. }
  3096. tc-getSTRIP ()
  3097. {
  3098. tc-getPROG STRIP strip "$@"
  3099. }
  3100. tc-has-openmp ()
  3101. {
  3102. local base="${T}/test-tc-openmp";
  3103. cat > "${base}.c" <<-EOF
  3104. #include <omp.h>
  3105. int main() {
  3106. int nthreads, tid, ret = 0;
  3107. #pragma omp parallel private(nthreads, tid)
  3108. {
  3109. tid = omp_get_thread_num();
  3110. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3111. }
  3112. return ret;
  3113. }
  3114. EOF
  3115.  
  3116. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  3117. local ret=$?;
  3118. rm -f "${base}"*;
  3119. return ${ret}
  3120. }
  3121. tc-has-tls ()
  3122. {
  3123. local base="${T}/test-tc-tls";
  3124. cat > "${base}.c" <<-EOF
  3125. int foo(int *i) {
  3126. static __thread int j = 0;
  3127. return *i ? j : *i;
  3128. }
  3129. EOF
  3130.  
  3131. local flags;
  3132. case $1 in
  3133. -s)
  3134. flags="-S"
  3135. ;;
  3136. -c)
  3137. flags="-c"
  3138. ;;
  3139. -l)
  3140.  
  3141. ;;
  3142. -*)
  3143. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3144. ;;
  3145. esac;
  3146. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3147. [[ $1 == -* ]] && shift;
  3148. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  3149. local ret=$?;
  3150. rm -f "${base}"*;
  3151. return ${ret}
  3152. }
  3153. tc-is-cross-compiler ()
  3154. {
  3155. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  3156. }
  3157. tc-is-softfloat ()
  3158. {
  3159. local CTARGET=${CTARGET:-${CHOST}};
  3160. case ${CTARGET} in
  3161. bfin* | h8300*)
  3162. echo "only"
  3163. ;;
  3164. *)
  3165. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  3166. echo "yes";
  3167. else
  3168. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  3169. echo "softfp";
  3170. else
  3171. echo "no";
  3172. fi;
  3173. fi
  3174. ;;
  3175. esac
  3176. }
  3177. tc-is-static-only ()
  3178. {
  3179. local host=${CTARGET:-${CHOST}};
  3180. return $([[ ${host} == *-mint* ]])
  3181. }
  3182. tc-ninja_magic_to_arch ()
  3183. {
  3184. function ninj ()
  3185. {
  3186. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3187. };
  3188. local type=$1;
  3189. local host=$2;
  3190. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3191. local KV=${KV:-${KV_FULL}};
  3192. [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info";
  3193. case ${host} in
  3194. aarch64*)
  3195. ninj arm64 arm
  3196. ;;
  3197. alpha*)
  3198. echo alpha
  3199. ;;
  3200. arm*)
  3201. echo arm
  3202. ;;
  3203. avr*)
  3204. ninj avr32 avr
  3205. ;;
  3206. bfin*)
  3207. ninj blackfin bfin
  3208. ;;
  3209. cris*)
  3210. echo cris
  3211. ;;
  3212. hppa*)
  3213. ninj parisc hppa
  3214. ;;
  3215. i?86*)
  3216. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  3217. echo i386;
  3218. else
  3219. echo x86;
  3220. fi
  3221. ;;
  3222. ia64*)
  3223. echo ia64
  3224. ;;
  3225. m68*)
  3226. echo m68k
  3227. ;;
  3228. mips*)
  3229. echo mips
  3230. ;;
  3231. nios2*)
  3232. echo nios2
  3233. ;;
  3234. nios*)
  3235. echo nios
  3236. ;;
  3237. powerpc*)
  3238. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  3239. echo powerpc;
  3240. else
  3241. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  3242. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3243. echo powerpc;
  3244. else
  3245. echo ppc;
  3246. fi;
  3247. else
  3248. if [[ ${host} == powerpc64* ]]; then
  3249. echo ppc64;
  3250. else
  3251. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3252. ninj ppc64 ppc;
  3253. else
  3254. echo ppc;
  3255. fi;
  3256. fi;
  3257. fi;
  3258. fi
  3259. ;;
  3260. s390*)
  3261. echo s390
  3262. ;;
  3263. sh64*)
  3264. ninj sh64 sh
  3265. ;;
  3266. sh*)
  3267. echo sh
  3268. ;;
  3269. sparc64*)
  3270. ninj sparc64 sparc
  3271. ;;
  3272. sparc*)
  3273. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3274. ;;
  3275. vax*)
  3276. echo vax
  3277. ;;
  3278. x86_64*freebsd*)
  3279. echo amd64
  3280. ;;
  3281. x86_64*)
  3282. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  3283. echo x86;
  3284. else
  3285. ninj x86_64 amd64;
  3286. fi
  3287. ;;
  3288. *)
  3289. echo unknown
  3290. ;;
  3291. esac
  3292. }
  3293. test-flag-CC ()
  3294. {
  3295. test-flag-PROG "CC" c "$1"
  3296. }
  3297. test-flag-CXX ()
  3298. {
  3299. test-flag-PROG "CXX" c++ "$1"
  3300. }
  3301. test-flag-F77 ()
  3302. {
  3303. test-flag-PROG "F77" f77 "$1"
  3304. }
  3305. test-flag-FC ()
  3306. {
  3307. test-flag-PROG "FC" f95 "$1"
  3308. }
  3309. test-flag-PROG ()
  3310. {
  3311. local comp=$1;
  3312. local lang=$2;
  3313. local flag=$3;
  3314. [[ -z ${comp} || -z ${flag} ]] && return 1;
  3315. local PROG=$(tc-get${comp});
  3316. if ${PROG} -c -o /dev/null -x${lang} - < /dev/null > /dev/null 2>&1; then
  3317. ${PROG} "${flag}" -c -o /dev/null -x${lang} - < /dev/null > /dev/null 2>&1;
  3318. else
  3319. ${PROG} "${flag}" -c -o /dev/null /dev/null > /dev/null 2>&1;
  3320. fi
  3321. }
  3322. test-flags ()
  3323. {
  3324. test-flags-CC "$@"
  3325. }
  3326. test-flags-CC ()
  3327. {
  3328. test-flags-PROG "CC" "$@"
  3329. }
  3330. test-flags-CXX ()
  3331. {
  3332. test-flags-PROG "CXX" "$@"
  3333. }
  3334. test-flags-F77 ()
  3335. {
  3336. test-flags-PROG "F77" "$@"
  3337. }
  3338. test-flags-FC ()
  3339. {
  3340. test-flags-PROG "FC" "$@"
  3341. }
  3342. test-flags-PROG ()
  3343. {
  3344. local comp=$1;
  3345. local flags=();
  3346. local x;
  3347. shift;
  3348. [[ -z ${comp} ]] && return 1;
  3349. for x in "$@";
  3350. do
  3351. test-flag-${comp} "${x}" && flags+=("${x}");
  3352. done;
  3353. echo "${flags[*]}";
  3354. [[ ${#flags[@]} -gt 0 ]]
  3355. }
  3356. test_version_info ()
  3357. {
  3358. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  3359. return 0;
  3360. else
  3361. return 1;
  3362. fi
  3363. }
  3364. use_if_iuse ()
  3365. {
  3366. in_iuse $1 || return 1;
  3367. use $1
  3368. }
  3369. usex ()
  3370. {
  3371. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  3372. }
  3373. validate_desktop_entries ()
  3374. {
  3375. if [[ -x /usr/bin/desktop-file-validate ]]; then
  3376. einfo "Checking desktop entry validity";
  3377. local directories="";
  3378. for d in /usr/share/applications $@;
  3379. do
  3380. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  3381. done;
  3382. if [[ -n ${directories} ]]; then
  3383. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  3384. do
  3385. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  3386. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  3387. done;
  3388. fi;
  3389. echo "";
  3390. else
  3391. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  3392. fi
  3393. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement