# use udev feature until things go right...
%define with_hal	0

Summary:	Firmware extraction tools for Apple Built-in iSight camera
Summary(ja):	Apple 内蔵 iSight カメラ用ファームウェア抽出プログラム
Name:		isight-firmware-tools
Version:	1.4.1
Release:	1%{?_dist_release}
License:	GPLv2+
Group:		System Environment/Base
URL:		http://bersace03.free.fr/ift/
Source0:	%{name}-%{version}.tar.gz
Source10:	%{name}-1.2_ja.po

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}

%if %{with_hal}
Requires:	hal
%else
Requires:	udev
%endif
Requires(post):	/sbin/install-info
Requires(preun): /sbin/install-info

BuildRequires:	gettext
BuildRequires:	glib2-devel
BuildRequires:	libgcrypt-devel
BuildRequires:	libusb-devel
%if %{with_hal}
BuildRequires:  hal-devel
%else
BuildRequires:	udev
%endif
BuildRequires:	perl(XML::Parser)


%description
iSight Firmware Tools provide tools to manipulate firmware for Built-in iSight
cameras found on Apple machines since iMac G5 (November 2005).

Before using Built-in iSight on Linux, you will need to extract the
firmware to /lib/firmware/isight.fw as:

    sudo ift-extract --apple-driver /path/to/AppleUSBVideoSupport

AppleUSBVideoSupport driver file should be located in

    /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport

on your Mac OS X root partition.


%description -l ja
iSight Firmware Tools を使って、2005年11月発売の iMac G5 以降の
Apple 社製コンピュータに内蔵されている iSight カメラ用のファームウェアを
操作することができます。

Linux で内蔵 iSight を使う前に、

    sudo ift-extract --apple-driver /path/to/AppleUSBVideoSupport

という風に実行してファームウェアを /lib/firmware/isight.fw として
取り出す必要があります。この AppleUSBVideoSupport ドライバファイルは
通常 Mac OS X ルートパーティションの

    /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport

に存在しているはずです。


%prep
%setup -q

install -m 644 %{SOURCE10} po/ja.po
echo "ja" >> po/LINGUAS

sed --in-place --expression 's|@udevdir@|%{_libdir}/udev|g' src/isight.rules.in.in


%build
%if %{with_hal}
%configure --enable-hal --disable-udev
%else
%configure --disable-hal --enable-udev
%endif
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT

make install INSTALL="%{__install} -p" DESTDIR=$RPM_BUILD_ROOT

rm -f $RPM_BUILD_ROOT%{_infodir}/dir

# Use %doc instead.
rm -rf $RPM_BUILD_ROOT%{_docdir}/%{name}

%find_lang %{name}


%clean
rm -rf $RPM_BUILD_ROOT


%post
/sbin/install-info %{_infodir}/ift-export.info %{_infodir}/dir || :
/sbin/install-info %{_infodir}/ift-extract.info %{_infodir}/dir || :


%preun
if [ $1 = 0 ]; then
  /sbin/install-info --delete %{_infodir}/ift-export.info %{_infodir}/dir || :
  /sbin/install-info --delete %{_infodir}/ift-extract.info %{_infodir}/dir || :
fi


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING HOWTO NEWS README
%{_bindir}/ift-export
%{_bindir}/ift-extract
%{_infodir}/ift-export.info.gz
%{_infodir}/ift-extract.info.gz
%if %{with_hal}
%{_libdir}/hal/ift-callout
%{_datadir}/hal/fdi/preprobe/20thirdparty/50-isight-firmware.fdi
%else
%{_libdir}/udev/ift-load
%{_sysconfdir}/udev/rules.d/isight.rules
%endif
%{_mandir}/man1/ift-export.1.gz
%{_mandir}/man1/ift-extract.1.gz


%changelog
* Sat May 30 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.4.1-1
- new upstream release

* Thu Dec  4 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.4-2
- switch back to udev support, until hal support gets stable

* Thu Dec  4 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.4-1
- new upstream release

* Thu Sep 18 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2-4
- now enable hal support; disable udev support

* Fri May 30 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2-3
- fix broken path in isight.rules

* Mon May 26 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2-2
- enable udev / disable hal (until Vine's udev gets updated enough)
- import Patch10 (for MacBookAir) and Source10 (ja.po) from Debian package

* Fri May 23 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2-1
- initial build for Vine Linux
- spec in UTF-8
