##
##  sqlite.spec -- OpenPKG RPM Specification
##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package options
%ifndef       with_utf8
%define       with_utf8            no
%endif
%ifndef       with_assert
%define       with_assert          no
%endif
%ifndef       with_readline
%define       with_readline        no
%endif

#   package information
Name:         sqlite
Summary:      SQL Lite
URL:          http://www.hwaci.com/sw/sqlite/
Vendor:       D. Richard Hipp
Packager:     The OpenPKG Project
Distribution: OpenPKG [BASE]
Group:        Database
License:      PD
Version:      2.7.5
Release:      20021228

#   list of sources
Source0:      http://www.hwaci.com/sw/sqlite/sqlite-%{version}.tar.gz

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20021020
PreReq:       OpenPKG, openpkg >= 20021020
%if "%{with_readline}" == "yes"
BuildPreReq:  readline
%endif
AutoReq:      no
AutoReqProv:  no

%description
    SQLite is a C library that implements an embeddable SQL database
    engine. Programs that link with the SQLite library can have SQL
    database access without running a separate RDBMS process. The
    distribution comes with a standalone command-line access program
    (sqlite) that can be used to administer an SQLite database and which
    serves as an example of how to use the SQLite library. SQLite is not
    a client library used to connect to a big database server. SQLite is
    the server. The SQLite library reads and writes directly to and from
    the database files on disk.
    --define "with_utf8 %{with_utf8}"
    --define "with_assert %{with_assert}"
    --define "with_readline %{with_readline}"

%prep
    %setup -q -n sqlite
    chmod a+x install-sh

%build
    CC="%{l_cc}"
    export CC
    CPPFLAGS="%{l_cppflags}"
    export CPPFLAGS
    CFLAGS="%{l_cflags -O}"
    export CFLAGS
    LDFLAGS="%{l_ldflags}"
    export LDFLAGS
    LIBS=""
    export LIBS
%if "%{with_assert}" == "no"
    CFLAGS="$CFLAGS -DNDEBUG=1"
%endif
%if "%{with_readline}" == "yes"
    CPPFLAGS="$CPPFLAGS %{l_cppflags readline}"
    CFLAGS="$CFLAGS %{l_cppflags readline}"
    LIBS="$LIBS -lreadline -ltermcap"
%endif
    ./configure \
        --prefix=%{l_prefix} \
%if "%{with_utf8}" == "yes"
        --enable-utf8 \
%endif
        --disable-shared
    %{l_make} %{l_mflags -O}

%install
    rm -rf $RPM_BUILD_ROOT
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/lib \
        $RPM_BUILD_ROOT%{l_prefix}/include \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1
    %{l_make} %{l_mflags} install \
        prefix=$RPM_BUILD_ROOT%{l_prefix}
    %{l_shtool} install -c -m 644 \
        sqlite.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean
    rm -rf $RPM_BUILD_ROOT

