Blob Blame History Raw
%bcond_without python
%bcond_without perl
%bcond_without ruby
%bcond_without octave
%bcond_without r
%bcond_without doc
%bcond_without check

%ifnarch s390 s390x %{arm} aarch64 ppc64 ppc64le
%bcond_without java
%bcond_without mono
%else
%bcond_with java
%bcond_with mono
%endif

# those have special requirements, the rest follows main package name
%global octpkg  SBML
%global perlpkg LibSBML
%global rubypkg SBML
%global rpkg    libSBML

%if %{with octave}
# Exclude .oct files from provides
%global __provides_exclude_from ^%{octpkglibdir}/.*\\.oct$
%endif

# Use the same directory of the main package for subpackage licence and docs
%global _docdir_fmt %{name}

Name:           libsbml
Version:        5.11.0
Release:        10%{?dist}
Summary:        Systems Biology Markup Language library

License:        LGPLv2+
URL:            http://sbml.org/Software/libSBML
Source0:        http://sourceforge.net/projects/sbml/files/libsbml/%{version}/stable/libSBML-%{version}-core-plus-packages-src.tar.gz
Source1:        http://sourceforge.net/projects/sbml/files/libsbml/%{version}/experimental/source/render-%{version}-beta-1.zip

## https://sourceforge.net/p/sbml/libsbml/392/
Patch0:         libsbml-trim-pc-file.patch
Patch1:         libsbml-use-system-minizip-cmake.patch
## https://sourceforge.net/p/sbml/libsbml/394/
Patch2:         libsbml_csharp-unexpected_symbol_error.patch
Patch3:         libsbml-fix_install_libpaths.patch
## https://sourceforge.net/p/sbml/libsbml/393/
Patch4:         libsbml-arm-fix.patch
## https://sourceforge.net/p/sbml/libsbml/399/
## https://sourceforge.net/p/sbml/libsbml/401/
Patch5:         libsbml-mark-arguments-to-easily-distinguish-the-ones-to-be-.patch
Patch6:         libsbml-these-typemaps-do-not-apply-to-java-C.patch

BuildRequires:  cmake
BuildRequires:  zlib-devel
BuildRequires:  bzip2-devel
BuildRequires:  libxml2-devel >= 2.6.16
BuildRequires:  check-devel
BuildRequires:  minizip-devel
BuildRequires:  swig
BuildRequires:  hostname

%description
LibSBML is an open-source programming library designed to
read, write, manipulate, translate, and validate SBML files and data
streams.  It is not an application itself (though it does come with
example programs), but rather a library you can embed in other
applications.

LibSBML %{version} understands SBML Level 3 Version 1 and older,
as well as the draft SBML Level 2 Layout proposal by Gauges, Rost,
Sahle and Wegner.  It’s written in ISO C and C++ but can also be
used from C#, Java, MATLAB, Octave, PERL, Python, and Ruby.

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

%description    devel
This package contains libraries and header files for developing
applications that use libSBML.

%if %{with python}
%package -n python-%{name}
BuildRequires:  python2-devel
Summary:        Python 2 bindings for libSBML
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n python-%{name}
This package contains %{summary}.

This is the version for Python 2.

%package -n python3-%{name}
BuildRequires:  python3-devel
Summary:        Python 3 bindings for libSBML
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n python3-%{name}
This package contains %{summary}.

This is the version for Python 3.
%endif

%if %{with perl}
%package -n perl-%{perlpkg}
BuildRequires:  perl(Test::More)
BuildRequires:  perl(ExtUtils::MakeMaker)
Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Summary:        PERL bindings for libSBML
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n perl-%{perlpkg}
This package contains %{summary}.
%endif

%if %{with ruby}
%package -n ruby-%{rubypkg}
BuildRequires:  ruby-devel
Requires:       ruby(release)
Requires:       %{name}%{?_isa} = %{version}-%{release}
Provides:       ruby(%{rubypkg}) = %{version}
Summary:        Ruby bindings for libSBML

%description -n ruby-%{rubypkg}
This package contains %{summary}.
%endif

%if %{with java}
%package -n java-%{name}
BuildRequires:  java-devel
Requires:       java-headless
Requires:       jpackage-utils
Requires:       %{name}%{?_isa} = %{version}-%{release}
Summary:        Java bindings for libSBML

%description -n java-%{name}
This package contains %{summary}.
%endif

%if %{with octave}
%package -n octave-%{octpkg}
BuildRequires:  octave-devel
Requires:       octave(api) = %{octave_api}
Requires(post): octave
Requires(postun): octave
Requires:       %{name}%{?_isa} = %{version}-%{release}
Summary:        Octave bindings for libSBML

%description -n octave-%{octpkg}
This package contains %{summary}.
%endif

