projects/guix·blob java-team · refs

169 lines · 7.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2015, 2018, 2020 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <[email protected]>
4;;; Copyright © 2014 Sree Harsha Totakura <[email protected]>
5;;; Copyright © 2015, 2016 Sou Bunnbu <[email protected]>
6;;; Copyright © 2016 Efraim Flashner <[email protected]>
7;;; Copyright © 2016 Ben Woodcroft <[email protected]>
8;;; Copyright © 2016 David Craven <[email protected]>
9;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Marius Bakke <[email protected]>
10;;; Copyright © 2017 Ricardo Wurmus <[email protected]>
11;;; Copyright © 2017 Jelle Licht <[email protected]>
12;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
13;;; Copyright © 2018 Alex Vong <[email protected]>
14;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email protected]>
15;;; Copyright © 2022 Matthew James Kraai <[email protected]>
16;;; Copyright © 2024 Zhu Zihao <[email protected]>
17;;; Copyright © 2025 Ashish SHUKLA <[email protected]>
18;;;
19;;; This file is part of GNU Guix.
20;;;
21;;; GNU Guix is free software; you can redistribute it and/or modify it
22;;; under the terms of the GNU General Public License as published by
23;;; the Free Software Foundation; either version 3 of the License, or (at
24;;; your option) any later version.
25;;;
26;;; GNU Guix is distributed in the hope that it will be useful, but
27;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29;;; GNU General Public License for more details.
30;;;
31;;; You should have received a copy of the GNU General Public License
32;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34(define-module (gnu packages sqlite)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages hurd)
37 #:use-module (gnu packages readline)
38 #:use-module ((guix licenses) #:prefix license:)
39 #:use-module (guix packages)
40 #:use-module (guix download)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix gexp)
43 #:use-module (guix utils)
44 #:use-module (guix deprecation)
45 #:use-module (ice-9 match)
46 #:use-module (srfi srfi-26))
47
48;;; Commentary:
49;;;
50;;; This module has been separated from (gnu packages databases) to reduce the
51;;; number of module references for core packages.
52
53(define (sqlite-uri version year)
54 (let ((numeric-version
55 (match (string-split version #\.)
56 ((first-digit other-digits ...)
57 (string-append first-digit
58 (string-pad-right
59 (string-concatenate
60 (map (cut string-pad <> 2 #\0)
61 other-digits))
62 6 #\0))))))
63 (string-append "https://sqlite.org/" (number->string year)
64 "/sqlite-autoconf-" numeric-version ".tar.gz")))
65
66(define-public sqlite
67 (package
68 (name "sqlite")
69 (version "3.39.3")
70 (source (origin
71 (method url-fetch)
72 (uri (sqlite-uri version 2022))
73 (patches (search-patches "sqlite-hurd.patch"))
74 (sha256
75 (base32
76 "1f922kq16g7f4h3gpzim78lvrp5xw9nvlvqw97s2qgxyh8qgns3q"))))
77 (build-system gnu-build-system)
78 (inputs (list readline))
79 (outputs '("out" "static"))
80 (arguments
81 `(#:configure-flags
82 ;; Add -DSQLITE_SECURE_DELETE, -DSQLITE_ENABLE_FTS3,
83 ;; -DSQLITE_ENABLE_UNLOCK_NOTIFY and -DSQLITE_ENABLE_DBSTAT_VTAB
84 ;; to CFLAGS. GNU Icecat will refuse to use the system SQLite
85 ;; unless these options are enabled.
86 (list (string-append "CFLAGS=-O2 -g -DSQLITE_SECURE_DELETE "
87 "-DSQLITE_ENABLE_FTS3 "
88 "-DSQLITE_ENABLE_UNLOCK_NOTIFY "
89 "-DSQLITE_ENABLE_DBSTAT_VTAB "
90 ;; Column metadata is required by GNU Jami and Qt, et.al.
91 "-DSQLITE_ENABLE_COLUMN_METADATA"))
92 #:phases (modify-phases %standard-phases
93 (add-after 'install 'move-static-library
94 (lambda* (#:key outputs #:allow-other-keys)
95 (let* ((out (assoc-ref outputs "out"))
96 (static (assoc-ref outputs "static"))
97 (source (string-append out "/lib/libsqlite3.a")))
98 (mkdir-p (string-append static "/lib"))
99 (link source (string-append static "/lib/libsqlite3.a"))
100 (delete-file source)
101
102 ;; Remove reference to the static library from the .la file
103 ;; so that Libtool looks for it in the usual places.
104 (substitute* (string-append out "/lib/libsqlite3.la")
105 (("^old_library=.*")
106 "old_library=''\n"))
107 #t))))))
108 (home-page "https://www.sqlite.org/")
109 (synopsis "The SQLite database management system")
110 (description
111 "SQLite is a software library that implements a self-contained, serverless,
112zero-configuration, transactional SQL database engine. SQLite is the most
113widely deployed SQL database engine in the world. The source code for SQLite
114is in the public domain.")
115 (license license:public-domain)))
116
117;; Newer version required for e.g. fossil.
118(define-public sqlite-next
119 (package
120 (inherit sqlite)
121 (version "3.53.4")
122 (source (origin
123 (method url-fetch)
124 (uri (sqlite-uri version 2026))
125 (sha256
126 (base32
127 "177b2saql7f8b8m59gnmgwgsci8143wnpla8zpl5vkcj1s88750f"))))
128 (arguments
129 (substitute-keyword-arguments arguments
130 ((#:tests? _ #f)
131 #f)
132 ((#:configure-flags flags #~(list))
133 #~(map (lambda (flag)
134 (if (string-prefix? "CFLAGS=" flag)
135 (string-append flag
136 ;; needed by fossil
137 " -DSQLITE_ENABLE_FTS4"
138 " -DSQLITE_ENABLE_FTS5"
139 ;; Needed by node (see
140 ;; deps/sqlite/sqlite.gyp).
141 " -DSQLITE_ENABLE_FTS3_PARENTHESIS"
142 " -DSQLITE_ENABLE_GEOPOLY"
143 " -DSQLITE_ENABLE_MATH_FUNCTIONS"
144 " -DSQLITE_ENABLE_PERCENTILE"
145 " -DSQLITE_ENABLE_PREUPDATE_HOOK"
146 " -DSQLITE_ENABLE_RBU"
147 " -DSQLITE_ENABLE_RTREE"
148 " -DSQLITE_ENABLE_SESSION")
149 flag))
150 ;; sqlite's configure script does not like
151 ;; --enable-fast-install
152 (cons* "--disable-option-checking"
153 (string-append "--with-readline-header="
154 #$(this-package-input "readline") "/include")
155 #$flags)))
156 ((#:phases phases #~(list))
157 #~(modify-phases #$phases
158 (replace 'move-static-library
159 (lambda* (#:key outputs #:allow-other-keys)
160 (let* ((out (assoc-ref outputs "out"))
161 (static (assoc-ref outputs "static"))
162 (source (string-append out "/lib/libsqlite3.a")))
163 (mkdir-p (string-append static "/lib"))
164 (link source (string-append static "/lib/libsqlite3.a"))
165 (delete-file source)
166 (when (file-exists? (string-append out "/lib/libsqlite3.la"))
167 (substitute* (string-append out "/lib/libsqlite3.la")
168 (("^old_library=.*")
169 "old_library=''\n"))))))))))))