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 ;;;
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 (guix utils)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages autotools)
29 #:use-module (gnu packages fontutils)
30 #:use-module (gnu packages gl)
31 #:use-module (gnu packages ncurses)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages tls)
34 #:use-module (gnu packages wxwidgets))
35
36 (define-public erlang
37 (package
38 (name "erlang")
39 (version "20.1.7")
40 (source (origin
41 (method url-fetch)
42 ;; The tarball from http://erlang.org/download contains many
43 ;; pre-compiled files, so we use this snapshot of the source
44 ;; repository.
45 (uri (string-append "https://github.com/erlang/otp/archive/OTP-"
46 version ".tar.gz"))
47 (file-name (string-append name "-" version ".tar.gz"))
48 (sha256
49 (base32
50 "00pmngdyh1h088anmx6fbk085i93ajgk92rz7qsyhfc0lx0sm0a9"))
51 (patches (search-patches "erlang-man-path.patch"))))
52 (build-system gnu-build-system)
53 (native-inputs
54 `(("perl" ,perl)
55 ("autoconf" ,autoconf)
56 ("automake" ,automake)
57
58 ;; Erlang's documentation is distributed in a separate tarball.
59 ("erlang-manpages"
60 ,(origin
61 (method url-fetch)
62 (uri (string-append "http://erlang.org/download/otp_doc_man_"
63 (version-major+minor version) ".tar.gz"))
64 (sha256
65 (base32
66 "0ikvdpn4z7az6szg176l1r2yxhgs3msa3wgb3gmy45jkz0pzik05"))))))
67 (inputs
68 `(("ncurses" ,ncurses)
69 ("openssl" ,openssl)
70 ("wxwidgets" ,wxwidgets)))
71 (propagated-inputs
72 `(("fontconfig" ,fontconfig)
73 ("glu" ,glu)
74 ("mesa" ,mesa)))
75 (arguments
76 `(#:test-target "release_tests"
77 #:configure-flags
78 (list "--disable-saved-compile-time"
79 "--enable-dynamic-ssl-lib"
80 "--enable-native-libs"
81 "--enable-shared-zlib"
82 "--enable-smp-support"
83 "--enable-threads"
84 "--enable-wx"
85 (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
86 #:modules ((srfi srfi-19) ; make-time, et cetera.
87 (guix build utils)
88 (guix build gnu-build-system))
89 #:phases
90 (modify-phases %standard-phases
91 ;; The are several code fragments that embed timestamps into the
92 ;; output. Here, we alter those fragments to use the value of
93 ;; SOURCE_DATE_EPOCH instead.
94 (add-after 'unpack 'remove-timestamps
95 (lambda _
96 (let ((source-date-epoch
97 (time-utc->date
98 (make-time time-utc 0 (string->number
99 (getenv "SOURCE_DATE_EPOCH"))))))
100 (substitute* "lib/reltool/src/reltool_target.erl"
101 (("Date = date\\(\\),")
102 (string-append "Date = "
103 (date->string source-date-epoch
104 "'{~Y,~m,~d}',"))))
105 (substitute* "lib/reltool/src/reltool_target.erl"
106 (("Time = time\\(\\),")
107 (string-append "Time = "
108 (date->string source-date-epoch
109 "'{~H,~M,~S}',"))))
110 (substitute* '("lib/reltool/src/reltool_target.erl"
111 "lib/sasl/src/systools_make.erl")
112 (("date\\(\\), time\\(\\),")
113 (date->string source-date-epoch
114 "{~Y,~m,~d}, {~H,~M,~S},")))
115 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
116 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
117 (date->string
118 source-date-epoch
119 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
120 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
121 (("\\{Y,Mo,D\\} = date\\(\\),")
122 (date->string source-date-epoch
123 "{Y,Mo,D} = {~Y,~m,~d},")))
124 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
125 (("\\{H,Mi,S\\} = time\\(\\),")
126 (date->string source-date-epoch
127 "{H,Mi,S} = {~H,~M,~S},"))))))
128 (add-after 'patch-source-shebangs 'patch-source-env
129 (lambda _
130 (let ((escripts
131 (append
132 (find-files "." "\\.escript")
133 (find-files "lib/stdlib/test/escript_SUITE_data/")
134 '("erts/lib_src/utils/make_atomics_api"
135 "erts/preloaded/src/add_abstract_code"
136 "lib/diameter/bin/diameterc"
137 "lib/reltool/examples/display_args"
138 "lib/reltool/examples/mnesia_core_dump_viewer"
139 "lib/snmp/src/compile/snmpc.src"
140 "make/verify_runtime_dependencies"
141 "make/emd2exml.in"))))
142 (substitute* escripts
143 (("/usr/bin/env") (which "env"))))))
144 (add-before 'configure 'set-erl-top
145 (lambda _
146 (setenv "ERL_TOP" (getcwd))))
147 (add-after 'patch-source-env 'autoconf
148 (lambda _ (zero? (system* "./otp_build" "autoconf"))))
149 (add-after 'install 'patch-erl
150 ;; This only works after install.
151 (lambda _
152 (substitute* (string-append (assoc-ref %outputs "out") "/bin/erl")
153 (("sed") (which "sed")))))
154 (add-after 'install 'install-doc
155 (lambda* (#:key inputs outputs #:allow-other-keys)
156 (let* ((out (assoc-ref outputs "out"))
157 (manpages (assoc-ref inputs "erlang-manpages"))
158 (share (string-append out "/share/")))
159 (mkdir-p share)
160 (mkdir-p (string-append share "/misc/erlang"))
161 (with-directory-excursion share
162 (and
163 (zero? (system* "tar" "xvf" manpages))
164 (rename-file "COPYRIGHT"
165 (string-append share "/misc/erlang/COPYRIGHT"))
166 ;; Delete superfluous file.
167 (delete-file "PR.template")))))))))
168 (home-page "http://erlang.org/")
169 (synopsis "The Erlang programming language")
170 (description
171 "Erlang is a programming language used to build massively
172 scalable soft real-time systems with requirements on high
173 availability. Some of its uses are in telecoms, banking, e-commerce,
174 computer telephony and instant messaging. Erlang's runtime system has
175 built-in support for concurrency, distribution and fault tolerance.")
176 ;; Erlang is distributed under the Apache License 2.0, but some components
177 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
178 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
179 license:lgpl2.0+ license:tcl/tk license:zlib))))