Blob Blame Raw
# TESTING NOTE: "make test" does not work, because the test drivers are not
# distributed with the released sources.  A Subversion repository containing
# all of the sources, including the test drivers, was made available recently.
# Once the next release of polymake occurs, we will extract the necessary test
# drivers from subversion and produce a check script.

# Release candidates are sometimes promoted to release without removing the tag
%global rctag -rc3

Name:           polymake
Version:        2.12
Release:        7%{?dist}
Summary:        Algorithms on convex polytopes and polyhedra

License:        GPLv2+
URL:            http://polymake.org/
Source0:        http://polymake.org/lib/exe/fetch.php/download/%{name}-%{version}%{rctag}.tar.bz2
# Man page written by Jerry James from text found in the sources.  Therefore,
# the copyright and license are the same as for the sources.
Source1:        %{name}.1
# This patch will not be sent upstream, since it is Fedora-specific.  Link
# against existing system libraries instead of building them from source,
# and do not use -rpath.
Patch0:         %{name}-fedora.patch
# This patch was sent upstream 1 Mar 2012.  Polymake uses nauty, which has a
# non-free license.  This patch converts polymake to bliss, which is free.
Patch1:         %{name}-bliss.patch
# Patch from upstream: adapt the sources to perl >= 5.15.
Patch2:         %{name}-perl.patch
# This patch was sent upstream 20 Mar 2013.  Fix a call to an lrslib function
# that segfaults when given a NULL argument.
Patch3:         %{name}-lrslib.patch

BuildRequires:  bliss-devel
BuildRequires:  cddlib-devel
BuildRequires:  libxml2-devel
BuildRequires:  lrslib-devel
BuildRequires:  mpfr-devel
BuildRequires:  perl(ExtUtils::MakeMaker)
BuildRequires:  perl(Term::ReadLine::Gnu)
BuildRequires:  perl(XML::LibXSLT)
BuildRequires:  perl(XML::SAX::Base)
BuildRequires:  perl(XML::Writer)
BuildRequires:  sympol-devel
BuildRequires:  xhtml1-dtds

Requires:       perl(:MODULE_COMPAT_%{perl_version})
Requires:       perl = 4:%{perl_version}
Requires:       perl(Term::ReadLine::Gnu)

%global sover   %(echo %{version} | cut -d. -f1-2)
%global major   %(echo %{version} | cut -d. -f1)
%global polydir %{_libdir}/%{name}

# Don't expose private shared objects or private perl interfaces
%global __provides_exclude perl
%global __provides_exclude_from ^%{polydir}/.*\\.so$

# Don't Require the private perl interfaces that we don't Provide.
%global __requires_exclude namespaces
%global __requires_exclude %{__requires_exclude}|BackgroundViewer
%global __requires_exclude %{__requires_exclude}|Geomview
%global __requires_exclude %{__requires_exclude}|Graphviz
%global __requires_exclude %{__requires_exclude}|InteractiveViewer
%global __requires_exclude %{__requires_exclude}|Java
%global __requires_exclude %{__requires_exclude}|JReality
%global __requires_exclude %{__requires_exclude}|Metapost
%global __requires_exclude %{__requires_exclude}|Polymake
%global __requires_exclude %{__requires_exclude}|Postscript
%global __requires_exclude %{__requires_exclude}|Povray
%global __requires_exclude %{__requires_exclude}|Sketch
%global __requires_exclude %{__requires_exclude}|SplitsTree
%global __requires_exclude %{__requires_exclude}|Visual

%description
Polymake is a tool to study the combinatorics and the geometry of convex
polytopes and polyhedra.  It is also capable of dealing with simplicial
complexes, matroids, polyhedral fans, graphs, tropical objects, and so
forth.

Polymake can use various computational packages if they are installed.
Those available from Fedora are: 4ti2, azove, gfan, latte-integrale,
normaliz, ocaml-tplib-tools, qhull, Singular, TOPCOM, and vinci.

Polymake can interface with various visualization packages if they are
installed.  Install one or more of the tools from the following list:
evince, geomview, graphviz, gv, and okular.

%package devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description devel
This package contains header files and libraries for developing
plugins (applications) that use %{name}.

%package doc
Summary:        Documentation for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description doc
This package contains documentation for %{name}.

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

# Make sure we don't build against the bundled libraries.
# Don't delete the jreality directory, though, or the installer crashes.
rm -fr external/{cdd,lrs,nauty,permlib,sympol}

# Don't force -O3
sed -i "s/-O3//" support/configure.pl

# Give the main library an soname (markers added by the -libs patch)
sed -i "s/@VERSION@/%{sover}/;s/@MAJVER@/%{major}/" support/corelib.make

# Adapt to a newer version of sympol
sed -i "s|yal/||;s|symmetrygroupconstruction/||" \
    apps/polytope/src/sympol_interface.cc

