##
##  dspam.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  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 version
%define       V_opkg 3.10.2
%define       V_dist 3.10.2

#   package information
Name:         dspam
Summary:      Statistical Anti-Spam Filter
URL:          http://dspam.sourceforge.net/
Vendor:       Jonathan A. Zdziarski
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        Mail
License:      GPL
Version:      %{V_opkg}
Release:      20120424

#   list of sources
Source0:      http://download.sourceforge.net/dspam/dspam-%{V_dist}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  sqlite
PreReq:       sqlite

%description
    DSPAM (as in De-Spam) is an extremely scalable, open-source
    statistical anti-spam filter. While most commercial solutions only
    claim a mere 95% accuracy (1 error in 20), a majority of DSPAM users
    frequently see around 99.95% (1 error in 2000) and can sometimes
    reach peaks as high as 99.991% (2 errors in 22,786). DSPAM presently
    functions as both a server-side agent for UNIX email servers and a
    developer's library for mail clients, other anti-spam tools, and
    similar projects requiring drop-in spam filtering. DSPAM has been
    implemented on many large and small scale systems.

%track
    prog dspam = {
        version   = %{version}
        url       = http://sourceforge.net/projects/dspam/files/
        regex     = dspam-(\d+\.\d+\.\d+)\.tar\.gz
    }

%prep
    %setup -q -n dspam-%{V_dist}
    %{l_shtool} subst \
        -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
        -e 's;LIBS="-lm";LIBS="$LIBS -lm";' \
        configure

%build
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O} `pkg-config sqlite3 --cflags-only-other`" \
    CPPFLAGS="%{l_cppflags} `pkg-config sqlite3 --cflags-only-I`" \
    LDFLAGS="%{l_ldflags} `pkg-config sqlite3 --libs-only-other`" \
    LIBS="`pkg-config sqlite3 --libs-only-l`" \
    ./configure \
        --prefix=%{l_prefix} \
        --sysconfdir=%{l_prefix}/etc/dspam \
        --with-dspam-home=%{l_prefix}/share/dspam \
        --with-dspam-home-mode=755 \
        --with-dspam-home-owner="`%{l_shtool} echo -e %u`" \
        --with-dspam-home-group="`%{l_shtool} echo -e %g`" \
        --with-dspam-mode=755 \
        --with-dspam-owner="`%{l_shtool} echo -e %u`" \
        --with-dspam-group="`%{l_shtool} echo -e %g`" \
        --with-logdir=%{l_prefix}/var/dspam \
        --with-storage-driver="sqlite3_drv" \
        --with-sqlite-includes=%{l_prefix}/include \
        --with-sqlite-libraries=%{l_prefix}/lib \
        --disable-homedir \
        --disable-shared \
        --enable-warnings=no
    %{l_make} %{l_mflags -O}

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man3 \
        $RPM_BUILD_ROOT%{l_prefix}/var/dspam
    %{l_shtool} subst -e 's;ln -s ;ln $(DESTDIR);g' Makefile
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/dspam/dspam.conf'

%files -f files

%clean

