gnu: erlang: Delete the bootstrap phase.
[jackhill/guix/guix.git] / gnu / packages / erlang.scm
CommitLineData
3c6e42b3
SS
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Steve Sprang <scs@stevesprang.com>
35e86e36 3;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
5c4ea872 4;;; Copyright © 2016, 2017 Pjotr Prins <pjotr.guix@thebird.nl>
629c1947 5;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
3c6e42b3
SS
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)
35e86e36 27 #:use-module (guix utils)
a4078acf 28 #:use-module (gnu packages)
3c6e42b3
SS
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")
629c1947 40 (version "20.2.3")
3c6e42b3
SS
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
629c1947 51 "0s9g4ijdbqq21k4cqggz074d3fiimah942qisv2kgizhlivpw2nm"))
a4078acf 52 (patches (search-patches "erlang-man-path.patch"))))
3c6e42b3
SS
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_"
35e86e36 64 (version-major+minor version) ".tar.gz"))
3c6e42b3
SS
65 (sha256
66 (base32
629c1947 67 "1pyb8wbk7znsyni8d1k4dj1m01lr191dcrrzisli1z27ks7hh3lm"))))))
3c6e42b3
SS
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
9b25e1d1 92 (delete 'bootstrap)
3c6e42b3
SS
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
1b0ce451
TGR
99 (time-utc->date
100 (make-time time-utc 0 (string->number
101 (getenv "SOURCE_DATE_EPOCH"))))))
3c6e42b3
SS
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},")))
ee217402 117 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
3c6e42b3
SS
118 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
119 (date->string
1b0ce451
TGR
120 source-date-epoch
121 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
3c6e42b3
SS
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
1b0ce451
TGR
129 "{H,Mi,S} = {~H,~M,~S},")))
130 #t)))
3c6e42b3
SS
131 (add-after 'patch-source-shebangs 'patch-source-env
132 (lambda _
133 (let ((escripts
134 (append
135 (find-files "." "\\.escript")
136 (find-files "lib/stdlib/test/escript_SUITE_data/")
137 '("erts/lib_src/utils/make_atomics_api"
138 "erts/preloaded/src/add_abstract_code"
139 "lib/diameter/bin/diameterc"
140 "lib/reltool/examples/display_args"
141 "lib/reltool/examples/mnesia_core_dump_viewer"
142 "lib/snmp/src/compile/snmpc.src"
143 "make/verify_runtime_dependencies"
144 "make/emd2exml.in"))))
145 (substitute* escripts
1b0ce451
TGR
146 (("/usr/bin/env") (which "env")))
147 #t)))
3c6e42b3
SS
148 (add-before 'configure 'set-erl-top
149 (lambda _
1b0ce451
TGR
150 (setenv "ERL_TOP" (getcwd))
151 #t))
d10092b8 152 (add-after 'patch-source-env 'autoconf
1b0ce451
TGR
153 (lambda _
154 (invoke "./otp_build" "autoconf")
155 #t))
3c6e42b3
SS
156 (add-after 'install 'patch-erl
157 ;; This only works after install.
1b0ce451
TGR
158 (lambda* (#:key outputs #:allow-other-keys)
159 (let* ((out (assoc-ref outputs "out")))
160 (substitute* (string-append out "/bin/erl")
161 (("sed") (which "sed")))
162 #t)))
3c6e42b3
SS
163 (add-after 'install 'install-doc
164 (lambda* (#:key inputs outputs #:allow-other-keys)
165 (let* ((out (assoc-ref outputs "out"))
166 (manpages (assoc-ref inputs "erlang-manpages"))
167 (share (string-append out "/share/")))
1b0ce451
TGR
168 (mkdir-p share)
169 (mkdir-p (string-append share "/misc/erlang"))
170 (with-directory-excursion share
171 (invoke "tar" "xvf" manpages)
3c6e42b3
SS
172 (rename-file "COPYRIGHT"
173 (string-append share "/misc/erlang/COPYRIGHT"))
5c4ea872 174 ;; Delete superfluous file.
1b0ce451
TGR
175 (delete-file "PR.template"))
176 #t))))))
eae7ece1 177 (home-page "https://www.erlang.org/")
3c6e42b3
SS
178 (synopsis "The Erlang programming language")
179 (description
180 "Erlang is a programming language used to build massively
181scalable soft real-time systems with requirements on high
182availability. Some of its uses are in telecoms, banking, e-commerce,
183computer telephony and instant messaging. Erlang's runtime system has
184built-in support for concurrency, distribution and fault tolerance.")
185 ;; Erlang is distributed under the Apache License 2.0, but some components
186 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
187 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
188 license:lgpl2.0+ license:tcl/tk license:zlib))))