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