# To make src.rpm
# rpm -bs --define 'src:1'
# To make nosrc.rpm
# rpm -bs --define 'nosrc:1'

%define build_html 0

Summary:	SANE -- Easy local and networked scanner access
Summary(ja):	スキャナ操作ツール
Name:		sane
Version:	1.0.25
Release:	1%{?_dist_release}
URL:		http://www.sane-project.org/
Source:		ftp://ftp.sane-project.org/pub/sane/%{name}-backends-%{version}.tar.gz
Source10:       sane-hierarchy.png
Patch0:		sane-1.0.24-vine.patch
%{?nosrc:NoSource: 0}
License:	GPL (programs), relaxed LGPL (libraries), and public domain (docs)
Group:		Applications/Multimedia
#Icon:		sane-logo.png
Provides:	libsane.so.1 sane-backends

BuildRequires:  sed
BuildRequires:  libjpeg-devel
BuildRequires:  libusb1-devel
BuildRequires:  libgphoto2-devel
#BuildPrereq:    latex2html
#BuildPrereq: emacs/or/xemacs pLaTeX2e/or/tetex-latex pTeX/or/tetex
Buildroot: 	%{_tmppath}/%{name}-%{version}-root

%{?nosrc:%define src 1} 
%{?src:%define _src 1}
%{?!src:%define _src 0}

Vendor: Project Vine
Distribution: Vine Linux

%description
SANE (Scanner Access Now Easy) is a sane and simple interface
to both local and networked scanners and other image acquisition devices
like digital still and video cameras.  SANE currently includes modules for
accessing a range of scanners, including models from Agfa SnapScan, Apple,
Artec, Canon, CoolScan, Epson, HP, Microtek, Mustek, Nikon, Siemens,
Tamarack, UMAX, Connectix, QuickCams and other SANE devices via network.
This package also include a client program 'scanimage','sane-find-scanner',
'xerox' and etc.

For the latest information on SANE, the SANE standard definition, and
mailing list access, see http://www.mostang.com/sane/
%if %{_src}
You need xemacs or emacs to build this package.
And you need latex2html to build this package if you like html documents.
%endif

%description -l ja
SANE (Scanner Access Now Easy) はローカル/ネットワーク・スキャナや
デジタルカメラ、デジタルビデオカメラなど画像取り込み装置の簡単なイン
ターフェースです。SANE は Agfa SnapScan, Apple, Artec, Canon, CoolScan, 
Epson, HP, Microtek, Mustek, Nikon, Siemens, Tamarack, UMAX, Connectix, 
QuickCams その他、いろいろなスキャナを使うことができます。
コマンドラインで動くscanimage, sane-find-scanner, xeroxなどもこのパッケージに
含まれています。
%if %{_src}
このソースパッケージからビルドするにはxemacsまたはemacsが必要です。
またHTMLドキュメントを含めるにはlatex2htmlが必要です。
%endif

%package devel
Summary:  SANE (Scanner Access Now Easy) development toolkit
Summary(ja):  SANE (Scanner Access Now Easy) 開発ツールキット
Group:    Development/Libraries
Requires: %{name} = %{version}
Requires: pkgconfig
Requires: libjpeg-devel
Requires: libgphoto2-devel
Requires: libexif-devel
Requires: libusb1-devel

%description devel
Static libraries and header files for writing SANE modules.

%description devel -l ja
SANE のモジュールを書くための、ヘッダファイルと静的ライブラリ
です。

%prep
%setup -q -n %{name}-backends-%{version}
%patch0 -p1 -b .vine

%build
%configure --with-gnu-ld --enable-static --enable-libusb_1_0
# don't set smp flags!
make

# dll.conf: comment out all lines
# epson.conf: add example for usb scanner
( cd backend
cat dll.conf | %__sed "s/^\([^#]\)/#\1/" > dll.conf~
%__mv -f dll.conf~ dll.conf
echo "#usb /dev/usb/scanner0" >> epson.conf
)

