Blob Blame History Raw
Name:		arprec
Version:	2.2.16
Release:	4%{?dist}
Summary:	Software package for performing arbitrary precision arithmetic
%{?el5:Group:	System Environment/Libraries}

License:	BSD
URL:		http://crd.lbl.gov/~dhbailey/mpdist
Source0:	%{url}/%{name}-%{version}.tar.gz
Source1:	%{url}/BSD-LBNL-License.doc

%{?el5:BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)}
BuildRequires:	catdoc
BuildRequires:	chrpath
BuildRequires:	gcc-gfortran
BuildRequires:	libtool
BuildRequires:	qd-devel

%description
ARPREC is a software package for performing arbitrary precision
arithmetic.  It consists of a revision and extension of Bailey's
earlier MPFUN package, enhanced with special IEEE numerical
techniques.  Features include:

  * Written in C++ for broad portability and fast execution.

  * Includes C++ and Fortran 90/95 interfaces based on custom data-types
    and operator/function overloading, which permit the library to be
    used with only minor modifications for many conventional C++ and
    Fortran-90 programs.

  * Includes all of the usual arithmetic operations, as well as many
    transcendental functions, including cos, sin, tan, arccos, arcsin,
    arctan, exp, log, log10, erf, gamma and Bessel functions.

  * Supports three arbitrary precision data-types: mp_real, mp_int
    and mp_complex.

  * Supports many mixed-mode operations between arbitrary precision
    variables or constants and conventional variables or constants.

  * Includes special library routines, incorporating advanced
    algorithms for extra-high precision (above 1000 digits) computation.

  * Includes a number of sample application programs, including programs
    for quadrature (numerical definite integrals), PLSQ (integer relation
    finding) and polynomial root finding.

  * Includes the "Experimental Mathematician's Toolkit".  This is a
    self-contained interactive program that performs many operations
    typical of modern experimental mathematics, including arithmetic
    expressions, common transcendental functions, infinite series
    evaluation, definite integrals, polynomial roots, user-defined
    functions, all evaluated to a user-defined level of numeric
    precision, up to 1000 decimal digits.


%package data
Summary:	Data files for %{name}-tools
%{?el5:Group:	Applications/Engineering}

%{?!el5:BuildArch:	noarch}

%description data
This package contains data-files used with %{name}-tools.


%package devel
Summary:	Development files for %{name}
%{?el5:Group:	System Environment/Libraries}

Requires:	%{name}%{?_isa} = %{version}-%{release}
%{?el5:Requires:	pkgconfig}

%description devel
This package contains the development files and headers for %{name}.


%package doc
Summary:	Documentation files for %{name}
%{?el5:Group:	Documentation}

%{?!el5:BuildArch:	noarch}

%description doc
This package contains the documentation and some brief examples.


%package tools
Summary:	Interactive high-precision arithmetic computing environment
%{?el5:Group:	Applications/Engineering}

Requires:	%{name}%{?_isa} = %{version}-%{release}
Requires:	%{name}-data = %{version}-%{release}

%description tools
This is a complete interactive high-precision arithmetic computing
environment.  One enters expressions in a Mathematica-style syntax,
and the operations are performed using the ARPREC package, with a
level of precision that can be set from 100 to 1000 decimal digit
accuracy.  Variables and vector arrays can be defined and referenced.
This program supports all basic arithmetic operations, common
transcendental and combinatorial functions, multi-pair PSLQ (one-,
two- or three-level versions), high-precision quadrature, i.e. numeric
integration (Gaussian, error function or tanh-sinh), and summation of
series.


%prep
%setup -q

# Pull-in upstream's .doc-license.
cp -a %{SOURCE1} .

# Create an user-friendly ascii-text from original .doc-license.
catdoc -d utf-8 %{SOURCE1} | sed -e 's!\f!!g' > BSD-LBNL-License.txt

# Remove some unneeded and obsoleted files.
find . -depth -name '._*' -print0 | xargs -0 rm -rf
find . -depth -name '.[dD][sS]_[sS]tore' -print0 | xargs -0 rm -rf

# The testsuite is a good example for using this lib.  So let's store it's
# files in antoher location before they get cluttered with intermediate stuff.
cp -a tests examples
rm -rf examples/Makefile*

# Get all pre-build quads-data from mathinit.
sed -i	-e 's!nquadopt = 1!nquadopt = 3!g'	\
	toolkit/mathinit.f

