%define ver 1.18.1
# clean old caches when groff =< %{cache_clean_ver}
# is uninstalled.
%define cache_clean_ver 1.18.1.1-4%{?_dist_release}

Summary: A document formatting system.
Summary(ja): GNU groff 日本語対応版
Name: groff
Version: 1.18.1.1
Release: 5%{?_dist_release}
License: GPL
Group: Applications/Publishing

Vendor: Project Vine
Distribution: Vine Linux

Source0: ftp://ftp.gnu.org/gnu/groff/groff-%{version}.tar.gz
Source1: troff-to-ps.fpi
Source2: groff-tmac-ja.tar.gz
# Japanese Patch from Debian
Patch1: groff_1.18.1.1-20.diff.gz
Patch2: groff-1.18.1.1-fix-minus-char.patch

Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: libX11-devel, libICE-devel, libSM-devel, libXext-devel
BuildRequires: libXmu-devel, libXpm-devel, libXt-devel
BuildRequires: libXaw-devel >= 1.0.5
BuildRequires: psutils, byacc, imake, netpbm-progs, ghostscript
Requires(post,preun): install-info
Obsoletes: groff-tools


%description
Groff is a document formatting system.  Groff takes standard text and
formatting commands as input and produces formatted output.  The
created documents can be shown on a display or printed on a printer. 
Groff's formatting commands allow you to specify font type and size, bold
type, italic type, the number and size of columns on a page, and more.

You should install groff if you want to use it as a document formatting
system.  Groff can also be used to format man pages. If you are going
to use groff with the X Window System, you'll also need to install the
groff-gxditview package.

%description -l ja
GNU roff (groff) 日本語対応版です。日本語で書かれたマニュアルを表示す
るのに必要です. 


%package perl
Summary: Parts of the groff formatting system that require Perl.
Group: Applications/Publishing
Requires: %{name} = %{version}
Requires: mktemp

%description perl
The groff-perl package contains the parts of the groff text processor
package that require Perl. These include the afmtodit font processor
for creating PostScript font files, the grog utility that can be used
to automatically determine groff command-line options, and the
troff-to-ps print filter.


%package gxditview
Summary: An X previewer for groff text processor output.
Group: Applications/Publishing
Requires: %{name} = %{version}

%description gxditview
Gxditview displays the groff text processor's output on an X Window
System display.

If you are going to use groff as a text processor, you should install
gxditview so that you preview your processed text files in X.  You'll also
need to install the groff package and the X Window System.


%prep
%setup -q -n groff-%{version}
%patch1 -p1 -b .debian
%patch2 -p0 -b .fix-minus


%build
PATH=$PATH:/usr/X11R6/bin
#autoconf
#configure --enable-japanese
%configure --enable-multibyte
make

cd src/xditview
xmkmf
make
cd ../..


%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
PATH=$PATH:/usr/X11R6/bin
mkdir -p $RPM_BUILD_ROOT%{_prefix}
mkdir -p $RPM_BUILD_ROOT%{_mandir}
%makeinstall manroot=$RPM_BUILD_ROOT%{_mandir}

# install xditview
cd src/xditview
make install DESTDIR=$RPM_BUILD_ROOT
cd ../..

# for groff-ja
#mkdir -p $RPM_BUILD_ROOT%{_datadir}/groff/%{ver}
#tar xzf %{SOURCE2} -C $RPM_BUILD_ROOT%{_datadir}/groff/%{ver}

ln -s s.tmac	$RPM_BUILD_ROOT%{_datadir}/groff/%{ver}/tmac/tmac.gs
ln -s mse.tmac  $RPM_BUILD_ROOT%{_datadir}/groff/%{ver}/tmac/tmac.gmse
ln -s m.tmac	$RPM_BUILD_ROOT%{_datadir}/groff/%{ver}/tmac/tmac.gm
ln -s troff	$RPM_BUILD_ROOT%{_bindir}/gtroff
ln -s tbl	$RPM_BUILD_ROOT%{_bindir}/gtbl
ln -s pic	$RPM_BUILD_ROOT%{_bindir}/gpic
ln -s eqn	$RPM_BUILD_ROOT%{_bindir}/geqn
ln -s neqn	$RPM_BUILD_ROOT%{_bindir}/gneqn
ln -s refer	$RPM_BUILD_ROOT%{_bindir}/grefer
ln -s lookbib	$RPM_BUILD_ROOT%{_bindir}/glookbib
ln -s indxbib	$RPM_BUILD_ROOT%{_bindir}/gindxbib
ln -s soelim	$RPM_BUILD_ROOT%{_bindir}/gsoelim
ln -s soelim    $RPM_BUILD_ROOT%{_bindir}/zsoelim
ln -s nroff	$RPM_BUILD_ROOT%{_bindir}/gnroff

