%define pkg_name    dSFMT
%define pkg_version 2.2.3
%define pkg_release 1%{?_dist_release}

Summary: Double precision SIMD-oriented Fast Mersenne Twister
Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: BSD
Group:   System Environment/Libraries
URL:     http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT

Source0: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/%{name}-src-%{version}.tar.gz

Patch0: %{name}-%{version}_sharedlib.patch
Patch1: %{name}-%{version}_pkgconfig.patch
Patch2: %{name}-%{version}_exportfuns.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: nkf


%description
The purpose of dSFMT is to speed up the generation by avoiding
the expensive conversion of integer to double (floating point).
dSFMT directly generates double precision floating point
pseudo-random numbers which have the IEEE Standard for Binary
Floating-Point Arithmetic (ANSI/IEEE Std 754-1985) format.

dSFMT is only available on the CPUs which use IEEE 754 format
double precision floating point numbers.

dSFMT doesn't support integer outputs.
dSFMT supports the output of double precision floating point
pseudo-random numbers which distribute in the range of
[1, 2), [0, 1), (0, 1] and (0, 1).
And it also supports the various periods form 2^521 - 1 to 2^132049 - 1.
#'

%description -l ja
dSFMT の開発目的は整数から浮動小数点数への変換のコストを避けることにあります。
dSFMT は IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std
754-1985) 形式の倍精度浮動小数点擬似乱数を直接生成します。 したがって、dSFMT
は IEEE 754 形式の倍精度浮動小数点数を使用する CPU でしか利用出来ません。

dSFMT は整数の出力をサポートしません。
dSFMT がサポートするのは [1, 2), [0, 1), (0, 1], (0, 1) の範囲に分布する
倍精度浮動小数点擬 似乱数です。また、2^521 - 1 から 2^216091 - 1 までの様々な
周期をサポートします。


%package devel
Summary: Development files for %{name}
Group:   Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%prep
%setup -q -n %{name}-src-%{version}
%patch0 -p1 -b .sharedlib
%patch1 -p0 -b .pkgconfig
%patch2 -p1 -b .exportfuns

nkf -w -Lu --overwrite README.jp.txt

%build
%{__make} %{?_smp_mflags} sharedlib \
 libdir=%{_libdir} CCFLAGS="-fPIC %{optflags}"

%install
%{make_install} libdir=%{_libdir}
%{__install} -pm644 %{name}.pc ${RPM_BUILD_ROOT}%{_libdir}/pkgconfig/

%check
%{__make} std-check

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post -p %{_syssbindir}/ldconfig

%postun -p %{_syssbindir}/ldconfig


%files
%doc CHANGE-LOG.txt LICENSE.txt README.txt README.jp.txt
%doc html/
%{_libdir}/*.so.*

%files devel
%{_libdir}/*.so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/*.h


%changelog
* Sat Jun 09 2018 Toshiaki Ara <ara_t@384.jp> 2.2.3-1
- initial build for Vine Linux

* Wed Sep 3 2014 Milan Bouchet-Valat <nalimilan@club.fr> - 2.2.3-4
- Move documentation to -devel-doc package.
- Run tests (modify and simplify Makefile patch to do this).

* Sat Jun 28 2014 Milan Bouchet-Valat <nalimilan@club.fr> - 2.2.3-3
- Add patch to export functions required to use the library.

* Tue Jun 17 2014 Xavier Lamien <laxathom@fedoraproject.org> - 2.2.3-2
- Update license.
- lower variable into Makefile.

* Thu Jun  5 2014 Xavier Lamien <laxathom@fedoraproject.org> - 2.2.3-1
- Initial RPM release.
