gnu: racket: Remove obsolete patch.
[jackhill/guix/guix.git] / gnu / packages / racket.scm
CommitLineData
3df04eb0
PM
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
4;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
5;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu packages racket)
23 #:use-module ((guix licenses)
24 #:select (asl2.0 expat lgpl3+))
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix gexp)
30 #:use-module (guix build-system gnu)
31 #:use-module (srfi srfi-1)
32 #:use-module (ice-9 match)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages bash)
35 #:use-module ((gnu packages chez)
36 #:select (chez-scheme))
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages databases)
39 #:use-module (gnu packages fontutils)
40 #:use-module (gnu packages gl)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages libedit)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages sqlite)
47 #:use-module (gnu packages tls)
48 #:use-module (gnu packages xorg))
49
50(define-public racket
51 (package
52 (name "racket")
53 (version "8.0") ; note: remember to also update racket-minimal!
54 (source (origin
55 (method url-fetch)
56 (uri (list (string-append "https://mirror.racket-lang.org/installers/"
57 version "/racket-src.tgz")
58 ;; this mirror seems to have broken HTTPS:
59 (string-append
60 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
61 version "/racket-src.tgz")))
62 (sha256
63 (base32
64 "047wpjblfzmf1msz7snrp2c2h0zxyzlmbsqr9bwsyvz3frcg0888"))
65 (patches (search-patches
cd9454f6 66 "racket-sh-via-rktio.patch"))))
3df04eb0
PM
67 (build-system gnu-build-system)
68 (arguments
69 `(#:configure-flags
70 `(,(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
71 (assoc-ref %build-inputs "sh")
72 "/bin/sh")
73 "--enable-libz"
74 "--enable-liblz4")
75 #:modules
76 ((guix build gnu-build-system)
77 (guix build utils)
78 (srfi srfi-1))
79 #:phases
80 (modify-phases %standard-phases
81 (add-after 'unpack 'patch-chez-configure
82 (lambda* (#:key inputs outputs #:allow-other-keys)
83 (substitute* "src/cs/c/Makefile.in"
84 (("/bin/sh") (which "sh")))
85 ;; TODO: Racket CS uses a fork of Chez Scheme.
86 ;; Most of this is copy-pasted from the "chez.scm",
87 ;; but maybe there's a way to reuse more directly.
88 (with-directory-excursion "src/ChezScheme"
89 (substitute* (find-files "mats" "Mf-.*")
90 (("^[[:space:]]+(cc ) *") "\tgcc "))
91 (substitute*
92 (find-files "." (string-append
93 "("
94 "Mf-[a-zA-Z0-9.]+"
95 "|Makefile[a-zA-Z0-9.]*"
96 "|checkin"
97 "|stex\\.stex"
98 "|newrelease"
99 "|workarea"
100 "|unix\\.ms"
101 "|^6\\.ms"
102 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
103 ")"))
104 (("/bin/rm") (which "rm"))
105 (("/bin/ln") (which "ln"))
106 (("/bin/cp") (which "cp"))
107 (("/bin/echo") (which "echo")))
108 (substitute* "makefiles/installsh"
109 (("/bin/true") (which "true"))))
110 #t))
111 (add-before 'configure 'pre-configure-minimal
112 (lambda* (#:key inputs #:allow-other-keys)
113 (chdir "src")
114 #t))
115 (add-after 'build 'patch-config.rktd-lib-search-dirs
116 (lambda* (#:key inputs outputs #:allow-other-keys)
117 ;; We do this between the `build` and `install` phases
118 ;; so that we have racket to read and write the hash table,
119 ;; but it comes before `raco setup`, when foreign libraries
120 ;; are needed to build the documentation.
121 (define out (assoc-ref outputs "out"))
122 (apply invoke
123 "./cs/c/racketcs"
124 "-e"
125 ,(format #f
126 "~s"
127 '(let* ((args
128 (vector->list
129 (current-command-line-arguments)))
130 (file (car args))
131 (extra-lib-search-dirs (cdr args)))
132 (write-to-file
133 (hash-update
134 (file->value file)
135 'lib-search-dirs
136 (lambda (dirs)
137 (append dirs extra-lib-search-dirs))
138 null)
139 #:exists 'truncate/replace
140 file)))
141 "--"
142 "../etc/config.rktd"
143 (filter-map (lambda (lib)
144 (cond
145 ((assoc-ref inputs lib)
146 => (lambda (pth)
147 (string-append pth "/lib")))
148 (else
149 #f)))
150 '("cairo"
151 "fontconfig"
152 "glib"
153 "glu"
154 "gmp"
155 "gtk+"
156 "libjpeg"
157 "libpng"
158 "libx11"
159 "mesa"
160 "mpfr"
161 "openssl"
162 "pango"
163 "sqlite"
164 "unixodbc"
165 "libedit")))
166 #t)))
167 ;; XXX: how to run them?
168 #:tests? #f))
169 (inputs
170 `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
171 ("sh" ,bash-minimal)
172 ("zlib" ,zlib)
173 ("zlib:static" ,zlib "static")
174 ("lz4" ,lz4)
175 ("lz4:static" ,lz4 "static")
176 ("cairo" ,cairo)
177 ("fontconfig" ,fontconfig)
178 ("glib" ,glib)
179 ("glu" ,glu)
180 ("gmp" ,gmp)
181 ("gtk+" ,gtk+) ; propagates gdk-pixbuf+svg
182 ("libjpeg" ,libjpeg-turbo)
183 ("libpng" ,libpng)
184 ("libx11" ,libx11)
185 ("mesa" ,mesa)
186 ("mpfr" ,mpfr)
187 ("openssl" ,openssl)
188 ("pango" ,pango)
189 ("sqlite" ,sqlite)
190 ("unixodbc" ,unixodbc)
191 ("libedit" ,libedit)))
192 (home-page "https://racket-lang.org")
193 (synopsis "A programmable programming language in the Scheme family")
194 (description
195 "Racket is a general-purpose programming language in the Scheme family,
196with a large set of libraries and a compiler based on Chez Scheme. Racket is
197also a platform for language-oriented programming, from small domain-specific
198languages to complete language implementations.
199
200The main Racket distribution comes with many bundled packages, including the
201DrRacket IDE, libraries for GUI and web programming, and implementations of
202languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")
203 ;; https://download.racket-lang.org/license.html
204 (license (list lgpl3+ asl2.0 expat))))
205
206(define-public racket-minimal
207 (package
208 (inherit racket)
209 (name "racket-minimal")
210 (version (package-version racket))
211 (source
212 (origin
213 (inherit (package-source racket))
214 (uri (list (string-append "https://mirror.racket-lang.org/installers/"
215 version "/racket-minimal-src.tgz")
216 ;; this mirror seems to have broken HTTPS:
217 (string-append
218 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
219 version "/racket-minimal-src.tgz")))
220 (sha256 "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21")))
221 (synopsis "Racket without bundled packages such as DrRacket")
222 (inputs
223 `(("openssl" ,openssl)
224 ("sqlite" ,sqlite)
225 ("sh" ,bash-minimal)
226 ("zlib" ,zlib)
227 ("zlib:static" ,zlib "static")
228 ("lz4" ,lz4)
229 ("lz4:static" ,lz4 "static")))
230 (description
231 "Racket is a general-purpose programming language in the Scheme family,
232with a large set of libraries and a compiler based on Chez Scheme. Racket is
233also a platform for language-oriented programming, from small domain-specific
234languages to complete language implementations.
235
236The ``minimal Racket'' distribution includes just enough of Racket for you to
237use @command{raco pkg} to install more. Bundled packages, such as the
238DrRacket IDE, are not included.")))