sqlite.spec 8.6 KB

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