1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools eutils flag-o-matic multilib multilib-minimal toolchain-funcs versionator
9 SRC_PV="$(printf "%u%02u%02u%02u" $(get_version_components))"
11 # DOC_PV="$(printf "%u%02u%02u00" $(get_version_components $(get_version_component_range 1-3)))"
13 DESCRIPTION="A SQL Database Engine in a C Library"
14 HOMEPAGE="http://sqlite.org/"
15 SRC_URI="doc? ( http://sqlite.org/2015/${PN}-doc-${DOC_PV}.zip )
16 tcl? ( http://sqlite.org/2015/${PN}-src-${SRC_PV}.zip )
17 test? ( http://sqlite.org/2015/${PN}-src-${SRC_PV}.zip )
18 tools? ( http://sqlite.org/2015/${PN}-src-${SRC_PV}.zip )
19 !tcl? ( !test? ( !tools? ( http://sqlite.org/2015/${PN}-autoconf-${SRC_PV}.tar.gz ) ) )"
21 LICENSE="public-domain"
23 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
24 IUSE="debug doc icu +readline secure-delete static-libs tcl test tools"
26 RDEPEND="icu? ( dev-libs/icu:0=[${MULTILIB_USEDEP}] )
27 readline? ( sys-libs/readline:0=[${MULTILIB_USEDEP}] )
28 tcl? ( dev-lang/tcl:0=[${MULTILIB_USEDEP}] )
30 !<=app-emulation/emul-linux-x86-baselibs-20131008-r14
31 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
34 doc? ( app-arch/unzip )
35 tcl? ( app-arch/unzip )
38 dev-lang/tcl:0[${MULTILIB_USEDEP}]
40 tools? ( dev-lang/tcl:0 )"
43 ! use tcl && ! use test && ! use tools
48 S="${WORKDIR}/${PN}-autoconf-${SRC_PV}"
50 S="${WORKDIR}/${PN}-src-${SRC_PV}"
56 epatch "${FILESDIR}/${PN}-3.8.1-autoconf-dlopen_check.patch"
58 # http://www.sqlite.org/cgi/src/info/85bfa9a67f997084
60 -e "s/^sqlite3_SOURCES = shell.c sqlite3.h$/sqlite3_SOURCES = shell.c sqlite3.c sqlite3.h/" \
61 -e "s/^sqlite3_LDADD = sqlite3.\$(OBJEXT) @READLINE_LIBS@$/sqlite3_LDADD = @READLINE_LIBS@\nsqlite3_CFLAGS = \$(AM_CFLAGS)/" \
64 epatch "${FILESDIR}/${PN}-3.8.1-src-dlopen_check.patch"
65 epatch "${FILESDIR}/${PN}-3.8.1-tests-icu-52.patch"
67 # Fix shell1-5.0 test.
68 # http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2015-May/002575.html
69 sed -e "/if {\$i==0x0D /s/\$i==0x0D /&|| (\$i>=0xE0 \&\& \$i<=0xEF) /" -i test/shell1.test
74 # At least ppc-aix, x86-interix and *-solaris need newer libtool.
75 # use prefix && eautoreconf
79 sed -e "s/LIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
81 sed -e "s/TLIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
89 # `configure` from amalgamation tarball does not add -DSQLITE_DEBUG or -DNDEBUG flag.
92 append-cppflags -DSQLITE_DEBUG
94 append-cppflags -DNDEBUG
98 # Support detection of misuse of SQLite API.
99 # http://sqlite.org/compile.html#enable_api_armor
100 append-cppflags -DSQLITE_ENABLE_API_ARMOR
102 # Support column metadata functions.
103 # http://sqlite.org/c3ref/column_database_name.html
104 append-cppflags -DSQLITE_ENABLE_COLUMN_METADATA
106 # Support dbstat virtual table.
107 # http://sqlite.org/dbstat.html
108 append-cppflags -DSQLITE_ENABLE_DBSTAT_VTAB
110 # Support Full-Text Search versions 3 and 4.
111 # http://sqlite.org/fts3.html
112 append-cppflags -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4
115 # http://sqlite.org/rtree.html
116 append-cppflags -DSQLITE_ENABLE_RTREE
118 # Support scan status functions.
119 # http://sqlite.org/c3ref/stmt_scanstatus.html
120 # http://sqlite.org/c3ref/stmt_scanstatus_reset.html
121 append-cppflags -DSQLITE_ENABLE_STMT_SCANSTATUS
123 # Support unlock notification.
124 # http://sqlite.org/unlock_notify.html
125 append-cppflags -DSQLITE_ENABLE_UNLOCK_NOTIFY
127 # Support soundex() function.
128 # http://sqlite.org/lang_corefunc.html#soundex
129 append-cppflags -DSQLITE_SOUNDEX
132 # Support ICU extension.
133 # http://sqlite.org/compile.html#enable_icu
134 append-cppflags -DSQLITE_ENABLE_ICU
137 if use secure-delete; then
138 # Enable secure_delete pragma by default.
139 # http://sqlite.org/pragma.html#pragma_secure_delete
140 append-cppflags -DSQLITE_SECURE_DELETE
143 if [[ "${CHOST}" == *-mint* ]]; then
144 append-cppflags -DSQLITE_OMIT_WAL
147 # Use pread(), pread64(), pwrite(), pwrite64() functions for better performance if they are available.
148 if $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -Werror=implicit-function-declaration -x c - -o "${T}/pread_pwrite_test" <<< $'#include <unistd.h>\nint main()\n{\n pread(0, NULL, 0, 0);\n pwrite(0, NULL, 0, 0);\n return 0;\n}' &> /dev/null; then
149 append-cppflags -DUSE_PREAD
151 if $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -Werror=implicit-function-declaration -x c - -o "${T}/pread64_pwrite64_test" <<< $'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}' &> /dev/null; then
152 append-cppflags -DUSE_PREAD64
153 elif $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -D_LARGEFILE64_SOURCE -Werror=implicit-function-declaration -x c - -o "${T}/pread64_pwrite64_test" <<< $'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}' &> /dev/null; then
154 append-cppflags -DUSE_PREAD64 -D_LARGEFILE64_SOURCE
157 multilib-minimal_src_configure
160 multilib_src_configure() {
161 # `configure` from amalgamation tarball does not support
162 # --with-readline-inc and --(enable|disable)-tcl options.
164 --enable-$(amalgamation && echo dynamic-extensions || echo load-extension) \
165 --enable-threadsafe \
166 $(use_enable readline) \
167 $(use_enable static-libs static) \
168 $(amalgamation || echo --with-readline-inc="-I${EPREFIX}/usr/include/readline") \
169 $(amalgamation || use_enable debug) \
170 $(amalgamation || if use tcl || use test; then echo --enable-tcl; else echo --disable-tcl; fi)
173 multilib_src_compile() {
174 emake TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}"
176 if use tools && multilib_is_native_abi; then
177 emake showdb showjournal showstat4 showwal sqldiff
181 multilib_src_test() {
182 if [[ "${EUID}" -eq 0 ]]; then
183 ewarn "Skipping tests due to root permissions"
187 emake $(use debug && echo fulltest || echo test)
190 multilib_src_install() {
191 emake DESTDIR="${D}" HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}" install
193 if use tools && multilib_is_native_abi; then
194 newbin showdb sqlite3-show-db
195 newbin showjournal sqlite3-show-journal
196 newbin showstat4 sqlite3-show-stat4
197 newbin showwal sqlite3-show-wal
198 newbin sqldiff sqlite3-diff
202 multilib_src_install_all() {
208 dohtml -A ico,odg,pdf,svg -r "${WORKDIR}/${PN}-doc-${DOC_PV}/"