1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
5 ;;; Copyright © 2015, 2016 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
8 ;;; Copyright © 2016 David Craven <david@craven.ch>
9 ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
10 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
11 ;;; Copyright © 2017 Jelle Licht <jlicht@fsfe.org>
12 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
13 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
14 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
16 ;;; This file is part of GNU Guix.
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31 (define-module (gnu packages sqlite)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages hurd)
34 #:use-module (gnu packages readline)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix packages)
37 #:use-module (guix download)
38 #:use-module (guix build-system gnu)
39 #:use-module (guix utils)
40 #:use-module (ice-9 match)
41 #:use-module (srfi srfi-26))
45 ;;; This module has been separated from (gnu packages databases) to reduce the
46 ;;; number of module references for core packages.
54 (uri (let ((numeric-version
55 (match (string-split version #\.)
56 ((first-digit other-digits ...)
57 (string-append first-digit
60 (map (cut string-pad <> 2 #\0)
63 (string-append "https://sqlite.org/2020/sqlite-autoconf-"
64 numeric-version ".tar.gz")))
67 "1bj936svd8i5g25xd1bj52hj4zca01fgl3sqkj86z9q5pkz4wa32"))))
68 (replacement sqlite/fixed)
69 (build-system gnu-build-system)
70 (inputs `(("readline" ,readline)))
71 (native-inputs (if (hurd-target?)
72 ;; TODO move into origin on the next rebuild cycle.
73 `(("hurd-locking-mode.patch"
74 ,@(search-patches "sqlite-hurd.patch")))
76 (outputs '("out" "static"))
79 ;; Add -DSQLITE_SECURE_DELETE, -DSQLITE_ENABLE_FTS3,
80 ;; -DSQLITE_ENABLE_UNLOCK_NOTIFY and -DSQLITE_ENABLE_DBSTAT_VTAB
81 ;; to CFLAGS. GNU Icecat will refuse to use the system SQLite
82 ;; unless these options are enabled.
83 (list (string-append "CFLAGS=-O2 -DSQLITE_SECURE_DELETE "
84 "-DSQLITE_ENABLE_FTS3 "
85 "-DSQLITE_ENABLE_UNLOCK_NOTIFY "
86 "-DSQLITE_ENABLE_DBSTAT_VTAB "
87 ;; Column metadata is required by GNU Jami and Qt, et.al.
88 "-DSQLITE_ENABLE_COLUMN_METADATA"))
89 #:phases (modify-phases %standard-phases
90 ;; TODO: remove in the next rebuild cycle
92 `((add-after 'unpack 'patch-sqlite/hurd
93 (lambda* (#:key inputs native-inputs
95 (let ((patch (assoc-ref
96 (if ,(%current-target-system)
99 "hurd-locking-mode.patch")))
100 (invoke "patch" "-p1" "--force" "-i" patch)))))
102 (add-after 'install 'move-static-library
103 (lambda* (#:key outputs #:allow-other-keys)
104 (let* ((out (assoc-ref outputs "out"))
105 (static (assoc-ref outputs "static"))
106 (source (string-append out "/lib/libsqlite3.a")))
107 (mkdir-p (string-append static "/lib"))
108 (link source (string-append static "/lib/libsqlite3.a"))
111 ;; Remove reference to the static library from the .la file
112 ;; so that Libtool looks for it in the usual places.
113 (substitute* (string-append out "/lib/libsqlite3.la")
117 (home-page "https://www.sqlite.org/")
118 (synopsis "The SQLite database management system")
120 "SQLite is a software library that implements a self-contained, serverless,
121 zero-configuration, transactional SQL database engine. SQLite is the most
122 widely deployed SQL database engine in the world. The source code for SQLite
123 is in the public domain.")
124 (license license:public-domain)))
126 (define-public sqlite/fixed
132 (uri (let ((numeric-version
133 (match (string-split version #\.)
134 ((first-digit other-digits ...)
135 (string-append first-digit
138 (map (cut string-pad <> 2 #\0)
141 (string-append "https://sqlite.org/2020/sqlite-autoconf-"
142 numeric-version ".tar.gz")))
145 "0rlbaq177gcgk5dswd3akbhv2nvvzljrbhgy18hklbhw7h90f5d3"))))))
147 ;; Column metadata support was added to the regular 'sqlite' package with
148 ;; commit fad5b1a6d8d9c36bea5785ae4fbc1beb37e644d7.
149 (define-public sqlite-with-column-metadata
150 (deprecated-package "sqlite-with-column-metadata" sqlite))