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