gnu: julia: Fix make-flags on non-Intel platforms.
[jackhill/guix/guix.git] / gnu / packages / julia.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages julia)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages algebra)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages elf)
28 #:use-module (gnu packages gcc)
29 #:use-module (gnu packages llvm)
30 #:use-module (gnu packages libunwind)
31 #:use-module (gnu packages maths)
32 #:use-module (gnu packages multiprecision) ; mpfr
33 #:use-module (gnu packages pcre)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages textutils)
38 #:use-module (gnu packages version-control)
39 #:use-module (ice-9 match))
40
41 (define-public julia
42 (package
43 (name "julia")
44 (version "0.3.6")
45 (source (origin
46 (method url-fetch)
47 (uri (string-append
48 "https://github.com/JuliaLang/julia/releases/download/v"
49 version "/julia-" version "_0c24dca65c.tar.gz"))
50 (sha256
51 (base32
52 "1hnbc2blzr9bc27m3vsr127fhg0h5imgqlrx00jakf0my0ccw8gr"))))
53 (build-system gnu-build-system)
54 (arguments
55 `(#:test-target "test"
56 #:modules ((ice-9 match)
57 (guix build gnu-build-system)
58 (guix build utils))
59
60
61 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
62 ;; gremlin) doesn't support it yet, so skip this phase.
63 #:validate-runpath? #f
64
65 #:phases
66 (alist-cons-after
67 'unpack 'hardcode-soname-map
68 ;; ./src/ccall.cpp creates a map from library names to paths using the
69 ;; output of "/sbin/ldconfig -p". Since ldconfig is not used in Guix,
70 ;; we patch ccall.cpp to contain a static map.
71 (lambda* (#:key inputs #:allow-other-keys)
72 (use-modules (ice-9 match))
73 (substitute* "src/ccall.cpp"
74 (("jl_read_sonames.*;")
75 (string-join
76 (map (match-lambda
77 ((input libname soname)
78 (string-append
79 "sonameMap[\"" libname "\"] = "
80 "\"" (assoc-ref inputs input) "/lib/" soname "\";")))
81 '(("libc" "libc" "libc.so.6")
82 ("pcre" "libpcre" "libpcre.so")
83 ("mpfr" "libmpfr" "libmpfr.so")
84 ("openblas" "libblas" "libopenblas.so")
85 ("arpack-ng" "libarpack" "libarpack.so")
86 ("lapack" "liblapack" "liblapack.so")
87 ("gmp" "libgmp" "libgmp.so")
88 ("openlibm" "libopenlibm" "libopenlibm.so")
89 ("openspecfun" "libopenspecfun" "libopenspecfun.so")
90 ("fftw" "libfftw3" "libfftw3.so")
91 ("fftwf" "libfftw3f" "libfftw3f.so")))))))
92 (alist-cons-before
93 'build 'replace-default-shell
94 (lambda _
95 (substitute* "base/client.jl"
96 (("/bin/sh") (which "sh"))))
97 (alist-cons-before
98 'build 'patch-include-path
99 (lambda _
100 (substitute* "deps/Makefile"
101 (("/usr/include/double-conversion")
102 (string-append (assoc-ref %build-inputs "double-conversion")
103 "/include/double-conversion"))))
104 (alist-cons-before
105 'check 'disable-broken-test
106 ;; One test fails because it produces slightly different output.
107 (lambda _
108 (substitute* "test/repl.jl"
109 (("@test output") "# @test output")))
110 ;; no configure script
111 (alist-delete 'configure %standard-phases)))))
112 #:make-flags
113 (list
114 (string-append "prefix=" (assoc-ref %outputs "out"))
115
116 ;; Passing the MARCH flag is necessary to build binary substitutes for
117 ;; the supported architectures.
118 ,(match (or (%current-target-system)
119 (%current-system))
120 ("x86_64-linux" "MARCH=x86-64")
121 ("i686-linux" "MARCH=pentium4")
122 ;; Prevent errors when querying this package on unsupported
123 ;; platforms, e.g. when running "guix package --search="
124 (_ "MARCH=UNSUPPORTED"))
125
126 "CONFIG_SHELL=bash" ;needed to build bundled libraries
127 "USE_SYSTEM_LIBUV=0" ;Julia expects a modified libuv
128 "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no
129 ;build system for a shared library.
130 "USE_SYSTEM_RMATH=0" ;Julia uses a bundled version of R's math
131 ;library, patched to use the DSFMT RNG.
132
133 "USE_SYSTEM_LAPACK=1"
134 "USE_SYSTEM_BLAS=1"
135 "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1
136
137 "USE_SYSTEM_FFTW=1"
138 "LIBFFTWNAME=libfftw3"
139 "LIBFFTWFNAME=libfftw3f"
140
141 ;; TODO: Suitesparse does not install shared libraries, so we cannot
142 ;; use the suitesparse package.
143 ;; "USE_SYSTEM_SUITESPARSE=1"
144 ;; (string-append "SUITESPARSE_INC=-I "
145 ;; (assoc-ref %build-inputs "suitesparse")
146 ;; "/include")
147
148 "USE_SYSTEM_GRISU=1" ;for double-conversion
149 "USE_SYSTEM_UTF8PROC=1"
150 "USE_SYSTEM_LLVM=1"
151 "USE_SYSTEM_LIBUNWIND=1"
152 "USE_SYSTEM_PCRE=1"
153 "USE_SYSTEM_OPENLIBM=1"
154 "USE_SYSTEM_GMP=1"
155 "USE_SYSTEM_MPFR=1"
156 "USE_SYSTEM_ARPACK=1"
157 "USE_SYSTEM_LIBGIT2=1"
158 "USE_SYSTEM_OPENSPECFUN=1")))
159 (inputs
160 `(("llvm" ,llvm-3.5)
161 ("arpack-ng" ,arpack-ng)
162 ("lapack" ,lapack)
163 ("openblas" ,openblas) ;Julia does not build with Atlas
164 ("libunwind" ,libunwind)
165 ("openlibm" ,openlibm)
166 ("openspecfun" ,openspecfun)
167 ("double-conversion" ,double-conversion)
168 ("fftw" ,fftw)
169 ("fftwf" ,fftwf)
170 ("fortran" ,gfortran-4.8)
171 ("pcre" ,pcre)
172 ("utf8proc" ,utf8proc)
173 ("git" ,git)
174 ("mpfr" ,mpfr)
175 ("gmp" ,gmp)))
176 (native-inputs
177 `(("perl" ,perl)
178 ("patchelf" ,patchelf)
179 ("pkg-config" ,pkg-config)
180 ("python" ,python-2)
181 ("which" ,which)))
182 ;; Julia is not officially released for ARM and MIPS.
183 ;; See https://github.com/JuliaLang/julia/issues/10639
184 (supported-systems '("i686-linux" "x86_64-linux"))
185 (home-page "http://julialang.org/")
186 (synopsis "High-performance dynamic language for technical computing")
187 (description
188 "Julia is a high-level, high-performance dynamic programming language for
189 technical computing, with syntax that is familiar to users of other technical
190 computing environments. It provides a sophisticated compiler, distributed
191 parallel execution, numerical accuracy, and an extensive mathematical function
192 library.")
193 (license license:expat)))