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