%define name	libffi
%define version	3.0.9
%define release	3%{?_dist_release}

Summary:	Foreign function interface library
Summary(ja): 	Foreign function interface ライブラリ
Name:		%{name}
Version:	%{version}
Release: 	%{release}
Source0:	ftp://sourceware.org/pub/libffi/%{name}-%{version}.tar.gz
License:	Distributable
Group:		System Environment/Libraries
URL:		http://sourceware.org/libffi/

BuildRequires:	gcc
BuildRoot:	%{_tmppath}/%{name}-%{version}-root


%description
A foreign function interface is the popular name for the interface
that allows code written in one language to call code written in
another language. 

%description -l ja
Foreign function interface は一般に普及しているインターフェイスで、
ある言語で書かれたコードから、他の言語で書かれたコードを呼び出すこ
とを可能にします。

#-----------------------------------------------------------------------------

%package devel
Summary:	Libraries and headers for %{name}
Summary(ja): 	%{name} 用の開発ライブラリおよびヘッダファイル
Group:		Development/Libraries
Requires:	%{name} = %{version}

%description devel
This package includes the files needed for developing and compiling
applications which use the ffi library.

You should install the libffi-devel package if you would like to
develop applications using libffi.

%description devel -l ja
このパッケージは ffi ライブラリを使用するアプリケーションを開発
するのに必要なライブラリやヘッダファイルを含んでいます。

libffi を使用したアプリケーションを開発するなら、このパッケージ
をインストールしてください。

#-----------------------------------------------------------------------------


%prep

%setup -q


%build
%configure
%{__make}


%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__make} install DESTDIR=${RPM_BUILD_ROOT}

# move include files.
%{__mv} ${RPM_BUILD_ROOT}/%{_libdir}/libffi-%{version}/include ${RPM_BUILD_ROOT}/%{_includedir}
sed -i -e "s|^includedir=.*include$|includedir=%{_includedir}|" \
	${RPM_BUILD_ROOT}/%{_libdir}/pkgconfig/libffi.pc

# remove unnecessary files.
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_libdir}/libffi.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_infodir}/dir

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%defattr(-,root,root)
%doc ChangeLog* LICENSE README  
%{_libdir}/libffi.so.*
%{_infodir}/libffi.info*
%{_mandir}/man3/ffi.3*
%{_mandir}/man3/ffi_call.3*
%{_mandir}/man3/ffi_prep_cif.3*

%files devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/*
%{_libdir}/libffi.a
%{_libdir}/libffi.so
%{_includedir}/*.h


%changelog
* Fri Nov 26 2010 Shu KONNO <owa@bg.wakwak.com> 3.0.9-3
- fixed includedir in libffi.pc

* Tue Sep 21 2010 IWAI, Masaharu <iwai@alib.jp> 3.0.9-2
- build with rpm-4.8.1-1 for pkg-config file

* Tue Feb 23 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.0.9-1
- new upstream release
- built with new toolchain

* Wed Jan 21 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 3.0.8-1
- new upstream release
- spec in UTF-8

* Thu Apr 17 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 3.0.5-1
- updated to new upstream release

* Wed Apr 02 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 3.0.4-1
- apply new versioning policy

* Sun Mar 02 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 3.0.4-0vl1
- initial build for Vine Linux