*/*: slotmove sys-libs/libunwind from SLOT=7 to SLOT=0
[gentoo.git] / dev-lang / julia / julia-1.2.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 RESTRICT="test"
7
8 inherit pax-utils toolchain-funcs
9
10 MY_PV="${PV//_rc/-rc}"
11 MY_LIBUV_V="2348256acf5759a544e5ca7935f638d2bc091d60"
12 MY_UTF8PROC_V="454f60150c7f023526d353e1e6b386f93ee0b116"
13 MY_LIBWHICH_V="81e9723c0273d78493dc8c8ed570f68d9ce7e89e"
14 MY_DSFMT_V="2.2.3"
15 MY_LLVM="6.0.1"
16
17 DESCRIPTION="High-performance programming language for technical computing"
18 HOMEPAGE="https://julialang.org/"
19 SRC_URI="
20         https://github.com/JuliaLang/${PN}/releases/download/v${MY_PV}/${PN}-${MY_PV}.tar.gz
21         https://api.github.com/repos/JuliaLang/libuv/tarball/${MY_LIBUV_V} -> ${PN}-libuv-${MY_LIBUV_V}.tar.gz
22         https://api.github.com/repos/JuliaLang/utf8proc/tarball/${MY_UTF8PROC_V} -> ${PN}-utf8proc-${MY_UTF8PROC_V}.tar.gz
23         https://api.github.com/repos/vtjnash/libwhich/tarball/${MY_LIBWHICH_V} -> ${PN}-libwhich-${MY_LIBWHICH_V}.tar.gz
24         http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${MY_DSFMT_V}.tar.gz -> ${PN}-dsfmt-${MY_DSFMT_V}.tar.gz
25         http://releases.llvm.org/${MY_LLVM}/llvm-${MY_LLVM}.src.tar.xz
26 "
27
28 LICENSE="MIT"
29 SLOT="0"
30 KEYWORDS="~amd64 ~x86"
31 IUSE=""
32
33 RDEPEND+="
34         dev-libs/double-conversion:0=
35         dev-libs/gmp:0=
36         dev-libs/libgit2:0=
37         >=dev-libs/libpcre2-10.23:0=[jit]
38         dev-libs/mpfr:0=
39         dev-libs/openspecfun
40         sci-libs/amd:0=
41         sci-libs/arpack:0=
42         sci-libs/camd:0=
43         sci-libs/ccolamd:0=
44         sci-libs/cholmod:0=
45         sci-libs/colamd:0=
46         sci-libs/fftw:3.0=[threads]
47         sci-libs/openlibm:0=
48         sci-libs/spqr:0=
49         sci-libs/umfpack:0=
50         sci-mathematics/glpk:0=
51         >=sys-libs/libunwind-1.1:0=
52         sys-libs/readline:0=
53         sys-libs/zlib:0=
54         >=virtual/blas-3.6
55         virtual/lapack"
56
57 DEPEND="${RDEPEND}
58         dev-vcs/git
59         dev-util/patchelf
60         virtual/pkgconfig"
61
62 PATCHES=(
63         "${FILESDIR}"/${PN}-1.1.0-fix_build_system.patch
64         "${FILESDIR}"/${PN}-1.1.0-fix_llvm_install.patch
65 )
66
67 S="${WORKDIR}/${PN}-${MY_PV}"
68
69 src_unpack() {
70         tounpack=(${A})
71         # the main source tree, followed by deps
72         unpack "${A/%\ */}"
73
74         mkdir -p "${S}/deps/srccache/"
75         for i in "${tounpack[@]:1}"; do
76                 cp "${DISTDIR}/${i}" "${S}/deps/srccache/${i#julia-}" || die
77         done
78 }
79
80 src_prepare() {
81         default
82
83         # Sledgehammer:
84         # - prevent fetching of bundled stuff in compile and install phase
85         # - respect CFLAGS
86         # - respect EPREFIX and Gentoo specific paths
87         # - fix BLAS and LAPACK link interface
88
89         sed -i \
90                 -e 's|git submodule|${EPREFIX}/bin/true|g' \
91                 -e "s|GENTOOCFLAGS|${CFLAGS}|g" \
92                 -e "s|/usr/include|${EPREFIX}/usr/include|g" \
93                 deps/Makefile || die
94
95         local libblas="$($(tc-getPKG_CONFIG) --libs-only-l blas)"
96         libblas="${libblas%% *}"
97         libblas="lib${libblas#-l}"
98         local liblapack="$($(tc-getPKG_CONFIG) --libs-only-l lapack)"
99         liblapack="${liblapack%% *}"
100         liblapack="lib${liblapack#-l}"
101
102         sed -i \
103                 -e "s|GENTOOCFLAGS|${CFLAGS}|g" \
104                 -e "s|GENTOOLIBDIR|$(get_libdir)|" \
105                 -e "s|^JULIA_COMMIT = .*|JULIA_COMMIT = v${PV}|" \
106                 -e "s|-lblas|$($(tc-getPKG_CONFIG) --libs blas)|" \
107                 -e "s|= libblas|= ${libblas}|" \
108                 -e "s|-llapack|$($(tc-getPKG_CONFIG) --libs lapack)|" \
109                 -e "s|= liblapack|= ${liblapack}|" \
110                 Make.inc || die
111
112         sed -i \
113                 -e "s|,lib)|,$(get_libdir))|g" \
114                 -e "s|\$(BUILD)/lib|\$(BUILD)/$(get_libdir)|g" \
115                 Makefile || die
116
117         sed -i \
118                 -e "s|ar -rcs|$(tc-getAR) -rcs|g" \
119                 src/Makefile || die
120
121         # disable doc install starting  git fetching
122         sed -i -e 's~install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html~install: $(build_depsbindir)/stringreplace~' Makefile || die
123 }
124
125 src_configure() {
126         # julia does not play well with the system versions of dsfmt, libuv,
127         # and utf8proc
128
129         # USE_SYSTEM_LIBM=0 implies using external openlibm
130         cat <<-EOF > Make.user
131                 USE_SYSTEM_ARPACK:=1
132                 USE_SYSTEM_BLAS:=1
133                 USE_SYSTEM_DSFMT:=0
134                 USE_SYSTEM_GMP:=1
135                 USE_SYSTEM_GRISU:=1
136                 USE_SYSTEM_LAPACK:=1
137                 USE_SYSTEM_LIBGIT2:=1
138                 USE_SYSTEM_LIBM:=0
139                 USE_SYSTEM_LIBUNWIND:=1
140                 USE_SYSTEM_LIBUV:=0
141                 USE_SYSTEM_LLVM:=0
142                 USE_SYSTEM_MPFR:=1
143                 USE_SYSTEM_OPENLIBM:=1
144                 USE_SYSTEM_OPENSPECFUN:=1
145                 USE_SYSTEM_PATCHELF:=1
146                 USE_SYSTEM_PCRE:=1
147                 USE_SYSTEM_READLINE:=1
148                 USE_SYSTEM_RMATH:=0
149                 USE_SYSTEM_SUITESPARSE:=1
150                 USE_SYSTEM_UTF8PROC:=0
151                 USE_SYSTEM_ZLIB=1
152                 VERBOSE=1
153                 libdir="${EROOT}/usr/$(get_libdir)"
154         EOF
155
156 }
157
158 src_compile() {
159
160         # Julia accesses /proc/self/mem on Linux
161         addpredict /proc/self/mem
162
163         emake cleanall
164         emake julia-release \
165                 prefix="${EPREFIX}/usr" DESTDIR="${D}" \
166                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" \
167                 USE_BINARYBUILDER=0
168         pax-mark m $(file usr/bin/julia-* | awk -F : '/ELF/ {print $1}')
169         emake USE_BINARYBUILDER=0
170 }
171
172 src_test() {
173         emake test
174 }
175
176 src_install() {
177         # Julia is special. It tries to find a valid git repository (that would
178         # normally be cloned during compilation/installation). Just make it
179         # happy...
180         git init && \
181                 git config --local user.email "whatyoudoing@example.com" && \
182                 git config --local user.name "Whyyyyyy" && \
183                 git commit -a --allow-empty -m "initial" || die "git failed"
184
185         emake install \
186                 prefix="${EPREFIX}/usr" DESTDIR="${D}" \
187                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" \
188                 USE_BINARYBUILDER=0
189         cat > 99julia <<-EOF
190                 LDPATH=${EROOT}/usr/$(get_libdir)/julia
191         EOF
192         doenvd 99julia
193
194         dodoc README.md
195
196         mv "${ED}"/usr/etc/julia "${ED}"/etc || die
197         rmdir "${ED}"/usr/etc || die
198         mv "${ED}"/usr/share/doc/julia/html "${ED}"/usr/share/doc/${PF} || die
199         rmdir "${ED}"/usr/share/doc/julia || die
200 }