%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

%define name	libffi
%define version	3.2.1
%define release	1%{?_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
Patch0:		libffi-3.1-fix-include-path.patch
License:	Distributable
Group:		System Environment/Libraries
URL:		http://sourceware.org/libffi/

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

Vendor: Project Vine
Distribution: Vine Linux

%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}
Requires:	pkgconfig

%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 を使用したアプリケーションを開発するなら、このパッケージ
をインストールしてください。

#compat32
%package -n compat32-%{name}
Summary:        Foreign function interface library
Summary(ja):    Foreign function interface ライブラリ
Group:          System Environment/Libraries
Requires:	%{name} = %{version}

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

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

%description -n compat32-%{name}-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 -n compat32-%{name}-devel -l ja
このパッケージは ffi ライブラリを使用するアプリケーションを開発
するのに必要なライブラリやヘッダファイルを含んでいます。

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

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


%prep

%setup -q
%patch0 -p1

%build
autoreconf -ifv
%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*
%{_mandir}/man3/ffi_prep_cif_var.3*

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

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root)
%{_libdir}/libffi.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/libffi.so
%endif

%changelog
* Tue Jan 02 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.1-1
- updated to 3.2.1.
- imported Patch0 from rawhide.

* Sun Jul 06 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.13-1
- update to 3.0.13

* Wed Aug 17 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.9-4
- create compat32 sub packages

* 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