%define gimpdirs %(/bin/ls -d %{_libdir}/gimp/*/plug-ins 2> /dev/null)
Name: xsane
Summary: XSane is a graphical frontend for scanners. It uses the library SANE.
Summary: SANE スキャナインタフェースの Xウィンドウ用フロントエンドです
Version: 0.997
Release: 2%{?_dist_release}
Source: http://www.xsane.org/download/%{name}-%{version}.tar.gz
%{?nosrc:NoSource:     0}
License: GPL
URL: http://www.xsane.org/
Group: Applications/Multimedia
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: sane >= 1.0.0, gtk2, glib2, atk, pango, zlib 
BuildRequires: sane-devel, gtk2-devel, atk-devel, pango-devel 
BuildRequires: gimp >= 1.3.23
BuildRequires: libjpeg-devel, libpng-devel, libtiff-devel,zlib-devel
BuildRequires: sed, glibc-common
BuildRequires: gimp-devel

%description
Xsane is a grahical frontend for sane. Install this if you want a grahpical
frontend for sane for use in the X Windowing System.

%description -l ja
XSane は、多くのスキャナ、デジタルカメラ、その他の画像取り込み装置に対応
した SANE スキャナインタフェースの Xウィンドウ用フロントエンドです。
XSane は GTK+ で書かれ、画像取り込みや取込み画像の操作を行うことができま
す。

%prep
%setup -q

# correct some links in html documents
cd doc
DOCFILE=sane-backends-doc.html
cat ${DOCFILE} | sed 's,/usr/local/share,%{_datadir},' > ${DOCFILE}.new
[ -f  ${DOCFILE}.new ] && mv -f ${DOCFILE}.new ${DOCFILE}
DOCFILE=sane-xsane-gimp-doc.html
cat ${DOCFILE} | sed 's,/usr/local/bin,%{_bindir},' > ${DOCFILE}.new
[ -f  ${DOCFILE}.new ] && mv -f ${DOCFILE}.new ${DOCFILE}
ICONFILE=sane-logo2.jpg
[ -f %{_datadir}/sane/${ICONFILE} ] && cp %{_datadir}/sane/${ICONFILE} ./

%build
%configure
%{__make} %{?_smp_mflags}

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

cp src/*.xpm $RPM_BUILD_ROOT%{_datadir}/sane/%{name}

if (echo "%{gimpdirs}" | grep -q plug-ins) ;then
	for D in %{gimpdirs} ; do
		mkdir -p $RPM_BUILD_ROOT${D}
		%__ln_s -f %{_bindir}/xsane $RPM_BUILD_ROOT${D}/xsane
	done
fi

# prepare applnk
%define applnkdir /etc/X11/applnk/Graphics
%define icondir %{_datadir}/sane/%{name}

mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
cat > $RPM_BUILD_ROOT%{_datadir}/applications/%{name}.desktop <<EOF
[Desktop Entry]
Encoding=UTF-8
Name=XSane
Name[ja]=XSane スキャナ操作
Comment=Scanner program
Comment[ja]=スキャナを操作するツールです
Terminal=false
Type=Application
Icon=%{icondir}/xsane-48x48.xpm
Exec=xsane 
MultipleArgs=false
Categories=Application;Graphics;
EOF

%find_lang %{name}

%clean
rm -rf $RPM_BUILD_ROOT

%files -f %{name}.lang
%defattr(-,root,root)
%doc xsane.*
%{_bindir}/*
%{_mandir}/*/*
%{_datadir}/sane/*
%{_libdir}/gimp/*/plug-ins/*
%{_datadir}/pixmaps/xsane.xpm
%config(missingok) %{_datadir}/applications/*

%changelog
* Fri Jan 11 2013 IWAI, Masaharu <iwai@alib.jp> 0.997-2
- build with libgphoto2 2.5.0-1

* Sun Jul 25 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.997-1
- new upstream release
- add BuildRequires: gimp-devel
- remove configure option (--enable-gimp)
- fix %files

* Sat Jul 26 2008 Shu KONNO <owa@bg.wakwak.com> 0.995-1vl5
- applied new versioning policy
- updated script to create %{name}.desktop

* Mon Dec 24 2007 Shu KONNO <owa@bg.wakwak.com> 0.995-0vl1
- new upstream
- updated xsane.desktop

* Sat Jan 08 2005 Satoshi MACHINO <machino@vinelinux.org> 0.96-0vl1
- new upstream version (xsane-0.96)
- fixed spec file
	-- cleaned up
	-- added Requires: sane >= 1.0.0, gtk2, glib2, atk, pango, zlib
	-- added BuildRequires: sane-devel, gtk2-devel, atk-devel, pango-devel
	-- added BuildRequires: gimp >= 1.3.23
	-- added BuildRequires: libjpeg-devel, libpng-devel, libtiff-devel,zlib-devel

* Fri Oct 25 2002 Tomoya TAKA <taka@vinelinux.org> 0.89-0vl1
- new upstream release

* Mon May 13 2002 Satoshi MACHINO <machino@vinelinux.org> xsane-0.86-0vl1
- updated xsane-0.86

* Wed Apr 4 2002 Masaki Shinomiya <shino@pos.to>
- 0.84-0vl1 for Vine Linux-2.x
- 0.84-0.1
- symlink for gimp listed in %file section
- some html-documents
- set %_sysconfdir to /etc for RedHat6.x/Vine2.x
- RPM Group move to Applications/Multimedia

* Tue Mar 12 2002 Masaki Shinomiya <shino@pos.to>
- 0.84-0
- bugfix in %post script

* Sun Dec 23 2001 Masaki Shinomiya <shino@pos.to>
- 0.82-0.1
- use mocros as possible, nosrc

* Thu Jul 5 2001 Masaki Shinomiya <shino@pos.to>
- 0.79-0test
- remove the patch of the tooltips

* Thu Jul 5 2001 Masaki Shinomiya <shino@pos.to>
- 0.78-1vl2
- fixed script for gimp plug-in setup

* Sat Jun 23 2001 Masaki Shinomiya <shino@pos.to>
- rename for VinePlus. program registoration for gnome

* Tue Jun 19 2001 Masaki Shinomiya <shino@pos.to>
- patch to provide proper fonts for the tooltips

* Thu Jun 14 2001 Masaki Shinomiya <shino@pos.to>
- 0.78-1
- escape confliction of the document file 'sane-pnm-doc.html' with one from SANE

* Sun Jun 3 2001 Masaki Shinomiya <shino@pos.to>
- 0.77-1

* Mon May 21 2001 Masaki Shinomiya <shino@pos.to>
- 0.76-1
- refined script for gimp plug-in setup

* Wed Nov 15 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 0.64-0vl1
- updated to 0.64 (hope it'll be compatible with gimp-1.1.27...)

* Mon Oct 16 2000 Jun Nishii <jun@vinelinux.org>
- 0.61-0vl3
- build with gimp-1.1.27

* Mon Sep 25 2000 Jun Nishii <jun@vinelinux.org>
- 0.61-0vl2
- build with gimp-1.1.25

* Thu Sep 21 2000 Jun Nishii <jun@vinelinux.org>
- 0.61-0vl1

* Sat Jan 22 2000 Jun Nishii <jun@vinelinux.org>
- 0.51-0vl1

* Mon Aug 30 1999 Tim Powers <timp@redhat.com>
- changed group

* Mon Jul 26 1999 Tim Powers <timp@redhat.com>
- update to 0.30
- added %defattr
- built for 6.1

* Thu Apr 22 1999 Preston Brown <pbrown@redhat.com>
- initial RPM for PowerTools 6.0






