sqlite.spec 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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.5.0
  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: 20070906
  39. # package options
  40. %option with_assert no
  41. %option with_readline no
  42. %option with_threads no
  43. %option with_fts1 no
  44. %option with_fts2 no
  45. %option with_odbc no
  46. # list of sources
  47. Source0: http://www.sqlite.org/sqlite-%{V_sqlite}.tar.gz
  48. Source1: http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
  49. Patch0: sqlite.patch
  50. Patch1: sqlite.patch.odbc
  51. # build information
  52. Prefix: %{l_prefix}
  53. BuildRoot: %{l_buildroot}
  54. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gawk
  55. PreReq: OpenPKG, openpkg >= 20040130
  56. %if "%{with_readline}" == "yes"
  57. BuildPreReq: readline, pkgconfig
  58. PreReq: readline
  59. %endif
  60. %if "%{with_odbc}" == "yes"
  61. BuildPreReq: ODBC
  62. PreReq: ODBC
  63. %endif
  64. AutoReq: no
  65. AutoReqProv: no
  66. %description
  67. SQLite is a C library that implements an embeddable SQL database
  68. engine. Programs that link with the SQLite library can have SQL
  69. database access without running a separate RDBMS process. The
  70. distribution comes with a standalone command-line access program
  71. (sqlite) that can be used to administer an SQLite database and which
  72. serves as an example of how to use the SQLite library. SQLite is not
  73. a client library used to connect to a big database server. SQLite is
  74. the server. The SQLite library reads and writes directly to and from
  75. the database files on disk.
  76. %track
  77. prog sqlite = {
  78. version = %{V_sqlite}
  79. url = http://www.sqlite.org/download.html
  80. regex = sqlite-(\d+\.\d+\.\d+)\.tar\.gz
  81. }
  82. prog sqlite:odbc = {
  83. version = %{V_odbc}
  84. url = http://www.ch-werner.de/sqliteodbc/
  85. regex = sqliteodbc-(__VER__)\.tar\.gz
  86. }
  87. %prep
  88. %setup -q
  89. %patch -p0 -P 0
  90. %if "%{with_odbc}" == "yes"
  91. %setup -q -D -T -a 1
  92. %patch -p0 -d sqliteodbc-%{V_odbc} -P 1
  93. %endif
  94. # post-adjust sources
  95. %{l_shtool} subst \
  96. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  97. configure
  98. %build
  99. # configure and build SQLite
  100. CC="%{l_cc}"
  101. CFLAGS="%{l_cflags -O}"
  102. %if "%{with_assert}" == "no"
  103. CFLAGS="$CFLAGS -DNDEBUG=1"
  104. %endif
  105. CPPFLAGS="%{l_cppflags}"
  106. LDFLAGS="%{l_ldflags}"
  107. LIBS="-lm"
  108. export CC
  109. export CPPFLAGS
  110. export CFLAGS
  111. export LDFLAGS
  112. export LIBS
  113. GREP="grep" \
  114. ./configure \
  115. --prefix=%{l_prefix} \
  116. %if "%{with_threads}" == "yes"
  117. --enable-threadsafe \
  118. %else
  119. --disable-threadsafe \
  120. %endif
  121. %if "%{with_readline}" == "yes"
  122. --enable-readline \
  123. --with-readline-lib="`%{l_prefix}/bin/pkg-config --libs readline`" \
  124. --with-readline-inc="`%{l_prefix}/bin/pkg-config --cflags readline`" \
  125. %else
  126. --disable-readline \
  127. %endif
  128. --disable-shared
  129. %if "%{with_assert}" == "yes"
  130. %{l_shtool} subst \
  131. -e 's;-DNDEBUG;;' \
  132. Makefile
  133. %endif
  134. MFLAGS=""
  135. %if "%{with_fts1}" == "yes"
  136. MFLAGS="$MFLAGS FTS1=1"
  137. %endif
  138. %if "%{with_fts2}" == "yes"
  139. MFLAGS="$MFLAGS FTS2=1"
  140. %endif
  141. %{l_make} %{l_mflags -O} $MFLAGS
  142. # optionally build ODBC driver
  143. %if "%{with_odbc}" == "yes"
  144. ( cd sqliteodbc-%{V_odbc}
  145. export CC="%{l_cc}"
  146. export CFLAGS="%{l_cflags -O}"
  147. export CPPFLAGS=""
  148. export LDFLAGS=""
  149. CPPFLAGS="$CPPFLAGS -I.."
  150. LDFLAGS="$LDFLAGS -L../.libs"
  151. ./configure \
  152. --prefix=%{l_prefix} \
  153. --with-sqlite3=.. \
  154. --with-odbc=%{l_prefix} \
  155. --disable-static \
  156. --enable-shared
  157. %{l_make} %{l_mflags -O}
  158. ) || exit $?
  159. %endif
  160. %install
  161. # create installation hierarchy
  162. rm -rf $RPM_BUILD_ROOT
  163. %{l_shtool} mkdir -f -p -m 755 \
  164. $RPM_BUILD_ROOT%{l_prefix}/bin \
  165. $RPM_BUILD_ROOT%{l_prefix}/lib \
  166. $RPM_BUILD_ROOT%{l_prefix}/include \
  167. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  168. # install SQLite
  169. %{l_make} %{l_mflags} install \
  170. prefix=$RPM_BUILD_ROOT%{l_prefix}
  171. %{l_shtool} install -c -m 644 \
  172. sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
  173. # install SQLite ODBC driver (optional)
  174. %if "%{with_odbc}" == "yes"
  175. ( cd sqliteodbc-%{V_odbc}
  176. %{l_make} %{l_mflags} install \
  177. prefix=$RPM_BUILD_ROOT%{l_prefix}
  178. ) || exit $?
  179. %endif
  180. # strip down installation files
  181. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  182. # provide convenient symlinks
  183. ln $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite3 \
  184. $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite
  185. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1 \
  186. $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
  187. # determine installation files
  188. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  189. %{l_files_std}
  190. %files -f files
  191. %clean
  192. rm -rf $RPM_BUILD_ROOT
  193. %post
  194. if [ $1 -eq 1 ]; then : ;
  195. # optionally link into ODBC
  196. %if "%{with_odbc}" == "yes"
  197. ( echo "[SQLite3]"
  198. echo "Description = SQLite 3 ODBC Driver"
  199. echo "Driver = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  200. echo "Setup = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  201. echo "FileUsage = 1"
  202. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
  203. ( echo "[SQLite3 DataSource]"
  204. echo "Driver = SQLite3"
  205. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite3 DataSource" -r >/dev/null 2>&1 || true
  206. %endif
  207. fi
  208. %preun
  209. if [ $1 -eq 1 ]; then : ;
  210. # optionally unlink from ODBC
  211. %if "%{with_odbc}" == "yes"
  212. $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
  213. $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "SQLite3" >/dev/null 2>&1 || true
  214. %endif
  215. fi