%if %{with r}
%package -n R-%{rpkg}
BuildRequires:  R-devel
BuildRequires:  R-core-devel
BuildRequires:  tex(latex)
Requires:       R-core
Summary:        R bindings for libSBML
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n R-%{rpkg}
This package contains %{summary}.
%endif

%if %{with mono}
%package sharp
BuildRequires:  mono-core
BuildRequires:  xerces-c-devel, libxml2-devel, expat-devel
Summary:        C# bindings for libSBML
Requires:       mono-core
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description sharp
This package contains %{summary}.
%endif

%if %{with doc}
%package        doc
BuildRequires:  doxygen
BuildRequires:  doxygen-latex
BuildRequires:  graphviz
Summary:        API documentation for %{name}
Requires:       %{name} = %{version}-%{release}
Provides:       bundled(jquery)
BuildArch:      noarch

%description    doc
This package contains %{summary}.
%endif

%prep
%autosetup -n libSBML-%{version}-Source -p1

sed -i -r 's/DOXYGEN_MAX_VERSION=1\.8\.8/DOXYGEN_MAX_VERSION=1.8.9/' configure

unzip -n %{SOURCE1}

# https://sourceforge.net/p/sbml/libsbml/391
iconv -f latin1 -t utf8 NEWS.txt > t; touch -r NEWS.txt t; mv t NEWS.txt

# Fix invalid shebang
# https://sourceforge.net/p/sbml/libsbml/390
sed -i -r 's|(#!/usr/bin/env python) +#.*|#!%{__python2}|' docs/src/filters/doc-filter-python.py

# Delete bundled minizip
rm -v src/sbml/compress/{crypt.h,ioapi.*,iowin32.*,unzip.*,zip.*}

grep -e 'This file was automatically generated by SWIG' -r . -l|xargs rm

mkdir build-docs
cp -a $(/bin/ls -1|grep -v build-docs) build-docs/

%build
mkdir build2 build
pushd build2

export LDFLAGS="%{__global_ldflags} -Wl,--as-needed"
%if %{with python}
# This build is only for Python 2
%cmake -DENABLE_{LAYOUT,QUAL,COMP,FBC,RENDER}=ON \
       -DWITH_PYTHON=ON \
%if %{with check}
       -DWITH_CHECK=ON \
