projects/guix·blob ruby-team · refs

272 lines · 10.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012-2016, 2023 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014, 2015 Mark H Weaver <[email protected]>
4;;; Copyright © 2018, 2022-2024 Efraim Flashner <[email protected]>
5;;; Copyright © 2021, 2022 Marius Bakke <[email protected]>
6;;; Copyright © 2022 Paul A. Patience <[email protected]>
7;;; Copyright © 2024 Simon Tournier <[email protected]>
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages gawk)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages bash)
29 #:use-module (gnu packages bison)
30 #:use-module (gnu packages gcc)
31 #:use-module (gnu packages libsigsegv)
32 #:use-module (gnu packages multiprecision)
33 #:use-module (guix packages)
34 #:use-module (guix gexp)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix utils)
38 #:use-module (guix build-system copy)
39 #:use-module (guix build-system gnu))
40
41(define-public gawk
42 (package
43 (name "gawk")
44 (version "5.3.0")
45 (source (origin
46 (method url-fetch)
47 (uri (string-append "mirror://gnu/gawk/gawk-" version
48 ".tar.xz"))
49 (sha256
50 (base32 "02x97iyl9v84as4rkdrrkfk2j4vy4r3hpp3rkp3gh3qxs79id76a"))))
51 (build-system gnu-build-system)
52 (arguments
53 (list #:phases
54 #~(modify-phases %standard-phases
55 (add-before 'configure 'set-shell-file-name
56 (lambda* (#:key inputs #:allow-other-keys)
57 ;; Refer to the right shell.
58 (let ((/bin/sh (search-input-file inputs "bin/sh")))
59 (substitute* "io.c"
60 (("/bin/sh") /bin/sh))
61
62 ;; When cross-compiling, remove dependencies on the
63 ;; `check-for-shared-lib-support' target, which tries
64 ;; to run the cross-built `gawk'.
65 #$@(if (%current-target-system)
66 '((substitute* "extension/Makefile.in"
67 (("^.*: check-for-shared-lib-support" match)
68 (string-append "### " match))))
69 '()))))
70
71 (add-before 'check 'adjust-test-infrastructure
72 (lambda _
73 ;; Remove dependency on 'more' (from util-linux), which
74 ;; would needlessly complicate bootstrapping.
75 (substitute* "test/Makefile"
76 (("\\| more") ""))
77
78 ;; Adjust the shebang in that file since it is then diff'd
79 ;; against the actual test output.
80 (substitute* "test/watchpoint1.ok"
81 (("#! /usr/bin/gawk")
82 (string-append "#!" (which "gawk")))))))))
83
84 ;; Tests explicitly require en_US.UTF-8, fr_FR.UTF-8, ru_RU.UTF-8 and
85 ;; ja_JP.UTF-8.
86 (native-inputs (list (libc-utf8-locales-for-target)))
87
88 (inputs (list libsigsegv
89 ;; Use the full-fledged Bash package, otherwise the test suite
90 ;; sometimes fail non-deterministically.
91 bash))
92
93 (search-paths
94 (list (search-path-specification
95 (variable "AWKPATH")
96 (files (list "share/awk")))
97 (search-path-specification
98 (variable "AWKLIBPATH")
99 (files (list "lib/gawk")))))
100 (home-page "https://www.gnu.org/software/gawk/")
101 (synopsis "Text scanning and processing language")
102 (description
103 "Gawk is the GNU implementation of Awk, a specialized programming
104language for the easy manipulation of formatted text, such as tables of data.
105Gawk features many extensions beyond the traditional implementation,
106including network access, sorting, and large libraries.")
107 (license license:gpl3+)))
108
109;; Separate from gawk to facilitate bootstrapping.
110(define-public gawk-mpfr
111 (package/inherit gawk
112 (name "gawk-mpfr")
113 (inputs
114 (modify-inputs inputs
115 (prepend mpfr)))))
116
117;; Suffixed with -next because, similarly to Emacs, development versions are
118;; numbered x.y.60+z, and also there are no tagged versions of egawk yet.
119;; (However, though egawk's --version lists 5.1.60, it is actually forked from
120;; a development version of gawk 5.1.1.)
121(define-public egawk-next
122 (let ((commit "f00e74ffc73f6ba6fe74fb7a26319770b8c3792c")
123 (revision "0"))
124 (package
125 (inherit gawk-mpfr)
126 (name "egawk-next")
127 (version (git-version "5.1.60" revision commit))
128 (source
129 (origin
130 (method git-fetch)
131 (uri (git-reference
132 (url "https://www.kylheku.com/git/egawk")
133 (commit commit)))
134 (file-name (git-file-name name version))
135 (sha256
136 (base32 "0bmfbw6k1aiyiardnk7ha5zlpkvavj013mm4n7wwj2vdcgrs6p1f"))))
137 (home-page "https://www.kylheku.com/cgit/egawk/")
138 (synopsis "Enhanced GNU Awk")
139 (description
140 "@command{egawk} is Enhanced GNU Awk. It is a fork of GNU Awk with
141some enhancements designed and implemented by Kaz Kylheku. In particular,
142Enhanced GNU Awk provides the @code{@@let} statement for declaring
143block-scoped lexical variables."))))
144
145(define-public mawk
146 (package
147 (name "mawk")
148 (version "1.3.4-20240905")
149 (home-page "https://invisible-island.net/mawk/mawk.html")
150 (source (origin
151 (method url-fetch)
152 (uri (string-append "https://invisible-mirror.net/archives/mawk"
153 "/mawk-" version ".tgz"))
154 (sha256
155 (base32
156 "1q4rfcv7ppfw4fra8hp8z0s4qnsv1x598ny4xwb026zsgn96g6d3"))
157 (modules '((guix build utils)))
158 (snippet
159 '(begin
160 ;; Delete file generated by bison.
161 (delete-file "parse.c")
162 ;; Prevent tests from hard coding PATH to a bogus value.
163 (substitute* '("test/mawktest" "test/fpe_test")
164 (("^PATH=.*")
165 ""))))))
166 (build-system gnu-build-system)
167 (arguments
168 (list
169 #:parallel-build? #f ; Prevent a race condition.
170 #:phases
171 #~(modify-phases %standard-phases
172 (add-after 'install 'symlink-awk
173 (lambda _
174 (with-directory-excursion (string-append #$output "/bin")
175 (symlink "mawk" "awk")))))))
176 (native-inputs
177 (list bison))
178 (synopsis "Text scanning and processing language")
179 (description
180 "@command{mawk} is an interpreter for the Awk programming language.
181This version aims to be smaller and faster than GNU Awk, at the expense
182of fewer features and extensions.")
183 (license license:gpl2))) ;version 2 only
184
185(define-public cppawk
186 (package
187 (name "cppawk")
188 (version "20220703")
189 (source
190 (origin
191 (method git-fetch)
192 (uri (git-reference
193 (url "https://www.kylheku.com/git/cppawk")
194 (commit version)))
195 (file-name (git-file-name name version))
196 (sha256
197 (base32 "0b09757q81sz4gn62k3mv5bgllyb2v5m64346s8fc99mqqif70cx"))))
198 (build-system copy-build-system)
199 (arguments
200 `(#:install-plan '(("bin/cppawk" "bin/cppawk")
201 ("share/cppawk/include" "share/cppawk/include")
202 ("./" "share/man/man1" #:include-regexp (".*\\.1$")))
203 #:phases
204 (modify-phases %standard-phases
205 (add-after 'unpack 'fix-paths
206 (lambda _
207 (substitute* "bin/cppawk"
208 (("/bin/sh") (which "sh"))
209 (("/bin/bash") (which "bash"))
210 (("dirname") (which "dirname"))
211 (("mktemp") (which "mktemp"))
212 ;; Extra space to prevent matching Awk's printf.
213 (("printf ") (string-append (which "printf") " "))
214 (("rm -f") (string-append (which "rm") " -f"))
215 (("prepro=cpp") (string-append "prepro=" (which "cpp")))
216 (("sed -e") (string-append (which "sed") " -e")))
217 (substitute* '("runtests"
218 "testdir/testawk"
219 "testdir/testcpp"
220 "testdir/testdel")
221 (("/bin/sh") (which "sh")))
222 (substitute* "testsuite.awk"
223 (("/usr/bin/awk") (which "awk")))))
224 (add-after 'fix-paths 'fix-awk-paths
225 (lambda _
226 (substitute* "bin/cppawk"
227 (("awk=gawk") (string-append "awk=" (which "gawk")))
228 (("awk '") (string-append (which "gawk") " '")))))
229 (add-after 'fix-awk-paths 'check
230 (lambda _
231 (invoke "./runtests"))))))
232 (native-inputs
233 ;; For tests
234 (list mawk))
235 (inputs
236 (list coreutils ; For dirname, mktemp, printf, rm
237 gawk-mpfr ; Default variant, but supports others
238 gcc ; For cpp
239 sed))
240 (home-page "https://www.kylheku.com/cgit/cppawk/")
241 (synopsis "Wrapper script that adds C preprocessing to Awk")
242 (description
243 "@command{cppawk} is a shell script that invokes the C preprocessor
244(@command{cpp}) on Awk code and calls Awk (by default GNU Awk) on the result.
245
246@command{cppawk} understands the basic Awk options like @option{-F} and
247@option{-v}, and also understands common @command{cpp} options like
248@option{-I} and @option{-Dmacro=value}.
249
250@command{cppawk} has no dependencies beyond Awk, @command{cpp}, @command{sed}
251and some GNU core utilities (including @command{printf}). Preprocessed
252programs can be captured and transferred to systems that have Awk but not
253@command{cpp} or @command{cppawk}.")
254 (license license:bsd-2)))
255
256(define-public cppawk-egawk
257 (package/inherit cppawk
258 (name "cppawk-egawk")
259 (arguments
260 (substitute-keyword-arguments arguments
261 ((#:phases phases)
262 `(modify-phases ,phases
263 (replace 'fix-awk-paths
264 (lambda _
265 (substitute* "bin/cppawk"
266 (("awk=gawk") (string-append "awk=" (which "egawk")))
267 (("awk '") (string-append (which "egawk") " '")))))))))
268 (inputs
269 (modify-inputs inputs
270 (delete "gawk-mpfr")
271 (prepend egawk-next)))
272 (synopsis "Wrapper script that adds C preprocessing to Enhanced GNU Awk")))