Blob Blame History Raw
# Conditional for release and snapshot builds. Uncomment for release-builds.
#global rel_build				1

# Settings used for build from snapshots.
%{!?rel_build:%global commit			038280845fd7fb886f4459996f1405f8ca8c1612}
%{!?rel_build:%global commit_date		20160125}
%{!?rel_build:%global shortcommit		%(c=%{commit};echo ${c:0:7})}
%{!?rel_build:%global gitver			git%{commit_date}-%{shortcommit}}
%{!?rel_build:%global gitrel			.git%{commit_date}.%{shortcommit}}
%{!?rel_build:%global gittar			%{name}-%{version}-%{gitver}.tar.gz}

# This is needed, because src-url contains branched part of versioning-scheme.
%global branch					4.0

### Build configuration.
#
# Interfaces
%bcond_without	cli
%bcond_without	java
%bcond_without	lua

%ifarch %{mono_arches}
%bcond_without	mono
%else  # arch %%{mono_arches}
%bcond_with	mono
%endif # arch %%{mono_arches}

# Octave-bindings are failing on %%{arm} with "virtual memory exhausted:
# Operation not permitted", even when building single-threaded.  Retiring
# for now, until Koji-builders are on arm64-hardware. See rhbz# 1215737:
# https://bugzilla.redhat.com/show_bug.cgi?id=1215737

%ifnarch %{arm}
%bcond_without	octave
%else  # narch %%{arm}
%bcond_with	octave
%endif # narch %%{arm}

# Perl is not fully implemented by upstream, yet.  Disabling.
%bcond_with	perl
%bcond_without	python
#
# There's no Python3 on older distributions.
%if 0%{?fedora} >= 13 || 0%{?rhel} >= 8
%bcond_without	python3
%else  # 0%%{?fedora} >= 13 || 0%%{?rhel} >= 8
%bcond_with	python3
%endif # 0%%{?fedora} >= 13 || 0%%{?rhel} >= 8
#
%bcond_without	r
%bcond_without	ruby
#
# Configuration related to swig.
%bcond_without	reduce_swig_debug
%bcond_without	swig_single_threaded
#
# Testsuite is fully enabled.  Memtest is much too slow on %%arm.
%ifnarch %{arm}
%bcond_without	memtest
%else  # narch %{arm}
%bcond_with	memtest
%endif # narch %{arm}
%bcond_without	testsuite
#
# The doc-subpkg is noarch on Fedora and RHEL 6+.
#if 0%%{?fedora} >= 9 || 0%%{?rhel} >= 6
#bcond_without	noarch_doc
#else  # 0%%{?fedora} >= 9 || 0%%{?rhel} >= 6
#bcond_with	noarch_doc
#endif # 0%%{?fedora} >= 9 || 0%%{?rhel} >= 6
#
# For some reason docsubpkg differs on %%{arm}.
%bcond_with	noarch_doc
#
# Are licenses packaged using %%license?
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
%bcond_without	license_dir
%else  # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
%bcond_with	license_dir
%endif # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
#
# These are disabled by default.
#
# OpenCV-integration is crappy.
%bcond_with	opencv
#
# We cannot ship with build-in SVMlight, because of it's crappy license.
%bcond_with	svmlight

# This url is common for patches and snapshot builds.
%global giturl					https://github.com/%{name}-toolbox/%{name}/

# Filter all provides from bindings and private libs.
%global __provides_exclude_from			^(%{_libdir}/.*/.*%{name}\\.so|%{_libdir}/libmod%{name}.so)

# Do not check any files in docdir for Requires.
%global __requires_exclude_from			^%{_docdir}/.*$

# Turn off the brp-python-bytecompile script.  We don't want stuff in %%{_pkgdocdir} to be byte-compiled.
%global __os_install_post			%(echo '%{__os_install_post}' | %{__sed} -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')

# Setup _pkgdocdir if not defined already.
%{!?_pkgdocdir:%global _pkgdocdir		%{_docdir}/%{name}-%{version}}

# CMake-builds go out-of-tree.  Tests are not run in %%{buildroot}.
%global _cmake_build_subdir			build-%{?__isa}%{?dist}
%global _cmake_testinstall_dir			install-%{?__isa}%{?dist}

# Compiling the swig-generated bindings needs too much memory to build the
# the linker-objects in virtual memory for piping through different gcc
# instances, thus we use temporary files instead of pipes to pass the result.
%global optflags				%(echo '%{optflags}' | %{__sed} -e 's![ \t]*-pipe[ \t]*! !g')

# The description commonly used by all (sub-)packages.
%global common_description							\
The Shogun Machine learning toolbox provides a wide range of unified and	\
efficient Machine Learning (ML) methods.  The toolbox seamlessly allows to	\
easily combine multiple data representations, algorithm classes, and general	\
purpose tools.  This enables both rapid prototyping of data pipelines and	\
extensibility in terms of new algorithms.  We combine modern software		\
architecture in C++ with both efficient low-level computing backends and	\
cutting edge algorithm implementations to solve large-scale Machine Learning	\
problems (yet) on single machines.						\
										\
One of Shogun's most exciting features is that you can use the toolbox through	\
a unified interface from C++, Python(3), Octave, R, Java, Lua, etc.  This not	\
just means that we are independent of trends in computing languages, but it	\
also lets you use Shogun as a vehicle to expose your algorithm to multiple	\
communities.  We use SWIG to enable bidirectional communication between C++	\
and target languages.  Shogun runs under Linux/Unix, MacOS, Windows.		\
										\
Originally focussing on large-scale kernel methods and bioinformatics (for a	\
list of scientific papers mentioning Shogun, see here), the toolbox saw		\
massive extensions to other fields in recent years.  It now offers features	\
that span the whole space of Machine Learning methods, including many		\
classical methods in classification, regression, dimensionality reduction,	\
clustering, but also more advanced algorithm classes such as metric,		\
multi-task, structured output, and online learning, as well as feature		\
hashing, ensemble methods, and optimization, just to name a few.  Shogun in	\
addition contains a number of exclusive state-of-the art algorithms such as	\
a wealth of efficient SVM implementations, Multiple Kernel Learning, kernel	\
hypothesis testing, Krylov methods, etc.  All algorithms are supported by a	\
collection of general purpose methods for evaluation, parameter tuning,		\
preprocessing, serialisation & I/O, etc;  the resulting combinatorial		\
possibilities are huge.								\
										\
The wealth of ML open-source software allows us to offer bindings to other	\
sophisticated libraries including:  LibSVM, LibLinear, LibOCAS, libqp,		\
VowpalWabbit, Tapkee, SLEP, GPML and more.					\
										\
Shogun got initiated in 1999 by Soeren Sonnenburg and Gunnar Raetsch (that's	\
where the name ShoGun originates from).  It is now developed by a larger team	\
of authors, and would not have been possible without the patches and bug	\
reports by various people.  See contributions for a detailed list.  Statistics	\
on Shogun's development activity can be found on ohloh.

###############################################################################

Name:			shogun
Version:		%{branch}.1
Release:		0.9%{?gitrel}%{?dist}
Summary:		Large Scale Machine Learning Toolbox

