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

%define build_with_ijs_support 1

Summary: A collection of high-quality printer drivers.
Name: gimp-print
Version: 4.2.7
Release: 3asp
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.1-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
Patch8: gimp-print-ppds.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
%if %{build_with_ijs_support}
BuildRequires: ghostscript-devel
%endif
BuildRequires: gimp-devel >= 1:2.0, cups-devel, autoconf >= 2.59, libtool
BuildRequires: gettext-devel

%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.

%package utils
Summary: Utility programs from gimp-print
Requires: %{name} = %{version}
Group: Applications/Publishing

%description utils
This package contains the escputil program.

%package plugin
Summary: GIMP plug-in for gimp-print
Requires: %{name} = %{version}
Requires: gimp
Group: System Environment/Libraries

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

%package -n gimp-print-cups
Summary: CUPS drivers for Canon, Epson, HP and compatible printers
Requires: cups >= 1:1.1.17-10
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.

%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
rm -f libtool
libtoolize --copy --force
aclocal
autoconf
%if %{build_with_ijs_support}
%configure --with-ijs --with-foomatic --with-cups --without-ghost --with-gimp
%else
%configure --with-foomatic --with-cups --without-ghost --with-gimp
%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
for ver in %{_libdir}/gimp/*
do
  [ "${ver##*/}" == "1.2" ] && continue
  mkdir -p %{buildroot}$ver/plug-ins
  install -m0755 src/gimp/.libs/print %{buildroot}$ver/plug-ins/print
done

mkdir -p %{buildroot}%{_datadir}/%{name}/ppds

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

%find_lang %{name}

%if %{build_with_ijs_support}
%else
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/ijsgimpprint.1*
%endif

%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/*
%dir %{_datadir}/%{name}/ppds

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

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

%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

%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/*

%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

%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

%changelog
* Tue Jan 18 2005 Arkady L. Shane <shejn@msiu.ru> 4.2.7-3asp
- last upstream

* Wed Jan 12 2005 Tim Waugh <twaugh@redhat.com> 4.2.7-3
- Rebuilt for new readline.

* Fri Oct  8 2004 Tim Waugh <twaugh@redhat.com> 4.2.7-2
- Ship %%{_datadir}/%%{name}/ppds directory (feature #124687).
- Browse that directory when asking for a PPD (feature #124687).
- Build requires gettext-devel (bug #135042).

* Fri Jul 16 2004 Tim Waugh <twaugh@redhat.com> 4.2.7-1
- 4.2.7.

* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Mon Jun  7 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-13
- Fix translation issues (bug #124204).

* Tue May 25 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-12
- Fixed an autoconf test that was preventing rebuilds.

* Wed Mar 31 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-11
- Rebuilt.

* Thu Mar 18 2004 Nils Philippsen <nphilipp@redhat.com> 4.2.6-10
- Rebuild against new gimp.

* Mon Mar  8 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-9
- Fix 'underquoted definition' warning in gimpprint.m4.

* Tue Mar 02 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Sat Feb 28 2004 Tim Waugh <twaugh@redhat.com>
- Not much point in installing the plug-in into a 1.2 directory since
  we know it won't work for that.

* Fri Feb 27 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-8
- Fixed dither algorithm selection (bug #116516).
- Fixed another plug-in crash.

* Fri Feb 20 2004 Nils Philippsen <nphilipp@redhat.com> 4.2.6-7
- fix gimp_dialog_new() invocations and related stuff in gimp2 patch

* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Thu Feb 12 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-5
- Build for Fedora development.

* Sun Feb  1 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-4
- Build for Fedora Core 1 update.
- Fix for C8x paper alignment (bug #114698).

* Sat Jan 24 2004 Nils Philippsen <nphilipp@redhat.com> 4.2.6-3
- build against gimp2
- buildrequire gimp's epoch as well

* Mon Jan 12 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-2
- Build for Fedora Core 1 update.

* Mon Jan 12 2004 Tim Waugh <twaugh@redhat.com> 4.2.6-1
- 4.2.6.

* Thu Nov 27 2003 Tim Waugh <twaugh@redhat.com>
- Build requires cups-devel (bug #110765).

* Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Mon Jun  2 2003 Tim Waugh <twaugh@redhat.com> 4.2.5-1
- 4.2.5.

* 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.
