##
##  mlpack.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:         mlpack
Summary:      Machine Learning Library
URL:          http://mlpack.org/
Vendor:       Ryan Curtin et al.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Mathematics
License:      BSD
Version:      2.2.5
Release:      20180114

#   list of sources
Source0:      http://mlpack.org/files/mlpack-%{version}.tar.gz
Patch0:       mlpack.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, cmake, gcc, gcc::with_cxx = yes, pkgconfig, txt2man, bash
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  lapack, armadillo, boost
PreReq:       lapack, armadillo, boost

%description
    mlpack is an intuitive, fast, scalable C++ machine learning library,
    meant to be a machine learning analog to LAPACK. It aims to
    implement a wide array of machine learning methods and functions as
    a "swiss army knife" for machine learning researchers. In addition
    to its powerful C++ interface, mlpack also provides command-line
    programs and Python bindings.

%track
    prog mlpack = {
        version   = %{version}
        url       = http://mlpack.org/download.html
        regex     = mlpack-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    %patch -p0

%build
    mkdir build
    (   cd build
        cmake \
            -Wno-dev \
            -DCMAKE_BUILD_TYPE="Release" \
            -DCMAKE_INSTALL_PREFIX="%{l_prefix}" \
            -DCMAKE_C_COMPILER="%{l_cc}" \
            -DCMAKE_C_FLAGS="%{l_cflags} %{l_cppflags}" \
            -DCMAKE_CXX_COMPILER="%{l_cxx}" \
            -DCMAKE_CXX_FLAGS="%{l_cxxflags} %{l_cppflags}" \
            -DCMAKE_EXE_LINKER_FLAGS="%{l_ldflags}" \
            -DARMA_EXTRA_DEBUG=OFF \
            -DDEBUG=OFF \
            -DPROFILE=OFF \
            -DBUILD_CLI_EXECUTABLES=ON \
            -DMATLAB_BINDINGS=OFF \
            -DBUILD_TESTS=OFF \
            -DBUILD_SHARED_LIBS=OFF \
            -DBUILD_WITH_COVERAGE=OFF \
            -DMATHJAX=OFF \
            -DFORCE_CXX11=ON \
            ..
        %{l_make} %{l_mflags}
    ) || exit $?

%install
    (   cd build
        %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    ) || exit $?
    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

