# To bootstrap:
#  build this first without IJS support
#  build ghostscript
#  build this with IJS support re-enabled

%define build_with_ijs_support 1
%define build_with_cups_support 0
%define build_with_plugin_support 1
%define build_with_utils_support 1

Summary: A collection of high-quality printer drivers.
Summary(ja): ハイクオリティプリンタドライバ集
Name: gimp-print
Version: 4.2.7
Release: 1%{?_dist_release}
License: GPL
Group: System Environment/Libraries
URL: http://gimp-print.sourceforge.net/
Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Patch0: gimp-print-4.2.1-no-kitload.patch
Patch1: gimp-print-C8x.patch
Patch2: gimp-print-4.2.5-print.patch
Patch4: gimp-print-4.2.6-gimp2.patch
Patch5: gimp-print-plugindir.patch
Patch6: gimp-print-4.2.6-mkinstalldirs.patch
Patch7: gimp-print-textdomain.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%if %{build_with_ijs_support}
BuildRequires: ghostscript-devel
%endif
BuildRequires: gimp-devel >= 2.0

%description
These drivers provide printing quality for UNIX/Linux in many cases equal
to or better than proprietary vendor-supplied drivers, and can be used for
many of the most demanding printing tasks.

%package devel
Summary: Files for developing applications that use gimp-print.
Requires: %{name} = %{version}
Group: Development/Libraries

%description devel
The header files, static library, libtool library and man pages for
developing applications that use gimp-print.

%if %{build_with_utils_support}
%package utils
Summary: Utility programs from gimp-print
Summary(ja): gimp-print 用ユーティリティプログラム
Requires: %{name} = %{version}
Group: Applications/Publishing

%description utils
This package contains the escputil program.
%endif

%if %{build_with_plugin_support}
%package plugin
Summary: GIMP plug-in for gimp-print
Summary(ja): GIMP用 gimp-print プラグイン
Requires: %{name} = %{version}
Requires: gimp >= 2.0
Group: System Environment/Libraries

%description plugin
This package contains the gimp-print GIMP plug-in.
%endif

%if %{build_with_cups_support}
%package -n gimp-print-cups
Summary: CUPS drivers for Canon, Epson, HP and compatible printers
Requires: cups >= 1.1.17
BuildRequires: cups-devel
Group: Applications/Publishing

%description -n gimp-print-cups
gimp-print-cups provides native CUPS support for a wide range of Canon,
Epson, HP and compatible printers.
%endif

%prep
%setup -q
%patch0 -p1 -b .no-kitload
%patch1 -p1 -b .C8x
%patch2 -p1 -b .print
%patch4 -p1 -b .gimp2
%patch5 -p1 -b .plugindir
%patch6 -p1 -b .mkinstalldirs
%patch7 -p1 -b .textdomain

%build
libtoolize --force --copy
aclocal
autoconf
%if %{build_with_ijs_support}
%if %{build_with_cups_support}
%configure --with-ijs --with-foomatic --with-cups --with-gimp --without-ghost
%else 
%configure --with-ijs --with-foomatic --without-cups --with-gimp --without-ghost
%endif
%else
%configure --without-ijs --with-foomatic --without-cups --with-gimp --without-ghost
%endif

make CFLAGS="$RPM_OPT_FLAGS"

%install
rm -rf %{buildroot}
%makeinstall cups_prefix=%{buildroot}%{_prefix} \
	cups_exec_prefix=%{buildroot}%{_exec_prefix} \
	cups_bindir=%{buildroot}%{_bindir} \
	cups_conf_datadir=%{buildroot}%{_datadir}/cups \
	cups_conf_serverbin=%{buildroot}%{_libdir}/cups \
	cups_conf_serverroot=%{buildroot}%{_sysconfdir}/cups

%if %{build_with_plugin_support}
for ver in %{_libdir}/gimp/*
do
  mkdir -p %{buildroot}$ver/plug-ins
  install -m0755 src/gimp/.libs/print %{buildroot}$ver/plug-ins/print
done
%endif

# Don't install this, since we don't list it in the manifest.
rm -f %{buildroot}%{_infodir}/dir

%find_lang %{name}

%clean
rm -rf %{buildroot}

%files -f %{name}.lang
%defattr(-,root,root)
%doc README COPYING
%{_libdir}/*.so.*
%{_infodir}/gimpprint*
%{_datadir}/gimp-print
%if %{build_with_ijs_support}
%{_bindir}/ijsgimpprint
%{_mandir}/man1/ijsgimpprint.1*
%endif
%{_mandir}/man7/*

%if %{build_with_plugin_support}
%files plugin
%defattr(-,root,root)
%{_libdir}/gimp/*/plug-ins/print
%endif

%if %{build_with_utils_support}
%files utils
%defattr(-,root,root)
%{_bindir}/escputil
%{_mandir}/man1/escputil.1*
%endif

