%define version 1.20
%define release 3%{?_dist_release}
%define rel 1

Summary: Canon CAPT Printer Driver for Linux v%{version}
Summary(ja): キヤノン CAPT プリンタドライバ v%{version}
Name: cndrvcups-capt
Version: %{version}
Release: %{release}
License: See the README files.
# Copyright: Copyright CANON INC. 2004. All Rights Reserved.
Vendor: CANON INC.
Group: Applications/Publishing
Source0: http://download.canon.jp/pub/driver/lasershot/linux/%{name}-%{version}-%{rel}.tar.gz
Patch0: cndrvcups-capt-1.20-ppd.patch
ExclusiveArch: %ix86 x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: cups gtk+ glib popt libxml2 zlib
Requires: cndrvcups-common >= %{version}
BuildRequires: cndrvcups-common >= 1.01
BuildRequires: cups-devel gtk+-devel glib-devel
BuildRequires: libxml2-devel zlib-devel
BuildRequires: automake18

%description
Canon CAPT Printer Driver for Linux. 
This CAPT printer driver provides printing functions for Canon LBP printers
operating under the CUPS (Common UNIX Printing System) environment.

%description -l ja
Linux用キヤノンCAPTプリンタドライバ。
このCAPTプリンタドライバはCUPS (Common UNIX Printing System)環境で
キヤノンLBPプリンタを扱うために必要な印刷機能を提供します。

%prep

%setup -q 
%patch -p1 -b .ppd

%build
pushd backend 
  ./autogen.sh --prefix=%{_prefix}
popd

pushd pstocapt 
  ./autogen.sh --prefix=%{_prefix}
popd

pushd ppd 
  ./autogen.sh --prefix=%{_prefix}
popd

pushd statusui
if [ -x /usr/bin/automake-1.8 ] ; then
	./autogen.sh --prefix=%{_prefix}
elif [ -x /usr/bin/automake-1.6] ; then
	./autogen.sh --prefix=%{_prefix}
else
	./autogen-old.sh --prefix=%{_prefix}
fi

make

%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

mkdir -pv ${RPM_BUILD_ROOT}%{_bindir}
mkdir -pv ${RPM_BUILD_ROOT}%{_sbindir}
mkdir -pv ${RPM_BUILD_ROOT}%{_libdir}/cups/backend
mkdir -pv ${RPM_BUILD_ROOT}%{_libdir}/cups/filter
mkdir -pv ${RPM_BUILD_ROOT}%{_datadir}/locale/ja/LC_MESSAGES
mkdir -pv ${RPM_BUILD_ROOT}%{_datadir}/ccpd
mkdir -pv ${RPM_BUILD_ROOT}%{_datadir}/captmon
mkdir -pv ${RPM_BUILD_ROOT}%{_datadir}/captmon2
mkdir -pv ${RPM_BUILD_ROOT}%{_datadir}/cups/model/canon
mkdir -pv ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}/JP
mkdir -pv ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}/EN
mkdir -pv ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d
%makeinstall

install -c -s -m 755 libs/captmon/captmon       %{buildroot}%{_bindir}
install -c -s -m 755 libs/captmon2/captmon2       %{buildroot}%{_bindir}
install -c -s -m 755 libs/captfilter    %{buildroot}%{_bindir}
install -c -s -m 755 libs/ccpd          %{buildroot}%{_sbindir}
install -c -s -m 755 libs/ccpdadmin     %{buildroot}%{_sbindir}
#install -c -s -m 755 libs/ccpddata/CNAB1CL.BIN ${RPM_BUILD_ROOT}%{_datadir}/ccpd
#install -c -s -m 755 libs/captmon/msgtable.xml ${RPM_BUILD_ROOT}%{_datadir}/captmon
#install -c -s -m 755 libs/captmon2/msgtable2.xml ${RPM_BUILD_ROOT}%{_datadir}/captmon2
#install -c -s -m 755 samples/ccpd.conf  %{buildroot}%{_sysconfdir}
#install -c -s -m 755 samples/ccpd       %{buildroot}%{_sysconfdir}/init.d
install -c -m 755 libs/ccpddata/CNAB1CL.BIN ${RPM_BUILD_ROOT}%{_datadir}/ccpd
install -c -m 755 libs/captmon/msgtable.xml ${RPM_BUILD_ROOT}%{_datadir}/captmon
install -c -m 755 libs/captmon2/msgtable2.xml ${RPM_BUILD_ROOT}%{_datadir}/captmon2
install -c -m 755 samples/ccpd.conf  %{buildroot}%{_sysconfdir}
install -c -m 755 samples/ccpd       %{buildroot}%{_sysconfdir}/init.d

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%post
if [ ! -d /var/ccpd ] ; then
	mkdir /var/ccpd
	mkfifo -m 600 /var/ccpd/fifo0
	mkfifo -m 600 /var/ccpd/fifo1
	mkfifo -m 600 /var/ccpd/fifo2
	mkfifo -m 600 /var/ccpd/fifo3
	mkfifo -m 600 /var/ccpd/fifo4
	mkfifo -m 600 /var/ccpd/fifo5
	mkfifo -m 600 /var/ccpd/fifo6
	mkfifo -m 600 /var/ccpd/fifo7

	chown lp.lp /var/ccpd/*
fi

# /sbin/chkconfig --add ccpd

%preun
# if [ "$1" = 0 ] ; then
#	/sbin/service ccpd stop > /dev/null 2>&1
#	/sbin/chkconfig --del ccpd
# fi
# exit 0

%postun
if [ "$1" = 0 ] ; then
	rm -Rf /var/ccpd
# else
#	/sbin/service ccpd restart > /dev/null 2>&1
fi

%files
%defattr(-,root,root)
%doc README-capt-*.txt
%doc LICENSE-capt-*.txt
%{_libdir}/cups/backend/ccp
%{_libdir}/cups/filter/pstocapt
%{_bindir}/captstatusui
%{_datadir}/locale/ja/LC_MESSAGES/captstatusui.mo
%{_datadir}/cups/model/canon/CNCUPS*CAPT*.PPD
%{_datadir}/ccpd/CNAB1CL.BIN
%{_datadir}/captmon/msgtable.xml
%{_datadir}/captmon2/msgtable2.xml
%{_bindir}/captmon
%{_bindir}/captmon2
%{_bindir}/captfilter
%{_sbindir}/ccpd
%{_sbindir}/ccpdadmin

%config(noreplace) %{_sysconfdir}/ccpd.conf
%config		%{_sysconfdir}/init.d/ccpd


%changelog
* Tue Oct 21 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.20-3
- spec really in utf-8 :)
- add ExclusiveArch, because this package contains prebuilt binaries
  for ix86 archtecture (captmon etc.)

* Mon Oct 20 2008 Shu KONNO <owa@bg.wakwak.com> 1.20-2vl5
- applied new versioning policy, spec in utf-8
- without strip-option to install some files

* Tue Sep  6 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.20-1vl1
- new upstream release

* Tue Oct 26 2004 Satoshi MACHINO <machino@vinelinux.org> 1.02-1vl1
- intial release
	-- added cndrvcups-capt-1.02-ppd.patch

