sqlite.spec 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. ##
  2. ## sqlite.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_sqlite 3.4.2
  26. %define V_odbc 0.75
  27. # package information
  28. Name: sqlite
  29. Summary: SQL Lite
  30. URL: http://www.sqlite.org/
  31. Vendor: D. Richard Hipp
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: BASE
  35. Group: Database
  36. License: PD
  37. Version: %{V_sqlite}
  38. Release: 20070814
  39. # package options
  40. %option with_utf8 no
  41. %option with_assert no
  42. %option with_readline no
  43. %option with_threads no
  44. %option with_fts1 no
  45. %option with_fts2 no
  46. %option with_odbc no
  47. # list of sources
  48. Source0: http://www.sqlite.org/sqlite-%{V_sqlite}.tar.gz
  49. Source1: http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
  50. Patch0: sqlite.patch
  51. Patch1: sqlite.patch.odbc
  52. # build information
  53. Prefix: %{l_prefix}
  54. BuildRoot: %{l_buildroot}
  55. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gawk
  56. PreReq: OpenPKG, openpkg >= 20040130
  57. %if "%{with_readline}" == "yes"
  58. BuildPreReq: readline, pkgconfig
  59. PreReq: readline
  60. %endif
  61. %if "%{with_odbc}" == "yes"
  62. BuildPreReq: ODBC
  63. PreReq: ODBC
  64. %endif
  65. AutoReq: no
  66. AutoReqProv: no
  67. %description
  68. SQLite is a C library that implements an embeddable SQL database
  69. engine. Programs that link with the SQLite library can have SQL
  70. database access without running a separate RDBMS process. The
  71. distribution comes with a standalone command-line access program
  72. (sqlite) that can be used to administer an SQLite database and which
  73. serves as an example of how to use the SQLite library. SQLite is not
  74. a client library used to connect to a big database server. SQLite is
  75. the server. The SQLite library reads and writes directly to and from
  76. the database files on disk.
  77. %track
  78. prog sqlite = {
  79. version = %{V_sqlite}
  80. url = http://www.sqlite.org/download.html
  81. regex = sqlite-(\d+\.\d+\.\d+)\.tar\.gz
  82. }
  83. prog sqlite:odbc = {
  84. version = %{V_odbc}
  85. url = http://www.ch-werner.de/sqliteodbc/
  86. regex = sqliteodbc-(__VER__)\.tar\.gz
  87. }
  88. %prep
  89. %setup -q
  90. %patch -p0 -P 0
  91. %if "%{with_odbc}" == "yes"
  92. %setup -q -D -T -a 1
  93. %patch -p0 -d sqliteodbc-%{V_odbc} -P 1
  94. %endif
  95. # post-adjust sources
  96. %{l_shtool} subst \
  97. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  98. configure
  99. %build
  100. # configure and build SQLite
  101. CC="%{l_cc}"
  102. CFLAGS="%{l_cflags -O}"
  103. %if "%{with_assert}" == "no"
  104. CFLAGS="$CFLAGS -DNDEBUG=1"
  105. %endif
  106. CPPFLAGS="%{l_cppflags}"
  107. LDFLAGS="%{l_ldflags}"
  108. LIBS="-lm"
  109. export CC
  110. export CPPFLAGS
  111. export CFLAGS
  112. export LDFLAGS
  113. export LIBS
  114. ./configure \
  115. --prefix=%{l_prefix} \
  116. %if "%{with_utf8}" == "yes"
  117. --enable-utf8 \
  118. %else
  119. --disable-utf8 \
  120. %endif
  121. %if "%{with_threads}" == "yes"
  122. --enable-threadsafe \
  123. %else
  124. --disable-threadsafe \
  125. %endif
  126. %if "%{with_readline}" == "yes"
  127. --enable-readline \
  128. --with-readline-lib="`%{l_prefix}/bin/pkg-config --libs readline`" \
  129. --with-readline-inc="`%{l_prefix}/bin/pkg-config --cflags readline`" \
  130. %else
  131. --disable-readline \
  132. %endif
  133. --disable-shared
  134. %if "%{with_assert}" == "yes"
  135. %{l_shtool} subst \
  136. -e 's;-DNDEBUG;;' \
  137. Makefile
  138. %endif
  139. MFLAGS=""
  140. %if "%{with_fts1}" == "yes"
  141. MFLAGS="$MFLAGS FTS1=1"
  142. %endif
  143. %if "%{with_fts2}" == "yes"
  144. MFLAGS="$MFLAGS FTS2=1"
  145. %endif
  146. %{l_make} %{l_mflags -O} $MFLAGS
  147. # optionally build ODBC driver
  148. %if "%{with_odbc}" == "yes"
  149. ( cd sqliteodbc-%{V_odbc}
  150. export CC="%{l_cc}"
  151. export CFLAGS="%{l_cflags -O}"
  152. export CPPFLAGS=""
  153. export LDFLAGS=""
  154. CPPFLAGS="$CPPFLAGS -I.."
  155. LDFLAGS="$LDFLAGS -L../.libs"
  156. ./configure \
  157. --prefix=%{l_prefix} \
  158. --with-sqlite3=.. \
  159. --with-odbc=%{l_prefix} \
  160. --disable-static \
  161. --enable-shared
  162. %{l_make} %{l_mflags -O}
  163. ) || exit $?
  164. %endif
  165. %install
  166. # create installation hierarchy
  167. rm -rf $RPM_BUILD_ROOT
  168. %{l_shtool} mkdir -f -p -m 755 \
  169. $RPM_BUILD_ROOT%{l_prefix}/bin \
  170. $RPM_BUILD_ROOT%{l_prefix}/lib \
  171. $RPM_BUILD_ROOT%{l_prefix}/include \
  172. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  173. # install SQLite
  174. %{l_make} %{l_mflags} install \
  175. prefix=$RPM_BUILD_ROOT%{l_prefix}
  176. %{l_shtool} install -c -m 644 \
  177. sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
  178. # install SQLite ODBC driver (optional)
  179. %if "%{with_odbc}" == "yes"
  180. ( cd sqliteodbc-%{V_odbc}
  181. %{l_make} %{l_mflags} install \
  182. prefix=$RPM_BUILD_ROOT%{l_prefix}
  183. ) || exit $?
  184. %endif
  185. # strip down installation files
  186. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  187. # provide convenient symlinks
  188. ln $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite3 \
  189. $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite
  190. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1 \
  191. $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
  192. # determine installation files
  193. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  194. %{l_files_std}
  195. %files -f files
  196. %clean
  197. rm -rf $RPM_BUILD_ROOT
  198. %post
  199. if [ $1 -eq 1 ]; then : ;
  200. # optionally link into ODBC
  201. %if "%{with_odbc}" == "yes"
  202. ( echo "[SQLite3]"
  203. echo "Description = SQLite 3 ODBC Driver"
  204. echo "Driver = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  205. echo "Setup = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  206. echo "FileUsage = 1"
  207. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
  208. ( echo "[SQLite3 DataSource]"
  209. echo "Driver = SQLite3"
  210. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite3 DataSource" -r >/dev/null 2>&1 || true
  211. %endif
  212. fi
  213. %preun
  214. if [ $1 -eq 1 ]; then : ;
  215. # optionally unlink from ODBC
  216. %if "%{with_odbc}" == "yes"
  217. $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
  218. $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "SQLite3" >/dev/null 2>&1 || true
  219. %endif
  220. fi