gawk.scm 9.6 KB

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