%define dropdir %(pkg-config libpcsclite --variable usbdropdir 2>/dev/null)
%define libusb1_ver 1.0.9
%define pcsc_lite_ver 1.8.3

Name:           ccid145
Version:        1.4.5
Release:	1%{?_dist_release}
Summary:        Generic USB CCID smart card reader driver
Summary(ja):        Generic USB CCID smart card reader driver

Group:          System Environment/Libraries
License:        LGPLv2+
URL:            http://pcsclite.alioth.debian.org/ccid.html
Source0:        http://alioth.debian.org/download.php/1563/ccid-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires:  libusb1-devel >= %{libusb1_ver}
BuildRequires:  pcsc-lite-devel >= %{pcsc_lite_ver}
Requires(post): initscripts
Requires(postun): initscripts
Requires:       libusb1
Requires:       pcsc-lite
Provides:       pcsc-ifd-handler
Conflicts:	ccid
# 390 does not have libusb or smartCards
ExcludeArch: s390 s390x


%description
Generic USB CCID (Chip/Smart Card Interface Devices) driver.


%prep
%setup -q -n ccid-%{version}
for f in ChangeLog README ; do
  iconv -f iso-8859-1 -t utf-8 $f > $f.utf8 ; mv $f.utf8 $f
done


%build
%configure --disable-dependency-tracking --disable-static --enable-twinserial
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%{__mkdir_p} $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d
%{__install} -m 644 src/92_pcscd_ccid.rules $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d/92-pcscd_ccid.rules


%clean
rm -rf $RPM_BUILD_ROOT


%post
[ -x %{_initrddir}/pcscd ] && %{_initrddir}/pcscd status >> /dev/null 2>&1 && %{_sbindir}/pcscd -H > /dev/null 2>&1
exit 0

%postun
[ -x %{_initrddir}/pcscd ] && %{_initrddir}/pcscd status >> /dev/null 2>&1 && %{_sbindir}/pcscd -H  > /dev/null 2>&1
exit 0


%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README SCARDGETATTRIB.txt
%{dropdir}/ifd-ccid.bundle/
%{dropdir}/serial/
%config(noreplace) %{_sysconfdir}/reader.conf.d/libccidtwin
%config %{_sysconfdir}/udev/rules.d/92-pcscd_ccid.rules


%changelog
* Tue Jun 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.5-1
- initial build

