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>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
27 #:use-module (guix utils)
28 #:use-module (gnu packages)
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))
43 ;; The tarball from http://erlang.org/download contains many
44 ;; pre-compiled files, so we use this snapshot of the source
46 (uri (string-append "https://github.com/erlang/otp/archive/OTP-"
48 (file-name (string-append name "-" version ".tar.gz"))
51 "0s9g4ijdbqq21k4cqggz074d3fiimah942qisv2kgizhlivpw2nm"))
52 (patches (search-patches "erlang-man-path.patch"))))
53 (build-system gnu-build-system)
56 ("autoconf" ,autoconf)
57 ("automake" ,automake)
59 ;; Erlang's documentation is distributed in a separate tarball.
63 (uri (string-append "http://erlang.org/download/otp_doc_man_"
64 (version-major+minor version) ".tar.gz"))
67 "1pyb8wbk7znsyni8d1k4dj1m01lr191dcrrzisli1z27ks7hh3lm"))))))
69 `(("ncurses" ,ncurses)
71 ("wxwidgets" ,wxwidgets)))
73 `(("fontconfig" ,fontconfig)
77 `(#:test-target "release_tests"
79 (list "--disable-saved-compile-time"
80 "--enable-dynamic-ssl-lib"
81 "--enable-native-libs"
82 "--enable-shared-zlib"
83 "--enable-smp-support"
86 (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
87 #:modules ((srfi srfi-19) ; make-time, et cetera.
89 (guix build gnu-build-system))
91 (modify-phases %standard-phases
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
98 (let ((source-date-epoch
100 (make-time time-utc 0 (string->number
101 (getenv "SOURCE_DATE_EPOCH"))))))
102 (substitute* "lib/reltool/src/reltool_target.erl"
103 (("Date = date\\(\\),")
104 (string-append "Date = "
105 (date->string source-date-epoch
107 (substitute* "lib/reltool/src/reltool_target.erl"
108 (("Time = time\\(\\),")
109 (string-append "Time = "
110 (date->string source-date-epoch
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},")))
117 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
118 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
121 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
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
129 "{H,Mi,S} = {~H,~M,~S},")))
131 (add-after 'unpack 'patch-/bin/sh
133 (substitute* "erts/etc/unix/run_erl.c"
134 (("sh = \"/bin/sh\";")
135 (string-append "sh = \""
139 (substitute* "erts/emulator/sys/unix/sys_drivers.c"
140 (("SHELL \"/bin/sh\"")
141 (string-append "SHELL \""
144 (substitute* "erts/emulator/sys/unix/erl_child_setup.c"
145 (("SHELL \"/bin/sh\"")
146 (string-append "SHELL \""
150 (substitute* "lib/kernel/src/os.erl"
151 (("/bin/sh") (which "sh")))
154 (add-after 'patch-source-shebangs 'patch-source-env
158 (find-files "." "\\.escript")
159 (find-files "lib/stdlib/test/escript_SUITE_data/")
160 '("erts/lib_src/utils/make_atomics_api"
161 "erts/preloaded/src/add_abstract_code"
162 "lib/diameter/bin/diameterc"
163 "lib/reltool/examples/display_args"
164 "lib/reltool/examples/mnesia_core_dump_viewer"
165 "lib/snmp/src/compile/snmpc.src"
166 "make/verify_runtime_dependencies"
167 "make/emd2exml.in"))))
168 (substitute* escripts
169 (("/usr/bin/env") (which "env")))
171 (add-before 'configure 'set-erl-top
173 (setenv "ERL_TOP" (getcwd))
175 (add-after 'patch-source-env 'autoconf
177 (invoke "./otp_build" "autoconf")
179 (add-after 'install 'patch-erl
180 ;; This only works after install.
181 (lambda* (#:key outputs #:allow-other-keys)
182 (let* ((out (assoc-ref outputs "out")))
183 (substitute* (string-append out "/bin/erl")
184 (("sed") (which "sed")))
186 (add-after 'install 'install-doc
187 (lambda* (#:key inputs outputs #:allow-other-keys)
188 (let* ((out (assoc-ref outputs "out"))
189 (manpages (assoc-ref inputs "erlang-manpages"))
190 (share (string-append out "/share/")))
192 (mkdir-p (string-append share "/misc/erlang"))
193 (with-directory-excursion share
194 (invoke "tar" "xvf" manpages)
195 (rename-file "COPYRIGHT"
196 (string-append share "/misc/erlang/COPYRIGHT"))
197 ;; Delete superfluous file.
198 (delete-file "PR.template"))
200 (home-page "https://www.erlang.org/")
201 (synopsis "The Erlang programming language")
203 "Erlang is a programming language used to build massively
204 scalable soft real-time systems with requirements on high
205 availability. Some of its uses are in telecoms, banking, e-commerce,
206 computer telephony and instant messaging. Erlang's runtime system has
207 built-in support for concurrency, distribution and fault tolerance.")
208 ;; Erlang is distributed under the Apache License 2.0, but some components
209 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
210 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
211 license:lgpl2.0+ license:tcl/tk license:zlib))))