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