diff --git a/README.md b/README.md index 63c14e6..ca37de5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # libsvm +Libsvm is a simple, easy-to-use, and efficient software for SVM classification and regression. +It solves C-SVM classification, nu-SVM classification, one-class-SVM, epsilon-SVM regression, and nu-SVM regression. +It also provides an automatic model selection tool for C-SVM classification. + diff --git a/libsvm-3.20-Makefile.patch b/libsvm-3.20-Makefile.patch new file mode 100644 index 0000000..235d85d --- /dev/null +++ b/libsvm-3.20-Makefile.patch @@ -0,0 +1,47 @@ +--- libsvm-3.20/Makefile 2015-03-22 12:55:35.000000000 +0100 ++++ libsvm-3.20/Makefile.linux 2015-03-22 14:00:24.234436503 +0100 +@@ -1,25 +1,28 @@ + CXX ?= g++ +-CFLAGS = -Wall -Wconversion -O3 -fPIC ++MAKE = make ++CFLAGS_ADD = -Wall -Wconversion -O3 -fPIC + SHVER = 2 +-OS = $(shell uname) ++SHARED_LIB_FLAGS= -shared -Wl,-soname,liblinear.so.$(SHVER) ++LIBS= -L. -lsvm + + all: svm-train svm-predict svm-scale + + lib: svm.o +- if [ "$(OS)" = "Darwin" ]; then \ +- SHARED_LIB_FLAG="-dynamiclib -Wl,-install_name,libsvm.so.$(SHVER)"; \ +- else \ +- SHARED_LIB_FLAG="-shared -Wl,-soname,libsvm.so.$(SHVER)"; \ +- fi; \ +- $(CXX) $${SHARED_LIB_FLAG} svm.o -o libsvm.so.$(SHVER) +- +-svm-predict: svm-predict.c svm.o +- $(CXX) $(CFLAGS) svm-predict.c svm.o -o svm-predict -lm +-svm-train: svm-train.c svm.o +- $(CXX) $(CFLAGS) svm-train.c svm.o -o svm-train -lm ++ $(CXX) $(SHARED_LIB_FLAGS) $(LDFLAGS) svm.o -o libsvm.so.$(SHVER) ++ ln -fs libsvm.so.$(SHVER) libsvm.so ++ ++svm-predict: lib svm-predict.c ++ $(CXX) $(CFLAGS_ADD) svm-predict.c $(LIBS) -o svm-predict -lm ++ ++svm-train: lib svm-train.c ++ $(CXX) $(CFLAGS_ADD) svm-train.c $(LIBS) -o svm-train -lm ++ + svm-scale: svm-scale.c +- $(CXX) $(CFLAGS) svm-scale.c -o svm-scale ++ $(CXX) $(CFLAGS_ADD) svm-scale.c -o svm-scale ++ + svm.o: svm.cpp svm.h +- $(CXX) $(CFLAGS) -c svm.cpp ++ $(CXX) $(CFLAGS_ADD) $(CFLAGS) -c -o svm.o svm.cpp ++ + clean: +- rm -f *~ svm.o svm-train svm-predict svm-scale libsvm.so.$(SHVER) ++ rm -f *~ svm.o svm-train svm-predict svm-scale libsvm.so* ++ ${MAKE} -C python clean diff --git a/libsvm.spec b/libsvm.spec new file mode 100644 index 0000000..a43b6a1 --- /dev/null +++ b/libsvm.spec @@ -0,0 +1,128 @@ +Name: libsvm +Version: 3.24 +Release: 1mamba +Summary: A simple, easy-to-use, and efficient software for SVM classification and regression +Group: Development/Libraries +Vendor: openmamba +Distribution: openmamba +Packager: Davide Madrisan +URL: https://www.csie.ntu.edu.tw/~cjlin/libsvm +## GITSOURCE https://github.com/cjlin1/libsvm.git v320 +Source: https://github.com/cjlin1/libsvm.git/v320/libsvm-%{version}.tar.bz2 +Patch0: libsvm-3.20-Makefile.patch +License: BSD +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: libgcc +#BuildRequires: libpython-devel +BuildRequires: libstdc++6-devel +## AUTOBUILDREQ-END +BuildRequires: gcc-c++ +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +# FIXME +# build the java bindings, svm-toy-gtk, and svm-toy-qt + +%description +Libsvm is a simple, easy-to-use, and efficient software for SVM classification and regression. +It solves C-SVM classification, nu-SVM classification, one-class-SVM, epsilon-SVM regression, and nu-SVM regression. +It also provides an automatic model selection tool for C-SVM classification. + +%package devel +Group: Development/Libraries +Summary: Development files for %{name} +Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} +Requires: pkg-config + +%description devel +This package contains libraries and header files for developing applications that use %{name}. + +%package -n python-%{name} +Group: Development/Libraries/Python +Summary: Python bindings for %{name} +Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} +Requires: python + +%description -n python-%{name} +%{summary}. + +%prep +%setup -q +%patch0 -p1 + +# add pkg-config file +cat << _EOF >> %{name}.pc +Name: %{name} +Description: Library for SVM classification and regression +URL: %{url} +Version: 3.24 + +prefix=%{_prefix} +includedir=%{_includedir} + +Cflags: -I\${includedir}/libsvm +Libs: -lsvm +_EOF + +%build +CFLAGS="%optflags -O3"; export CFLAGS +%make all + +python -m compileall -l python +python -m compileall -l tools + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +mkdir -p %{buildroot}%{_bindir} +install -m 0755 svm-train %{buildroot}%{_bindir}/ +install -m 0755 svm-predict %{buildroot}%{_bindir}/ +install -m 0755 svm-scale %{buildroot}%{_bindir}/ + +mkdir -p %{buildroot}%{_libdir} +install libsvm.so* %{buildroot}%{_libdir}/ +mkdir -p %{buildroot}%{_libdir}/pkgconfig +install -m 0644 %{name}.pc %{buildroot}%{_libdir}/pkgconfig/ + +mkdir -p %{buildroot}%{_includedir}/%{name} +install -m 0644 svm.h %{buildroot}%{_includedir}/%{name}/ + +mkdir -p %{buildroot}%{python_sitearch}/%{name} +install -m 0644 python/*.py* tools/*.py* %{buildroot}%{python_sitearch}/%{name}/ +> %{buildroot}%{python_sitearch}/%{name}/__init__.py + +for f in python/*.py tools/*.py; do + ln -s %{python_sitearch}/%{name}/${f/*\/} %{buildroot}%{_bindir}/svm-${f/*\/} +done + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root) +%{_bindir}/svm-predict +%{_bindir}/svm-scale +%{_bindir}/svm-train +%{_libdir}/*.so.* + +%files devel +%defattr(-,root,root) +%{_includedir}/%{name} +%{_libdir}/*.so +%{_libdir}/pkgconfig/*.pc +%doc README + +%files -n python-%{name} +%defattr(-,root,root) +%{_bindir}/svm-*.py +%{python_sitearch}/%{name} + +%changelog +* Tue Feb 09 2021 Automatic Build System 3.24-1mamba +- automatic version update by autodist + +* Sun Mar 22 2015 Davide Madrisan 3.20-1mamba +- package created by autospec