sqlite-3.16.2.ebuild 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. inherit autotools eutils flag-o-matic multilib multilib-minimal toolchain-funcs versionator
  5. SRC_PV="$(printf "%u%02u%02u%02u" $(get_version_components))"
  6. DOC_PV="${SRC_PV}"
  7. # DOC_PV="$(printf "%u%02u%02u00" $(get_version_components $(get_version_component_range 1-3)))"
  8. DESCRIPTION="A SQL Database Engine in a C Library"
  9. HOMEPAGE="https://sqlite.org/"
  10. SRC_URI="doc? ( https://sqlite.org/2017/${PN}-doc-${DOC_PV}.zip )
  11. tcl? ( https://sqlite.org/2017/${PN}-src-${SRC_PV}.zip )
  12. test? ( https://sqlite.org/2017/${PN}-src-${SRC_PV}.zip )
  13. tools? ( https://sqlite.org/2017/${PN}-src-${SRC_PV}.zip )
  14. !tcl? ( !test? ( !tools? ( https://sqlite.org/2017/${PN}-autoconf-${SRC_PV}.tar.gz ) ) )"
  15. LICENSE="public-domain"
  16. SLOT="3"
  17. KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-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"
  18. IUSE="debug doc icu +readline secure-delete static-libs tcl test tools"
  19. RDEPEND="icu? ( dev-libs/icu:0=[${MULTILIB_USEDEP}] )
  20. readline? ( sys-libs/readline:0=[${MULTILIB_USEDEP}] )
  21. tcl? ( dev-lang/tcl:0=[${MULTILIB_USEDEP}] )
  22. tools? ( dev-lang/tcl:0=[${MULTILIB_USEDEP}] )"
  23. DEPEND="${RDEPEND}
  24. doc? ( app-arch/unzip )
  25. tcl? ( app-arch/unzip )
  26. test? (
  27. app-arch/unzip
  28. dev-lang/tcl:0[${MULTILIB_USEDEP}]
  29. )
  30. tools? ( app-arch/unzip )"
  31. full_tarball() {
  32. use tcl || use test || use tools
  33. }
  34. pkg_setup() {
  35. if full_tarball; then
  36. S="${WORKDIR}/${PN}-src-${SRC_PV}"
  37. else
  38. S="${WORKDIR}/${PN}-autoconf-${SRC_PV}"
  39. fi
  40. }
  41. src_prepare() {
  42. if full_tarball; then
  43. eapply -p0 "${FILESDIR}/${PN}-3.16.0-full_tarball-build.patch"
  44. eapply_user
  45. # Fix AC_CHECK_FUNCS.
  46. # https://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2016-March/002762.html
  47. 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"
  48. else
  49. eapply -p0 "${FILESDIR}/${PN}-3.16.0-nonfull_tarball-build.patch"
  50. eapply_user
  51. # Fix AC_CHECK_FUNCS.
  52. # https://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-dev/2016-March/002762.html
  53. sed \
  54. -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])/" \
  55. -e "/AC_CHECK_FUNCS(posix_fallocate)/d" \
  56. -i configure.ac || die "sed failed"
  57. fi
  58. eautoreconf
  59. multilib_copy_sources
  60. }
  61. multilib_src_configure() {
  62. local CPPFLAGS="${CPPFLAGS}" options=()
  63. options+=(
  64. --enable-$(full_tarball && echo load-extension || echo dynamic-extensions)
  65. --enable-threadsafe
  66. )
  67. if ! full_tarball; then
  68. options+=(--disable-static-shell)
  69. fi
  70. # Support detection of misuse of SQLite API.
  71. # https://sqlite.org/compile.html#enable_api_armor
  72. append-cppflags -DSQLITE_ENABLE_API_ARMOR
  73. # Support column metadata functions.
  74. # https://sqlite.org/c3ref/column_database_name.html
  75. append-cppflags -DSQLITE_ENABLE_COLUMN_METADATA
  76. # Support dbstat virtual table.
  77. # https://sqlite.org/dbstat.html
  78. append-cppflags -DSQLITE_ENABLE_DBSTAT_VTAB
  79. # Support comments in output of EXPLAIN.
  80. # https://sqlite.org/compile.html#enable_explain_comments
  81. append-cppflags -DSQLITE_ENABLE_EXPLAIN_COMMENTS
  82. # Support Full-Text Search versions 3, 4 and 5.
  83. # https://sqlite.org/fts3.html
  84. # https://sqlite.org/fts5.html
  85. append-cppflags -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4
  86. options+=(--enable-fts5)
  87. # Support hidden columns.
  88. append-cppflags -DSQLITE_ENABLE_HIDDEN_COLUMNS
  89. # Support JSON1 extension.
  90. # https://sqlite.org/json1.html
  91. append-cppflags -DSQLITE_ENABLE_JSON1
  92. # Support memsys5 memory allocator.
  93. # https://sqlite.org/malloc.html#memsys5
  94. append-cppflags -DSQLITE_ENABLE_MEMSYS5
  95. # Support Resumable Bulk Update extension.
  96. # https://sqlite.org/rbu.html
  97. append-cppflags -DSQLITE_ENABLE_RBU
  98. # Support R*Trees.
  99. # https://sqlite.org/rtree.html
  100. append-cppflags -DSQLITE_ENABLE_RTREE
  101. # Support scan status functions.
  102. # https://sqlite.org/c3ref/stmt_scanstatus.html
  103. # https://sqlite.org/c3ref/stmt_scanstatus_reset.html
  104. append-cppflags -DSQLITE_ENABLE_STMT_SCANSTATUS
  105. # Support Session extension.
  106. # https://sqlite.org/sessionintro.html
  107. options+=(--enable-session)
  108. # Support unknown() function.
  109. # https://sqlite.org/compile.html#enable_unknown_sql_function
  110. append-cppflags -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
  111. # Support unlock notification.
  112. # https://sqlite.org/unlock_notify.html
  113. append-cppflags -DSQLITE_ENABLE_UNLOCK_NOTIFY
  114. # Support soundex() function.
  115. # https://sqlite.org/lang_corefunc.html#soundex
  116. append-cppflags -DSQLITE_SOUNDEX
  117. # debug USE flag.
  118. if full_tarball; then
  119. options+=($(use_enable debug))
  120. else
  121. if use debug; then
  122. append-cppflags -DSQLITE_DEBUG
  123. else
  124. append-cppflags -DNDEBUG
  125. fi
  126. fi
  127. # icu USE flag.
  128. if use icu; then
  129. # Support ICU extension.
  130. # https://sqlite.org/compile.html#enable_icu
  131. append-cppflags -DSQLITE_ENABLE_ICU
  132. if full_tarball; then
  133. sed -e "s/^TLIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
  134. else
  135. sed -e "s/^LIBS = @LIBS@/& -licui18n -licuuc/" -i Makefile.in || die "sed failed"
  136. fi
  137. fi
  138. # readline USE flag.
  139. options+=(
  140. --disable-editline
  141. $(use_enable readline)
  142. )
  143. if full_tarball && use readline; then
  144. options+=(--with-readline-inc="-I${EPREFIX}/usr/include/readline")
  145. fi
  146. # secure-delete USE flag.
  147. if use secure-delete; then
  148. # Enable secure_delete pragma by default.
  149. # https://sqlite.org/pragma.html#pragma_secure_delete
  150. append-cppflags -DSQLITE_SECURE_DELETE
  151. fi
  152. # static-libs USE flag.
  153. options+=($(use_enable static-libs static))
  154. # tcl, test, tools USE flags.
  155. if full_tarball; then
  156. options+=(--enable-tcl)
  157. fi
  158. if [[ "${CHOST}" == *-mint* ]]; then
  159. append-cppflags -DSQLITE_OMIT_WAL
  160. fi
  161. econf "${options[@]}"
  162. }
  163. multilib_src_compile() {
  164. emake HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}"
  165. if use tools && multilib_is_native_abi; then
  166. emake changeset dbhash rbu scrub showdb showjournal showstat4 showwal sqldiff sqlite3_analyzer
  167. fi
  168. }
  169. multilib_src_test() {
  170. if [[ "${EUID}" -eq 0 ]]; then
  171. ewarn "Skipping tests due to root permissions"
  172. return
  173. fi
  174. emake HAVE_TCL="$(usex tcl 1 "")" $(use debug && echo fulltest || echo test)
  175. }
  176. multilib_src_install() {
  177. emake DESTDIR="${D}" HAVE_TCL="$(usex tcl 1 "")" TCLLIBDIR="${EPREFIX}/usr/$(get_libdir)/${P}" install
  178. if use tools && multilib_is_native_abi; then
  179. install_tool() {
  180. if [[ -f ".libs/${1}" ]]; then
  181. newbin ".libs/${1}" "${2}"
  182. else
  183. newbin "${1}" "${2}"
  184. fi
  185. }
  186. install_tool changeset sqlite3-changeset
  187. install_tool dbhash sqlite3-db-hash
  188. install_tool rbu sqlite3-rbu
  189. install_tool scrub sqlite3-scrub
  190. install_tool showdb sqlite3-show-db
  191. install_tool showjournal sqlite3-show-journal
  192. install_tool showstat4 sqlite3-show-stat4
  193. install_tool showwal sqlite3-show-wal
  194. install_tool sqldiff sqlite3-diff
  195. install_tool sqlite3_analyzer sqlite3-analyzer
  196. unset -f install_tool
  197. fi
  198. }
  199. multilib_src_install_all() {
  200. prune_libtool_files
  201. doman sqlite3.1
  202. if use doc; then
  203. rm "${WORKDIR}/${PN}-doc-${DOC_PV}/"*.{db,txt}
  204. (
  205. docinto html
  206. dodoc -r "${WORKDIR}/${PN}-doc-${DOC_PV}/"*
  207. )
  208. fi
  209. }