%define python_sitearch %(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib(1)')
%define ruby_vendorarch %(ruby -r rbconfig -e 'print RbConfig::CONFIG["vendorarchdir"]')

Name: obexftp
Summary: Tool to access devices via the OBEX protocol
Summary(ja): OBEX プロトコルを使用する機器にアクセスするためのツール
Version: 0.24
Release: 1%{?_dist_release}
License: GPLv2+
Group: Applications/Communications
URL: http://openobex.triq.net/

Source: http://dl.sourceforge.net/project/openobex/obexftp/0.24/obexftp-0.24-Source.tar.gz
Patch0: obexftp-norpath.patch
# From upstream git, fixes fuse apps not being installed
Patch1: %{name}-0.24-fuse.patch
# From OpenSUSE, thanks: fix pkgconfig to require bluez not bluetooth
Patch2: %{name}-pkgconfig_requires.patch
# From OpenSUSE, thanks: fix python install path
Patch3: %{name}-0.24-fix-absurd-install-path.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: asciidoc
BuildRequires: cmake
BuildRequires: bluez-libs-devel
BuildRequires: fuse-devel
BuildRequires: gettext-devel
BuildRequires: openobex-devel
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: python-devel
BuildRequires: ruby-devel
BuildRequires: swig
BuildRequires: tcl
BuildRequires: xmlto

#----------------------------------------------------------------------------
%description
The overall goal of this project is to make mobile devices featuring the OBEX
protocol and adhering to the OBEX FTP standard accessible by an open source
implementation. The common usage for ObexFTP is to access your mobile phones
memory to  store and retrieve e.g. your phonebook, logos, ringtones, music,
 pictures and alike.

%description -l ja
このプロジェクトは OBEX プロトコルおよび、標準的で便利な OBEX FTP をフィーチャーしたモバイルデバイスを、オープンソースで実装する事を全体的な目標としています。

ObexFTPの共通の使い方
お使いの携帯電話のメモリにアクセスし、電話帳、ロゴ、着メロ、音楽、写真等の保存や取得を行います。

#----------------------------------------------------------------------------
%package -n fuse-%{name}
Summary: FUSE based filesystem using ObexFTP
Group: Applications/Communications
Requires: %{name} = %{version}-%{release}

%description -n fuse-%{name}
This package provides a FUSE based filesystem using Obex protocol as backend.

#----------------------------------------------------------------------------
%package -n python-%{name}
Summary: Python library to access devices via the OBEX protocol
Summary(ja): OBEX プロトコルを使って機器を扱う Python ライブラリ
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description -n python-%{name}
The overall goal of this project is to make mobile devices featuring the OBEX
protocol and adhering to the OBEX FTP standard accessible by an open source
implementation. The common usage for ObexFTP is to access your mobile phones
memory to  store and retrieve e.g. your phonebook, logos, ringtones, music,
 pictures and alike.

%description -n python-%{name} -l ja
このプロジェクトは OBEX プロトコルおよび、標準的で便利な OBEX FTP をフィーチャーしたモバイルデバイスを、オープンソースで実装する事を全体的な目標としています。

ObexFTP の共通の使い方
お使いの携帯電話のメモリにアクセスし、電話帳、ロゴ、着メロ、音楽、写真等の保存や取得を行います。
(このパッケージは Python 向けライブラリです)

#----------------------------------------------------------------------------
%package -n perl-%{name}
Summary: Perl library to access devices via the OBEX protocol
Summary(ja): OBEX プロトコルを使って機器を扱う Perl ライブラリ
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Provides: perl-OBEXFTP = %{version}-%{release}

%description -n perl-%{name}
The overall goal of this project is to make mobile devices featuring the OBEX
protocol and adhering to the OBEX FTP standard accessible by an open source
implementation. The common usage for ObexFTP is to access your mobile phones
memory to  store and retrieve e.g. your phonebook, logos, ringtones, music,
 pictures and alike.

%description -n perl-%{name} -l ja
このプロジェクトは OBEX プロトコルおよび、標準的で便利な OBEX FTP をフィーチャーしたモバイルデバイスを、オープンソースで実装する事を全体的な目標としています。

ObexFTPの共通の使い方
お使いの携帯電話のメモリにアクセスし、電話帳、ロゴ、着メロ、音楽、写真等の保存や取得を行います。
(このパッケージは perl 向けライブラリです)

#----------------------------------------------------------------------------
%package -n ruby-%{name}
Summary: Ruby library to access devices via the OBEX protocol
Summary(ja): OBEX プロトコルを使って機器を扱う Ruby ライブラリ
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description -n ruby-%{name}
The overall goal of this project is to make mobile devices featuring the OBEX
protocol and adhering to the OBEX FTP standard accessible by an open source
implementation. The common usage for ObexFTP is to access your mobile phones
memory to  store and retrieve e.g. your phonebook, logos, ringtones, music,
 pictures and alike.

%description -n ruby-%{name} -l ja
このプロジェクトは OBEX プロトコルおよび、標準的で便利な OBEX FTP をフィーチャーしたモバイルデバイスを、オープンソースで実装する事を全体的な目標としています。

ObexFTPの共通の使い方
お使いの携帯電話のメモリにアクセスし、電話帳、ロゴ、着メロ、音楽、写真等の保存や取得を行います。
(このパッケージは ruby 向けライブラリです)

#----------------------------------------------------------------------------
%package devel
Summary: Header files and libraries for %{name}
Summary(ja): OBEX-FTP の開発用ヘッダーファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: bluez-libs-devel
Requires: openobex-devel
Requires: pkgconfig

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

%description devel -l ja
このパッケージには、%{name} を使用するアプリケーションを開発するためのライブラリ及びヘッダファイルが含まれています。

#----------------------------------------------------------------------------
%prep
%setup -q -n %{name}-%{version}-Source
%patch0 -p1 -b .norpath
%patch1 -p1 -b .fuse
%patch2 -p1 -b .pkgconfig
%patch3 -p1 -b .pythonpath

%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
%cmake -DCMAKE_SKIP_RPATH=YES ..

# fix xmlto option to build man pages
sed -i 's|\/usr\/bin\/xmlto |\/usr\/bin\/xmlto --skip-validation |g' doc/CMakeFiles/doc.dir/build.make

popd

make %{?_smp_mflags} -C %{_target_platform}
make %{?_smp_mflags} doc -C %{_target_platform}

%install
rm -rf $RPM_BUILD_ROOT

make install -C %{_target_platform} \
     DESTDIR=$RPM_BUILD_ROOT \
     RUBYARCHDIR=$RPM_BUILD_ROOT%{ruby_vendorarch} 
chmod 755 $RPM_BUILD_ROOT%{perl_vendorarch}/*/OBEXFTP/OBEXFTP.so

# rm $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f  $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod
rm -f $RPM_BUILD_ROOT%{perl_vendorarch}/*/OBEXFTP/{.packlist,OBEXFTP.bs}


%clean
rm -rf $RPM_BUILD_ROOT

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

%files
%defattr(-, root, root, -)
%doc AUTHORS ChangeLog NEWS README THANKS TODO
%{_bindir}/obexftp
%{_bindir}/obexftpd
%{_libdir}/*.so.*
%{_mandir}/man1/obexftp.1*
%{_mandir}/man1/obexftpd.1*

%files devel
%defattr(-, root, root, -)
%{_includedir}/bfb/
%{_includedir}/multicobex/
%{_includedir}/obexftp/
%{_libdir}/*.so
%{_libdir}/pkgconfig/obexftp.pc

%files -n fuse-%{name}
%{_bindir}/obexautofs
%{_bindir}/obexfs

%files -n python-%{name}
%defattr(-, root, root, -)
%{python_sitearch}/_obexftp.so*
%{python_sitearch}/obexftp.py*

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

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


#----------------------------------------------------------------------------
# Maintainers: babasaki@mindgear.org
#
#----------------------------------------------------------------------------
%changelog
* Tue Nov 11 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> - 0.24-1
- updaed to 0.24
- added fuse-obexftp subpackage
- built with openobex 1.7,1 and perl 5.16.3

* Sat Jul 27 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 0.23-2
- rebuild with perl-5.12.3

* Sat Dec 12 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.23-1
- new upstream release
- removed Requires: ruby(abi) (= 1.8) <BTS:799>

* Thu Apr 30 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.22-4
- rebuild (ruby-obexftp subpackage not uploaded on i386/x86_64 yet)

* Fri Oct 24 2008 Seiichirou Babasaki 0.22-3
- change %{perl_sitearch} -> %{perl_vendorarch}
- added "# Maintainers: " comments.
- changed UTF-8 encode at obexftp.vs.spec
- Updated specfile

* Wed Oct 2 2008 Seiichirou Babasaki 0.22-2
- change %{perl_vendorarch} -> %{perl_sitearch}
- Updated specfile

* Wed Jan 16 2008 Seiichirou Babasaki 0.20-0.5_2-1
- Import obexftp - Packager: Babasaki
- Updated specfile

#----------------------------------------------------------------------------
* Thu Sep 06 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.22-0.5.rc7
- updated to 0.22-rc7
- added pkgconfig file
- make perl BR more specific

* Mon Aug 27 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.22-0.4.rc6
- rebuilt for BuildID
- updated license tag

* Mon Aug 06 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.22-0.3.rc6
- updated to 0.22-rc6
- added ruby bindings (patch by Andy Shevchenko)
- dropped upstreamed patch
- added missing BRs for F7+

* Mon Mar 26 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.22-0.2.pre4
- fix segfault in obexftpd (patch by Jan Kratochvil), closes (#230991)

* Fri Mar 23 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.22-0.1.pre4
- updated to 0.22-pre4
- updated patches

* Fri Jan 26 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.20-3
- add missing disttag

* Thu Jan 25 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.20-2
- added missing defattr
- require openobex-devel > 1.2
- added missing MODULE_COMPAT Requires: to perl subpackage
- renamed subpackages to perl/python-obexftp
- fixed rpaths

* Mon Jan 01 2007 Dominik Mierzejewski <rpm@greysector.net> - 0.20-1
- updated to 0.20

* Sun Jan 29 2006 Dag Wieers <dag@wieers.com> - 0.18-1
- Initial package. (using DAR)