# Use the pre-build data-files in mathtool.
sed -i	-e 's!const\.dat!%{_datadir}/%{name}/&!g'	\
	-e 's!quad.*\.dat!%{_datadir}/%{name}/&!g'	\
	toolkit/mathtool.f

# Make arprec-config multilib-friendly.  Substitute original script
# with a wrapper-script for pkg-config.
cat << EOS > arprec-config.rpmbuild
#!/bin/sh
# arprec-config.  Generated during rpmbuild.
pc=\`which pkg-config\`

usage()
{
  cat <<EOF
Usage: arprec-config [OPTIONS]
Options:
    [--prefix]
    [--exec-prefix]
    [--version]
    [--libs]
    [--fc]
    [--fclibs]
    [--fcflags]
    [--fmainlib]
    [--cxx]
    [--cxxflags]
    [--configure-args]
EOF
  exit $1
}

while test \$# -gt 0; do
  case "\$1" in
  -*=*) optarg=\`echo "\$1" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
  *) optarg= ;;
  esac

  case \$1 in
    --prefix)
      \$pc --variable=prefix %{name}
      ;;
    --exec-prefix)
      \$pc --variable=exec_prefix %{name}
      ;;
    --version)
      \$pc --modversion %{name}
      ;;
    --libs)
      \$pc --libs %{name}
      ;;
    --cxx)
      \$pc --variable=cxx %{name}
      ;;
    --configure-args)
      \$pc --variable=configure_args %{name}
      ;;
    --fclibs)
      \$pc --variable=fclibs %{name}
      ;;
    --fcflags)
      \$pc --variable=fcflags %{name}
      ;;
    --fmainlib)
      \$pc --variable=fmainlib %{name}
      ;;
    --cxxflags)
      \$pc --variable=cxxflags %{name}
      ;;
    --fc)
      \$pc --variable=fc %{name}
      ;;
    *)
      usage 1 1>&2
      ;;
  esac
  shift
done
EOS

# Create a template for pkg-config.  This will be used by the modified
# arprec-config as well.
cat << EOF > %{name}.pc
############################
# Pkg-Config file for @name@
############################

prefix=@prefix@
exec_prefix=\${prefix}

bindir=@bindir@
datarootdir=@datadir@
datadir=\${datarootdir}/@name@
includedir=@includedir@
libdir=@libdir@
mandir=@mandir@
sharedstatedir=@sharedstatedir@
sysconfdir=@sysconfdir@

configure_args=@configure_args@
cxx=@cxx@
cxxflags=@cxxflags@
fc=@fc@
fcflags=-I${includedir}/@name@ @fcflags@
fclibs=@fclibs@
fmainlib=@fmainlib@

Name:		@name@
Version:	@version@
Description:	@name@ - @summary@

Libs:		@libs@
Cflags:		-I\${includedir}
EOF


%build
# Remove obsoleted autotools-macros from configure.ac for el6+.  Running
# `autoupdate` and `autoreconf -fiv` is the recommended procedure to do so.
# For further reference have a look at libtool's manual on gnu.org:
# http://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html
#
# During the el5-build we need to correct some timestamps, because they are
# broken in upstream's pristine tarballs.  This is not needed for el6+,
# because this will be taken care of by `autoupdate` and `autoreconf -fiv`.
%{?el5:touch -r aclocal.m4 configure configure.ac}
%{?!el5:autoupdate}
%{?!el5:autoreconf -fiv}

# Invoke the `regular` build-procedure.
%configure			\
	--disable-static	\
%{?!el5:--enable-qd}		\
	--enable-shared
make %{?_smp_mflags}
make %{?_smp_mflags} toolkit

# Substitute @var@ in .pc-template from %%prep
chmod +x %{name}-config
sed -i	-e 's!@prefix@!%{_prefix}!g'								\
	-e 's!@bindir@!%{_bindir}!g'								\
	-e 's!@datadir@!%{_datadir}!g'								\
	-e 's!@name@!%{name}!g'									\
	-e 's!@includedir@!%{_includedir}!g'							\
	-e 's!@libdir@!%{_libdir}!g'								\
	-e 's!@mandir@!%{_mandir}!g'								\
	-e 's!@sharedstatedir@!%{_sharedstatedir}!g'						\
	-e 's!@sysconfdir@!%{_sysconfdir}!g'							\
	-e 's!@version@!%{version}!g'								\
	-e 's!@summary@!Software package for performing arbitrary precision arithmetic!g'	\
	-e "s~@libs@~$(./%{name}-config --libs)~g"						\
	-e "s~@configure_args@~$(./%{name}-config --configure-args)~g"				\
	-e "s~@cxx@~$(./%{name}-config --cxx)~g"						\
	-e "s~@cxxflags@~$(./%{name}-config --cxxflags)~g"					\
	-e "s~@fc@~$(./%{name}-config --fc)~g"							\
	-e "s~@fcflags@~$(./%{name}-config --fcflags)~g"					\
	-e "s~@fclibs@~$(./%{name}-config --fclibs)~g"						\
	-e "s~@fmainlib@~$(./%{name}-config --fmainlib)~g"					\
	%{name}.pc
chmod -x %{name}-config

# Pre-build the data-files for `mathtool`.
pushd toolkit
./mathinit
popd


%install
%{?el5:rm -rf %{buildroot}}
make install DESTDIR=%{buildroot}

# Remove unneeded and obsolete stuff.  %%{name}-config will be replaced by the
# new wrapper later.  The pre-installed docs will be picked as %%doc within
# %%files.  The .la-dumpings from libtool are obsolete and not useful.
rm -rf	%{buildroot}%{_bindir}/%{name}-config	\
	%{buildroot}%{_datadir}/*	\
	%{buildroot}%{_libdir}/*.la

# Create needed dirs.
mkdir -p %{buildroot}%{_datadir}/%{name}	\
	%{buildroot}%{_libdir}/pkgconfig

# There's no install-target for `mathtool`, so it must be install `by hand`.
for tool in toolkit/.libs/math*
do
  install -pm 0755 ${tool}	\
	%{buildroot}%{_bindir}/%{name}-`echo ${tool} | sed -e's!.*/!!g'`
done

# Install the custom arprec-config wrapper-script and the needed .pc-file.
install -pm 0755 %{name}-config.rpmbuild %{buildroot}%{_bindir}/%{name}-config
install -pm 0644 %{name}.pc %{buildroot}%{_libdir}/pkgconfig

# Install the pre-build data-files for `mathtool`.
install -pm 0644 toolkit/*.dat %{buildroot}%{_datadir}/%{name}

# Kill rpath on all binaries within %{_bindir}.
chrpath -d %{buildroot}%{_bindir}/%{name}-math*


%check
# On Fedora the IO-read test failes for some unknown reason.  On RHEL all
# tests run fine.  The comment from upstream on bugreport with build.log:
#
# It looks like everything is working fine.  I don't know why it is failing
# that one test.  Let me know if you have any problems in running your codes
# -- I don't think you will.
# DHB
make check ||:


%clean
%{?el5:rm -rf %{buildroot}}


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%doc BSD-LBNL-License* COPYING
%{_libdir}/lib%{name}*.so.*

%files data
%doc BSD-LBNL-License* COPYING
%{_datadir}/%{name}

%files devel
%{_bindir}/%{name}-config
%{_includedir}/*
%{_libdir}/lib%{name}*.so
%{_libdir}/pkgconfig/%{name}.pc

%files doc
%doc AUTHORS* BSD-LBNL-License* ChangeLog* COPYING*
%doc NEWS* README* TODO* doc/* examples

%files tools
%doc toolkit/README*
%{_bindir}/%{name}-math*


%changelog
* Thu Sep 19 2013 Björn Esser <bjoern.esser@gmail.com> - 2.2.16-4
- fix "Variable 'datarootdir' not defined in '%%{_libdir}/pkgconfig/arprec.pc'"

* Fri Sep 13 2013 Björn Esser <bjoern.esser@gmail.com> - 2.2.16-3
- added needed bits for el5
- created an ascii-txt license from the license.doc provided by upstream
- nuked rpath from %%{_bindir}/%{name}-math*
- added .pc-file to solve the multiarch-problematic and aged %%{name}-config
- fix some broken timestamps when building for el5 (not needed for el6+)
- run `autoupdate` and `autoreconf -fiv` to fix-up obsolete autotools-macros
  for el6+

* Fri Sep 13 2013 Björn Esser <bjoern.esser@gmail.com> - 2.2.16-2
- renamed tools-common pkg to data
- merged common-devel pkg with devel, because it can't be noarch
- removed calling autoreconf during %%build
- some minor improvements in %%prep, mostly comments
- as suggested in rhbz# 1007577 c#2

* Thu Sep 12 2013 Björn Esser <bjoern.esser@gmail.com> - 2.2.16-1
- Initial rpm release (#1007577)