%if %{build_html}
( cd doc
  %__make html
  %__mv sane html
  cd html
  %__cp -f %{SOURCE10} img1.png
  %__cat node10.html | \
    %__sed 's/WIDTH="5.." HEIGHT="2"/WIDTH="500" HEIGHT="246"/' \
    > node10.html~
  %__mv -f node10.html~ node10.html
  %__rm -f WARNINGS
)
[ -d doc/html ] || %__mkdir doc/html
%endif

%install
%__rm -rf $RPM_BUILD_ROOT
%{__make} install DESTDIR=${RPM_BUILD_ROOT}
%__mv $RPM_BUILD_ROOT%{_sbindir}/saned $RPM_BUILD_ROOT%{_sbindir}/in.saned
%__install -m755 tools/xerox $RPM_BUILD_ROOT%{_bindir}
%__install -m755 tools/umax_pp $RPM_BUILD_ROOT%{_bindir}
%__cp tools/README README.tools
%__mkdir_p $RPM_BUILD_ROOT%{_datadir}/%{name}
%if %{build_html}
%__cp doc/*.html doc/*.png doc/*.jpg $RPM_BUILD_ROOT%{_datadir}/%{name}
##%__mv doc/*.html doc/*.png doc/*.jpg doc/html
%endif

pushd $RPM_BUILD_ROOT%{_bindir}
%__ln_s sane-find-scanner find-scanner
popd

# Create ld.so.conf.d entry
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf << EOF
%{_libdir}/%{name}
EOF

# clear uninstall files
%__rm -rf $RPM_BUILD_ROOT%{_prefix}/doc
%__rm -rf $RPM_BUILD_ROOT%{_libdir}/lib*.la
%__rm -rf $RPM_BUILD_ROOT%{_libdir}/sane/lib*.la


%post
/sbin/ldconfig

[ -d /dev/usb ] || %__mkdir /dev/usb
[ -c /dev/usb/scanner0 ] || mknod /dev/usb/scanner0 c 180 48 -m 777

# network settings
SERVICES=%{_sysconfdir}/services
if [ -x "%__grep" -a -f "$SERVICES" ] ; then
%__grep -q "^sane" $SERVICES || \
echo "sane          6566/tcp       # network sccaner deamon" >> $SERVICES
fi
INETDCONF=%{_sysconfdir}/inetd.conf 
if [ -x "%__grep" -a -f "$INETDCONF" ] ; then
%__grep -q "^#*sane" $INETDCONF || \
echo "#sane    stream  tcp     nowait  root    %{_sbindir}/in.saned   %{_sbindir}/in.saned" >>   $INETDCONF
fi
#kill -HUP `/sbin/pidof inetd`

%postun -p /sbin/ldconfig


%clean
%__rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README* AUTHORS ChangeLog* COPYING LICENSE PROBLEMS PROJECTS NEWS
%doc doc/figs doc/icons doc/canon doc/mustek doc/mustek_usb doc/umax
%if %{build_html}
%doc doc/html
%endif
%doc doc/*.{txt,tex,sty}
%doc tools
%dir %{_sysconfdir}/sane.d
%config %{_sysconfdir}/sane.d/*
%config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
%{_sbindir}/*
%{_bindir}/find-scanner
%{_bindir}/gamma4scanimage
%{_bindir}/sane-find-scanner
%{_bindir}/scanimage
%{_bindir}/umax_pp
%{_bindir}/xerox
%{_libdir}/lib*.so.*
%{_libdir}/lib*.so
%{_libdir}/sane/lib*.so.*
%{_libdir}/sane/lib*.so
%dir %{_libdir}/sane
%{_datadir}/sane
%{_mandir}/man1/*.1*
%{_mandir}/man5/*.5*
%{_mandir}/man7/*.7*
%{_mandir}/man8/*.8*
%{_datadir}/locale

%files devel
%defattr(-,root,root)
%{_bindir}/sane-config
%{_includedir}/sane
%{_libdir}/pkgconfig/sane-backends.pc
%{_libdir}/lib*.a
%{_libdir}/sane/lib*.a

%changelog
* Wed May 18 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.0.25-1
- new upstream release.
- replace BR:libusb with BR:libusb1.

* Mon Feb 09 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.24-2
- rebuild with libgphoto2-2.5.7

* Sun Feb 01 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.24-1
- update to 1.0.24
- update Patch0 (sane-1.0.24-vine.patch)
- remove Patch1 (sane-backends-1.0.21-i18n.patch)
- fix %%post and %%postun (fix BTS:2514)

* Fri Jan 11 2013 IWAI, Masaharu <iwai@alib.jp> 1.0.21-2
- build with libghoto2 2.5.0-1
- stop generating HTML manual: missing man2html(1) in current VineSeed
- add Vendor and Distribution tags

* Sun Jul 25 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.21-1
- new upstream release
- change Patch (from sane-1.0.15-vine.patch to sane-1.0.21-vine.patch)
- move sane-config to devel package
- add Requires: libjpeg-devel, libgphoto2-devel, libexif-devel, libusb-devel (devel package)
- add Patch1(sane-backends-1.0.21-i18n.patch)

* Sun Oct 12 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.18-3
- added BuildRequires: libgphoto2-devel instead of ghoto2-devel

* Sat Oct 11 2008 Shu KONNO <owa@bg.wakwak.com> 1.0.18-2
- spec in utf-8

* Mon May 12 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.18-1
- applied new versioning policy
- removed lib*.la files from devel package

* Mon Dec 24 2007 Shu KONNO <owa@bg.wakwak.com> 1.0.18-0vl1
- new upstream release

* Sun Jan 09 2005 Satoshi MACHINO <machino@vinelinux.org> 1.0.15-0vl1
- new upstream version(sane-1.0.15)
- fixed spec file
	-- cleaned up patches
	-- added Requires:       libjpeg, libusb
	-- added BuildRequires:  glibc, libjpeg-devel, libusb-devel

* Fri Oct 25 2002 Tomoya TAKA <taka@vinelinux.org> 1.0.8-0vl1
- new upstream release
- update sane-1.0.8-vine.patch
- add --enable-static option to %%configure

* Mon May 13 2002 Masaki Shinomiya <shino@pos.to>
- 1.0.7-0vl2: sparc.patch, ppc.patch both from Mandrake(4mdk)
- informed by Iohara [VinePlus:01130]

* Thu Apr 4 2002 Masaki Shinomiya <shino@pos.to>
- 1.0.7-0vl1 for Vine Linux-2.x
- 1.0.7-0.1
- set %_sysconfdir to /etc for RedHat6.x/Vine2.x

* Wed Mar 6 2002 Masaki SHINOMIYA <shino@pos.to>
- 1.0.7-0
- new source
- avoid listing %{_libdir}/sane from sane-devel
- add LEVEL2 in doc

* Fri Feb 1 2002 Masaki SHINOMIYA <shino@pos.to>
- 1.0.6-0.3
- allow to build without latex2html
- prereq ldconfig, buildprereq sed, provide sane-backends

* Sun Dec 23 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.6-0.2
- dll.conf, epson.conf, network settings

* Tue Dec 18 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.6-0.1
- new source

* Mon Dec 17 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.5-1.3
- allow to use emacs or xemacs in building
- nosrc

#* Wed Oct 3 2001 Masaki SHINOMIYA <shino@pos.to>
#- 1.0.5-1.2
#- surpress swapping R<-->G colors on EPSON GT-8700/Perfection1640
#- ( information from [vine-users:037559] tyu <tyu@mbd.nifty.com> )
#- omit doc/*.tex etc.

* Tue Sep 18 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.5-1.1
- use emacs instead of xemacs in building

* Sat Jul 7 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.5-1

* Thu Jun 7 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.4 + epson backend ver.20010519
- sane-clients is removed from this package
- scanimage, find-scanner and xerox are left in this package

* Thu May 17 2001 Masaki SHINOMIYA <shino@pos.to>
- 1.0.4 + epson backend ver.20010331
- 'scanimage' is included in the binary'sane-1.0.4-1.i386.rpm'package.
- refined script for gimp plug-in setup
- html documents shal be installed in the directory '/usr/share/sane'
- automatically make device the file /dev/usb/scanner0

* Wed Nov 15 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.0.3-0vl8
- included missing "sane-config" script for sane

* Tue Oct 17 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.3-0vl7
- merge xscanimage patch

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

* Sun Oct  1 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.3-0vl5
- fixed group

* Sat Sep 30 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.3-0vl4
- added %defattr in clients

* Tue Sep 26 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.3-0vl3
- build with gimp-1.1.26

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

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

* Thu Jun  8 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.2-0vl1

* Mon Jan 17 2000 Jun Nishii <jun@vinelinux.org>
- build for Vine Linux 2.0
- added find-scanner, xerox

* Fri Apr 23 1999 Hugo van der Kooij <hvdkooij@caiw.nl>
- Fixed packaging a bit.

* Wed Apr 21 1999 Hugo van der Kooij <hvdkooij@caiw.nl>
- Updated package to 1.01

* Fri Apr 09 1999 Hugo van der Kooij <hvdkooij@caiw.nl>
- Split off the clients
- Fixed a Alpha system anomaly by removing the specific backend.

* Mon Nov 23 1998 Jonathan Miller <jlm@mvhi.com>
 [1.00-1]
- upgraded to 1.00 (and made description less space-consuming)
- included the post 1.00 fixed "configure" script available 22 Nov 1998.

* Sat Aug 08 1998 Arne Coucheron <arneco@online.no>
  [0.74-3]
- added /etc/sane.d to %dir in file list

* Sat Aug 01 1998 Arne Coucheron <arneco@online.no>
  [0.74-2]
- devel Group: reverted back to Development/Libraries
- some changes to the %defattr and %attr usage in file list

* Tue Jul 28 1998 Binaire <binaire@binaire.ml.org>
  [0.74-1]

* Fri May 22 1998 Arne Coucheron <arneco@online.no>
  [0.73-3]
- added use of %%{name} and %%{version} macros
- added a %postun for running ldconfig after uninstall
- using BuildRoot properly now
- using %defattr and %attr macros in filelist, allows non-root build 
  this means that RPM 2.5 is required to build this spec file now!
- devel Group: changed to X11/Libraries
- added using RPM_OPT_FLAGS during make 
- added striping of programs and libraries
- added Requires: gtk+ >= 0.99.13 to main package
- added Requires: %%{name} = %%{version} to devel package
- added a %clean section for removing the buildroot dir
- simplified the filelist and added %config for sane-style.rc
- moved lib*.so to %files devel and dropped the *.la files
- added -q parameter to %setup
- removed some older changelog entries
- removed the "fix ldconfig brokenness..." stuff
- removed the Packager: line; use /etc/rpmrc if you want your name in
- if GIMP is installed, make symlink from xscanimage to plug-ins dir
- install the find-scanner program from the tools dir

* Mon May 18 1998 Hugo van der Kooij <hvdkooij@caiw.nl>
- Version 0.73 was created: May 13 1998
- gimp (original was build against 0.99.29)
- gtk+ (original was build against 1.0.1)
- dlh (original was build against 0.7d)
- X11 development tree including xpm libraries.

* Wed Apr 22 1998 Hugo van der Kooij <hvdkooij@caiw.nl>
- Binaries are now BuildRoot proof.

* Wed Apr 22 1998 Hugo van der Kooij <hvdkooij@caiw.nl>
- Binaries are not BuildRoot proof. release 3 is done without BuildRoot!

* Tue Apr 21 1998 Hugo van der Kooij <hvdkooij@caiw.nl>
- Temp. fix for some documentations problems with BuildRoot.

* Sat Apr 11 1998 Hugo van der Kooij <hvdkooij@caiw.nl>
- Formal 0.72 now made as RPM! (Build against GTK+ 0.99.10 and GIMP 0.99.24)
- Original package was released: Tue Apr 7 1998
