##
##  gmp.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_dist   6.3.0
%define       V_subdir 6.3.0

#   package information
Name:         gmp
Summary:      GNU Arbitrary Precision Arithmetic Library
URL:          http://gmplib.org/
Vendor:       Free Software Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        CORE
Group:        Algorithm
License:      LGPL
Version:      %{V_dist}
Release:      20230801

#   package options
%option       with_cxx  no

#   list of sources
Source0:      http://ftp.gnu.org/gnu/gmp/gmp-%{V_dist}.tar.xz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
%if "%{with_cxx}" == "yes"
BuildPreReq:  gcc::with_cxx = yes
%endif

%description
    GNU MP is a library for arbitrary precision arithmetic, operating
    on signed integers, rational numbers, and floating point numbers.
    It has a rich set of functions, and the functions have a regular
    interface. GNU MP is designed to be as fast as possible, both for
    small operands and for huge operands. The speed is achieved by using
    fullwords as the basic arithmetic type, by using fast algorithms, by
    carefully optimized assembly code for the most common inner loops
    for a lot of CPUs, and by a general emphasis on speed (instead of
    simplicity or elegance).

%track
    prog gmp = {
        version   = %{V_dist}
        url       = http://ftp.gnu.org/gnu/gmp/
        regex     = gmp-(__VER__)\.tar\.xz
    }

%prep
    %setup -q -n gmp-%{V_subdir}

%build
    export CC="%{l_cc} %{l_cflags -O}"
    export CFLAGS="%{l_cflags -O}"
%if "%{with_cxx}" == "yes"
    export CXX="%{l_cxx} %{l_cxxflags -O}"
    export CXXFLAGS="%{l_cxxflags -O}"
%endif
    ./configure \
        --prefix=%{l_prefix} \
        --infodir=%{l_prefix}/info \
        --disable-assembly \
%if "%{with_cxx}" == "yes"
        --enable-cxx \
%endif
        --disable-shared
    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

