Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / erlang.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Steve Sprang <scs@stevesprang.com>
3 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2016, 2017 Pjotr Prins <pjotr.guix@thebird.nl>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages erlang)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix build-system gnu)
24 #:use-module (guix download)
25 #:use-module (guix packages)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages autotools)
28 #:use-module (gnu packages fontutils)
29 #:use-module (gnu packages gl)
30 #:use-module (gnu packages ncurses)
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages tls)
33 #:use-module (gnu packages wxwidgets))
34
35 (define-public erlang
36 (package
37 (name "erlang")
38 (version "20.0")
39 (source (origin
40 (method url-fetch)
41 ;; The tarball from http://erlang.org/download contains many
42 ;; pre-compiled files, so we use this snapshot of the source
43 ;; repository.
44 (uri (string-append "https://github.com/erlang/otp/archive/OTP-"
45 version ".tar.gz"))
46 (file-name (string-append name "-" version ".tar.gz"))
47 (sha256
48 (base32
49 "1azjjyb743i6vjq7rnh5qnslsqg0x60a9zrlhg9n3dpm13z1b22l"))
50 (patches (search-patches "erlang-man-path.patch"))))
51 (build-system gnu-build-system)
52 (native-inputs
53 `(("perl" ,perl)
54 ("autoconf" ,autoconf)
55 ("automake" ,automake)
56
57 ;; Erlang's documentation is distributed in a separate tarball.
58 ("erlang-manpages"
59 ,(origin
60 (method url-fetch)
61 (uri (string-append "http://erlang.org/download/otp_doc_man_"
62 version ".tar.gz"))
63 (sha256
64 (base32
65 "1k25p37w1l1j20qd8rga4j4q7s7r0rbsi02x3xwzhw51jhm59wdp"))))))
66 (inputs
67 `(("ncurses" ,ncurses)
68 ("openssl" ,openssl)
69 ("wxwidgets" ,wxwidgets)))
70 (propagated-inputs
71 `(("fontconfig" ,fontconfig)
72 ("glu" ,glu)
73 ("mesa" ,mesa)))
74 (arguments
75 `(#:test-target "release_tests"
76 #:configure-flags
77 (list "--disable-saved-compile-time"
78 "--enable-dynamic-ssl-lib"
79 "--enable-native-libs"
80 "--enable-shared-zlib"
81 "--enable-smp-support"
82 "--enable-threads"
83 "--enable-wx"
84 (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
85 #:modules ((srfi srfi-19) ; make-time, et cetera.
86 (guix build utils)
87 (guix build gnu-build-system))
88 #:phases
89 (modify-phases %standard-phases
90 ;; The are several code fragments that embed timestamps into the
91 ;; output. Here, we alter those fragments to use the value of
92 ;; SOURCE_DATE_EPOCH instead.
93 (add-after 'unpack 'remove-timestamps
94 (lambda _
95 (let ((source-date-epoch
96 (time-utc->date
97 (make-time time-utc 0 (string->number
98 (getenv "SOURCE_DATE_EPOCH"))))))
99 (substitute* "lib/reltool/src/reltool_target.erl"
100 (("Date = date\\(\\),")
101 (string-append "Date = "
102 (date->string source-date-epoch
103 "'{~Y,~m,~d}',"))))
104 (substitute* "lib/reltool/src/reltool_target.erl"
105 (("Time = time\\(\\),")
106 (string-append "Time = "
107 (date->string source-date-epoch
108 "'{~H,~M,~S}',"))))
109 (substitute* '("lib/reltool/src/reltool_target.erl"
110 "lib/sasl/src/systools_make.erl")
111 (("date\\(\\), time\\(\\),")
112 (date->string source-date-epoch
113 "{~Y,~m,~d}, {~H,~M,~S},")))
114 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
115 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
116 (date->string
117 source-date-epoch
118 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
119 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
120 (("\\{Y,Mo,D\\} = date\\(\\),")
121 (date->string source-date-epoch
122 "{Y,Mo,D} = {~Y,~m,~d},")))
123 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
124 (("\\{H,Mi,S\\} = time\\(\\),")
125 (date->string source-date-epoch
126 "{H,Mi,S} = {~H,~M,~S},"))))))
127 (add-after 'patch-source-shebangs 'patch-source-env
128 (lambda _
129 (let ((escripts
130 (append
131 (find-files "." "\\.escript")
132 (find-files "lib/stdlib/test/escript_SUITE_data/")
133 '("erts/lib_src/utils/make_atomics_api"
134 "erts/preloaded/src/add_abstract_code"
135 "lib/diameter/bin/diameterc"
136 "lib/reltool/examples/display_args"
137 "lib/reltool/examples/mnesia_core_dump_viewer"
138 "lib/snmp/src/compile/snmpc.src"
139 "make/verify_runtime_dependencies"
140 "make/emd2exml.in"))))
141 (substitute* escripts
142 (("/usr/bin/env") (which "env"))))))
143 (add-before 'configure 'set-erl-top
144 (lambda _
145 (setenv "ERL_TOP" (getcwd))))
146 (add-before 'configure 'autoconf
147 (lambda _ (zero? (system* "./otp_build" "autoconf"))))
148 (add-after 'install 'patch-erl
149 ;; This only works after install.
150 (lambda _
151 (substitute* (string-append (assoc-ref %outputs "out") "/bin/erl")
152 (("sed") (which "sed")))))
153 (add-after 'install 'install-doc
154 (lambda* (#:key inputs outputs #:allow-other-keys)
155 (let* ((out (assoc-ref outputs "out"))
156 (manpages (assoc-ref inputs "erlang-manpages"))
157 (share (string-append out "/share/")))
158 (mkdir-p share)
159 (mkdir-p (string-append share "/misc/erlang"))
160 (with-directory-excursion share
161 (and
162 (zero? (system* "tar" "xvf" manpages))
163 (rename-file "COPYRIGHT"
164 (string-append share "/misc/erlang/COPYRIGHT"))
165 ;; Delete superfluous file.
166 (delete-file "PR.template")))))))))
167 (home-page "http://erlang.org/")
168 (synopsis "The Erlang programming language")
169 (description
170 "Erlang is a programming language used to build massively
171 scalable soft real-time systems with requirements on high
172 availability. Some of its uses are in telecoms, banking, e-commerce,
173 computer telephony and instant messaging. Erlang's runtime system has
174 built-in support for concurrency, distribution and fault tolerance.")
175 ;; Erlang is distributed under the Apache License 2.0, but some components
176 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
177 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
178 license:lgpl2.0+ license:tcl/tk license:zlib))))