Blob Blame History Raw
Name:           flint
Version:        1.6
Release:        1%{?dist}
Summary:        Fast Library for Number Theory
Group:          Applications/Engineering
License:        GPLv2+
URL:            http://www.flintlib.org/
Source0:        http://www.flintlib.org/flint-%{version}.tgz
# Build a static lib (since upstream doesn't keep track of compatible
# interfaces a soname really makes no sense
Patch0:         flint-1.2.0-add-static-lib.diff
# Use the system zn_poly instead of building the sources
Patch1:         flint-1.6-use-system-zn_poly.patch
# Fix some variable redefinitions; gcc 4.6 errors out otherwise
Patch2:         flint-1.6-redef.patch
# Fix some compiler warnings that indicate possible runtime problems
Patch3:         flint-1.6-warning.patch

BuildRequires:  gmp-devel
BuildRequires:  mpfr-devel
BuildRequires:  zn_poly-devel
BuildRequires:  tex(latex)

%global sover %(echo %{version} | cut -d. -f 1)


%description
FLINT is a C library for doing number theory, written by William Hart
and David Harvey.


%package        devel
Summary:        Development files for FLINT
Group:          Development/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       gmp-devel%{?_isa}, mpfr-devel%{?_isa}, zn_poly-devel%{?_isa}


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


%package        static
Summary:        Static libraries for FLINT
Group:          Development/Libraries
Requires:       %{name}-devel%{?_isa} = %{version}-%{release}


%description    static
The %{name}-static package contains static libraries for
developing applications that use %{name}.


%prep
%setup -q
%patch0
%patch1
%patch2
%patch3

# Make sure we don't accidentally use the included zn_poly sources
rm -fr zn_poly

# Add an soname for the shared library and set other values
sed -e 's|^LIBDIR=.*$|LIBDIR=%{_libdir}|'                        \
    -e 's|^INCLUDEDIR=.*$|INCLUDEDIR=%{_includedir}|'            \
    -e 's|^DOCDIR=.*$|DOCDIR=%{_docdir}|'                        \
    -e 's|^CFLAGS =.*$|CFLAGS = $(INCS) %{optflags}|'            \
    -e 's|^CFLAGS2 =.*$|CFLAGS2 = $(INCS) %{optflags} -fopenmp|' \
    -e "s|-shared|-shared -Wl,-h,libflint.so.%{sover}|"          \
    -e 's|mp_lprels\.o \$(FLINTOBJ)$|mp_lprels.o libflint.so|'   \
    -e 's|mp_lprels\.o \$(FLINTOBJ)|mp_lprels.o -L. -lflint|'    \
    -i makefile

# Fix end-of-line encodings
sed 's/\r//' CHANGES.txt > CHANGES
touch -r CHANGES.txt CHANGES
mv -f CHANGES CHANGES.txt


%build
make %{?_smp_mflags} MAKECMDGOALS=library FLINT_GMP_LIB_DIR=%{_libdir}
rm -f *.o
make libflint.a FLINT_GMP_LIB_DIR=%{_libdir}

# Build the documentation
cd doc
pdflatex %{name}-%{version}.tex
pdflatex %{name}-%{version}.tex


%install
# generated in build: mpQS libflint.so libflint.a
install -d -m 755 $RPM_BUILD_ROOT%{_libdir}
install -p -m 644 libflint.a $RPM_BUILD_ROOT%{_libdir}/
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
install -p -m 755 mpQS $RPM_BUILD_ROOT%{_bindir}/
# install the headers somehow...
install -d -m 755 $RPM_BUILD_ROOT%{_includedir}/%{name}
for header in *.h; do
  install -p -m 644 $header $RPM_BUILD_ROOT%{_includedir}/%{name}/
done

install -p -m 755 libflint.so $RPM_BUILD_ROOT%{_libdir}/libflint.so.%{sover}
pushd $RPM_BUILD_ROOT%{_libdir}/
  ln -s libflint.so.%{sover} libflint.so
popd

# add symlink FLINT -> flint | sagemath wants it that way
pushd $RPM_BUILD_ROOT%{_includedir}
    ln -s flint FLINT
popd


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%clean
rm -rf $RPM_BUILD_ROOT


%files
%doc CHANGES.txt gpl-2.0.txt doc/%{name}-%{version}.pdf
%{_bindir}/mpQS
%{_libdir}/libflint.so.%{sover}


%files devel
%{_includedir}/flint
%{_includedir}/FLINT
%{_libdir}/libflint.so


%files static
%{_libdir}/libflint.a


%changelog
* Mon Jul 18 2011 Jerry James <loganjerry@gmail.com> - 1.6-1
- New upstream release
- Build against the system zn_poly instead of the included sources
- Make sure there is no PIC code in the static archive
- Link mpQS against the shared library instead of including the library
- Fix build errors and scary warnings with gcc 4.6
- Remove unnecessary spec file elements (BuildRoot, etc.)

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Sat Jun 26 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.5.2-1
- update to new version
- renew both patches

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Mar 10 2009 Conrad Meyer <konrad@tylerc.org> - 1.2.0-1
- Bump to 1.2.0.

* Fri Mar 6 2009 Conrad Meyer <konrad@tylerc.org> - 1.0.21-1
- Bump to 1.0.21.
- Build static subpackage.

* Sat Dec 6 2008 Conrad Meyer <konrad@tylerc.org> - 1.0.18-1
- Bump to 1.0.18.
- Patches apply with --fuzz=0.

* Sat Nov 29 2008 Conrad Meyer <konrad@tylerc.org> - 1.0.17-1
- Initial package.