%define perl_vendorarch %(eval "`perl -V:installvendorarch`"; echo $installvendorarch)
%define perl_archlib %(eval "`perl -V:archlib`"; echo $archlib)

Name:             openbabel
Version:          2.3.2
Release:          4%{?_dist_release}
Summary:          Chemistry software file format converter
Summary(ja):      化学ソフトデータファイル変換プログラム
License:          GPLv2
Group:            Applications/Edutainment
URL:              http://openbabel.sourceforge.net/
Source:           http://dl.sourceforge.net/sourceforge/openbabel/%{name}-%{version}.tar.gz

# fron fedora
Patch0:		openbabel-2.3.1-gcc47-darwin.patch
Patch1:		openbabel-rpm.patch
Patch2:		openbabel-2.3.2-cmake.patch
Patch3:		openbabel-2.3.1-ruby19-vendorarch.patch
Patch4:		openbabel-2.3.1-ruby22-remove-deprecated-usage.patch

BuildRoot:        %{_tmppath}/%{name}-%{version}-root
BuildRequires: inchi-devel
BuildRequires: libtool
BuildRequires: libxml2-devel
BuildRequires: perl
BuildRequires: python
BuildRequires: python-devel
BuildRequires: ruby
BuildRequires: ruby-devel
BuildRequires: swig
BuildRequires: wxGTK-devel
BuildRequires: zlib-devel
BuildRequires: cmake
BuildRequires: eigen2-devel

Distribution:  Vine Linux
Vendor:       Project Vine
Packager:     inagaki

%description
Open Babel is a free, open-source version of the Babel chemistry file
translation program. Open Babel is a project designed to pick up where
Babel left off, as a cross-platform program and library designed to
interconvert between many file formats used in molecular modeling,
computational chemistry, and many related areas.

Open Babel includes two components, a command-line utility and a C++
library. The command-line utility is intended to be used as a replacement
for the original babel program, to translate between various chemical file
formats. The C++ library includes all of the file-translation code as well
as a wide variety of utilities to foster development of other open source
scientific software. 

%package devel
Summary: Development tools for programs which will use the Open Babel library
Summary(ja): %{name} の開発用ヘッダファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig

%description devel
The %{name}-devel package includes the header files and libraries
necessary for developing programs using the Open Babel library.

If you are going to develop programs which will use this library
you should install %{name}-devel.  You'll also need to have the
%{name} package installed.

%description devel -l ja
%{name}の開発用ヘッダファイル

%package -n perl-%{name}
Summary: Perl wrapper for the Open Babel library
Summary(ja): Open Babel ライブラリの Perl ラッパー
Group: Development/Libraries
Requires: perl > %(eval "`%{__perl} -V:version`"; echo $version)
Obsoletes: %{name}-perl < 2.2.0
Provides: %{name}-perl = %{version}-%{release}

%description -n perl-%{name}
Perl wrapper for the Open Babel library.

%description -n perl-%{name} -l ja
Open Babel ライブラリの Perl ラッパーです．

%package -n python-%{name}
Group: Development/Libraries
Summary: Python wrapper for the Open Babel library
Summary(ja): Open Babel ライブラリの Python ラッパー
Obsoletes: %{name}-python < 2.2.0
Provides: %{name}-python = %{version}-%{release}

%description -n python-%{name}
Python wrapper for the Open Babel library.

%description -n python-%{name} -l ja
Open Babel ライブラリの Python ラッパー

%package -n ruby-%{name}
Summary: Ruby wrapper for the Open Babel library
Summary(ja): Open Babel ライブラリの Ruby ラッパー
Group: Development/Libraries
Requires: ruby >= 1.8
Requires: %{name} = %{version}-%{release}

%description -n ruby-%{name}
Open Babel ライブラリの Ruby ラッパー

%prep
%setup -q
%patch0 -p1 -b .gcc47
%patch1 -p1 -b .rpm
%patch2 -p1 -b .cmake
%patch3 -p1 -b .ruby_vendor
%patch4 -p1 -b .rbconfig

chmod 644 src/formats/{mmcif,fchk}format.cpp

%build
%cmake \
	-DOPENBABEL_USE_SYSTEM_INCHI=true \
	-DPYTHON_BINDINGS:BOOL=ON \
	-DRUBY_BINDINGS:BOOL=ON \
	-DPERL_BINDINGS:BOOL=ON \
    .

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

