##
##  logtools.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 information
Name:         logtools
Summary:      Common Log Format (CRL) Tools
URL:          http://doc.coker.com.au/projects/logtools/
Vendor:       Russell Coker
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Logfile
License:      Open Source
Version:      0.13e
Release:      20161225

#   list of sources
Source0:      http://www.coker.com.au/logtools/logtools-%{version}.tgz
Patch0:       logtools.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101

%description
    Logtools contains a number of programs for managing log files
    (mainly for web servers): clfmerge(1) will merge a number of
    Common Logfile Format web log files into a single file while also
    re-ordering them in a sliding window to cope with web servers
    that generate log entries with the start-time of the request and
    write them in order of completion. logprn(1) operates like tail
    -f but will (after a specified period of inactivity) spawn a
    process and write the new data in the log file to its standard
    input. clfsplit(1) will split up a single CLF format web log into
    a number of files based on the clients IP address. funnel(1)
    will write its standard-input to a number of files or processes.
    clfdomainsplit(1) split a CLF format web log containing fully
    qualified URLs (including the host name) into separate files, one
    for each host.

%track
    prog logtools = {
        version   = %{version}
        url       = http://doc.coker.com.au/projects/logtools/
        regex     = logtools-(__VER__)\.tgz
    }

%prep
    %setup -q
    %patch -p0

%build
    %{l_shtool} subst \
        -e 's;/etc/clfdomainsplit.cfg;%{l_prefix}/etc/logtools/clfdomainsplit.cfg;' \
        crldomainsplit.cpp
    CC="%{l_cc}" \
    CXX="%{l_cxx}" \
    CFLAGS="%{l_cflags -O}" \
    CXXFLAGS="%{l_cxxflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    ./configure \
        --prefix=%{l_prefix} \
        --sysconfdir=%{l_prefix}/etc/logtools
    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install \
        prefix=$RPM_BUILD_ROOT%{l_prefix} \
        sysconfdir=$RPM_BUILD_ROOT%{l_prefix}/etc/logtools
    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/logtools/*'

%files -f files

%clean