# whether or not build system is compressing man-pages
ln -s eqn.1	%{buildroot}%{_mandir}/man1/geqn.1
ln -s indxbib.1 %{buildroot}%{_mandir}/man1/gindxbib.1
ln -s lookbib.1 %{buildroot}%{_mandir}/man1/glookbib.1
ln -s neqn.1	%{buildroot}%{_mandir}/man1/gneqn.1
ln -s nroff.1   %{buildroot}%{_mandir}/man1/gnroff.1
ln -s pic.1 	%{buildroot}%{_mandir}/man1/gpic.1
ln -s refer.1   %{buildroot}%{_mandir}/man1/grefer.1
ln -s soelim.1  %{buildroot}%{_mandir}/man1/gsoelim.1
ln -s soelim.1  %{buildroot}%{_mandir}/man1/zsoelim.1
ln -s tbl.1 	%{buildroot}%{_mandir}/man1/gtbl.1
ln -s troff.1   %{buildroot}%{_mandir}/man1/gtroff.1

mkdir -p $RPM_BUILD_ROOT%{_libdir}/rhs/rhs-printfilters
install -m755 %{SOURCE1} $RPM_BUILD_ROOT%{_libdir}/rhs/rhs-printfilters

# document files
mkdir -p docs-to-install
cp -pr $RPM_BUILD_ROOT%{_datadir}/doc/%{name}/%{ver}/* docs-to-install
rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}

# 
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
rm -rf $RPM_BUILD_ROOT/%{_prefix}/lib/X11/app-defaults

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

%post
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/groff.gz

%preun
if [ "$1" = 0 ]; then
    /sbin/install-info --delete \
	--info-dir=%{_infodir} %{_infodir}/groff.gz
fi

%triggerpostun -- %{name} <= %{cache_clean_ver}
find %{_var}/cache/man -type f -name "*.bz2" -exec %{__rm} -f {} \;

# -f groff-files
%files 
%defattr(-,root,root)
%doc BUG-REPORT COPYING ChangeLog NEWS PROBLEMS README TODO
%doc README.jp ChangeLog.jp docs-to-install/* 
%{_bindir}/*
%exclude %{_bindir}/gxditview
%{_datadir}/groff
%{_libdir}/rhs/*/*
%{_mandir}/man?/*
%{_infodir}/*
%exclude %{_bindir}/afmtodit
%exclude %{_bindir}/grog
%exclude %{_bindir}/mmroff
%exclude %{_mandir}/man1/afmtodit.*
%exclude %{_mandir}/man1/grog.*
%exclude %{_mandir}/man1/mmroff.*


%files perl
%defattr(-,root,root)
%{_bindir}/afmtodit
%{_bindir}/grog
%{_bindir}/mmroff
%{_mandir}/man1/afmtodit.*
%{_mandir}/man1/grog.*
%{_mandir}/man1/mmroff.*


%files gxditview
%defattr(-,root,root)
%{_bindir}/gxditview
%config %{_sysconfdir}/X11/app-defaults/GXditview


%changelog
* Fri Apr 02 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 1.18.1.1-5
- add %posttriggerun to clean old caches (<BTS:VineLinux:960>)

* Tue Mar 23 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 1.18.1.1-4
- add Patch2 to fix minus/hyphen character width (<BTS:VineLinux:960>)
- add BuildRequires: psutils, byacc, imake, netpbm-progs, ghostscript

* Tue Apr 07 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.18.1.1-3
- remove gxditview from main package

* Sun Nov 09 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.18.1.1-2
- rebuild with libXaw.so.7 (libXaw-1.0.5)

* Sat May 10 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.18.1.1-1
- rebuild with new versioning policy
- update Debian patch

* Sat Sep 22 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.18.1.1-0vl1
- rebuilt with new toolchain
- updated source and Japanese patch based on Debian
- added BuildRequires: XOrg-devel

* Fri Sep 22 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 1.17.2-0vl7
- rebuild to add gpg sign

* Tue Apr  8 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.17.2-0vl6
- rebuild

* Mon Nov 25 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.17.2-0vl5
- rebuilt with new toolchain

* Wed Mar 06 2002 Toru Sagami <sagami@vinelinux.org> 1.17.2-0vl4
- corrected zsoelim.1 symlink in %%{_mandir}

* Mon Feb 11 2002 Satoshi MACHINO <machino@vinelinux.org> 1.17.2-0vl3
- fixed symlink of *.tmac

* Mon Jan 21 2002 Satoshi MACHINO <machino@vinelinux.org> 1.17.2-0vl2
- build on VineSeed

* Mon Jan 21 2002 Satoshi MACHINO <machino@vinelinux.org> 1.17.2-0vl1
- updated groff-1.17.2
    -- security fixed of CAN-2002-0003
    -- changed japanese patch to debian patch
    -- modified spec file

* Mon Sep 10 2001 Toru Sagami <sagami@vinelinux.org>
- 1.16.1-0vl1: split perl components into separate subpackage

* Tue Jul 17 2001 <sagami@vinelinux.org>
- 1.16.1: version up to 1.16.1
- add groff-1.16.1-japanese.patch originally taken from Kondara
- use %%configure after autoconf, %%makeinstall

* Tue Jan 23 2001 Toru Sagami <czs14350@mb.infoweb.ne.jp>
- 1.15_jp-7
- built on egcs-1.1/libstdc++2_9-2.9.0
- fixed: whether or not build system compress man pages

* Tue Dec 26 2000 Tomoya TAKA <tomoya@olive.plala.or.jp> 1.15_jp-6
- some fixes to handle man pages correctly

* Sat Nov 11 2000 MACHINO, Satoshi <machino@vinelinux.org> 1.15_jp-5
- build on gcc-2.95.3
- partially used macros

* Mon Aug  7 2000 Jun Nishii <jun@vinelinux.org>
- 1.15_jp-4
- follow up to RHL62 (1.15-8)

* Thu Feb 24 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.15_jp-3
- modified ja patch, namely lib.h

* Sun Jan  9 2000 Jun Nishii <jun@vinelinux.org>
- groff-tmac-ja was lacked in Source entry(;_;) fixed!

* Tue Jan  4 2000 Jun Nishii <jun@vinelinux.org>
- build for Vine Linux 2.0 with ja patch

* Wed Dec 29 1999 Bill Nottingham <notting@redhat.com>
- update to 1.15

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

* Tue Feb 16 1999 Cristian Gafton <gafton@redhat.com>
- glibc 2.1 patch for xditview (#992)

* Thu Oct 22 1998 Bill Nottingham <notting@redhat.com>
- build for Raw Hide

* Thu Sep 10 1998 Cristian Gafton <gafton@redhat.com>
- fix makefiles to work with bash2

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

* Thu Apr 30 1998 Cristian Gafton <gafton@redhat.com>
- use g++ for C++ code

* Wed Apr 08 1998 Cristian Gafton <gafton@redhat.com>
- manhattan and buildroot

* Mon Nov  3 1997 Michael Fulbright <msf@redhat.com>
- made xdefaults file a config file

* Thu Oct 23 1997 Erik Troan <ewt@redhat.com>
- split perl components into separate subpackage

* Tue Oct 21 1997 Michael Fulbright <msf@redhat.com>
- updated to 1.11a
- added safe troff-to-ps.fpi

* Tue Oct 14 1997 Michael Fulbright <msf@redhat.com>
- removed troff-to-ps.fpi for security reasons.

* Fri Jun 13 1997 Erik Troan <ewt@redhat.com>
- built against glibc

