Merge branch 'master' into core-updates
[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 ;; The are several code fragments that embed timestamps into the
93 ;; output. Here, we alter those fragments to use the value of
94 ;; SOURCE_DATE_EPOCH instead.
95 (add-after 'unpack 'remove-timestamps
96 (lambda _
97 (let ((source-date-epoch
98 (time-utc->date
99 (make-time time-utc 0 (string->number
100 (getenv "SOURCE_DATE_EPOCH"))))))
101 (substitute* "lib/reltool/src/reltool_target.erl"
102 (("Date = date\\(\\),")
103 (string-append "Date = "
104 (date->string source-date-epoch
105 "'{~Y,~m,~d}',"))))
106 (substitute* "lib/reltool/src/reltool_target.erl"
107 (("Time = time\\(\\),")
108 (string-append "Time = "
109 (date->string source-date-epoch
110 "'{~H,~M,~S}',"))))
111 (substitute* '("lib/reltool/src/reltool_target.erl"
112 "lib/sasl/src/systools_make.erl")
113 (("date\\(\\), time\\(\\),")
114 (date->string source-date-epoch
115 "{~Y,~m,~d}, {~H,~M,~S},")))
116 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
117 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
118 (date->string
119 source-date-epoch
120 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
121 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
122 (("\\{Y,Mo,D\\} = date\\(\\),")
123 (date->string source-date-epoch
124 "{Y,Mo,D} = {~Y,~m,~d},")))
125 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
126 (("\\{H,Mi,S\\} = time\\(\\),")
127 (date->string source-date-epoch
128 "{H,Mi,S} = {~H,~M,~S},")))
129 #t)))
130 (add-after 'patch-source-shebangs 'patch-source-env
131 (lambda _
132 (let ((escripts
133 (append
134 (find-files "." "\\.escript")
135 (find-files "lib/stdlib/test/escript_SUITE_data/")
136 '("erts/lib_src/utils/make_atomics_api"
137 "erts/preloaded/src/add_abstract_code"
138 "lib/diameter/bin/diameterc"
139 "lib/reltool/examples/display_args"
140 "lib/reltool/examples/mnesia_core_dump_viewer"
141 "lib/snmp/src/compile/snmpc.src"
142 "make/verify_runtime_dependencies"
143 "make/emd2exml.in"))))
144 (substitute* escripts
145 (("/usr/bin/env") (which "env")))
146 #t)))
147 (add-before 'configure 'set-erl-top
148 (lambda _
149 (setenv "ERL_TOP" (getcwd))
150 #t))
151 (add-after 'patch-source-env 'autoconf
152 (lambda _
153 (invoke "./otp_build" "autoconf")
154 #t))
155 (add-after 'install 'patch-erl
156 ;; This only works after install.
157 (lambda* (#:key outputs #:allow-other-keys)
158 (let* ((out (assoc-ref outputs "out")))
159 (substitute* (string-append out "/bin/erl")
160 (("sed") (which "sed")))
161 #t)))
162 (add-after 'install 'install-doc
163 (lambda* (#:key inputs outputs #:allow-other-keys)
164 (let* ((out (assoc-ref outputs "out"))
165 (manpages (assoc-ref inputs "erlang-manpages"))
166 (share (string-append out "/share/")))
167 (mkdir-p share)
168 (mkdir-p (string-append share "/misc/erlang"))
169 (with-directory-excursion share
170 (invoke "tar" "xvf" manpages)
171 (rename-file "COPYRIGHT"
172 (string-append share "/misc/erlang/COPYRIGHT"))
173 ;; Delete superfluous file.
174 (delete-file "PR.template"))
175 #t))))))
176 (home-page "http://erlang.org/")
177 (synopsis "The Erlang programming language")
178 (description
179 "Erlang is a programming language used to build massively
180 scalable soft real-time systems with requirements on high
181 availability. Some of its uses are in telecoms, banking, e-commerce,
182 computer telephony and instant messaging. Erlang's runtime system has
183 built-in support for concurrency, distribution and fault tolerance.")
184 ;; Erlang is distributed under the Apache License 2.0, but some components
185 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
186 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
187 license:lgpl2.0+ license:tcl/tk license:zlib))))