rm -f $RPM_BUILD_ROOT%{_libdir}{,/%{name}}/*.la

mkdir -p $RPM_BUILD_ROOT%{python_sitearch}
mv $RPM_BUILD_ROOT%{_libdir}/_openbabel.so \
   $RPM_BUILD_ROOT%{_libdir}/openbabel.py \
   $RPM_BUILD_ROOT%{_libdir}/pybel.py \
   $RPM_BUILD_ROOT%{python_sitearch}

rm -rf $RPM_BUILD_ROOT%{_libdir}/cmake/openbabel2
rm -f $RPM_BUILD_ROOT%{_libdir}/perl5/*/*/perllocal.pod
rm -f $RPM_BUILD_ROOT%{perl_vendorarch}/auto/Chemistry/OpenBabel/.packlist
rm -f $RPM_BUILD_ROOT%{perl_vendorarch}/auto/Chemistry/OpenBabel/OpenBabel.bs

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog README THANKS
%doc doc/*.html
#doc doc/README* doc/babel*.inc doc/dioxin.*
%doc doc/README* doc/dioxin.*
%{_bindir}/*
%{_mandir}/man1/*
%{_datadir}/%{name}
%{_libdir}/libopenbabel.so.*
%{_libdir}/%{name}

%files devel
%defattr(-,root,root,-)
%{_includedir}/%{name}-2.0
%{_libdir}/libopenbabel.so
%{_libdir}/pkgconfig/*.pc

%files -n perl-%{name}
%defattr(-,root,root,-)
%{perl_vendorarch}/Chemistry/OpenBabel.pm
%dir %{perl_vendorarch}/*/Chemistry/OpenBabel
%{perl_vendorarch}/*/Chemistry/OpenBabel/OpenBabel.so

%files -n python-%{name}
%defattr(-,root,root,-)
%{python_sitearch}/_openbabel.so
%{python_sitearch}/openbabel.py*
%{python_sitearch}/pybel.py*

%files -n ruby-%{name}
%defattr(-,root,root,-)
%{ruby_vendorarchdir}/openbabel.so

%changelog
* Sun Sep 13 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.3.2-4
- rebuild with ruby-2.2.3
- add Patch4 (openbabel-2.3.1-ruby22-remove-deprecated-usage.patch) from fedora

* Fri Jan 02 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.3.2-3
- add BuildRequires: wxGTK-devel, eigen2-devel

* Wed Dec 31 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 2.3.2-2
- rebuilt with ruby 2.1.5 and perl 5.16.3

* Sun Dec 08 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.3.2-1
- new upstream release
- add BuildRequires: cmake
- add Patch0,1,2,3 from fedora

* Sat Oct 02 2010 Shu KONNO <owa@bg.wakwak.com> 2.2.3-4
- rebuilt with rpm-4.8.1 for pkg-config

* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 2.2.3-3
- rebuild with python-2.6

* Fri Nov 13 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.3-2
- <BTS:0789> ruby binding install path changed to Config::CONFIG["archdir"]

* Wed Aug 26 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.3-1
- applied new versioning policy, spec in UTF-8
- using system inchi package
- added ruby-%{name} package

* Mon May 14 2007 Susumu Tanimura <arumiant@gmail.com> 2.1.0-0vl1
- Updated to 2.1.0

* Tue May  1 2007  Susumu Tanimura <arumiant@gmail.com> 2.0.2-5vl1
- built for VineLinux

* Tue Oct 03 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.2-5
- rebuilt for unwind info generation, broken in gcc-4.1.1-21

* Wed Sep 20 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.2-4
- .pyo files no longer ghosted
- fix chicken-and-egg problem when building perl and python bindings

* Tue Aug 29 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.2-3
- simplified autotools invocation
- mass rebuild

* Mon Aug 07 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.2-2
- simplified file lists and permissions
- removed weird character from inchi summary and description
- added missing pkgconfig Req: for -devel

* Sat Aug 05 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.2-1
- updated to 2.0.2
- dropped GCC4 fix (upstream'd)
- split off inchi package
- added python and perl bindings packages

* Sat Jan 07 2006 Dominik Mierzejewski <rpm@greysector.net> 2.0.0-1
- updated to 2.0.0
- fix compilation with GCC4
- FE compliance

* Thu Feb 10 2005 Dominik Mierzejewski <rpm@greysector.net> 1.100.2-1
- rebuilt for Fedora 3

* Tue Jan 18 2005 ALT QA Team Robot <qa-robot@altlinux.org> 1.100.2-alt1.1
- Rebuilt with libstdc++.so.6.

* Wed Mar 03 2004 Michael Shigorin <mike@altlinux.ru> 1.100.2-alt1
- 1.100.2

* Wed Dec 17 2003 Michael Shigorin <mike@altlinux.ru> 1.100.1-alt2
- removed *.la
- don't package static library by default

* Mon Sep 22 2003 Michael Shigorin <mike@altlinux.ru> 1.100.1-alt1
- 1.100.1
- #2994 fixed; thanks to Alex Ott (ott@) for a pointer
- spec cleanup (underlibification fixup)

* Mon Jun 30 2003 Michael Shigorin <mike@altlinux.ru> 1.100.0-alt1
- built for ALT Linux
- based on Mandrake Cooker spec by:
  * Lenny Cartier <lenny@mandrakesoft.com>
  * Austin Acton <aacton@yorku.ca>
- spec cleanup
