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