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