Blob Blame History Raw
# Failsafe backport of Python2-macros for RHEL <= 6
%{!?python_sitelib:	%global python_sitelib		%(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch:	%global python_sitearch		%(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%{!?python_version:	%global python_version		%(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
%{!?__python2:		%global __python2		%{__python}}
%{!?python2_sitelib:	%global python2_sitelib		%{python_sitelib}}
%{!?python2_sitearch:	%global python2_sitearch	%{python_sitearch}}
%{!?python2_version:	%global python2_version		%{python_version}}

Name:			liblinear
Version:		1.94
Release:		4%{?dist}
Summary:		Library for Large Linear Classification
%{?el5:Group:		System Environment/Libraries}

License:		BSD
URL:			http://www.csie.ntu.edu.tw/~cjlin/%{name}
Source0:		%{url}/%{name}-%{version}.tar.gz
Source1:		%{url}/index.html
Source2:		%{url}/FAQ.html
Source3:		%{url}/exp.html
Source4:		http://www.csie.ntu.edu.tw/~cjlin/papers/%{name}.pdf

# simple fixes, not needed by upstream
Patch0:			liblinear-adapt_makefile.patch
Patch1:			liblinear-fix_compiler_warnings.patch

%{?el5:BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)}
BuildRequires:		blas-devel


%description
%{name} is an open source library for large-scale linear classification.
It supports logistic regression and linear support vector machines.  It
provides easy-to-use command-line tools and library calls for users and
developers.  Comprehensive documents are available for both beginners
and advanced users.

Experiments demonstrate that %{name} is very efficient on large sparse
data sets.  %{name} is the winner of ICML 2008 large-scale learning
challenge (linear SVM track).  It is also used for winning KDD Cup 2010.

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

%files
%doc COPYRIGHT
%{_libdir}/%{name}.so.*


%package cli
Summary:		CLI-tools for %{name}
%{?el5:Group:		Applications/Engineering}

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

%description cli
This package contains cli-tools for use with %{name}.

For further information read "3.1 Practical Usage" from the pdf included
in the %{name}-doc package.

%files cli
%doc heart_scale
%{_bindir}/*


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

Requires:		%{name}%{?_isa}		== %{version}-%{release}
%{?el5:Requires:	%{_bindir}/pkg-config}

%{?el5:Provides:	pkgconfig(%{name})	== %{version}}

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

%files devel
%{_includedir}/*
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc


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

%{!?el5:BuildArch:	noarch}

%description doc
The %{name}-doc package contains some brief documentation for developing
applications that use %{name}.

%files doc
%doc COPYRIGHT README* {predict,train}.c *.html *.pdf


%package -n python-%{name}
Summary:		Python bindings for %{name}
%{?el5:Group:		System Environment/Libraries}

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

%description  -n python-%{name}
This package contains bindings for developing Python applications that
use %{name}.

For further information read "README.python" included in the
%{name}-doc package.

%files -n python-%{name}
%{python2_sitearch}/*


%if 0%{?fedora} || 0%{?rhel} >= 8
%package -n python3-%{name}
Summary:		Python3 bindings for %{name}

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

%description  -n python3-%{name}
This package contains bindings for developing Python3 applications that
use %{name}.

For further information read "README.python" included in the
%{name}-doc package.

%files -n python3-%{name}
%{python3_sitearch}/*
%endif #0%{?fedora} || 0%{?rhel} >= 8


%prep
%setup -q
%patch0 -p1
%patch1 -p1

# pull in other sources
install -pm 0644 %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} .

# remove bundled stuff
rm -rf blas/ matlab/ windows/ Makefile.*

# add pkg-config file
cat << EOF >> %{name}.pc
#################################
# Pkg-Config file for %{name} #
#################################

Name: %{name}
Description: Library for Large Linear Classification
URL: %{url}
Version: %{version}

prefix=%{_prefix}
includedir=%{_includedir}

Cflags: -I\$\{includedir\}/liblinear
Libs: -llinear
EOF

# rename python/README for inclusion in doc
mv python/README README.python

# remove hashbang from lib's files
for _file in python/*.py
do
  sed '1{\@^#!/usr/bin/env python@d}' ${_file} > ${_file}.new &&
  touch -r ${_file} ${_file}.new &&
  mv -f ${_file}.new ${_file}
done


%build
%configure ||:
make %{?_smp_mflags}


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

# no install-target in Makefile
mkdir -p %{buildroot}%{_bindir}			\
	%{buildroot}%{_libdir}/pkgconfig	\
	%{buildroot}%{_includedir}/%{name}	\
	%{buildroot}%{python2_sitearch}

install -pm 0755 predict %{buildroot}%{_bindir}/%{name}-predict
install -pm 0755 train %{buildroot}%{_bindir}/%{name}-train
install -pm 0755 %{name}.so.1 %{buildroot}%{_libdir}
ln -s %{name}.so.1 %{buildroot}%{_libdir}/%{name}.so
install -pm 0644 %{name}.pc %{buildroot}%{_libdir}/pkgconfig
install -pm 0644 {linear,tron}.h %{buildroot}%{_includedir}/%{name}

install -pm 0644 python/*.py %{buildroot}%{python2_sitearch}

%if 0%{?fedora} || 0%{?rhel} >= 8
mkdir -p %{buildroot}%{python3_sitearch}
install -pm 0644 python/*.py %{buildroot}%{python3_sitearch}
%endif #0%{?fedora} || 0%{?rhel} >= 8


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


%changelog
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.94-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.94-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 1.94-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Sun May 04 2014 Björn Esser <bjoern.esser@gmail.com> - 1.94-1
- new upstream release (#1051090)
- failsafe backport of Python2-macros for RHEL <= 6
- Python3 is not available on RHEL7, yet
- preserve timestamps of modified files
- minor improvements

* Wed Oct 02 2013 Björn Esser <bjoern.esser@gmail.com> - 1.93-3
- adaptions for new Python-guidelines
- generate .pc-file on-the-fly
- minor cleanup

* Mon Aug 12 2013 Björn Esser <bjoern.esser@gmail.com> - 1.93-2
- build arched python-plugins
- nuke hashbang from python-plugins

* Sun Aug 11 2013 Björn Esser <bjoern.esser@gmail.com> - 1.93-1
- Initial rpm release (#995864)