##
##  lpsolve.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_major 5.5
%define       V_minor 2.3

#   package information
Name:         lpsolve
Summary:      Mixed-Integer Linear Programming (LP) Solver
URL:          http://lpsolve.sourceforge.net/
Vendor:       Peter Notebaert & Kjell Eikland
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Algorithm
License:      LGPL
Version:      %{V_major}.%{V_minor}
Release:      20160509

#   list of sources
Source0:      http://download.sourceforge.net/lpsolve/lp_solve_%{version}_source.tar.gz
Patch0:       lpsolve.patch

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

%description
    lp_solve is a free linear integer programming solver based on the
    revised Simplex method and the Branch-and-Bound method for the
    integers. lp_solve solves pure linear, (mixed) integer/binary,
    semi-continuous and special ordered sets (SOS) models.

%track
    prog lpsolve = {
        version   = %{version}
        url       = http://sourceforge.net/projects/lpsolve/files/
        regex     = lp_solve_(__VER__)_source\.tar\.gz
    }

%prep
    %setup -q -n lp_solve_%{V_major}
    %patch -p0

%build
    ( cd lpsolve55; sh -x ccc ) || exit $?
    ( cd lp_solve;  sh -x ccc ) || exit $?

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/include/lpsolve \
        $RPM_BUILD_ROOT%{l_prefix}/lib
    %{l_shtool} install -c -s -m 755 \
        lp_solve/bin/*/lp_solve $RPM_BUILD_ROOT%{l_prefix}/bin/lpsolve
    %{l_shtool} install -c -m 644 \
        lpsolve55/bin/*/liblpsolve55.a $RPM_BUILD_ROOT%{l_prefix}/lib/liblpsolve.a
    %{l_shtool} install -c -m 644 \
        lp*.h $RPM_BUILD_ROOT%{l_prefix}/include/lpsolve/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