%build
export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/eigen3"
export CXXFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/eigen3"
export LDFLAGS="$RPM_LD_FLAGS -Wl,--as-needed"
export Arch=%{_arch}
# NOT an autoconf-generated configure script; do not use %%configure.
./configure --build=%{_arch} --prefix=%{_prefix} --libdir=%{_libdir} \
  --libexecdir=%{polydir} --without-java
make %{?_smp_mflags} all

# Help the debuginfo generator find generated files
cd build.%{_arch}
cp -p perlx-*linux-*/CPlusPlus.xxs lib/CPlusPlus.xxs
cp -p perlx-*linux-*/CPlusPlus.cc lib/CPlusPlus.xxs.c

%install
# Don't recompile the main library with DESTDIR compiled in
sed -i "/conf\.make/d" support/corelib.make

# The release-docs target copies docs to their installed locations
export Arch=%{_arch}
make install release-docs DESTDIR=%{buildroot}

# The apps have undefined weak symbols.  However, fixing that kills the
# documentation building step for reasons I can't seem to track down.  So
# instead, we wait until after the docs have been generated, then relink.
sed -e 's|^Libs :=.*|& -L$(wildcard ${BuildDir}/perlx-*-linux-*) -lpolymake|' \
    -i support/app.make
sed -e 's|-lgmp ${LIBS}|& -L${PerlExtDir} -lpolymake|' \
    -e 's|^${CoreLib} :.*|& ${CallableLib}|' \
    -i support/corelib.make
rm -f build.%{_arch}/lib/*.so
make %{?_smp_mflags} all
chmod 0755 %{buildroot}%{polydir}/lib/*.so
cp -p build.%{_arch}/lib/*.so %{buildroot}%{polydir}/lib

# Fix up the shared library links
mv %{buildroot}%{_libdir}/lib%{name}.so \
   %{buildroot}%{_libdir}/lib%{name}.so.%{version}
ln -s lib%{name}.so.%{version} %{buildroot}%{_libdir}/lib%{name}.so.%{major}
ln -s lib%{name}.so.%{major} %{buildroot}%{_libdir}/lib%{name}.so

# Install the man page
mkdir -p %{buildroot}%{_mandir}/man1
sed "s/@VERSION@/%{version}/" %{SOURCE1} > %{buildroot}%{_mandir}/man1/%{name}.1
touch -r %{SOURCE1} %{buildroot}%{_mandir}/man1/%{name}.1

# We don't want the documentation in /usr/share/polymake
mv %{buildroot}%{_datadir}/%{name}/doc .

# Remove stuff that shouldn't be installed
rm -fr %{buildroot}%{_datadir}/%{name}/apps/*/src \
  %{buildroot}%{_datadir}/%{name}/java_build \
  %{buildroot}%{polydir}/perlx/*/*/auto/Polymake/Ext/{.packlist,Ext.bs} \
  %{buildroot}%{polydir}/lib/jreality

# Fix permissions
chmod 0755 %{buildroot}%{_bindir}/*
chmod 0755 %{buildroot}%{_libdir}/lib*
find %{buildroot}%{polydir} -name \*.so | xargs chmod 0755

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc COPYING
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*
%{_libdir}/lib%{name}.so.*
%{polydir}/
%{_datadir}/%{name}/
%exclude %{_datadir}/%{name}/lib/

%files devel
%{_bindir}/%{name}-config
%{_includedir}/%{name}/
%{_datadir}/%{name}/lib/
%{_libdir}/lib%{name}.so

%files doc
%doc doc/*

%changelog
* Sun Jul 21 2013 Rich Mattes <richmattes@gmail.com> - 2.12-7
- Rebuild for eigen3-3.1.3

* Wed May 15 2013 Jerry James <loganjerry@gmail.com> - 2.12-6
- Require version of perl used to build (bz 963486)
- perl(Term::ReadLine::Gnu) dependency is not autogenerated (bz 963486)

* Wed Mar 20 2013 Jerry James <loganjerry@gmail.com> - 2.12-5
- Add -lrslib patch to fix a segfault (bz 923269)

* Wed Feb 27 2013 Jerry James <loganjerry@gmail.com> - 2.12-4
- Remove rpath and -L%%{_libdir} from polymake-config --ldflags output

* Thu Jan 24 2013 Jerry James <loganjerry@gmail.com> - 2.12-3
- Also need to filter perl(Graphviz)

* Wed Jan 23 2013 Jerry James <loganjerry@gmail.com> - 2.12-2
- Change -libs patch to also remove -rpath arguments
- Filter Provides/Requires to hide private perl interfaces
- Remove the broken check script and explain why

* Thu Jan 10 2013 Jerry James <loganjerry@gmail.com> - 2.12-1
- Initial RPM