PageRenderTime 60ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/gnu/packages/erlang.scm

https://gitlab.com/janneke/guix
Scheme | 205 lines | 168 code | 4 blank | 33 comment | 3 complexity | 52313422221b3c81f451d24b13dc3931 MD5 | raw file
  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.2.1")
  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. "0glbdh4la0k4ikygj6rssvlbxbzybjn0bpp276wq170d6rgahlf6"))
  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. "0k2zghkkqmf8g66hfb6zff2b7q5sl3r9y6lmv56ky03wzh9lpbjn"))))))
  68. (inputs
  69. (list ncurses openssl wxwidgets))
  70. (propagated-inputs
  71. (list fontconfig glu mesa))
  72. (arguments
  73. `(#:test-target "release_tests"
  74. #:configure-flags
  75. (list "--disable-saved-compile-time"
  76. "--enable-dynamic-ssl-lib"
  77. "--enable-native-libs"
  78. "--enable-shared-zlib"
  79. "--enable-smp-support"
  80. "--enable-threads"
  81. "--enable-wx"
  82. (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
  83. #:modules ((srfi srfi-19) ; make-time, et cetera.
  84. (guix build utils)
  85. (guix build gnu-build-system))
  86. #:phases
  87. (modify-phases %standard-phases
  88. (delete 'bootstrap)
  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. (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
  115. (date->string
  116. source-date-epoch
  117. "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
  118. (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
  119. (("\\{Y,Mo,D\\} = date\\(\\),")
  120. (date->string source-date-epoch
  121. "{Y,Mo,D} = {~Y,~m,~d},")))
  122. (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
  123. (("\\{H,Mi,S\\} = time\\(\\),")
  124. (date->string source-date-epoch
  125. "{H,Mi,S} = {~H,~M,~S},"))))))
  126. (add-after 'unpack 'patch-/bin/sh
  127. (lambda* (#:key inputs #:allow-other-keys)
  128. (let ((sh (search-input-file inputs "/bin/sh")))
  129. (substitute* "erts/etc/unix/run_erl.c"
  130. (("sh = \"/bin/sh\";")
  131. (string-append "sh = \"" sh "\";")))
  132. (substitute* "erts/emulator/sys/unix/sys_drivers.c"
  133. (("SHELL \"/bin/sh\"")
  134. (string-append "SHELL \"" sh "\"")))
  135. (substitute* "erts/emulator/sys/unix/erl_child_setup.c"
  136. (("SHELL \"/bin/sh\"")
  137. (string-append "SHELL \"" sh "\"")))
  138. (substitute* "lib/kernel/src/os.erl"
  139. (("/bin/sh") sh)))))
  140. (add-after 'patch-source-shebangs 'patch-source-env
  141. (lambda _
  142. (let ((escripts
  143. (append
  144. (find-files "." "\\.escript")
  145. (find-files "lib/stdlib/test/escript_SUITE_data/")
  146. '("erts/lib_src/utils/make_atomics_api"
  147. "erts/preloaded/src/add_abstract_code"
  148. "lib/diameter/bin/diameterc"
  149. "lib/reltool/examples/display_args"
  150. "lib/reltool/examples/mnesia_core_dump_viewer"
  151. "lib/snmp/src/compile/snmpc.src"
  152. "make/verify_runtime_dependencies"
  153. "make/emd2exml.in"))))
  154. (substitute* escripts
  155. (("/usr/bin/env") (which "env"))))))
  156. (add-before 'configure 'set-erl-top
  157. (lambda _
  158. (setenv "ERL_TOP" (getcwd))))
  159. (add-after 'install 'patch-erl
  160. ;; This only works after install.
  161. (lambda* (#:key outputs #:allow-other-keys)
  162. (let ((out (assoc-ref outputs "out")))
  163. (substitute* (string-append out "/bin/erl")
  164. (("sed") (which "sed"))))))
  165. (add-after 'install 'install-doc
  166. (lambda* (#:key inputs outputs #:allow-other-keys)
  167. (let* ((out (assoc-ref outputs "out"))
  168. (manpages (assoc-ref inputs "erlang-manpages"))
  169. (share (string-append out "/share/")))
  170. (mkdir-p share)
  171. (with-directory-excursion share
  172. (invoke "tar" "xvf" manpages))))))))
  173. (home-page "https://www.erlang.org/")
  174. (synopsis "The Erlang programming language")
  175. (description
  176. "Erlang is a programming language used to build massively
  177. scalable soft real-time systems with requirements on high
  178. availability. Some of its uses are in telecoms, banking, e-commerce,
  179. computer telephony and instant messaging. Erlang's runtime system has
  180. built-in support for concurrency, distribution and fault tolerance.")
  181. ;; Erlang is distributed under the Apache License 2.0, but some components
  182. ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
  183. (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
  184. license:lgpl2.0+ license:tcl/tk license:zlib))))
  185. (define-public emacs-erlang
  186. (package
  187. (name "emacs-erlang")
  188. (version (package-version erlang))
  189. (source (package-source erlang))
  190. (build-system emacs-build-system)
  191. (arguments
  192. `(#:phases
  193. (modify-phases %standard-phases
  194. (add-before 'expand-load-path 'change-working-directory
  195. (lambda _ (chdir "lib/tools/emacs") #t)))))
  196. (home-page "https://www.erlang.org/")
  197. (synopsis "Erlang major mode for Emacs")
  198. (description
  199. "This package provides an Emacs major mode for editing Erlang source
  200. files.")
  201. (license license:asl2.0)))