%endif
       -DPYTHON_INCLUDE_DIR:PATH=$(pkg-config --cflags python2|sed s/-I//) \
       -DPYTHON_LIBRARY:FILEPATH=$(pkg-config --libs python2) \
       -DPYTHON_EXECUTABLE:FILEPATH=%{__python2} \
       -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \
       -Wno-dev \
       ..
make
%endif

pushd ../build
%cmake -DENABLE_{LAYOUT,QUAL,COMP,FBC,RENDER}=ON \
%if %{with python}
       -DWITH_PYTHON=ON \
       -DPYTHON_INCLUDE_DIR:PATH=$(pkg-config --cflags python3|sed s/-I//) \
       -DPYTHON_LIBRARY:FILEPATH=$(pkg-config --libs python3) \
       -DPYTHON_EXECUTABLE:FILEPATH=%{__python3} \
%endif
%if %{with perl}
       -DWITH_PERL=ON \
%endif
%if %{with ruby}
       -DWITH_RUBY=ON \
%endif
%if %{with java}
       -DWITH_JAVA=ON \
       -DWITH_JAVASCRIPT:BOOL=OFF \
       -DWITH_SWIG:BOOL=ON \
%endif
%if %{with octave}
       -DWITH_OCTAVE=ON \
%endif
%if %{with octave}
       -DWITH_OCTAVE=ON \
%endif
%if %{with r}
       -DWITH_R=ON \
       -DR_INCLUDE_DIRS:PATH=%{_includedir}/R \
%endif
%if %{with mono}
       -DWITH_CSHARP:BOOL=ON \
       -DWITH_EXPAT:BOOL=OFF \
       -DWITH_XERCES:BOOL=OFF \
       -DWITH_LIBXML:BOOL=ON \
       -DWITH_SWIG:BOOL=ON \
%endif
%if %{with check}
       -DWITH_CHECK=ON \
%endif
       -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \
       -DCMAKE_BUILD_TYPE:STRING=Release \
       -DCMAKE_SKIP_RPATH:BOOL=YES \
       -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \
       -Wno-dev \
       ..
make

pushd ../build-docs
%configure --disable-static \
%if %{with doc}
           --with-doxygen \
%endif
%if %{with python}
           --with-python --with-python-interpreter=%{__python3} \
%endif
           --enable-layout --enable-comp --enable-fbc --enable-qual
%if %{with doc}
cp ../build/src/bindings/python/libsbml-doxygen.py src/bindings/python/
make %{?_smp_mflags} docs
%endif
make %{?_smp_mflags} libsbml.pc

%install
%if %{with python}
make -C build2 install DESTDIR=%{buildroot}
%endif
make -C build install DESTDIR=%{buildroot}

%if %{with octave}
chmod 0755 %{buildroot}%{octpkglibdir}/*.mex
%endif

%if %{with java}
mkdir -p %{buildroot}%{_libdir}/%{name} %{buildroot}%{_jnidir}
mv %{buildroot}%{_javadir}/libsbmlj.jar %{buildroot}%{_jnidir}/
mv %{buildroot}%{_libdir}/libsbmlj.so %{buildroot}%{_libdir}/%{name}/
%endif

%if %{with r}
mkdir -p %{buildroot}%{_libdir}/R/library
R CMD INSTALL -l %{buildroot}%{_libdir}/R/library build/src/bindings/r/%{rpkg}_%{version}_R_*.tar.gz
rm -rf %{buildroot}%{_libdir}/R/library/%{rpkg}/R.css
%endif

%if %{with doc}
make -C build-docs install-docs DESTDIR=%{buildroot}
mv %{buildroot}%{_pkgdocdir}-%{version} %{buildroot}%{_pkgdocdir}
%endif
make -C build-docs install-pc DESTDIR=%{buildroot}

%if %{with ruby}
install -Dm0644 src/bindings/ruby/README.txt %{buildroot}%{_pkgdocdir}/README-ruby.txt
%endif

%if %{with check}
%check
%if %{with python}
pushd build2
ctest -V %{?_smp_mflags}
popd
%endif
pushd build
ctest -V %{?_smp_mflags}
popd
%endif

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%license COPYING.txt
%doc AUTHORS.txt README.txt NEWS.txt OLD_NEWS.txt
%{_libdir}/*.so.*
##This directory provides just some txt documentation files
%exclude %{_datadir}/libsbml
%if %{with doc}
%exclude %{_pkgdocdir}/*-api
%endif

%files devel
%{_includedir}/sbml/
%{_libdir}/*.so
%exclude %{_libdir}/libsbml-static.a
%{_libdir}/pkgconfig/%{name}.pc

%if %{with python}
%license COPYING.txt
%files -n python-%{name}
#%%{python2_sitearch}/%%{name}*.egg-info
%{python2_sitearch}/%{name}.pth
%{python2_sitearch}/%{name}

%files -n python3-%{name}
%license COPYING.txt
#%%{python3_sitearch}/%%{name}*.egg-info
%{python3_sitearch}/%{name}.pth
%{python3_sitearch}/%{name}
%endif

%if %{with perl}
%files -n perl-%{perlpkg}
%license COPYING.txt
%{perl_vendorarch}/*
%exclude %dir %{perl_vendorarch}/auto/
%endif

%if %{with ruby}
%files -n ruby-%{rubypkg}
%license COPYING.txt
%doc %{_pkgdocdir}/README-ruby.txt
%{ruby_vendorarchdir}/*.so
%endif

%if %{with java}
%files -n java-%{name}
%license COPYING.txt
%{_jnidir}/libsbmlj.jar
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/libsbmlj.so
%endif

%if %{with octave}
%files -n octave-%{octpkg}
%license COPYING.txt
%{octpkglibdir}/
%endif

%if %{with r}
%files -n R-%{rpkg}
%license COPYING.txt
%{_libdir}/R/library/%{rpkg}/
%endif

%if %{with mono}
%files sharp
%license COPYING.txt
%{_monodir}/libsbmlcsP/
%endif

%if %{with doc}
%files doc
%{_pkgdocdir}/cpp-api
# Binding docs are here too, as a compromise. Making a separate
# python-libsbml-doc seems overkill, but including them in an arched
# package is not nice.
%{_pkgdocdir}/python-api
%endif


%changelog
* Fri Feb 06 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-10
- Rename -docs to -doc, run make unparallelized

* Wed Feb 04 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-9
- Apply upstream patch for arm test failures

* Tue Feb 03 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-8
- Fix things found in review (macro in comment, R:mono-core, %%doc
  duplication, macro usage)

* Mon Jan 26 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-7
- Allow newer doxygen

* Fri Jan 09 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-6
- Enable many many subpackages

* Tue Jan 06 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-5
- Unbundle minizip

* Wed Dec 17 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-4
- Do not build on arm

* Sat Dec 13 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-3
- Convert to hybrid cmake (main part) / make (docs).

* Fri Dec 12 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-2
- docs subpackage is no arch, remove %%{_isa} from dependency.

* Tue Dec 09 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.11.0-1
- Initial packaging.