Debian Codegraph @

.guix/modules/guile-package.scm

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