%define desktop_file 1
%define desktop_file_utils_version 0.2.90

Summary: An X Window System tool for drawing basic vector graphics.
Name: xfig
Version: 3.2.5b
Release: 1%{?_dist_release}
License: Freeware
Group: Applications/Graphics
Url: http://www.xfig.org/
Source0: http://www.xfig.org/xfigdist/xfig.%{version}.full.tar.gz
Source1: xfig.png
Source2: xfig.desktop
Source3: xfig.sh
Source4: Fig.ad.ja

Patch0: xfig-3.2.5a-default-apps.patch
Patch1: xfig-3.2.5-fhs.patch
Patch7: xfig.3.2.5-modularX.patch
Patch9: xfig.3.2.5-Xaw3d.patch
Patch10: xfig-3.2.5-enable-Xaw3d.patch
Patch13: xfig-3.2.5-urwfonts.patch
Patch19: xfig-3.2.5-debian.patch

BuildRequires: libjpeg-devel
BuildRequires: libpng-devel
BuildRequires: imake
BuildRequires: libICE-devel
BuildRequires: libSM-devel
BuildRequires: libX11-devel
BuildRequires: libXaw-devel
BuildRequires: libXext-devel
BuildRequires: libXi-devel
BuildRequires: libXmu-devel
BuildRequires: libXpm-devel
BuildRequires: libXt-devel
BuildRequires: Xaw3d-devel
BuildRequires: desktop-file-utils

Buildroot: %{_tmppath}/%{name}-root
Requires: transfig >= 3.2.5
Requires: xdg-utils, enchant, urw-fonts
Requires: hicolor-icon-theme

Vendor: Project Vine
Distribution: Vine Linux

%description
Xfig is an X Window System tool for creating basic vector graphics,
including bezier curves, lines, rulers and more.  The resulting
graphics can be saved, printed on PostScript printers or converted to
a variety of other formats (e.g., X11 bitmaps, Encapsulated
PostScript, LaTeX).

%prep
%setup -q -n xfig.%{version}
%patch0 -p1 -b .redhat
%patch1 -p1 -b .fhs
%patch7 -p1 -b .modularX
%patch9 -p1 -b .Xaw3d
%patch10 -p1 -b .no-Xaw3d
%patch13 -p1 -b .urw
%patch19 -p1
rm Doc/html/images/sav1a0.tmp

%build
xmkmf
make XFIGDOCDIR=%{_docdir}/%{name}-%{version} \
     CDEBUGFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fno-strength-reduce -fno-strict-aliasing"

%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=%{buildroot} XFIGDOCDIR=%{_docdir}/%{name}-%{version} \
     INSTALL="install -p" install.all
install -p -m 644 CHANGES README LATEX.AND.XFIG* FIGAPPS \
  %{buildroot}%{_docdir}/%{name}-%{version}

# remove the map generation scripts, these are for xfig developers only
rm %{buildroot}%{_datadir}/%{name}/Libraries/Maps/{USA,Canada}/assemble

mkdir -p %{buildroot}%{_datadir}/icons/hicolor/32x32/apps \
         %{buildroot}%{_datadir}/applications

install -p -m 644 %{SOURCE1} %{buildroot}%{_datadir}/icons/hicolor/32x32/apps

desktop-file-install --vendor ""         \
  --dir %{buildroot}%{_datadir}/applications \
  %{SOURCE2}

# remove app-defaults symlink which gets installed
rm %{buildroot}%{_prefix}/lib*/X11/app-defaults


%clean
rm -rf $RPM_BUILD_ROOT

%post
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi

%postun
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi


%files
%defattr(-,root,root)
%doc %{_docdir}/%{name}-%{version}
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_mandir}/*/*
%{_datadir}/X11/app-defaults/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/32x32/apps/%{name}.png


%changelog
* Thu Sep 03 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 3.2.5-1
- new usptream release
- build with modular X
- import patched from fedora package.
- drop jp patch

* Sat Jul 29 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.2.4-2vl5
- rebuilt with Xaw3d-1.5-17vl3

* Fri Sep 10 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.2.4-2vl4
- Requires transfig >= 3.2.4, ghostscript 
- build with -march=i386
- changed Group
- fixed .desktop file

* Wed Sep  8 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.2.4-2vl3
- rebuild with gcc-3.3.2
- added BuildPrereq: Xaw3d-devel

* Sun Aug 31 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.2.4-2vl2
- based on Rawhide 3.2.4-2
  * Tue May  6 2003 Than Ngo <than@redhat.com> 3.2.4-1
  - 3.2.4
  * Wed Jul 24 2002 Than Ngo <than@redhat.com> 3.2.3d-8
  - desktop file issue (bug #69543)
  * Tue Jun 25 2002 Than Ngo <than@redhat.com> 3.2.3d-7
  - add patch file using mkstemp (bug #67351)
  * Tue Jul 03 2001 Than Ngo <than@redhat.com>
  - fix export to eps when i18n set (bug #45114)

- update Source3
- previous Patch0 moved to Patch10
- rebuild with new toolchains

* Sun Aug 20 2000 Jun Nishii <jun@vinelinux.org>
- 3.2.3c-0vl1
- use brp

* Mon Jan 24 2000 Atsushi Saito <saito4@slb.com>
- update to 3.2.3a

* Tue Dec 21 1999 Atsushi Saito <saito4@slb.com>
- update to 3.2.3-beta-1
- i18n

* Thu Sep 23 1999 Preston Brown <pbrown@redhat.com>
- add icon
- don't compile with optimization on alpha

* Mon Aug 30 1999 Preston Brown <pbrown@redhat.com>
- converted to use a .desktop file

* Fri Mar 26 1999 Michael Maher <mike@redhat.com>
- added files that were missing. 

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 4)
- varargs fix

* Thu Feb 18 1999 Jeff Johnson <jbj@redhat.com>
- correct DESTDIRR typo (#962)

* Wed Dec 30 1998 Cristian Gafton <gafton@redhat.com>
- build for glibc 2.1

* Tue Jul  7 1998 Jeff Johnson <jbj@redhat.com>
- updated to 3.2.2.

* Wed Jun 10 1998 Prospector System <bugs@redhat.com>
- translations modified for de

* Fri May 08 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Sat Apr 11 1998 Cristian Gafton <gafton@redhat.com>
- updated for manhattan
- buildroot

* Thu Oct 23 1997 Marc Ewing <marc@redhat.com>
- new version
- messed with config for 5.0
- updated Requires and Copyright
- added wmconfig

* Mon Jul 21 1997 Erik Troan <ewt@redhat.com>
- built against glibc