%files devel
%defattr(-,root,root)
%dir %{_includedir}/%{name}
%{_includedir}/%{name}/*.h
%{_libdir}/*.a
%{_libdir}/*.so
%{_libdir}/*.la
%{_bindir}/gimpprint-config
%{_mandir}/man1/gimpprint-config.1*
%{_mandir}/man3/*
%{_datadir}/aclocal/gimpprint.m4

%if %{build_with_cups_support}
%files cups
%defattr(-,root,root)
%{_mandir}/man8/cups-calibrate.8*
%{_libdir}/cups/backend/*
%{_libdir}/cups/filter/*
%{_bindir}/cups-calibrate
%{_datadir}/cups/calibrate.ppm
%dir %{_datadir}/cups/model/*
%{_datadir}/cups/model/*/*
%config %{_sysconfdir}/cups/*
%endif

%post
/sbin/ldconfig
/sbin/install-info /usr/share/info/gimpprint.info.gz /usr/share/info/dir

%postun
/sbin/ldconfig
if [ $1 = 0 ]; then
    /sbin/install-info --delete /usr/share/info/gimpprint.info.gz /usr/share/info/dir
fi

%if %{build_with_cups_support}
%post -n gimp-print-cups
/sbin/install-info /usr/share/info/gimpprint.info.gz /usr/share/info/dir
/sbin/ldconfig
if [ $1 -eq 1 ]; then
  # First install.
  /sbin/service cups reload >/dev/null 2>&1 || :
fi
exit 0

%preun -n gimp-print-cups
if [ $1 = 0 ]; then
    /sbin/install-info --delete /usr/share/info/gimpprint.info.gz /usr/share/info/dir
fi

%postun -n gimp-print-cups
/sbin/ldconfig
if [ "$1" -ge "1" ]; then
  /sbin/service cups reload >/dev/null 2>&1 || :
fi
exit 0
%endif

%changelog
* Wed Oct 29 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 4.2.7-1
- rebuild with ghostscript-8.63
- new versioning policy, spec in utf-8

* Sun Apr 16 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.2.7-0vl2
- rebuilt with readline 5.1

* Fri Jul 30 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 4.2.7-0vl1
- new upstream release
- import Patches from fedora's gimp-print-4.2.7-1
- add Japanese Summaries

* Thu Apr 17 2003 Satoshi MACHINO <machino@vinelinux.org> 4.2.5-0vl4
- rebuild gimp-1.2.3-0vl4 and ghostscript-7.06-0vl1

* Thu Mar 13 2003 Satoshi MACHINO <machino@vinelinux.org> 4.2.5-0vl3
- Ships the gimp print plug-in
	-- enable plugin/utils support

* Sun Mar 2 2003 Satoshi MACHINO <machino@vinelinux.org> 4.2.5-0vl2
- Enable IJS support
- fixed spec file
	-- disable {cups, plugin, utils}_support

* Sat Mar 1 2003 Satoshi MACHINO <machino@vinelinux.org> 4.2.5-0vl1
- New upstream version
- added patch1
- dropped patch2

* Sat Mar 1 2003 Satoshi MACHINO <machino@vinelinux.org> 4.2.4-5vl1
- build for VineLinux
	-- without IJS support

* Fri Jan 24 2003 Tim Waugh <twaugh@redhat.com> 4.2.4-5
- Use 'reload' not 'condrestart' for cups.
- Reload cups on first install as well as upgrade (part of bug #82500).

* Wed Jan 22 2003 Tim Powers <timp@redhat.com> 4.2.4-4
- rebuilt

* Tue Jan  7 2003 Nalin Dahyabhai <nalin@redhat.com> 4.2.4-3
- Rebuild

* Tue Dec 19 2002 Tim Waugh <twaugh@redhat.com> 4.2.4-2
- Add plugin subpackage.

* Tue Nov 26 2002 Tim Waugh <twaugh@redhat.com> 4.2.4-1
- 4.2.4.
- Ship more man pages.

* Sun Nov 17 2002 Tim Waugh <twaugh@redhat.com> 4.2.3-2
- Fix print plug-in.

* Thu Nov  7 2002 Tim Waugh <twaugh@redhat.com> 4.2.3-1
- 4.2.3.
- No longer need the ijsparam patch.
- Ship the man page for ijsgimpprint.

* Wed Nov  6 2002 Tim Waugh <twaugh@redhat.com> 4.2.1-6
- Don't install files not shipped.
- Build gimp plug-in.
- Add a mechanism for bootstrapping.

* Thu Jul 18 2002 Tim Waugh <twaugh@redhat.com> 4.2.1-5
- Make the cups package own some directories.

* Tue Jul 16 2002 Tim Waugh <twaugh@redhat.com> 4.2.1-4
- Fix PS:Duplex problems.

* Fri Jun 21 2002 Tim Powers <timp@redhat.com> 4.2.1-3
- automated rebuild

* Sun May 26 2002 Tim Powers <timp@redhat.com> 4.2.1-2
- automated rebuild

* Mon May 20 2002 Tim Waugh <twaugh@redhat.com> 4.2.1-1
- Enable IJS support.

* Mon May 20 2002 Tim Waugh <twaugh@redhat.com> 4.2.1-0.1
- Initial package.
