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