gnu: Use 'modify-phases' syntax.
[jackhill/guix/guix.git] / gnu / packages / regex.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages regex)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix utils))
27
28 (define-public re2
29 (package
30 (name "re2")
31 (version "2017-08-01")
32 (source (origin
33 (method url-fetch)
34 (uri
35 (string-append
36 "https://github.com/google/re2/archive/"
37 version ".tar.gz"))
38 (file-name (string-append name "-" version ".tar.gz"))
39 (sha256
40 (base32
41 "0dhndzr4ncdpa3yq22qlzxk7i1vlrcdg9z65k0k3j9bi37f271wk"))))
42 (build-system gnu-build-system)
43 (arguments
44 `(#:modules ((guix build gnu-build-system)
45 (guix build utils)
46 (srfi srfi-1))
47 #:test-target "test"
48 ;; There is no configure step, but the Makefile respects a prefix.
49 ;; As ./configure does not know anything about the target CXX
50 ;; we need to specify TARGET-g++ explicitly.
51 #:make-flags (list (string-append "prefix=" %output)
52 (string-append
53 "CXX=" ,(string-append
54 (if (%current-target-system)
55 (string-append
56 (%current-target-system) "-")
57 "")
58 "g++")))
59 #:phases
60 (modify-phases %standard-phases
61 (delete 'configure)
62 (add-after 'install 'delete-static-library
63 (lambda* (#:key outputs #:allow-other-keys)
64 ;; No make target for shared-only; delete the static version.
65 (delete-file (string-append (assoc-ref outputs "out")
66 "/lib/libre2.a"))
67 #t)))))
68 (home-page "https://github.com/google/re2")
69 (synopsis "Fast, safe, thread-friendly regular expression engine")
70 (description "RE2 is a fast, safe, thread-friendly alternative to
71 backtracking regular expression engines like those used in PCRE, Perl and
72 Python. It is a C++ library.")
73 (license license:bsd-3)))
74
75 (define-public tre
76 (package
77 (name "tre")
78 (version "0.8.0")
79 (source (origin
80 (method url-fetch)
81 (uri (string-append "http://laurikari.net/tre/"
82 name "-" version ".tar.bz2"))
83 (sha256
84 (base32
85 "0n36cgqys59r2gmb7jzbqiwsy790v8nbxk82d2n2saz0rp145ild"))))
86 (build-system gnu-build-system)
87 (arguments
88 `(#:phases
89 (modify-phases %standard-phases
90 (add-before 'check 'install-locales
91 (lambda _
92 ;; The tests require the availability of the
93 ;; 'en_US.ISO-8859-1' locale.
94 (setenv "LOCPATH" (getcwd))
95 (zero? (system* "localedef" "--no-archive"
96 "--prefix" (getcwd) "-i" "en_US"
97 "-f" "ISO-8859-1" "./en_US.ISO-8859-1")))))))
98 (synopsis "Approximate regex matching library and agrep utility")
99 (description "Superset of the POSIX regex API, enabling approximate
100 matching. Also ships a version of the agrep utility which behaves similar to
101 grep but features inexact matching.")
102 (home-page "http://laurikari.net/tre")
103 (license license:bsd-2)))