julia-9999.ebuild 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. RESTRICT="test"
  5. inherit git-r3 elisp-common eutils multilib pax-utils toolchain-funcs
  6. DESCRIPTION="High-performance programming language for technical computing"
  7. HOMEPAGE="http://julialang.org/"
  8. SRC_URI=""
  9. EGIT_REPO_URI="git://github.com/JuliaLang/julia.git"
  10. LICENSE="MIT"
  11. SLOT="0"
  12. KEYWORDS=""
  13. IUSE="emacs"
  14. RDEPEND="
  15. dev-lang/R:0=
  16. dev-libs/double-conversion:0=
  17. dev-libs/gmp:0=
  18. dev-libs/libgit2:0=
  19. dev-libs/mpfr:0=
  20. dev-libs/openspecfun
  21. sci-libs/arpack:0=
  22. sci-libs/camd:0=
  23. sci-libs/cholmod:0=
  24. sci-libs/fftw:3.0=[threads]
  25. sci-libs/openlibm:0=
  26. sci-libs/spqr:0=
  27. sci-libs/umfpack:0=
  28. sci-mathematics/glpk:0=
  29. >=sys-devel/llvm-3.9:0=
  30. >=sys-libs/libunwind-1.1:7=
  31. sys-libs/readline:0=
  32. sys-libs/zlib:0=
  33. >=virtual/blas-1.1
  34. virtual/lapack
  35. emacs? ( app-emacs/ess )"
  36. DEPEND="${RDEPEND}
  37. dev-util/patchelf
  38. virtual/pkgconfig"
  39. PATCHES=(
  40. "${FILESDIR}"/${PN}-9999-fix_build_system.patch
  41. )
  42. src_prepare() {
  43. epatch "${PATCHES[@]}"
  44. eapply_user
  45. # Sledgehammer:
  46. # - respect CFLAGS
  47. # - respect EPREFIX and Gentoo specific paths
  48. # - fix BLAS and LAPACK link interface
  49. sed -i \
  50. -e 's|$(JLDOWNLOAD)|${EPREFIX}/bin/true|' \
  51. -e 's|git submodule|${EPREFIX}/bin/true|g' \
  52. -e "s|GENTOOCFLAGS|${CFLAGS}|g" \
  53. -e "s|/usr/include|${EPREFIX%/}/usr/include|g" \
  54. deps/Makefile || die
  55. local libblas="$($(tc-getPKG_CONFIG) --libs-only-l blas)"
  56. libblas="${libblas%% *}"
  57. libblas="lib${libblas#-l}"
  58. local liblapack="$($(tc-getPKG_CONFIG) --libs-only-l lapack)"
  59. liblapack="${liblapack%% *}"
  60. liblapack="lib${liblapack#-l}"
  61. sed -i \
  62. -e "s|\(JULIA_EXECUTABLE = \)\(\$(JULIAHOME)/julia\)|\1 LD_LIBRARY_PATH=\$(BUILD)/$(get_libdir) \2|" \
  63. -e "s|GENTOOCFLAGS|${CFLAGS}|g" \
  64. -e "s|LIBDIR = lib|LIBDIR = $(get_libdir)|" \
  65. -e "s|/usr/lib|${EPREFIX}/usr/$(get_libdir)|" \
  66. -e "s|/usr/include|${EPREFIX}/usr/include|" \
  67. -e "s|\$(BUILD)/lib|\$(BUILD)/$(get_libdir)|" \
  68. -e "s|^JULIA_COMMIT = .*|JULIA_COMMIT = v${PV}|" \
  69. -e "s|-lblas|$($(tc-getPKG_CONFIG) --libs blas)|" \
  70. -e "s|= libblas|= ${libblas}|" \
  71. -e "s|-llapack|$($(tc-getPKG_CONFIG) --libs lapack)|" \
  72. -e "s|= liblapack|= ${liblapack}|" \
  73. Make.inc || die
  74. sed -i \
  75. -e "s|,lib)|,$(get_libdir))|g" \
  76. -e "s|\$(BUILD)/lib|\$(BUILD)/$(get_libdir)|g" \
  77. Makefile || die
  78. sed -i \
  79. -e "s|ar -rcs|$(tc-getAR) -rcs|g" \
  80. src/Makefile || die
  81. }
  82. src_configure() {
  83. # julia does not play well with the system versions of
  84. # dsfmt, libuv, pcre2 and utf8proc
  85. cat <<-EOF > Make.user
  86. USE_SYSTEM_DSFMT=0
  87. USE_SYSTEM_LIBUV=0
  88. USE_SYSTEM_PCRE=0
  89. USE_SYSTEM_RMATH=0
  90. USE_SYSTEM_UTF8PROC=0
  91. USE_LLVM_SHLIB=1
  92. USE_SYSTEM_ARPACK=1
  93. USE_SYSTEM_BLAS=1
  94. USE_SYSTEM_FFTW=1
  95. USE_SYSTEM_GMP=1
  96. USE_SYSTEM_GRISU=1
  97. USE_SYSTEM_LAPACK=1
  98. USE_SYSTEM_LIBGIT2=1
  99. USE_SYSTEM_LIBM=1
  100. USE_SYSTEM_LIBUNWIND=1
  101. USE_SYSTEM_LLVM=1
  102. USE_SYSTEM_MPFR=1
  103. USE_SYSTEM_OPENLIBM=1
  104. USE_SYSTEM_OPENSPECFUN=1
  105. USE_SYSTEM_PATCHELF=1
  106. USE_SYSTEM_READLINE=1
  107. USE_SYSTEM_SUITESPARSE=1
  108. USE_SYSTEM_ZLIB=1
  109. VERBOSE=1
  110. libdir="${EROOT}/usr/$(get_libdir)"
  111. EOF
  112. }
  113. src_compile() {
  114. # Julia accesses /proc/self/mem on Linux
  115. addpredict /proc/self/mem
  116. emake cleanall
  117. emake julia-release \
  118. prefix="/usr" DESTDIR="${D}" CC="$(tc-getCC)" CXX="$(tc-getCXX)"
  119. pax-mark m $(file usr/bin/julia-* | awk -F : '/ELF/ {print $1}')
  120. emake
  121. use emacs && elisp-compile contrib/julia-mode.el
  122. }
  123. src_test() {
  124. emake test
  125. }
  126. src_install() {
  127. emake install \
  128. prefix="/usr" DESTDIR="${D}" CC="$(tc-getCC)" CXX="$(tc-getCXX)"
  129. cat > 99julia <<-EOF
  130. LDPATH=${EROOT%/}/usr/$(get_libdir)/julia
  131. EOF
  132. doenvd 99julia
  133. if use emacs; then
  134. elisp-install "${PN}" contrib/julia-mode.el
  135. elisp-site-file-install "${FILESDIR}"/63julia-gentoo.el
  136. fi
  137. dodoc README.md
  138. mv "${ED}"/usr/etc/julia "${ED}"/etc || die
  139. rmdir "${ED}"/usr/etc || die
  140. rmdir "${ED}"/usr/libexec || die
  141. mv "${ED}"/usr/share/doc/julia/{examples,html} \
  142. "${ED}"/usr/share/doc/${P} || die
  143. rmdir "${ED}"/usr/share/doc/julia || die
  144. if [[ $(get_libdir) != lib ]]; then
  145. mkdir -p "${ED}"/usr/$(get_libdir) || die
  146. mv "${ED}"/usr/lib/julia "${ED}"/usr/$(get_libdir)/julia || die
  147. fi
  148. }
  149. pkg_postinst() {
  150. use emacs && elisp-site-regen
  151. }
  152. pkg_postrm() {
  153. use emacs && elisp-site-regen
  154. }