1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools eutils flag-o-matic multilib multilib-minimal toolchain-funcs versionator
8 SRC_PV="$(printf "%u%02u%02u%02u" $(get_version_components))"
10 # DOC_PV="$(printf "%u%02u%02u00" $(get_version_components $(get_version_component_range 1-3)))"
12 DESCRIPTION="SQL database engine"
13 HOMEPAGE="https://sqlite.org/"
14 SRC_URI="doc? ( https://sqlite.org/2018/${PN}-doc-${DOC_PV}.zip )
15 tcl? ( https://sqlite.org/2018/${PN}-src-${SRC_PV}.zip )
16 test? ( https://sqlite.org/2018/${PN}-src-${SRC_PV}.zip )
17 tools? ( https://sqlite.org/2018/${PN}-src-${SRC_PV}.zip )
18 !tcl? ( !test? ( !tools? ( https://sqlite.org/2018/${PN}-autoconf-${SRC_PV}.tar.gz ) ) )"
20 LICENSE="public-domain"
22 KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ia64 ~m68k ~mips ppc ~ppc64 ~s390 ~sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
23 IUSE="debug doc icu +readline secure-delete static-libs tcl test tools"
25 RDEPEND="sys-libs/zlib:0=[${MULTILIB_USEDEP}]
26 icu? ( dev-libs/icu:0=[${MULTILIB_USEDEP}] )
27 readline? ( sys-libs/readline:0=[${MULTILIB_USEDEP}] )
28 tcl? ( dev-lang/tcl:0=[${MULTILIB_USEDEP}] )
29 tools? ( dev-lang/tcl:0=[${MULTILIB_USEDEP}] )"
31 doc? ( app-arch/unzip )
32 tcl? ( app-arch/unzip )
35 >=dev-lang/tcl-8.6:0[${MULTILIB_USEDEP}]
37 tools? ( app-arch/unzip )"
40 use tcl || use test || use tools
45 S="${WORKDIR}/${PN}-src-${SRC_PV}"
47 S="${WORKDIR}/${PN}-autoconf-${SRC_PV}"
53 eapply "${FILESDIR}/${PN}-3.24.0-full_archive-build.patch"
54 eapply "${FILESDIR}/${PN}-3.24.0-full_archive-archive_command_paths_handling.patch"
59 # https://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2016-March/002762.html
60 sed -e "s/AC_CHECK_FUNCS(.*)/AC_CHECK_FUNCS([fdatasync fullfsync gmtime_r isnan localtime_r localtime_s malloc_usable_size posix_fallocate pread pread64 pwrite pwrite64 strchrnul usleep utime])/" -i configure.ac || die "sed failed"
62 eapply "${FILESDIR}/${PN}-3.21.0-nonfull_archive-build.patch"
63 eapply "${FILESDIR}/${PN}-3.24.0-nonfull_archive-archive_command_paths_handling.patch"
68 # https://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2016-March/002762.html
70 -e "s/AC_CHECK_FUNCS(\[fdatasync.*/AC_CHECK_FUNCS([fdatasync fullfsync gmtime_r isnan localtime_r localtime_s malloc_usable_size posix_fallocate pread pread64 pwrite pwrite64 strchrnul usleep utime])/" \
71 -e "/AC_CHECK_FUNCS(posix_fallocate)/d" \
72 -i configure.ac || die "sed failed"
80 multilib_src_configure() {
81 local CPPFLAGS="${CPPFLAGS}" CFLAGS="${CFLAGS}" options=()
84 --enable-$(full_archive && echo load-extension || echo dynamic-extensions)
87 if ! full_archive; then
88 options+=(--disable-static-shell)
91 # Support detection of misuse of SQLite API.
92 # https://sqlite.org/compile.html#enable_api_armor
93 append-cppflags -DSQLITE_ENABLE_API_ARMOR
95 # Support column metadata functions.
96 # https://sqlite.org/c3ref/column_database_name.html
97 append-cppflags -DSQLITE_ENABLE_COLUMN_METADATA
99 # Support sqlite_dbpage virtual table.
100 # https://sqlite.org/compile.html#enable_dbpage_vtab
101 append-cppflags -DSQLITE_ENABLE_DBPAGE_VTAB
103 # Support dbstat virtual table.
104 # https://sqlite.org/dbstat.html
105 append-cppflags -DSQLITE_ENABLE_DBSTAT_VTAB
107 # Support sqlite3_serialize() and sqlite3_deserialize() functions.
108 # https://sqlite.org/compile.html#enable_deserialize
109 # https://sqlite.org/c3ref/serialize.html
110 # https://sqlite.org/c3ref/deserialize.html
111 append-cppflags -DSQLITE_ENABLE_DESERIALIZE
113 # Support comments in output of EXPLAIN.
114 # https://sqlite.org/compile.html#enable_explain_comments
115 append-cppflags -DSQLITE_ENABLE_EXPLAIN_COMMENTS
117 # Support Full-Text Search versions 3, 4 and 5.
118 # https://sqlite.org/fts3.html
119 # https://sqlite.org/fts5.html
120 append-cppflags -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4
121 options+=(--enable-fts5)
123 # Support hidden columns.
124 append-cppflags -DSQLITE_ENABLE_HIDDEN_COLUMNS
126 # Support JSON1 extension.
127 # https://sqlite.org/json1.html
128 append-cppflags -DSQLITE_ENABLE_JSON1
130 # Support memsys5 memory allocator.
131 # https://sqlite.org/malloc.html#memsys5
132 append-cppflags -DSQLITE_ENABLE_MEMSYS5
134 # Support sqlite_offset() function.
135 # https://sqlite.org/lang_corefunc.html#sqlite_offset
136 append-cppflags -DSQLITE_ENABLE_OFFSET_SQL_FUNC
138 # Support pre-update hook functions.
139 # https://sqlite.org/c3ref/preupdate_count.html
140 append-cppflags -DSQLITE_ENABLE_PREUPDATE_HOOK
142 # Support Resumable Bulk Update extension.
143 # https://sqlite.org/rbu.html
144 append-cppflags -DSQLITE_ENABLE_RBU
147 # https://sqlite.org/rtree.html
148 append-cppflags -DSQLITE_ENABLE_RTREE
150 # Support scan status functions.
151 # https://sqlite.org/c3ref/stmt_scanstatus.html
152 # https://sqlite.org/c3ref/stmt_scanstatus_reset.html
153 append-cppflags -DSQLITE_ENABLE_STMT_SCANSTATUS
155 # Support sqlite_stmt virtual table.
156 # https://sqlite.org/stmt.html
157 append-cppflags -DSQLITE_ENABLE_STMTVTAB
159 # Support Session extension.
160 # https://sqlite.org/sessionintro.html
161 options+=(--enable-session)
163 # Support unknown() function.
164 # https://sqlite.org/compile.html#enable_unknown_sql_function
165 append-cppflags -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
167 # Support unlock notification.
168 # https://sqlite.org/unlock_notify.html
169 append-cppflags -DSQLITE_ENABLE_UNLOCK_NOTIFY
171 # Support LIMIT and ORDER BY clauses on DELETE and UPDATE statements.
172 # https://sqlite.org/compile.html#enable_update_delete_limit
173 append-cppflags -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT
175 # Support PRAGMA function_list, PRAGMA module_list and PRAGMA pragma_list statements.
176 # https://sqlite.org/pragma.html#pragma_function_list
177 # https://sqlite.org/pragma.html#pragma_module_list
178 # https://sqlite.org/pragma.html#pragma_pragma_list
179 append-cppflags -DSQLITE_INTROSPECTION_PRAGMAS
181 # Support soundex() function.
182 # https://sqlite.org/lang_corefunc.html#soundex
183 append-cppflags -DSQLITE_SOUNDEX
186 if full_archive; then
187 options+=($(use_enable debug))
190 append-cppflags -DSQLITE_DEBUG
192 append-cppflags -DNDEBUG
198 # Support ICU extension.
199 # https://sqlite.org/compile.html#enable_icu
200 append-cppflags -DSQLITE_ENABLE_ICU
201 if full_archive; then
202 sed -e "s/^TLIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
204 sed -e "s/^LIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
211 $(use_enable readline)
213 if full_archive && use readline; then
214 options+=(--with-readline-inc="-I${EPREFIX}/usr/include/readline")
217 # secure-delete USE flag.
218 if use secure-delete; then
219 # Enable secure_delete pragma by default.
220 # https://sqlite.org/pragma.html#pragma_secure_delete
221 append-cppflags -DSQLITE_SECURE_DELETE
224 # static-libs USE flag.
225 options+=($(use_enable static-libs static))
227 # tcl, test, tools USE flags.
228 if full_archive; then
229 options+=(--enable-tcl)
232 if [[ "${CHOST}" == *-mint* ]]; then
233 append-cppflags -DSQLITE_OMIT_WAL
236 if [[ "${ABI}" == "x86" ]]; then
237 if $(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P -dM - < /dev/null 2> /dev/null | grep -q "^#define __SSE__ 1$"; then
238 append-cflags -mfpmath=sse
240 append-cflags -ffloat-store
244 econf "${options[@]}"
247 multilib_src_compile() {
248 emake HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}"
250 if use tools && multilib_is_native_abi; then
251 emake changeset dbdump dbhash rbu scrub showdb showjournal showshm showstat4 showwal sqldiff sqlite3_analyzer sqlite3_checker sqlite3_expert sqltclsh
255 multilib_src_test() {
256 if [[ "${EUID}" -eq 0 ]]; then
257 ewarn "Skipping tests due to root permissions"
261 emake HAVE_TCL="$(usex tcl 1 "")" $(use debug && echo fulltest || echo test)
264 multilib_src_install() {
265 emake DESTDIR="${D}" HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}" install
267 if use tools && multilib_is_native_abi; then
269 if [[ -f ".libs/${1}" ]]; then
270 newbin ".libs/${1}" "${2}"
276 install_tool changeset sqlite3-changeset
277 install_tool dbdump sqlite3-db-dump
278 install_tool dbhash sqlite3-db-hash
279 install_tool rbu sqlite3-rbu
280 install_tool scrub sqlite3-scrub
281 install_tool showdb sqlite3-show-db
282 install_tool showjournal sqlite3-show-journal
283 install_tool showshm sqlite3-show-shm
284 install_tool showstat4 sqlite3-show-stat4
285 install_tool showwal sqlite3-show-wal
286 install_tool sqldiff sqlite3-diff
287 install_tool sqlite3_analyzer sqlite3-analyzer
288 install_tool sqlite3_checker sqlite3-checker
289 install_tool sqlite3_expert sqlite3-expert
290 install_tool sqltclsh sqlite3-tclsh
292 unset -f install_tool
296 multilib_src_install_all() {
302 rm "${WORKDIR}/${PN}-doc-${DOC_PV}/"*.{db,txt}
305 dodoc -r "${WORKDIR}/${PN}-doc-${DOC_PV}/"*