# ===== License-breakdown =====
#
# GPLv3+
# ------
# * except the files explicitly named below
#
# BSD (2 clause)
# --------------
# src/shogun/classifier/GaussianProcessClassification.h				src/shogun/classifier/GaussianProcessClassification.cpp
# src/shogun/distributions/EMMixtureModel.cpp					src/shogun/distributions/KernelDensity.cpp
# src/shogun/distributions/MixtureModel.cpp					src/shogun/distributions/classical/GaussianDistribution.h
# src/shogun/distributions/DiscreteDistribution.h				src/shogun/distributions/EMBase.h
# src/shogun/distributions/EMMixtureModel.h					src/shogun/distributions/KernelDensity.h
# src/shogun/distributions/MixModelData.h					src/shogun/distributions/MixtureModel.h
# src/shogun/features/IndexFeatures.h						src/shogun/features/SubsetStack.cpp
# src/shogun/labels/MultilabelLabels.cpp					src/shogun/labels/MultilabelLabels.h
# src/shogun/lib/OpenCV/CV2SGFactory.cpp					src/shogun/lib/OpenCV/OpenCVTypeName.cpp
# src/shogun/lib/OpenCV/SG2CVFactory.cpp					src/shogun/lib/OpenCV/CV2SGFactory.h
# src/shogun/lib/OpenCV/OpenCVTypeName.h					src/shogun/lib/OpenCV/SG2CVFactory.h
# src/shogun/lib/external/shogun_libsvm.cpp					src/shogun/lib/external/shogun_libsvm.h
# src/shogun/loss/AbsoluteDeviationLoss.cpp					src/shogun/loss/ExponentialLoss.cpp
# src/shogun/loss/HuberLoss.cpp							src/shogun/loss/AbsoluteDeviationLoss.h
# src/shogun/loss/ExponentialLoss.h						src/shogun/loss/HuberLoss.h
# src/shogun/machine/GaussianProcessMachine.h					src/shogun/machine/StochasticGBMachine.cpp
# src/shogun/machine/RandomForest.h						src/shogun/machine/GaussianProcessMachine.cpp
# src/shogun/machine/RandomForest.cpp						src/shogun/machine/gp/ConstMean.cpp
# src/shogun/machine/gp/DualVariationalGaussianLikelihood.cpp			src/shogun/machine/gp/KLCholeskyInferenceMethod.cpp
# src/shogun/machine/gp/KLDualInferenceMethod.cpp				src/shogun/machine/gp/KLLowerTriangularInferenceMethod.h
# src/shogun/machine/gp/SingleLaplacianInferenceMethodWithLBFGS.h		src/shogun/machine/gp/LogitVGPiecewiseBoundLikelihood.h
# src/shogun/machine/gp/KLApproxDiagonalInferenceMethod.cpp			src/shogun/machine/gp/KLInferenceMethod.h
# src/shogun/machine/gp/SingleLaplacianInferenceMethodWithLBFGS.cpp		src/shogun/machine/gp/SoftMaxLikelihood.cpp
# src/shogun/machine/gp/SoftMaxLikelihood.h					src/shogun/machine/gp/LogitDVGLikelihood.cpp
# src/shogun/machine/gp/LogitVGLikelihood.cpp					src/shogun/machine/gp/LogitVGPiecewiseBoundLikelihood.cpp
# src/shogun/machine/gp/MatrixOperations.cpp					src/shogun/machine/gp/MatrixOperations.h
# src/shogun/machine/gp/NumericalVGLikelihood.cpp				src/shogun/machine/gp/ProbitVGLikelihood.cpp
# src/shogun/machine/gp/LogitDVGLikelihood.h					src/shogun/machine/gp/StudentsTVGLikelihood.cpp
# src/shogun/machine/gp/VariationalGaussianLikelihood.cpp			src/shogun/machine/gp/VariationalLikelihood.cpp
# src/shogun/machine/gp/StudentsTVGLikelihood.h					src/shogun/machine/gp/MultiLaplacianInferenceMethod.h
# src/shogun/machine/gp/ConstMean.h						src/shogun/machine/gp/DualVariationalGaussianLikelihood.h
# src/shogun/machine/gp/KLDualInferenceMethod.h					src/shogun/machine/gp/KLLowerTriangularInferenceMethod.cpp
# src/shogun/machine/gp/NumericalVGLikelihood.h					src/shogun/machine/gp/KLApproxDiagonalInferenceMethod.h
# src/shogun/machine/gp/KLCovarianceInferenceMethod.h				src/shogun/machine/gp/LogitVGLikelihood.h
# src/shogun/machine/gp/VariationalGaussianLikelihood.h				src/shogun/machine/gp/KLInferenceMethod.cpp
# src/shogun/machine/gp/LaplacianInferenceBase.h				src/shogun/machine/gp/ProbitVGLikelihood.h
# src/shogun/machine/gp/VariationalLikelihood.h					src/shogun/machine/gp/KLCovarianceInferenceMethod.cpp
# src/shogun/machine/gp/LaplacianInferenceBase.cpp				src/shogun/machine/gp/KLCholeskyInferenceMethod.h
# src/shogun/machine/gp/MultiLaplacianInferenceMethod.cpp			src/shogun/machine/StochasticGBMachine.h
# src/shogun/mathematics/linalg/internal/Block.h				src/shogun/mathematics/linalg/internal/implementation/Add.h
# src/shogun/mathematics/linalg/internal/implementation/Convolve.h		src/shogun/mathematics/linalg/internal/implementation/Dot.h
# src/shogun/mathematics/linalg/internal/implementation/ElementwiseProduct.h	src/shogun/mathematics/linalg/internal/implementation/ElementwiseSquare.h
# src/shogun/mathematics/linalg/internal/implementation/MatrixProduct.h		src/shogun/mathematics/linalg/internal/implementation/Max.h
# src/shogun/mathematics/linalg/internal/implementation/Scale.h			src/shogun/mathematics/linalg/internal/implementation/SetRowsConst.h
# src/shogun/mathematics/linalg/internal/implementation/SpecialPurpose.h	src/shogun/mathematics/linalg/internal/implementation/Sum.h
# src/shogun/mathematics/linalg/internal/implementation/VectorSum.h		src/shogun/mathematics/linalg/internal/modules/Core.h
# src/shogun/mathematics/linalg/internal/modules/Redux.h			src/shogun/mathematics/linalg/internal/modules/SpecialPurpose.h
# src/shogun/mathematics/linalg/internal/modules/Util.h				src/shogun/mathematics/linalg/linalg.h
# src/shogun/multiclass/tree/CHAIDTree.h					src/shogun/multiclass/tree/ID3ClassifierTree.h
# src/shogun/multiclass/tree/ID3TreeNodeData.h					src/shogun/multiclass/tree/KNNHeap.h
# src/shogun/multiclass/tree/NbodyTreeNodeData.h				src/shogun/multiclass/tree/TreeMachineNode.h
# src/shogun/multiclass/tree/BallTree.cpp					src/shogun/multiclass/tree/C45ClassifierTree.cpp
# src/shogun/multiclass/tree/CARTree.cpp					src/shogun/multiclass/tree/CHAIDTree.cpp
# src/shogun/multiclass/tree/ID3ClassifierTree.cpp				src/shogun/multiclass/tree/KDTree.cpp
# src/shogun/multiclass/tree/KNNHeap.cpp					src/shogun/multiclass/tree/NbodyTree.cpp
# src/shogun/multiclass/tree/RandomCARTree.cpp					src/shogun/multiclass/tree/BallTree.h
# src/shogun/multiclass/tree/BinaryTreeMachineNode.h				src/shogun/multiclass/tree/C45ClassifierTree.h
# src/shogun/multiclass/tree/C45TreeNodeData.h					src/shogun/multiclass/tree/CARTree.h
# src/shogun/multiclass/tree/CARTreeNodeData.h					src/shogun/multiclass/tree/CHAIDTreeNodeData.h
# src/shogun/multiclass/tree/KDTree.h						src/shogun/multiclass/tree/NbodyTree.h
# src/shogun/multiclass/tree/RandomCARTree.h					src/shogun/multiclass/tree/TreeMachine.h
# src/shogun/optimization/liblinear/shogun_liblinear.cpp			src/shogun/optimization/liblinear/shogun_liblinear.h
# src/shogun/preprocessor/BAHSIC.h						src/shogun/preprocessor/FeatureSelection.h
# src/shogun/preprocessor/KernelDependenceMaximization.h			src/shogun/preprocessor/DependenceMaximization.cpp
# src/shogun/preprocessor/DependenceMaximization.h				src/shogun/preprocessor/BAHSIC.cpp
# src/shogun/preprocessor/FeatureSelection.cpp					src/shogun/preprocessor/KernelDependenceMaximization.cpp
# src/shogun/statistics/HSIC.cpp						src/shogun/statistics/HypothesisTest.cpp
# src/shogun/statistics/IndependenceTest.cpp					src/shogun/statistics/KernelIndependenceTest.cpp
# src/shogun/statistics/KernelSelection.cpp					src/shogun/statistics/LinearTimeMMD.cpp
# src/shogun/statistics/MMDKernelSelection.cpp					src/shogun/statistics/HSIC.h
# src/shogun/statistics/HypothesisTest.h					src/shogun/statistics/IndependenceTest.h
# src/shogun/statistics/KernelIndependenceTest.h				src/shogun/statistics/KernelSelection.h
# src/shogun/statistics/LinearTimeMMD.h						src/shogun/statistics/MMDKernelSelection.h
# src/shogun/statistics/NOCCO.h							src/shogun/statistics/QuadraticTimeMMD.h
# src/shogun/statistics/TwoSampleTest.h						src/shogun/statistics/NOCCO.cpp
# src/shogun/statistics/QuadraticTimeMMD.cpp					src/shogun/statistics/StreamingMMD.cpp
# src/shogun/statistics/TwoSampleTest.cpp					src/shogun/statistics/StreamingMMD.h
#
# BSD (3 clause)
# --------------
# src/shogun/io/NeuralNetworkFileReader.cpp					src/shogun/io/NeuralNetworkFileReader.h
# src/shogun/lib/GPUMatrix.h							src/shogun/lib/GPUMatrix.cpp
# src/shogun/lib/GPUVector.cpp							src/shogun/lib/GPUVector.h
# src/shogun/mathematics/linalg/internal/opencl_config.h			src/shogun/mathematics/linalg/internal/opencl_util.h
# src/shogun/preprocessor/FisherLDA.h						src/shogun/preprocessor/FisherLDA.cpp
# src/shogun/neuralnets/Autoencoder.cpp						src/shogun/neuralnets/ConvolutionalFeatureMap.cpp
# src/shogun/neuralnets/DeepAutoencoder.cpp					src/shogun/neuralnets/DeepBeliefNetwork.cpp
# src/shogun/neuralnets/NeuralConvolutionalLayer.cpp				src/shogun/neuralnets/NeuralInputLayer.cpp
# src/shogun/neuralnets/NeuralLayer.cpp						src/shogun/neuralnets/NeuralLinearLayer.cpp
# src/shogun/neuralnets/NeuralLogisticLayer.cpp					src/shogun/neuralnets/NeuralRectifiedLinearLayer.cpp
# src/shogun/neuralnets/NeuralSoftmaxLayer.cpp					src/shogun/neuralnets/RBM.cpp
# src/shogun/neuralnets/Autoencoder.h						src/shogun/neuralnets/ConvolutionalFeatureMap.h
# src/shogun/neuralnets/DeepAutoencoder.h					src/shogun/neuralnets/DeepBeliefNetwork.h
# src/shogun/neuralnets/NeuralConvolutionalLayer.h				src/shogun/neuralnets/NeuralInputLayer.h
# src/shogun/neuralnets/NeuralLayer.h						src/shogun/neuralnets/NeuralLinearLayer.h
# src/shogun/neuralnets/NeuralLogisticLayer.h					src/shogun/neuralnets/NeuralNetwork.h
# src/shogun/neuralnets/NeuralRectifiedLinearLayer.h				src/shogun/neuralnets/NeuralSoftmaxLayer.h
# src/shogun/neuralnets/RBM.h							src/shogun/neuralnets/NeuralLayers.cpp
# src/shogun/neuralnets/NeuralLayers.h						src/shogun/neuralnets/NeuralNetwork.cpp
#
# GPLv2+
# ------
# src/shogun/lib/external/ssl.cpp						src/shogun/lib/external/ssl.h
# src/shogun/mathematics/munkres.cpp						src/shogun/mathematics/munkres.h
# src/shogun/structure/DynProg.cpp						src/shogun/transfer/multitask/MultitaskKernelMaskNormalizer.h
# src/shogun/transfer/multitask/MultitaskKernelMaskPairNormalizer.h		src/shogun/transfer/multitask/MultitaskKernelPlifNormalizer.h
# src/shogun/transfer/multitask/MultitaskKernelTreeNormalizer.h
#
# GPLv2+ or LGPLv2+
# -----------------
# src/shogun/multiclass/LaRank.cpp						src/shogun/multiclass/LaRank.h
#
# LGPLv2+
# -------
# src/shogun/classifier/svm/OnlineSVMSGD.cpp					src/shogun/classifier/svm/SGDQN.cpp
# src/shogun/classifier/svm/SVMSGD.cpp						src/shogun/classifier/svm/OnlineSVMSGD.h
# src/shogun/classifier/svm/SGDQN.h						src/shogun/classifier/svm/SVMSGD.h
#
# MIT/X11 (BSD like)
# ------------------
# src/shogun/optimization/lbfgs/lbfgs.cpp					src/shogun/optimization/lbfgs/lbfgs.h
#
License:		GPLv3+ and BSD and GPLv2+ and (GPLv2+ or LGPLv2+) and GPLv3 and LGPLv2+ and MIT and (Public Domain or GPLv3+)
URL:			http://%{name}-toolbox.org
# Sources for release-builds.
%{?rel_build:Source0:	%{url}/archives/%{name}/releases/%{branch}/sources/%{name}-%{version}.tar.bz2}
# Sources for snapshot-builds.
%{!?rel_build:Source0:	%{?giturl}archive/%{commit}.tar.gz#/%{gittar}}
Source1:		%{name}.pc.in
Source99:		http://googlemock.googlecode.com/files/gmock-1.7.0.zip

%if 0%{?rhel} && 0%{?rhel} <= 5
BuildRoot:		%(/bin/mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%endif # 0%%{?rhel} && 0%%{?rhel} <= 5

BuildRequires:		arpack-devel
BuildRequires:		arprec-devel
BuildRequires:		atlas-devel
BuildRequires:		blas-devel
BuildRequires:		bzip2-devel
BuildRequires:		chrpath
BuildRequires:		ColPack-devel
BuildRequires:		glpk-devel
BuildRequires:		hdf5-devel
BuildRequires:		iputils
BuildRequires:		json-c-devel
BuildRequires:		lapack-devel
BuildRequires:		libcurl-devel
BuildRequires:		libxml2-devel
BuildRequires:		lpsolve-devel
BuildRequires:		lzo-devel
BuildRequires:		NLopt-devel
BuildRequires:		ocl-icd-devel
BuildRequires:		opencl-headers
BuildRequires:		opencv-devel
BuildRequires:		protobuf-devel
BuildRequires:		qd-devel
BuildRequires:		%{name}-data
BuildRequires:		snappy-devel
BuildRequires:		tapkee-devel
BuildRequires:		xz-devel
BuildRequires:		zlib-devel

%if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires:		cmake
BuildRequires:		eigen3-devel
BuildRequires:		swig
%else  # 0%%{?fedora} || 0%%{?rhel} >= 7
BuildRequires:		cmake28
BuildRequires:		eigen32-devel
BuildRequires:		swig2
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7

# Needed for testsuite.
BuildRequires:		gdb
BuildRequires:		valgrind

%if !%{with mono}
Obsoletes:		mono-%{name}		<= %{version}-%{release}
Obsoletes:		mono-%{name}%{?_isa}	<= %{version}-%{release}
%endif # !%%{with mono}

# Retiring octave-shogun on %%{arm}.  See above.
%if (0%{?fedora} && 0%{?fedora} <= 26) && !%{with octave}
Obsoletes:		octave-%{name}		<= %{version}-%{release}
Obsoletes:		octave-%{name}%{?_isa}	<= %{version}-%{release}
%endif # (0%%{?fedora} && 0%%{?fedora} <= 26) && !%%{with octave}

# Copylib - Wildcard-exception granted by FPC.
# See: https://fedorahosted.org/fpc/ticket/174
Provides:		bundled(dSFMT)
Provides:		bundled(gnulib)
Provides:		bundled(liblinear)
Provides:		bundled(libsvm)
Provides:		bundled(SFMT)
Provides:		bundled(SVMlin)


%description
%{?common_description}


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

%files
%doc %dir %{_pkgdocdir}
%if %{with license_dir}
%license COPYING
%else  # %%{with license_dir}
%doc %{_pkgdocdir}/COPYING
%endif # %%{with license_dir}
%doc %{_pkgdocdir}/README.md
%{_libdir}/lib%{name}.so.*

###############################################################################

%if %{with cli}
%package cli

Summary:		CLI-interface for %{name}

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


%description cli
This package contains the CLI-interface for %{name}.

%{?common_description}


%files cli
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/cmdline_static
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/README.txt
%{_bindir}/%{name}
%endif # %%{with cli}

###############################################################################

%package devel

Summary:		Development files for %{name}

Requires:		arpack-devel%{?_isa}
Requires:		arprec-devel%{?_isa}
Requires:		atlas-devel%{?_isa}
Requires:		blas-devel%{?_isa}
Requires:		bzip2-devel%{?_isa}
Requires:		ColPack-devel%{?_isa}
Requires:		eigen3-devel
Requires:		glpk-devel%{?_isa}
Requires:		hdf5-devel%{?_isa}
Requires:		json-c-devel%{?_isa}
Requires:		lapack-devel%{?_isa}
Requires:		libcurl-devel%{?_isa}
Requires:		libxml2-devel%{?_isa}
Requires:		lpsolve-devel%{?_isa}
Requires:		lzo-devel%{?_isa}
Requires:		NLopt-devel%{?_isa}
Requires:		opencv-devel%{?_isa}
Requires:		qd-devel%{?_isa}
Requires:		snappy-devel%{?_isa}
Requires:		tapkee-devel
Requires:		xz-devel%{?_isa}
Requires:		zlib-devel%{?_isa}
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description devel
This package contains files needed for development with %{name}.

%{?common_description}


%files devel
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/lib%{name}
%doc %{_pkgdocdir}/examples/README.txt
%doc %{_pkgdocdir}/NEWS
%doc %{_pkgdocdir}/OpenCV_docs
%if %{with memtest}
%doc %{_pkgdocdir}/mem.%{?__isa}%{?dist}.log
%endif # %%{with memtest}
%if %{with testsuite}
%doc %{_pkgdocdir}/unit.%{?__isa}%{?dist}.log
%if %{with python3}
%doc %{_pkgdocdir}/unit.py3.%{?__isa}%{?dist}.log
%endif # %%{with python3}
%endif # %%{with testsuite}
%{_includedir}/%{name}-%{version}
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

###############################################################################

%package doc
Summary:		Documentation files for %{name}

%if %{with noarch_doc}
BuildArch:		noarch
%endif # %%{with noarch_doc}

BuildRequires:		doxygen
BuildRequires:		graphviz
BuildRequires:		hardlink


%description doc
This package contains very detailed documentation,
and some great examples for %{name}.

If you need the Chinese API-docs, you would want to install
%{name}-doc-cn, too.

%{?common_description}


%files doc
%doc %dir %{_pkgdocdir}
%doc %exclude %{_pkgdocdir}/html_cn
%doc %exclude %{_pkgdocdir}/*.%{?__isa}%{?dist}.log
%doc %{_pkgdocdir}/*
%if %{with license_dir}
%license %{_datadir}/licenses/%{name}
%endif # %%{with license_dir}

###############################################################################

%package doc-cn

Summary:		Documentation files for %{name} in Chinese language
Requires:		%{name}-doc		== %{version}-%{release}

%if %{with noarch_doc}
BuildArch:		noarch
%endif # %%{with noarch_doc}


%description doc-cn
This package contains the documentation files for %{name} in Chinese
language.

%{?common_description}


%files doc-cn
%doc %dir %{_pkgdocdir}
%doc %{_pkgdocdir}/html_cn

###############################################################################

%if %{with java}
%package -n java-%{name}
Summary:		Java-plugin for %{name}

BuildRequires:		java-devel
BuildRequires:		jblas

Requires:		%{_sysconfdir}/profile.d

%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
Requires:		java-headless
%else  # 0%%{?fedora} >= 20 || 0%%{?rhel} >= 7
Requires:		java
%endif # 0%%{?fedora} >= 20 || 0%%{?rhel} >= 7

Requires:		jblas%{?_isa}
Requires:		jpackage-utils
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n java-%{name}
This package contains the Java-plugin for %{name}.

%{?common_description}


%files -n java-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/java_modular
%doc %{_pkgdocdir}/examples/README.txt
%{_jnidir}/*
%{_libdir}/%{name}.java
%{_sysconfdir}/profile.d/%{name}-java.*sh
%endif # %%{with java}

###############################################################################

%if %{with lua}
%package -n lua-%{name}
# http://fedoraproject.org/wiki/PackagingDrafts/Lua
%{!?lua_ver: %global lua_ver			%(%{_bindir}/lua -e 'print(string.sub(_VERSION, 5))' || echo 0)}
%global lualibdir				%{_libdir}/lua/%{lua_ver}
%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8
%global luanext					5.4
%endif # 0%%{?fedora} >= 22 || 0%%{?rhel} >= 8
%if (0%{?fedora} >= 20 && 0%{?fedora} <= 21)
%global luanext					5.3
%endif # (0%%{?fedora} >= 20 && 0%%{?fedora} <= 21)
%if (0%{?fedora} && 0%{?fedora} <= 19) || (0%{?rhel} && 0%{?rhel} <= 7)
%global luanext					5.2
%endif # (0%%{?fedora} && 0%%{?fedora} <= 19) || (0%%{?rhel} && 0%%{?rhel} <= 7)

Summary:		LUA-plugin for %{name}

BuildRequires:		lua-devel

Requires:		lua%{?_isa}
%if 0%{?fedora} || 0%{?rhel} >= 7
Requires:		lua(abi)		== %{lua_ver}
%else  # 0%%{?fedora} || 0%%{?rhel} >= 7
Requires:		lua			>= %{lua_ver}
Requires:		lua			<  %{luanext}
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n lua-%{name}
This package contains the LUA-plugin for %{name}.

%{?common_description}


%files -n lua-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/lua_modular
%doc %{_pkgdocdir}/examples/README.txt
%{lualibdir}/libmod%{name}.so
%endif # %%{with lua}

###############################################################################

%if %{with mono}
%package -n mono-%{name}
Summary:		Mono(C#)-plugin for %{name}

# On fc23+ we build against Mono >= 4.0.0.
%if 0%{?fedora} >= 23
BuildRequires:		mono-devel		>= 4.0.0
%else #  0%%{?fedora} >= 23
BuildRequires:		mono-devel
%endif # 0%%{?fedora} >= 23

Requires:		%{_sysconfdir}/profile.d
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n mono-%{name}
This package contains the Mono(C#)-plugin for %{name}.

%{?common_description}


%files -n mono-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/csharp_modular
%doc %{_pkgdocdir}/examples/README.txt
%{_libdir}/%{name}.mono
%{_sysconfdir}/profile.d/%{name}-mono.*sh
%endif # %%{with mono}

###############################################################################

%if %{with octave}
%package -n octave-%{name}
# https://fedoraproject.org/wiki/Packaging:Octave
%{!?octave_api:		%global octave_api	%(%{_bindir}/octave-config -p API_VERSION || echo 0)}
%global octave_octdir				%(%{_bindir}/octave-config -p LOCALAPIOCTFILEDIR || echo '')

Summary:		Octave-plugin for %{name}

BuildRequires:		octave-devel

Requires:		octave%{?_isa}		>= 3.6
Requires:		octave(api)		== %{octave_api}
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n octave-%{name}
This package contains the Octave-plugin for %{name}.

%{?common_description}


%files -n octave-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/matlab_and_octave
%doc %{_pkgdocdir}/examples/octave_modular
%doc %{_pkgdocdir}/examples/README.txt
%{octave_octdir}/%{name}
%endif # %%{with octave}

###############################################################################

%if %{with perl}
%package -n perl-%{name}
Summary:		Perl-plugin for %{name}

BuildRequires:		perl-devel

Requires:		perl%{?_isa}
Requires:		perl(:MODULE_COMPAT_%(eval "$(%{__perl} -V:version)"; echo $version))
Requires:		%{name}%{?_isa}		=  %{version}-%{release}


%description -n perl-%{name}
This package contains the Perl-plugin for %{name}.

%{?common_description}


%files -n perl-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/perl_modular
%doc %{_pkgdocdir}/examples/README.txt
%{perl_vendorarch}/*
%exclude %dir %{perl_vendorarch}/auto
%endif # %%{with perl}

###############################################################################

%if %{with python}
%if (0%{?fedora} >= 24) || (0%{?rhel} >= 8)
%package -n python2-%{name}
%else  # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
%package -n python-%{name}
%endif # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
%{!?__python2: %global __python2		%{__python27}}
%{!?python2_sitearch: %global python2_sitearch	%{python27_sitearch}}
%{!?python2_ver: %global python2_ver		%(%{__python2} -c 'import platform; print platform.python_version();' || echo 0)}

Summary:		Python-plugin for %{name}

%if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires:		numpy
BuildRequires:		python-docutils
BuildRequires:		python-jinja2
BuildRequires:		python2-devel
BuildRequires:		scipy

Requires:		numpy%{?_isa}
Requires:		python%{?_isa}
Requires:		scipy%{?_isa}
%else  # 0%%{?fedora} || 0%%{?rhel} >= 7
BuildRequires:		python27-numpy
BuildRequires:		python27-docutils
BuildRequires:		python27-jinja2
BuildRequires:		python27-devel

Requires:		python27%{?_isa}
Requires:		python27-numpy%{?_isa}
Requires:		python27-scipy%{?_isa}
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7

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

%if (0%{?fedora} >= 24 && 0%{?fedora} <= 28) || (0%{?rhel} >= 8 && 0%{?rhel} <= 11)
Provides:		python-%{name}		== %{version}-%{release}
Provides:		python-%{name}%{?_isa}	== %{version}-%{release}
Obsoletes:		python-%{name}		<= 4.0.1-0.4
%endif # (0%%{?fedora} >= 24 && 0%%{?fedora} <= 28) || (0%%{?rhel} >= 8 && 0%%{?rhel} <= 11)


%if (0%{?fedora} >= 24) || (0%{?rhel} >= 8)
%description -n python2-%{name}
%else  # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
%description -n python-%{name}
%endif # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
This package contains the Python-plugin for %{name}.

%{?common_description}


%if (0%{?fedora} >= 24) || (0%{?rhel} >= 8)
%files -n python2-%{name}
%else  # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
%files -n python-%{name}
%endif # (0%%{?fedora} >= 24) || (0%%{?rhel} >= 8)
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/python_modular
%doc %{_pkgdocdir}/examples/README.txt
%doc %{_pkgdocdir}/ipython-notebooks
%{python2_sitearch}/*
%endif # %%{with python}

###############################################################################

%if %{with python3}
%package -n python3-%{name}
Summary:		Python-plugin for %{name}

BuildRequires:		python3-devel
BuildRequires:		python3-docutils
BuildRequires:		python3-jinja2
BuildRequires:		python3-numpy
BuildRequires:		python3-scipy

Requires:		python3%{?_isa}
Requires:		python3-numpy%{?_isa}
Requires:		python3-scipy%{?_isa}
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n python3-%{name}
This package contains the Python3-plugin for %{name}.

%{?common_description}


%files -n python3-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/python_modular
%doc %{_pkgdocdir}/examples/README.txt
%doc %{_pkgdocdir}/ipython-notebooks
%{python3_sitearch}/*
%endif # %%{with python3}

###############################################################################

%if %{with r}
%package -n R-%{name}
Summary:		R-plugin for %{name}

BuildRequires:		R-core-devel

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


%description -n R-%{name}
This package contains the R-plugin for %{name}.

%{?common_description}


%files -n R-%{name}
%dir %{_libdir}/R/library/%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_libdir}/R/library/%{name}/DESCRIPTION
%doc %{_libdir}/R/library/%{name}/demo
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/r_modular
%doc %{_pkgdocdir}/examples/README.txt
%{_libdir}/R/library/%{name}/libs
%{_libdir}/R/library/%{name}/Meta
%{_libdir}/R/library/%{name}/NAMESPACE
%{_libdir}/R/library/%{name}/R
%endif # %%{with r}

###############################################################################

%if %{with ruby}
%package -n ruby-%{name}
# For compatibility with RHEL <= 6.
%{!?ruby_vendorlibdir: %global ruby_vendorlibdir	%(%{_bindir}/ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")}
%{!?ruby_vendorarchdir:	%global ruby_vendorarchdir	%(%{_bindir}/ruby -rrbconfig -e "puts RbConfig::CONFIG['sitearchdir']")}

# We need to pass the path for rubygem(narray) to CMake, so it can find it.
%global narray_gem					%(%{_bindir}/gem list narray | %{__grep} narray | %{__sed} -e's! .!-!' -e 's!.$!!')

%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
%global narray_include					%{_libdir}/gems/ruby/%{narray_gem}
%else  # 0%{?fedora} >= 21 || 0%{?rhel} >= 8
%global narray_include					%{_datadir}/gems/gems/%{narray_gem}
%endif # 0%{?fedora} >= 21 || 0%{?rhel} >= 8

%if 0%{?fedora} || 0%{?rhel} >= 7
%global narray_lib					%{_libdir}/gems/ruby/%{narray_gem}/narray.so
%else  # 0%{?fedora} || 0%{?rhel} >= 7
%global narray_lib					%{ruby_vendorarchdir}/narray.so
%endif # 0%{?fedora} || 0%{?rhel} >= 7

Summary:		Ruby-plugin for %{name}

BuildRequires:		ruby-devel
BuildRequires:		rubygem-narray-devel

%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
Requires:		ruby(release)
%else  # 0%%{?fedora} >= 19 || 0%%{?rhel} >= 7
Requires:		ruby(abi)		== %{?rhel:1.8}%{!?rhel:1.9.1}
%endif # 0%%{?fedora} >= 19 || 0%%{?rhel} >= 7
Requires:		rubygem(narray)%{?_isa}
Requires:		%{name}%{?_isa}		== %{version}-%{release}


%description -n ruby-%{name}
This package contains the Ruby-plugin for %{name}.

%{?common_description}


%files -n ruby-%{name}
%doc %dir %{_pkgdocdir}
%doc %dir %{_pkgdocdir}/examples
%doc %{_pkgdocdir}/examples/data
%doc %{_pkgdocdir}/examples/README.txt
%doc %{_pkgdocdir}/examples/ruby_modular
%{ruby_vendorarchdir}/mod%{name}.rb
%{ruby_vendorarchdir}/mod%{name}.so
%endif # %%{with ruby}

###############################################################################

%prep
# Get amount of avail RAM.
%{__cat} /proc/meminfo

# Unpack sources.
%setup -q%{!?rel_build:n %{name}-%{commit}}

# Apply patches.

# Remove cluttering stuff and create some needed dirs.
%{__rm} -rf %{py3dir} %{_cmake_build_subdir} build data doc/tutorial third_party
%{__mkdir} -p %{_cmake_build_subdir} third_party/GoogleMock

# Scrub SVMlight.
%if !%{with svmlight}
./scripts/light-scrubber.sh
%endif # !%%{with svmlight}

# Unbundle Tapkee.  This is pretty the same as we have in our repos.
%{__rm} -rf doc/md/LICENSE_tapkee.md
pushd src/%{name}/lib/tapkee
for _needed_sources in tapkee_%{name}.*
do
  %{__sed} -e 's!<%{name}/lib/!<!g'						\
	-e 's!tapkee/tapkee_%{name}.hpp>$!%{name}/lib/&!g'			\
	-e 's!config.h>$!%{name}/lib/&!g'					\
	< ${_needed_sources} > ${_needed_sources}.mod  &&			\
  /bin/touch -r ${_needed_sources} ${_needed_sources}.mod
done
%{__rm} -rf */ *.{cpp,h,hpp}
for _needed_sources in tapkee_%{name}.*
do
  %{__mv} ${_needed_sources} $(echo ${_needed_sources} | %{__sed} -e 's!\.mod$!!g')
done
popd

# Fix testsuite invocation for C#/Mono plugin.
%{__sed} -i -e 's!\${CSHARP_INTERPRETER}!%(which mono)!g'			\
	examples/undocumented/csharp_modular/CMakeLists.txt

# Fix finding PerlLibs and linking against HDF5.
%{__sed} -i -e 's!FindPerlLibs REQUIRED!PerlLibs REQUIRED!'			\
	-e '/SET.HDF5_LIBRARIES/d'						\
	CMakeLists.txt

# Ruby-plugins go to %%{ruby_vendorarchdir}, but on <= el6.
%if 0%{?fedora} >= 13 || 0%{?rhel} >= 7
%{__sed} -i -e 's!\${RUBY_SITE_ARCH_DIR}!\${RUBY_VENDORARCH_DIR}!g'		\
	src/interfaces/ruby_modular/CMakeLists.txt
%endif # 0%%{?fedora} >= 13 || 0%%{?rhel} >= 7

# Fix testsuite environment for Ruby.
%{__sed} -i -e 's!\${NARRAY_PATH}!%{narray_include}:&!'				\
	examples/undocumented/ruby_modular/CMakeLists.txt

# Copy the other sources into tree.
%{__install} -pm 0644 %{SOURCE99} third_party/GoogleMock

%if %{with python3}
# Copy all stuff into %%{py3dir} for the Python3-build.
%{__cp} -a . %{py3dir}
ln -fs $(/bin/pwd)/data %{py3dir}/data
%endif # %%{with python3}

# Copy data into proper location.
%{__cp} -a %{_shogun_data_dir} data

###############################################################################

%build
# These will be used for creation of CTest-files, only.  There's no impact on
# the built binaries caused by them.  They are needed to be defined on %%build,
# because CMake hardcodes them when creating the Makefiles and it's cache.

# We need to export a customized PYTHONPATH for testsuite.
export PYTHONPATH="${PYTHONPATH}:$(/bin/pwd)/%{_cmake_testinstall_dir}/%{python2_sitearch}/%{name}"
export PYTHONPATH="${PYTHONPATH}:$(/bin/pwd)/%{_cmake_testinstall_dir}/%{python2_sitearch}"
export PYTHONPATH="${PYTHONPATH}:$(/bin/pwd)/examples/undocumented/python_modular"
export PYTHONPATH="${PYTHONPATH}:%{python2_sitearch}:%{python2_sitelib}"

# We need to export a customized R_LIBS_USER for testsuite.
export R_LIBS_USER="${R_LIBS_USER}:$(/bin/pwd)/%{_cmake_testinstall_dir}%{_libdir}/R/library"

# We need to export some custom LD_LIBRARY_PATH for the tests, too.
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(/bin/pwd)/%{_cmake_testinstall_dir}/%{_libdir}"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:%{_libdir}/atlas"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:%{_libdir}"

pushd %{_cmake_build_subdir}
%cmake										\
	-DCMAKE_BUILD_TYPE=DISTRIBUTION						\
%ifarch %{ix86}
	-DDISABLE_SSE=ON							\
%endif # arch %%{ix86}
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
	-DATLAS_LAPACK="%{_libdir}/atlas/libtatlas.so"				\
	-DATLAS_LIBRARIES="%{_libdir}/atlas/libtatlas.so"			\
%else  # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
	-DUSE_ORIGINAL_LAPACK=ON						\
%endif # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
%if %{with cli}
	-DCmdLineStatic=ON							\
%endif # %%{with cli}
%if %{with java}
	-DJavaModular=ON							\
%endif # %%{with java}
%if %{with lua}
	-DLuaModular=ON								\
%endif # %%{with lua}
%if %{with mono}
	-DCSharpModular=ON							\
%endif # %%{with mono}
%if %{with octave}
	-DOctaveModular=ON							\
%endif # %%{with octave}
%if %{with opencv}
	-DOpenCV=ON								\
%endif # %%{with opencv}
%if %{with perl}
	-DPerlModular=ON							\
%endif # %%{with perl}
%if %{with python}
	-DPythonModular=ON							\
%endif # %%{with python}
%if %{with r}
	-DRModular=ON								\
%endif # %%{with r}
%if %{with reduce_swig_debug}
	-DREDUCE_SWIG_DEBUG=ON							\
%endif # %%{with reduce_swig_debug}
%if %{with ruby}
	-DRUBY_NARRAY_INCLUDE_DIR="%{narray_include}"				\
	-DRUBY_NARRAY_LIBRARY="%{narray_lib}"					\
	-DRubyModular=ON							\
%endif # %%{with ruby}
%if %{with swig_single_threaded}
	-DSWIG_SINGLE_THREADED=ON						\
%endif # %%{with swig_single_threaded}
%if !%{with svmlight}
	-DUSE_SVMLIGHT=OFF							\
%endif # !%%{with svmlight}
%if %{with testsuite}
	-DBUILD_DASHBOARD_REPORTS=ON						\
	-DENABLE_PYTHON_DEBUG=ON						\
	-DENABLE_TESTING=ON							\
%endif # %%{with testsuite}
	-DENABLE_CCACHE=OFF							\
	-DPYTHON_EXECUTABLE="%{__python2}"					\
	..

# Build needs to be single-threaded because of high memory consumption, when
# building the swig-generated bindings.
%{__make} %{?_smp_mflags}
popd

# Build the Python3-version.
%if %{with python3}
export PYTHONPATH="$(/bin/pwd)/%{_cmake_testinstall_dir}/%{python3_sitearch}/%{name}"
export PYTHONPATH="${PYTHONPATH}:$(/bin/pwd)/%{_cmake_testinstall_dir}/%{python3_sitearch}"
export PYTHONPATH="${PYTHONPATH}:$(/bin/pwd)/examples/undocumented/python_modular"
export PYTHONPATH="${PYTHONPATH}:%{python3_sitearch}:%{python3_sitelib}"

pushd %{py3dir}/%{_cmake_build_subdir}
%cmake										\
	-DCMAKE_BUILD_TYPE=DISTRIBUTION						\
%ifarch %{ix86}
	-DDISABLE_SSE=ON							\
%endif # arch %%{ix86}
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
	-DATLAS_LAPACK=%{_libdir}/atlas/libtatlas.so				\
	-DATLAS_LIBRARIES=%{_libdir}/atlas/libtatlas.so				\
%else  # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
	-DUSE_ORIGINAL_LAPACK=ON						\
%endif # 0%%{?fedora} >= 21 || 0%%{?rhel} >= 8
%if %{with opencv}
	-DOpenCV=ON								\
%endif # %%{with opencv}
%if %{with reduce_swig_debug}
	-DREDUCE_SWIG_DEBUG=ON							\
%endif # %%{with reduce_swig_debug}
%if !%{with svmlight}
	-DUSE_SVMLIGHT=OFF							\
%endif # !%%{with svmlight}
%if %{with testsuite}
	-DBUILD_DASHBOARD_REPORTS=ON						\
	-DENABLE_PYTHON_DEBUG=ON						\
	-DENABLE_TESTING=ON							\
%endif # %%{with testsuite}
	-DBUNDLE_EIGEN=OFF							\
	-DBUNDLE_NLOPT=OFF							\
	-DBUNDLE_JSON=OFF							\
	-DENABLE_CCACHE=OFF							\
	-DPythonModular=ON							\
	-DPYTHON_EXECUTABLE=%{__python3}					\
	..

%{__make} %{?_smp_mflags}
popd
%endif # %%{with python3}

# Building the autodocs.
pushd %{_cmake_build_subdir}
%{__make} doc
popd

###############################################################################

%install
%if 0%{?rhel} && 0%{?rhel} <= 5
%{__rm} -rf %{buildroot}
%endif # 0%%{?rhel} && 0%%{?rhel} <= 5

# We install to custom location first.  This will be needed by testsuite, too.
export CUSTOM_INSTALL_DIR="$(/bin/pwd)/%{_cmake_testinstall_dir}/"
# Install the Python3-version first.
%if %{with python3}
pushd %{py3dir}/%{_cmake_build_subdir}
%{__make} install DESTDIR=${CUSTOM_INSTALL_DIR} %{?_smp_mflags}
popd

# Remove the installed headers and libshogun.so
%{__rm} -rf  ${CUSTOM_INSTALL_DIR}%{_includedir}				\
	${CUSTOM_INSTALL_DIR}%{_libdir}/lib%{name}.so*
%endif # %%{with python3}

pushd %{_cmake_build_subdir}
%{__make} install DESTDIR=${CUSTOM_INSTALL_DIR} %{?_smp_mflags}
popd

# Move headers in versioned-subdir to avoid collisions.
%{__mkdir} -p ${CUSTOM_INSTALL_DIR}%{_includedir}/%{name}-%{version}
%{__mv} ${CUSTOM_INSTALL_DIR}%{_includedir}/%{name}				\
	${CUSTOM_INSTALL_DIR}%{_includedir}/%{name}-%{version}

%if %{with java}
# Move Java-bindings to proper location.
%{__mkdir} -p ${CUSTOM_INSTALL_DIR}%{_libdir}/%{name}.java			\
	${CUSTOM_INSTALL_DIR}%{_jnidir}						\
	${CUSTOM_INSTALL_DIR}%{_sysconfdir}/profile.d/
%{__mv} ${CUSTOM_INSTALL_DIR}%{_prefix}/lib/jni/libmod%{name}.so		\
	${CUSTOM_INSTALL_DIR}%{_libdir}/%{name}.java
%{__mv} ${CUSTOM_INSTALL_DIR}%{_javadir}/*.jar ${CUSTOM_INSTALL_DIR}%{_jnidir}

# Setup CLASSPATH-environment.
%{__cat} << EOF >> ${CUSTOM_INSTALL_DIR}%{_sysconfdir}/profile.d/%{name}-java.sh
CLASSPATH="${CLASSPATH}:%{_jnidir}/%{name}.jar"
CLASSPATH="${CLASSPATH}:%{_libdir}/%{name}.java/libmod%{name}.so"
export CLASSPATH
EOF

%{__cat} << EOF >> ${CUSTOM_INSTALL_DIR}%{_sysconfdir}/profile.d/%{name}-java.csh
set JCP_TEMP = getenv('CLASSPATH')
set JCP_TEMP = "$JCP_TEMP:%{_jnidir}/%{name}.jar"
set JCP_TEMP = "$JCP_TEMP:%{_libdir}/%{name}.java/libmod%{name}.so"
setenv CLASSPATH "$JCP_TEMP"
EOF
%endif # %%{with java}

%if %{with mono}
# Move Mono(C#)-bindings to the proper location.
%{__mkdir} -p ${CUSTOM_INSTALL_DIR}%{_libdir}/%{name}.mono
%{__mv} ${CUSTOM_INSTALL_DIR}%{_prefix}/lib/cli/%{name}/*mod%{name}*		\
	${CUSTOM_INSTALL_DIR}%{_libdir}/%{name}.mono

# Setup MONO_PATH-environment.
%{__cat} << EOF >> ${CUSTOM_INSTALL_DIR}%{_sysconfdir}/profile.d/%{name}-mono.sh
MONO_PATH="${MONO_PATH}:%{_libdir}/%{name}.mono"
export MONO_PATH
EOF

%{__cat} << EOF >> ${CUSTOM_INSTALL_DIR}%{_sysconfdir}/profile.d/%{name}-mono.csh
set MP_TEMP = getenv('MONO_PATH')
set MP_TEMP = "$MP_TEMP:%{_libdir}/%{name}.mono"
setenv MONO_PATH "$MP_TEMP"
EOF
%endif # %%{with mono}

# Fix-up the permissions for some plugins.
%{_bindir}/find ${CUSTOM_INSTALL_DIR} -depth -type f -name '*.so' -print0 |	\
	%{_bindir}/xargs -0 chmod -cf 0755

# Copy the custom installation to %%{buildroot} for having an installed
# version with rpaths preserved for the testsuite.
%{__cp} -a ${CUSTOM_INSTALL_DIR}/. %{buildroot}

# Kill rpath from binaries.
%{_bindir}/find %{buildroot}%{_libdir} -depth -type f -perm 0755 -print0 |	\
	%{_bindir}/xargs -0 chrpath -d -k
%{_bindir}/find %{buildroot}%{_bindir} -depth -type f -perm 0755 -print0 |	\
	%{_bindir}/xargs -0 chrpath -d -k

# Copy examples to keep them prestine.  Testsuite will clutter them.
%{__mkdir} -p doc/examples
%{__cp} -a examples/documented/* doc/examples

# Create a working symlink to sample-data.
/bin/unlink doc/examples/data
/bin/ln -fs %{_datadir}/%{name}/data/toy doc/examples/data

# Remove unneeded examples and clutter.
%{_bindir}/find doc/examples -maxdepth 1 -name '*static' -print0 |		\
	%{__grep} -zv 'cmd' | %{_bindir}/xargs -0 %{__rm} -rf
%{_bindir}/find doc/examples -name '.rubygems' -print0 |			\
	%{_bindir}/xargs -0 %{__rm} -rf

# Install documentation-files to %%{_pkgdocdir}
%{__mkdir} -p %{buildroot}%{_pkgdocdir}
%{__cp} -a COPYING NEWS README* benchmarks doc/examples doc/images	\
	doc/ipython-notebooks doc/OpenCV_docs %{_cmake_build_subdir}/doc/html*	\
	%{buildroot}%{_pkgdocdir}
%if %{with license_dir}
%{__rm} -f %{buildroot}%{_pkgdocdir}/COPYING
%endif # 0%%{with license_dir}


# Add a README.txt for the examples.
%{__cat} << EOF >> %{buildroot}%{_pkgdocdir}/examples/README.txt
To run the examples, you will need to have the 'shogun-data'-package
installed, too.
EOF

# Add pkg-config file.
%{__mkdir} -p %{buildroot}%{_libdir}/pkgconfig/
%{__sed} -e 's!@_datadir@!%{_datadir}!g' -e 's!@_includedir@!%{_includedir}!g'	\
	-e 's!@_libdir@!%{_libdir}!g' -e 's!@name@!%{name}!g'			\
	-e 's!@_prefix@!%{_prefix}!g' -e 's!@url@!%{url}!g'			\
	-e 's!@version@!%{version}!g'						\
	< %{SOURCE1} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc

# Make sure all files in %%{_pkgdocdir} have mode 0644.
%{_bindir}/find %{buildroot}%{_pkgdocdir} -depth -type f -print0 |		\
	%{_bindir}/xargs -0 chmod 0644

# Remove unneeded stuff, e.g. compiled examples in %%{buildroot}%%{_datadir},
# build-system files in examples and 0-size files in %%{buildroot}.
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/examples

%{_bindir}/find %{buildroot} -depth -type f -size 0 -print0 |			\
	%{_bindir}/xargs -0 %{__rm} -rf

for _del in 'CMake*' 'Makefile*' '*.log' '*.map' '*.md5' '*.sh'
do
  %{_bindir}/find %{buildroot} -depth -type f -name "${_del}" -print0 |	\
	%{_bindir}/xargs -0 %{__rm} -rf
done

# Hardlink API-docs.
/sbin/hardlink -v %{buildroot}%{_pkgdocdir}/html
/sbin/hardlink -v %{buildroot}%{_pkgdocdir}/html_cn

# Manually byte-compile Python-stuff…
%py_byte_compile %{__python2} %{buildroot}%{python2_sitearch}
%if %{with python3}
%py_byte_compile %{__python3} %{buildroot}%{python3_sitearch}
%endif # %%{with python3}

###############################################################################

%check
%if %{with testsuite}
pushd %{_cmake_build_subdir}
%if %{with memtest}
# Memory tests -- to find reasons for possible segfaults.
# These are allowed to fail and done in parallel.
%{_bindir}/ctest								\
	%{?_smp_mflags}								\
	-D ExperimentalMemCheck							\
	--timeout 5400								\
	--tests-regex "^lib%{name}-.*|^unit-.*"					\
	--output-log %{buildroot}%{_pkgdocdir}/mem.%{?__isa}%{?dist}.log	\
	--output-on-failure || :
%endif # %%{with memtest}

# Disabled tests:
#
# These tests need SVM^light, which we cannot ship in Fedora.
%if !%{with svmlight}
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_0017_1_15_Gaussian_1en05_001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_023_1_15_Gaussian_1en05_001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_15_1_15_Gaussian_1en05_001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_30_1_15_Gaussian_00001_0001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_30_1_15_Gaussian_00001_001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVRLight_30_1_15_Gaussian_1en05_001"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-mkl_regression_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-mkl_binclass_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-mkl_regression_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-mkl_binclass_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|java_modular-mkl_binclass_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|csharp-mkl_binclass_modular"
%endif # !%%{with svmlight}

# Tests fail because of missing dataset.
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-features_dense_protocols_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-features_dense_zero_copy_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-features_string_file_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_gaussian_process_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-features_string_file_modular"

# These tests are failing in Fedora 21+, because of some changes in json-c 0.12.
%if 0%{?fedora} >= 21
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-serialization_complex_example"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-SerializationJSON"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-serialization_complex_example"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-serialization_string_kernels_modular"
%endif # 0%%{?fedora} >= 21

# These test fail on ix86, because of memory-exhaustion or misalignments in
# floatingpoint-precission.
%ifarch %{ix86}
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-multiclass_cartree_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_spline_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_wavelet_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_geodesic_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_jensen_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_sparse_poly_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_salzberg_word_string_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-preprocessor_normone_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_multiclasslibsvm_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_wave_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_histogram_word_string_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_poly_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_gaussian_process_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_sparseeuclidean_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_averaged_perceptron_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-preprocessor_prunevarsubmean_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_cartree_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_svmocas_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_libsvr_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_cosine_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_combined_custom_poly_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-statistics_mmd_kernel_selection_combined"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-CARTree"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-LinearTimeMMD"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-MMDKernelSelectionCombOpt"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-MMDKernelSelectionOpt"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-MMDKernelSelectionCombMaxL2"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-SparseMatrixOperator"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-CGMShiftedFamilySolver"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-CMath"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-Statistics"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-PeriodicKernelTest"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-SGSparseMatrix"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|libshogun-converter_multidimensionalscaling"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-multiclass_cartree_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|python_modular-regression_cartree_modular"
%endif # arch %%{ix86}

# These test fail on arm, because of memory-exhaustion or misalignments in
# floatingpoint-precission or timeout.
%ifarch %{arm}
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-transfer_multitask_leastsquares_regression"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-library_fisher2x3_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-library_time"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_averaged_perceptron_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-CustomKernelTest"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-BAHSIC"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-Statistics"
# Timeout after ~ 25 mins.
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|java_modular-kernel_auc_modular"
%endif # arch %%{arm}

# These test fail on aarch64, because of memory-exhaustion or misalignments in
# floatingpoint-precission or timeout.
%ifarch aarch64
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVMOcas_30_1en05_16_05_False"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-SVMOcas_30_1en05_1_05_False"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_poly_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_sigmoid_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_libsvm_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_gaussian_process_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_averaged_perceptron_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-preprocessor_normone_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_sparse_poly_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_sparseeuclidean_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_jensen_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_svmocas_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_salzberg_word_string_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-classifier_multiclasslibsvm_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-kernel_wave_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_geodesic_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-preprocessor_prunevarsubmean_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-distance_cosine_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-library_fisher2x3_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-regression_libsvr_modular"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-BAHSIC"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-CustomKernelTest"
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|unit-Statistics"
%endif # arch aarch64

# Export the list.
EXCLUDE_FROM_TESTS="$(echo ${EXCLUDE_FROM_TESTS} | %{__sed} -e's!^|!!' -e's!|$!!')"
export EXCLUDE_FROM_TESTS

# Unit && integration tests -- usual testsuite.
%{_bindir}/ctest								\
	%{?_smp_mflags}								\
	--exclude-regex "${EXCLUDE_FROM_TESTS}"					\
	--output-log %{buildroot}%{_pkgdocdir}/unit.%{?__isa}%{?dist}.log	\
	--output-on-failure
popd

%if %{with python3}
# These test fail on ix86, because of memory-exhaustion or misalignments in
# floatingpoint-precission.
%ifarch %{ix86} %{arm}
EXCLUDE_FROM_TESTS="${EXCLUDE_FROM_TESTS}|integration-python_modular-tester-mathematics_linsolver_cg"
%endif # arch %%{ix86} %%{arm}

# Export the list.
EXCLUDE_FROM_TESTS="$(echo ${EXCLUDE_FROM_TESTS} | %{__sed} -e's!^|!!' -e's!|$!!')"
export EXCLUDE_FROM_TESTS

pushd %{py3dir}/%{_cmake_build_subdir}
# Unit && integration tests -- usual testsuite, but without running
# libshogun-tests twice.  They've been run previously anyways.
%{_bindir}/ctest								\
	%{?_smp_mflags}								\
	--exclude-regex "^lib%{name}-.*|^unit-.*|${EXCLUDE_FROM_TESTS}"		\
	--output-log %{buildroot}%{_pkgdocdir}/unit.py3.%{?__isa}%{?dist}.log	\
	--output-on-failure
popd
%endif # %%{with python3}
%endif # %%{with testsuite}

###############################################################################

%if 0%{?rhel} && 0%{?rhel} <= 5
%clean
%{__rm} -rf %{buildroot}
%endif # 0%%{?rhel} && 0%%{?rhel} <= 5

###############################################################################

%changelog
* Tue Jan 26 2016 Björn Esser <fedora@besser82.io> - 4.0.1-0.9.git20160125.0382808
- updated to new snapshot git20160125.038280845fd7fb886f4459996f1405f8ca8c1612
- re-enable mono, issues with mono >= 4 are fixed upstream (#1223446)

* Thu Jan 21 2016 Orion Poplawski <orion@cora.nwra.com> - 4.0.1-0.8.git20151219.af8c1df
- Rebuild for hdf5 1.8.16

* Sat Jan 16 2016 Mamoru TASAKA <mtasaka@fedoraproject.org> -4.0.1-0.7.git20151219.af8c1df
- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_2.3

* Mon Dec 21 2015 Björn Esser <fedora@besser82.io> - 4.0.1-0.6.git20151219.af8c1df
- updated to new snapshot git20151219.af8c1df859ed3d5780bbea5615a5c523e5651db9
- remove Patch0001, fixed in upstream-tarball

* Thu Dec 17 2015 Björn Esser <fedora@besser82.io> - 4.0.0-0.5.git20151217.7e4ac13
- updated to new snapshot git20151217.7e4ac1327cc3ee4b09f498c1b778d13f37ff0956
- updated %%description
- add modshogun.rb to ruby-shogun
- add Patch0001: revert removal of migration-framework

* Tue Dec 08 2015 Björn Esser <fedora@besser82.io> - 4.0.1-0.4.git20150913.d8eb73d
- changing name of python2-subpkg

* Sat Nov 21 2015 Björn Esser <fedora@besser82.io> - 4.0.1-0.3.git20150913.d8eb73d
- updated to new snapshot git20150913.d8eb73dd89f47e0da28f07163c4f635b96d0ec00
- removed ChangeLog from package, deleted in upstream tarball

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0.1-0.2.git20150808.779c3ad
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Sat Aug 08 2015 Björn Esser <bjoern.esser@gmail.com> - 4.0.1-0.1.git20150808.779c3ad
- updated to new snapshot git20150808.779c3ada68ae535062346ef71e6c1c39e482a8ca
- drop all patches, applied in upstream tarball
- add more testsuite-excludes for ix86
- disable memtests on %%arm

* Fri Aug 07 2015 Björn Esser <bjoern.esser@gmail.com> - 4.0.0-7
- rebuilt with full hardening
- add Patch11-13:	enable CMake-policy CMP0056
- add Patch14:		fix handling of C[XX]FLAGS

* Fri Aug 07 2015 Björn Esser <bjoern.esser@gmail.com> - 4.0.0-6
- temporarily disabling Mono-bindings on Fedora 23+

* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat May 23 2015 Björn Esser <bjoern.esser@gmail.com> - 4.0.0-4
- fix: Build fails on fc23+ because of hardening
- fix: BR: mono >= 4.0.0
- exclude tests, which are failing on aarch64 (#1222401)

* Tue May 19 2015 Peter Robinson <pbrobinson@fedoraproject.org> 4.0.0-3
- Rebuild (mono4)

* Sun May 17 2015 Orion Poplawski <orion@cora.nwra.com> - 4.0.0-2
- Rebuild for hdf5 1.8.15

* Wed Apr 29 2015 Björn Esser <bjoern.esser@gmail.com> - 4.0.0-1
- new release v4.0.0 (#1105909, #1183622)
- add Patch0:	fixes double delete[] and tests with swig 3.x
- add Patch1:	fixes to CMake-buildsys
- add Patch2,3:	enable python-debugging in testsuite
- add Patch4:	optionally disabling sse and sse2 features
- add Patch5:	requiring 'rubygems' in testsuite
- add Patch6:	testing Py structure hierarchical multilabel classification
- add Patch7:	replace deprecated json-c functions
- add Patch8:	obey $ENV{R_LIBS_USER} when running tests
- add Patch9:	reduce debuginfo of swig-generated bindings
- add Patch10:	make sure all modular interfaces are build single-threaded
- add automatic CLASSPATH-export for java-shogun
- add automatic MONO_PATH-export for mono-shogun
- add pkg-config file for easier use with gcc
- move headers to versioned include-subdir to avoid collisions
- retiring octave-shogun on %%{arm}
- R-shogun is stable now (#1043885)
- use atlas' clapack on <= fc20 and <= el7
- narrowed the list of failing tests and don't ignore fails anymore
- remove obsolete sed-kludges
- use temporary files instead of pipes to pass data between different gcc instances
- builds are running multi-threaded again
- use %%__isa instead of %%_arch for file / dir naming
- add memory-tests to find reasons for possible segfaults
- run memory- and unit-test multi-threaded
- use %%license when available
- use %%bconds instead of %%global madness
- spec-file cosmetics

* Wed Apr 29 2015 Kalev Lember <kalevlember@gmail.com> - 3.2.0.1-0.35.git20141224.d71e19a
- Rebuilt for protobuf soname bump

* Thu Apr 23 2015 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.34.git20141224.d71e19a
- rebuild for so-name bump in protobuf-2.6.1 (libprotobuf.so.9)

* Sun Jan 18 2015 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.2.0.1-0.33.git20141224.d71e19a
- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_2.2
- Once reduce debuginfo verbosity on arm to reduce memory comsumption
- And once mark -doc, -doc-cn arch dependent perhaps due to above

* Wed Jan 07 2015 Orion Poplawski <orion@cora.nwra.com> - 3.2.0.1-0.32.git20141224.d71e19a
- Rebuild for hdf5 1.8.14

* Wed Dec 24 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.31.git20141224.d71e19a
- updated to new snapshot git20141224.d71e19aa5a575b2b4e52c908a694eb1db7afc973
- reduced number of make-jobs on %%{arm}
- conditionalized and disabled OpenCV-integration

* Tue Dec 23 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.30.git20141223.c329375
- updated to new snapshot git20141223.c32937574df1c560ce7c10f1b8860679ce011a8b
- added BR: ocl-icd-devel, opencl-headers
- enabled OpenCV-features and R-shogun
- purged light-scrubber.sh from repo, now shipped with tarball
- updated documentation-files
- build mono-shogun on %%{mono_arches}, only
- install documentation-files to %%{_pkgdocdir}

* Mon Sep 01 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.29.git20140901.705b7de
- updated to new snapshot git20140901.705b7dea7093cb094fe90fcebac20b7e7d1debcd

* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.2.0.1-0.28.git20140804.96f3cf3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Mon Aug 04 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.27.git20140804.96f3cf3
- updated to new snapshot git20140804.96f3cf3ce58514299f98e688b7c43e057ad4fa41

* Mon Jul 21 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.26.git20140721.81c0008
- updated to new snapshot git20140721.81c00087da6f05d36aec410fef0fcef5be490f42
- enable SSE2 for %%{ix86}, because dSFMT-build will fail otherwise
- switch back to a monolithic build with limeted parallelization
- temporarily discard errors from testsuite

* Thu Jul 17 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.25.git20140717.1ba2924
- updated to new snapshot git20140717.1ba29247b850adef1b866a6c2112a6483c88428e

* Wed Jun 18 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.24.git20140618.2f7681e
- updated to new snapshot git20140618.2f7681ed0c1849088ee5bcc48b91a1c970ff3a9b
- excluded segfaulting tests

* Tue Jun 17 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.23.git20140616.31f5609
- updated to new snapshot git20140616.31f5609f7a7345ca05b5c1f8c7425236da2270df

* Thu Jun 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.22.git20140604.98900c2
- export additional C[XX]FLAGS on 32Bit-arches for SSE and SSE2
- fix typemapping for Mono (C#) with swig >= 3.0.0
- exclude testing python_modular on Fedora >= 21, segfaults related to swig3
- build libshogun with full parallelization, but the swig-bindings

* Thu Jun 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.21.git20140604.98900c2
- updated to new snapshot git20140604.98900c2996ccc4509099a6a337a71d7ca9991bd6

* Mon May 26 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.20.git20140526.7587570
- updated to new snapshot git20140526.758757094c30ae249f5ddc84f3cdc11b4b4203c4
- dropped obsolete BR LaTeX from -doc-pkg

* Mon May 26 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.19.git20140523.681b5ec
- updated to new snapshot git20140523.681b5ec17c0ca9c98cb54047dcd679bec9171989

* Sat May 17 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.18.git20140516.96b815f
- adapted the logic for finding rubygem-narray on Fedora >= 21

* Sat May 17 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.17.git20140516.96b815f
- updated to new snapshot git20140516.96b815fd1fa9769a24122f9016ff5a685a8a6944

* Thu Apr 24 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.16.git20140423.68a5124
- updated to new snapshot git20140423.68a5124bec8df5a013b2406e8c00d93ab83bf88d

* Fri Apr 18 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.15.git20140418.34f9672
- updated to new snapshot git20140418.34f96727f343b7f7f5e0426dbbf579f5dbc0f51e

* Mon Apr 14 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.14.git20140414.b0146f8
- updated to new snapshot git20140414.b0146f8b7314a4de25273dab2d6da4a37044bbec

* Tue Mar 18 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.13.git20140318.6134bc2
- updated to new snapshot git20140318.6134bc2e1e721726102624b372c1f8e7a31816df

* Mon Mar 17 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.12.git20140317.6ee3991
- updated to new snapshot git20140317.6ee39918dc99e72c23a30419a608f11217146e26

* Sat Mar 15 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.11.git20140315.55912da
- updated to new snapshot git20140315.55912da6dd499632ab2371cbbde9fdafaa913cac

* Fri Mar 14 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.10.git20140313.9b6dcd2
- updated to new snapshot git20140313.9b6dcd2a077868259029ce2f28b306e56b30bf2f

* Thu Mar 13 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.9.git20140313.e380071
- updated to new snapshot git20140313.e380071f5a8a5d35c0b33ea0ab55810ef9845354

* Thu Mar 13 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.8.git20140312.d9c535e
- updated to new snapshot git20140312.d9c535e85ed8dc61d537052a9abce200782b87b2

* Fri Mar 07 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.7.git20140307.c281eaa
- updated to new snapshot git20140307.c281eaaf51f44c16c9a7ded0678cbbac265714f6

* Wed Mar 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.6.git20140305.9c67564
- updated to new snapshot git20140305.9c67564278abd5a13efe9ae016f8b3e01bf209f9

* Wed Mar 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.5.git20140305.9b37dc1
- use new macros provided by shogun-data-pkg

* Wed Mar 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.4.git20140305.9b37dc1
- use `CMAKE_BUILD_TYPE=Release` for the Python3-version, too

* Wed Mar 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.3.git20140305.9b37dc1
- fixed year in git-snapshot-date

* Wed Mar 05 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.2.git20130305.9b37dc1
- updated to new snapshot git20130305.9b37dc1e630d54a9c16f2d19b6a10c34d8aef73a

* Tue Mar 04 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0.1-0.1.git20130303.df06a0e
- updated to new snapshot git20130303.df06a0e1a7e3551b0bee218246cfc4bf1a4696d8

* Tue Mar 04 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0-2
- require java-headless on Fedora >= 20 or RHEL >= 7
- exclude some tests on %%{arm} arches only

* Sun Feb 23 2014 Björn Esser <bjoern.esser@gmail.com> - 3.2.0-1
- new upstream release: v3.2.0 (#1066944)
- enabled build of Java-bindings (#1043882)
- enabled build of Python3-bindings (#1043884)
- dropped Patch0 for Octave 3.8.0 (#1047053)
- bumped required data-version to 0.8 (#1068941)
- split-off scrubber-script to seperate script
- exclude some tests on 32-Bit arches only

* Wed Jan 08 2014 Orion Poplawski <orion@cora.nwra.com> - 3.1.1-2
- Add patch for octave 3.8.0 support

* Mon Jan 06 2014 Björn Esser <bjoern.esser@gmail.com> - 3.1.1-1
- new upstream release: v3.1.1
- data-files are now moved into a separate package
- added example-applications to doc-pkg

* Sat Dec 28 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.13.git20131226.1c7fbaa
- rebuild for octave-3.8.0-rc2

* Thu Dec 26 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.12.git20131226.1c7fbaa
- updated to new snapshot git20131226.1c7fbaa732c8476b2df26bca2ae93de666959092
- updated to new testsuite-data git20131222.0bbb04f354a29ed3ab43ce002388b79bb274e886

* Fri Dec 20 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.11.git20131219.207a709
- rebuild for NLopt-2.4.1

* Fri Dec 20 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.10.git20131219.207a709
- rebuild for arprec-2.2.17
- added a line about `no-SVM^light-support` in %%description
- minor indention improvements for the list of bindings in %%description
- fixed `macro-in-comment %%{mono_arches}`
- added %%ifarch %%{mono_arches} for mono-shogun-pkg for building it on those
  arches, only

* Thu Dec 19 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.9.git20131219.207a709
- updated to new snapshot git20131219.207a70972e794df28f0fc67309f217f7fbf3b4e7

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.8.git20131217.70f2657
- copying and packaging the prestine examples to another location is better
  and less error-prone then removing the clutter left by testsuite afterwards

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.7.git20131217.70f2657
- remove more possible clutter from testsuite
- re-enable mldata-based tests when there is internet connectivity

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.6.git20131217.70f2657
- updated to new snapshot git20131217.70f26573a501791e11097615296127c1c36904d7

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.5.git20131216.7230f07
- temporarily disabled mono-shogun on all arm-arches

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.4.git20131216.7230f07
- enable build of mono-shogun, since it should be fixed in current
  checkout (#1043859)

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.3.git20131216.7230f07
- updated to new snapshot git20131216.7230f074751a97842170b8a5f9c69fbd9b8287ca

* Tue Dec 17 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.2.git20131212.70e774d
- remove cluttering *.map *.md5 in autodocs (#1043856)
- remove possible clutter from testsuite

* Mon Dec 16 2013 Björn Esser <bjoern.esser@gmail.com> - 3.1.0-0.1.git20131212.70e774d
- updated to latest git-snapshot (#1043283)
- disabled shogun-mono, because it segfaults currently and has some severe
  problems on ARMv7hl

* Sun Dec 15 2013 Björn Esser <bjoern.esser@gmail.com> - 3.0.0-1
- Initial rpm release (#1043283)