sqlite.spec 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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.3
  26. %define V_odbc 0.76
  27. %define V_jdbc 20071108
  28. # package information
  29. Name: sqlite
  30. Summary: SQL Lite
  31. URL: http://www.sqlite.org/
  32. Vendor: D. Richard Hipp
  33. Packager: OpenPKG Foundation e.V.
  34. Distribution: OpenPKG Community
  35. Class: BASE
  36. Group: Database
  37. License: PD
  38. Version: %{V_sqlite}
  39. Release: 20071128
  40. # package options
  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_fts3 no
  47. %option with_odbc no
  48. %option with_jdbc no
  49. # list of sources
  50. Source0: http://www.sqlite.org/sqlite-%{V_sqlite}.tar.gz
  51. Source1: http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
  52. Source2: http://www.ch-werner.de/javasqlite/javasqlite-%{V_jdbc}.tar.gz
  53. Patch0: sqlite.patch
  54. Patch1: sqlite.patch.odbc
  55. # build information
  56. Prefix: %{l_prefix}
  57. BuildRoot: %{l_buildroot}
  58. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gawk
  59. PreReq: OpenPKG, openpkg >= 20040130
  60. %if "%{with_readline}" == "yes"
  61. BuildPreReq: readline, pkgconfig
  62. PreReq: readline
  63. %endif
  64. %if "%{with_odbc}" == "yes"
  65. BuildPreReq: ODBC
  66. PreReq: ODBC
  67. %endif
  68. %if "%{with_jdbc}" == "yes"
  69. BuildPreReq: java, JAVA-JDK
  70. PreReq: java, JAVA-JDK
  71. %endif
  72. AutoReq: no
  73. AutoReqProv: no
  74. %description
  75. SQLite is a C library that implements an embeddable SQL database
  76. engine. Programs that link with the SQLite library can have SQL
  77. database access without running a separate RDBMS process. The
  78. distribution comes with a standalone command-line access program
  79. (sqlite) that can be used to administer an SQLite database and which
  80. serves as an example of how to use the SQLite library. SQLite is not
  81. a client library used to connect to a big database server. SQLite is
  82. the server. The SQLite library reads and writes directly to and from
  83. the database files on disk.
  84. %track
  85. prog sqlite = {
  86. version = %{V_sqlite}
  87. url = http://www.sqlite.org/download.html
  88. regex = sqlite-(\d+\.\d+\.\d+)\.tar\.gz
  89. }
  90. prog sqlite:odbc = {
  91. version = %{V_odbc}
  92. url = http://www.ch-werner.de/sqliteodbc/
  93. regex = sqliteodbc-(__VER__)\.tar\.gz
  94. }
  95. prog sqlite:jdbc = {
  96. version = %{V_jdbc}
  97. url = http://www.ch-werner.de/javasqlite/overview-summary.html
  98. regex = javasqlite-(\d+)\.tar\.gz
  99. }
  100. %prep
  101. %setup -q
  102. %patch -p0 -P 0
  103. %if "%{with_odbc}" == "yes"
  104. %setup -q -D -T -a 1
  105. %patch -p0 -d sqliteodbc-%{V_odbc} -P 1
  106. %endif
  107. %if "%{with_jdbc}" == "yes"
  108. %setup -q -D -T -a 2
  109. %endif
  110. # post-adjust sources
  111. %{l_shtool} subst \
  112. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  113. configure
  114. %build
  115. # configure and build SQLite
  116. CC="%{l_cc}"
  117. CFLAGS="%{l_cflags -O}"
  118. %if "%{with_assert}" == "no"
  119. CFLAGS="$CFLAGS -DNDEBUG=1"
  120. %endif
  121. CFLAGS="$CFLAGS -DSQLITE_MAX_SQL_LENGTH=10000000"
  122. CPPFLAGS="%{l_cppflags}"
  123. LDFLAGS="%{l_ldflags}"
  124. LIBS="-lm"
  125. export CC
  126. export CPPFLAGS
  127. export CFLAGS
  128. export LDFLAGS
  129. export LIBS
  130. GREP="grep" \
  131. ./configure \
  132. --prefix=%{l_prefix} \
  133. %if "%{with_threads}" == "yes"
  134. --enable-threadsafe \
  135. %else
  136. --disable-threadsafe \
  137. %endif
  138. %if "%{with_readline}" == "yes"
  139. --enable-readline \
  140. --with-readline-lib="`%{l_prefix}/bin/pkg-config --libs readline`" \
  141. --with-readline-inc="`%{l_prefix}/bin/pkg-config --cflags readline`" \
  142. %else
  143. --disable-readline \
  144. %endif
  145. --disable-shared
  146. %if "%{with_assert}" == "yes"
  147. %{l_shtool} subst \
  148. -e 's;-DNDEBUG;;' \
  149. Makefile
  150. %endif
  151. MFLAGS=""
  152. %if "%{with_fts1}" == "yes"
  153. MFLAGS="$MFLAGS FTS1=1"
  154. %endif
  155. %if "%{with_fts2}" == "yes"
  156. MFLAGS="$MFLAGS FTS2=1"
  157. %endif
  158. %{l_make} %{l_mflags -O} $MFLAGS
  159. # optionally build ODBC driver
  160. %if "%{with_odbc}" == "yes"
  161. ( cd sqliteodbc-%{V_odbc}
  162. export CC="%{l_cc}"
  163. export CFLAGS="%{l_cflags -O}"
  164. export CPPFLAGS=""
  165. export LDFLAGS=""
  166. CPPFLAGS="$CPPFLAGS -I.."
  167. LDFLAGS="$LDFLAGS -L../.libs"
  168. ./configure \
  169. --prefix=%{l_prefix} \
  170. --with-sqlite3=.. \
  171. --with-odbc=%{l_prefix} \
  172. --disable-static \
  173. --enable-shared
  174. %{l_make} %{l_mflags -O}
  175. ) || exit $?
  176. %endif
  177. # optionally build JDBC driver
  178. %if "%{with_jdbc}" == "yes"
  179. ( cd javasqlite-%{V_jdbc}
  180. export JAVA_PLATFORM="sun-jdk"
  181. eval `%{l_prefix}/bin/java-toolkit -e`
  182. export CC="%{l_cc}"
  183. export CFLAGS="%{l_cflags -O}"
  184. export CPPFLAGS=""
  185. export LDFLAGS=""
  186. CPPFLAGS="$CPPFLAGS -I.."
  187. LDFLAGS="$LDFLAGS -L../.libs"
  188. ./configure \
  189. --prefix=%{l_prefix} \
  190. --with-jardir=%{l_prefix}/lib \
  191. --with-jdk=$JAVA_HOME \
  192. --with-sqlite3=..
  193. %{l_make} %{l_mflags}
  194. ) || exit $?
  195. %endif
  196. %install
  197. # create installation hierarchy
  198. rm -rf $RPM_BUILD_ROOT
  199. %{l_shtool} mkdir -f -p -m 755 \
  200. $RPM_BUILD_ROOT%{l_prefix}/bin \
  201. $RPM_BUILD_ROOT%{l_prefix}/lib \
  202. $RPM_BUILD_ROOT%{l_prefix}/include \
  203. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  204. # install SQLite
  205. %{l_make} %{l_mflags} install \
  206. prefix=$RPM_BUILD_ROOT%{l_prefix}
  207. %{l_shtool} install -c -m 644 \
  208. sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
  209. # install SQLite ODBC driver (optional)
  210. %if "%{with_odbc}" == "yes"
  211. ( cd sqliteodbc-%{V_odbc}
  212. %{l_make} %{l_mflags} install \
  213. prefix=$RPM_BUILD_ROOT%{l_prefix}
  214. ) || exit $?
  215. %endif
  216. # install SQLite JDBC driver (optional)
  217. %if "%{with_jdbc}" == "yes"
  218. ( cd javasqlite-%{V_jdbc}
  219. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  220. ) || exit $?
  221. %endif
  222. # strip down installation files
  223. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  224. # provide convenient symlinks
  225. ln $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite3 \
  226. $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite
  227. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1 \
  228. $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
  229. # determine installation files
  230. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  231. %{l_files_std}
  232. %files -f files
  233. %clean
  234. rm -rf $RPM_BUILD_ROOT
  235. %post
  236. if [ $1 -eq 1 ]; then : ;
  237. # optionally link into ODBC
  238. %if "%{with_odbc}" == "yes"
  239. ( echo "[SQLite3]"
  240. echo "Description = SQLite 3 ODBC Driver"
  241. echo "Driver = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  242. echo "Setup = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  243. echo "FileUsage = 1"
  244. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
  245. ( echo "[SQLite3 DataSource]"
  246. echo "Driver = SQLite3"
  247. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite3 DataSource" -r >/dev/null 2>&1 || true
  248. %endif
  249. fi
  250. %preun
  251. if [ $1 -eq 1 ]; then : ;
  252. # optionally unlink from ODBC
  253. %if "%{with_odbc}" == "yes"
  254. $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
  255. $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "SQLite3" >/dev/null 2>&1 || true
  256. %endif
  257. fi