guile-package.scm 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. ;;; Copyright © 2023-2024 Free Software Foundation, Inc.
  2. ;;;
  3. ;;; This file is part of GNU Guile.
  4. ;;;
  5. ;;; GNU Guile is free software; you can redistribute it and/or modify it
  6. ;;; under the terms of the GNU General Public License as published by
  7. ;;; the Free Software Foundation; either version 3 of the License, or (at
  8. ;;; your option) any later version.
  9. ;;;
  10. ;;; GNU Guile is distributed in the hope that it will be useful, but
  11. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;;; GNU General Public License for more details.
  14. ;;;
  15. ;;; You should have received a copy of the GNU General Public License
  16. ;;; along with GNU Guile. If not, see <http://www.gnu.org/licenses/>.
  17. ;; This file defines a Guix package. It can be used to spawn an
  18. ;; interactive development environment:
  19. ;;
  20. ;; guix shell
  21. ;;
  22. ;; Or it can be used to build Guile from a checkout in an isolated
  23. ;; environment:
  24. ;;
  25. ;; guix build -f guix.scm
  26. ;;
  27. ;; Likewise, you may cross-compile it:
  28. ;;
  29. ;; guix build -f guix.scm --target=x86_64-w64-mingw32
  30. ;;
  31. ;; … or perform a native build for another architecture, assuming
  32. ;; either offloading or transparent QEMU emulation is set up:
  33. ;;
  34. ;; guix build -f guix.scm -s riscv64-linux
  35. (define-module (guile-package)
  36. #:use-module (guix)
  37. #:use-module (guix git-download)
  38. #:use-module (guix build-system gnu)
  39. #:use-module ((guix licenses) #:prefix license:)
  40. #:use-module (gnu packages autotools)
  41. #:use-module (gnu packages base)
  42. #:use-module (gnu packages bash)
  43. #:use-module (gnu packages bdw-gc)
  44. #:use-module (gnu packages compression)
  45. #:use-module (gnu packages flex)
  46. #:use-module (gnu packages gdb)
  47. #:use-module (gnu packages gettext)
  48. #:use-module (gnu packages gperf)
  49. #:use-module (gnu packages libffi)
  50. #:use-module (gnu packages libunistring)
  51. #:use-module (gnu packages linux)
  52. #:use-module (gnu packages pkg-config)
  53. #:use-module (gnu packages readline)
  54. #:use-module (gnu packages tex)
  55. #:use-module (gnu packages texinfo)
  56. #:use-module (gnu packages version-control))
  57. (define-public guile
  58. (let ((vcs-file? (or (git-predicate
  59. (string-append (current-source-directory)
  60. "/../.."))
  61. (const #t))))
  62. (package
  63. (name "guile")
  64. (version "3.0.99-git")
  65. (source (local-file "../.." "guile-checkout"
  66. #:recursive? #t
  67. #:select? vcs-file?))
  68. (build-system gnu-build-system)
  69. (arguments
  70. (list #:configure-flags
  71. #~'("--enable-mini-gmp"
  72. #$@(if (target-x86-32?) ;<https://issues.guix.gnu.org/49368>
  73. '("--disable-static" "CFLAGS=-g -O2 -fexcess-precision=standard")
  74. '("--disable-static"))) ;saves 3 MiB
  75. #:phases
  76. #~(modify-phases %standard-phases
  77. (add-before 'bootstrap 'set-version
  78. (lambda _
  79. ;; Tell 'git-version-gen' what version this is, or it will
  80. ;; just pick "UNKNOWN", making it unusable as a replacement
  81. ;; for 'guile-3.0'. XXX: This is inaccurate when using
  82. ;; '--with-branch' but using (package-version this-package)
  83. ;; wouldn't give us a valid version string.
  84. (call-with-output-file ".tarball-version"
  85. (lambda (port)
  86. (display #$version port)))
  87. ;; Set this one as well so 'version.test' passes.
  88. (substitute* "GUILE-VERSION"
  89. (("^GUILE_MICRO_VERSION=.*")
  90. "GUILE_MICRO_VERSION=99\n"))))
  91. (add-before 'configure 'pre-configure
  92. (lambda* (#:key inputs #:allow-other-keys)
  93. ;; Tell (ice-9 popen) the file name of Bash.
  94. (let ((bash (false-if-exception
  95. (search-input-file inputs "/bin/sh"))))
  96. (substitute* "module/ice-9/popen.scm"
  97. ;; If bash is #f allow fallback for user to provide
  98. ;; "bash" in PATH. This happens when cross-building to
  99. ;; MinGW for which we do not have Bash yet.
  100. (("/bin/sh")
  101. (or bash "/bin/sh")))))))))
  102. (native-inputs
  103. (append (list autoconf
  104. automake
  105. libtool
  106. gnu-gettext
  107. flex
  108. texinfo
  109. texlive-scheme-basic ;for "make pdf"
  110. texlive-epsf
  111. gperf
  112. git
  113. gdb
  114. strace
  115. readline
  116. lzip
  117. ;; Ensure we get a cross-pkg-config when needed.
  118. pkg-config)
  119. ;; When cross-compiling, a native version of Guile itself
  120. ;; is needed.
  121. (if (%current-target-system)
  122. (list this-package)
  123. '())))
  124. (inputs
  125. (append (list libffi)
  126. ;; We need Bash when cross-compiling because some of the
  127. ;; scripts in bin/ refer to it. Use 'bash-minimal' because
  128. ;; we don't need an interactive Bash with Readline and all.
  129. (if (target-mingw?)
  130. (list libiconv)
  131. (list bash-minimal))))
  132. (propagated-inputs
  133. (list libunistring libgc))
  134. (outputs '("out" "debug"))
  135. (native-search-paths
  136. (list (search-path-specification
  137. (variable "GUILE_LOAD_PATH")
  138. (files '("share/guile/site/3.0")))
  139. (search-path-specification
  140. (variable "GUILE_LOAD_COMPILED_PATH")
  141. (files '("lib/guile/3.0/site-ccache")))))
  142. (synopsis "Scheme implementation intended especially for extensions")
  143. (description
  144. "Guile is the GNU Ubiquitous Intelligent Language for Extensions, the
  145. official extension language of the GNU system. It is an implementation of
  146. the Scheme language which can be easily embedded in other applications to
  147. provide a convenient means of extending the functionality of the application
  148. without requiring the source code to be rewritten.")
  149. (home-page "https://www.gnu.org/software/guile/")
  150. (license license:lgpl3+))))
  151. (define (package-with-configure-flags p flags)
  152. "Return P with FLAGS as addition 'configure' flags."
  153. (package/inherit p
  154. (arguments
  155. (substitute-keyword-arguments (package-arguments p)
  156. ((#:configure-flags original-flags #~'())
  157. #~(append #$original-flags #$flags))))))
  158. (define-public guile-without-threads
  159. (package
  160. (inherit (package-with-configure-flags guile
  161. #~'("--without-threads")))
  162. (name "guile-without-threads")))
  163. (define-public guile-without-networking
  164. (package
  165. (inherit (package-with-configure-flags guile
  166. #~'("--disable-networking")))
  167. (name "guile-without-networking")))
  168. (define-public guile-debug
  169. (package
  170. (inherit (package-with-configure-flags guile
  171. #~'("--enable-guile-debug")))
  172. (name "guile-debug")))
  173. (define-public guile-strict-typing
  174. (package
  175. (inherit (package-with-configure-flags
  176. guile
  177. #~'("CPPFLAGS=-DSCM_DEBUG_TYPING_STRICTNESS=2")))
  178. (name "guile-strict-typing")))
  179. guile