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 epatch "${FILESDIR}/${PN}-3.8.1-src-dlopen_check.patch"
60 # Fix shell1-5.0 test.
61 # http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2015-May/002575.html
62 sed -e "/if {\$i==0x0D /s/\$i==0x0D /&|| (\$i>=0xE0 \&\& \$i<=0xEF) /" -i test/shell1.test
67 # At least ppc-aix, x86-interix and *-solaris need newer libtool.
68 # use prefix && eautoreconf
70 # Fix building with Full-Text Search version 5.
72 -e "/^LIBOBJS1 =/s/$/ fts5.lo/" \
73 -e "s/\$(LIBOBJ) \$(TLIBS)/& -lm/" \
74 -e "/^TESTFIXTURE_SRC1 =/s/$/ fts5.c/" \
75 -e "s/\$(TESTFIXTURE_SRC) \$(LIBTCL) \$(TLIBS)/& -lm/" \
76 -i Makefile.in || die "sed failed"
80 sed -e "s/LIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
82 sed -e "s/TLIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
90 # `configure` from amalgamation tarball does not add -DSQLITE_DEBUG or -DNDEBUG flag.
93 append-cppflags -DSQLITE_DEBUG
95 append-cppflags -DNDEBUG
99 # Support detection of misuse of SQLite API.
100 # http://sqlite.org/compile.html#enable_api_armor
101 append-cppflags -DSQLITE_ENABLE_API_ARMOR
103 # Support column metadata functions.
104 # http://sqlite.org/c3ref/column_database_name.html
105 append-cppflags -DSQLITE_ENABLE_COLUMN_METADATA
107 # Support dbstat virtual table.
108 # http://sqlite.org/dbstat.html
109 append-cppflags -DSQLITE_ENABLE_DBSTAT_VTAB
111 # Support Full-Text Search versions 3, 4 and 5.
112 # http://sqlite.org/fts3.html
113 # http://sqlite.org/fts5.html
114 append-cppflags -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
116 # Support Resumable Bulk Update extension.
117 # http://sqlite.org/rbu.html
118 append-cppflags -DSQLITE_ENABLE_RBU
121 # http://sqlite.org/rtree.html
122 append-cppflags -DSQLITE_ENABLE_RTREE
124 # Support scan status functions.
125 # http://sqlite.org/c3ref/stmt_scanstatus.html
126 # http://sqlite.org/c3ref/stmt_scanstatus_reset.html
127 append-cppflags -DSQLITE_ENABLE_STMT_SCANSTATUS
129 # Support unlock notification.
130 # http://sqlite.org/unlock_notify.html
131 append-cppflags -DSQLITE_ENABLE_UNLOCK_NOTIFY
133 # Support soundex() function.
134 # http://sqlite.org/lang_corefunc.html#soundex
135 append-cppflags -DSQLITE_SOUNDEX
138 # Support ICU extension.
139 # http://sqlite.org/compile.html#enable_icu
140 append-cppflags -DSQLITE_ENABLE_ICU
143 if use secure-delete; then
144 # Enable secure_delete pragma by default.
145 # http://sqlite.org/pragma.html#pragma_secure_delete
146 append-cppflags -DSQLITE_SECURE_DELETE
149 if [[ "${CHOST}" == *-mint* ]]; then
150 append-cppflags -DSQLITE_OMIT_WAL
153 # Use pread(), pread64(), pwrite(), pwrite64() functions for better performance if they are available.
154 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
155 append-cppflags -DUSE_PREAD
157 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
158 append-cppflags -DUSE_PREAD64
159 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
160 append-cppflags -DUSE_PREAD64 -D_LARGEFILE64_SOURCE
163 multilib-minimal_src_configure
166 multilib_src_configure() {
167 # `configure` from amalgamation tarball does not support
168 # --with-readline-inc and --(enable|disable)-tcl options.
170 --enable-$(amalgamation && echo dynamic-extensions || echo load-extension) \
171 --enable-threadsafe \
172 $(use_enable readline) \
173 $(use_enable static-libs static) \
174 $(amalgamation || echo --with-readline-inc="-I${EPREFIX}/usr/include/readline") \
175 $(amalgamation || use_enable debug) \
176 $(amalgamation || if use tcl || use test; then echo --enable-tcl; else echo --disable-tcl; fi)
179 multilib_src_compile() {
180 emake TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}"
182 if use tools && multilib_is_native_abi; then
183 emake showdb showjournal showstat4 showwal sqldiff
187 multilib_src_test() {
188 if [[ "${EUID}" -eq 0 ]]; then
189 ewarn "Skipping tests due to root permissions"
193 emake $(use debug && echo fulltest || echo test)
196 multilib_src_install() {
197 emake DESTDIR="${D}" HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}" install
199 if use tools && multilib_is_native_abi; then
200 newbin showdb sqlite3-show-db
201 newbin showjournal sqlite3-show-journal
202 newbin showstat4 sqlite3-show-stat4
203 newbin showwal sqlite3-show-wal
204 newbin sqldiff sqlite3-diff
208 multilib_src_install_all() {
214 dohtml -A ico,odg,pdf,svg -r "${WORKDIR}/${PN}-doc-${DOC_PV}/"