erlang.scm 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. ;;; Copyright © 2021 Cees de Groot <cg@evrl.com>
  9. ;;;
  10. ;;; This file is part of GNU Guix.
  11. ;;;
  12. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  13. ;;; under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 3 of the License, or (at
  15. ;;; your option) any later version.
  16. ;;;
  17. ;;; GNU Guix is distributed in the hope that it will be useful, but
  18. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;;; GNU General Public License for more details.
  21. ;;;
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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 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. (define-public erlang
  40. (package
  41. (name "erlang")
  42. (version "24.0.5")
  43. (source (origin
  44. (method git-fetch)
  45. ;; The tarball from http://erlang.org/download contains many
  46. ;; pre-compiled files, so we use this snapshot of the source
  47. ;; repository.
  48. (uri (git-reference
  49. (url "https://github.com/erlang/otp")
  50. (commit (string-append "OTP-" version))))
  51. (file-name (git-file-name name version))
  52. (sha256
  53. (base32
  54. "0f8zr2jxr0v4zcd98zqx99zxdn768vjpzwxsbsd6ss3if405sq2a"))
  55. (patches (search-patches "erlang-man-path.patch"))))
  56. (build-system gnu-build-system)
  57. (native-inputs
  58. `(("perl" ,perl)
  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_"
  64. (version-major+minor version) ".tar.gz"))
  65. (sha256
  66. (base32
  67. "1c9ccp93pmm54mmvpiyrmj8v00pq11a60c4xv220k97i965zkwsg"))))))
  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
  92. (delete 'bootstrap)
  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
  99. (time-utc->date
  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
  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},")))
  117. (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
  118. (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
  119. (date->string
  120. source-date-epoch
  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},")))
  130. #t)))
  131. (add-after 'unpack 'patch-/bin/sh
  132. (lambda _
  133. (substitute* "erts/etc/unix/run_erl.c"
  134. (("sh = \"/bin/sh\";")
  135. (string-append "sh = \""
  136. (which "sh")
  137. "\";")))
  138. (substitute* "erts/emulator/sys/unix/sys_drivers.c"
  139. (("SHELL \"/bin/sh\"")
  140. (string-append "SHELL \""
  141. (which "sh")
  142. "\"")))
  143. (substitute* "erts/emulator/sys/unix/erl_child_setup.c"
  144. (("SHELL \"/bin/sh\"")
  145. (string-append "SHELL \""
  146. (which "sh")
  147. "\"")))
  148. (substitute* "lib/kernel/src/os.erl"
  149. (("/bin/sh") (which "sh")))
  150. #t))
  151. (add-after 'patch-source-shebangs 'patch-source-env
  152. (lambda _
  153. (let ((escripts
  154. (append
  155. (find-files "." "\\.escript")
  156. (find-files "lib/stdlib/test/escript_SUITE_data/")
  157. '("erts/lib_src/utils/make_atomics_api"
  158. "erts/preloaded/src/add_abstract_code"
  159. "lib/diameter/bin/diameterc"
  160. "lib/reltool/examples/display_args"
  161. "lib/reltool/examples/mnesia_core_dump_viewer"
  162. "lib/snmp/src/compile/snmpc.src"
  163. "make/verify_runtime_dependencies"
  164. "make/emd2exml.in"))))
  165. (substitute* escripts
  166. (("/usr/bin/env") (which "env")))
  167. #t)))
  168. (add-before 'configure 'set-erl-top
  169. (lambda _
  170. (setenv "ERL_TOP" (getcwd))
  171. #t))
  172. (add-after 'install 'patch-erl
  173. ;; This only works after install.
  174. (lambda* (#:key outputs #:allow-other-keys)
  175. (let* ((out (assoc-ref outputs "out")))
  176. (substitute* (string-append out "/bin/erl")
  177. (("sed") (which "sed")))
  178. #t)))
  179. (add-after 'install 'install-doc
  180. (lambda* (#:key inputs outputs #:allow-other-keys)
  181. (let* ((out (assoc-ref outputs "out"))
  182. (manpages (assoc-ref inputs "erlang-manpages"))
  183. (share (string-append out "/share/")))
  184. (mkdir-p share)
  185. (with-directory-excursion share
  186. (invoke "tar" "xvf" manpages))
  187. #t))))))
  188. (home-page "https://www.erlang.org/")
  189. (synopsis "The Erlang programming language")
  190. (description
  191. "Erlang is a programming language used to build massively
  192. scalable soft real-time systems with requirements on high
  193. availability. Some of its uses are in telecoms, banking, e-commerce,
  194. computer telephony and instant messaging. Erlang's runtime system has
  195. built-in support for concurrency, distribution and fault tolerance.")
  196. ;; Erlang is distributed under the Apache License 2.0, but some components
  197. ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
  198. (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
  199. license:lgpl2.0+ license:tcl/tk license:zlib))))
  200. (define-public emacs-erlang
  201. (package
  202. (name "emacs-erlang")
  203. (version (package-version erlang))
  204. (source (package-source erlang))
  205. (build-system emacs-build-system)
  206. (arguments
  207. `(#:phases
  208. (modify-phases %standard-phases
  209. (add-before 'expand-load-path 'change-working-directory
  210. (lambda _ (chdir "lib/tools/emacs") #t)))))
  211. (home-page "https://www.erlang.org/")
  212. (synopsis "Erlang major mode for Emacs")
  213. (description
  214. "This package provides an Emacs major mode for editing Erlang source
  215. files.")
  216. (license license:asl2.0)))