%define buildnum 1
%define builddate 20030220
%define gcc_name gcc

%ifarch sparc
%define automakever 1.5
%endif

%ifarch ia64
%define gcc_name gcc3
%endif

Name:		irssi
Version:	0.8.6
#release starts with 2 since the stable release has a 1 (fedora style)
Release:    2.cvs%{builddate}.fedora.%{buildnum}
Vendor:		Timo Sirainen <tss@iki.fi>
Packager:	Kevin Sonney <ksonney@redhat.com>
Summary:	Irssi is a full-featured modular IRC client (CVS %{builddate})
License:	GPL
Group:		Applications/Communications
URL:		http://irssi.org/
Source0:	http://irssi.org/files/snapshots/%{name}-%{builddate}.tar.gz
Source1:    x%{name}-latest.tar.gz
Source2:    %{name}-themes.tar.gz
BuildRequires:	ncurses-devel, gcc
BuildRequires:	glib2-devel
Requires:	glib2
BuildRequires: %{gcc_name}
Requires:	perl = %(eval "`perl -V:version`"; echo $version), ncurses
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Provides:   %{name}-%{version}

%description
Irssi is a modular IRC client that currently has only text mode user
interface, but 80-90% of the code isn't text mode specific so other UI
could be created pretty easily. Also, Irssi isn't really even IRC
specific anymore, there's already a working SILC module available.
Support for other protocols like ICQ could be created some day too.

More information can be found at http://irssi.org/.

%package -n xirssi
Summary:  X IRSSI front-end
Group:    Applications/Communications
BuildRequires:	glib2-devel, gtk2-devel
BuildRequires: %{gcc_name}
Requires:	glib2, gtk2
Requires: irssi-%{version} = %{release}
Provides: xirssi

%description -n xirssi
A GTK frontend to the irssi IRC client. 

%define irssisource %{name}-%{version}.CVS

%prep
%setup -q -n %{irssisource}
%setup -q -D -a 1 -n %{irssisource}
%setup -q -D -a 2 -n %{irssisource}

%define default_buildparams --enable-ipv6 --with-textui --with-ncurses --with-socks --with-bot --with-proxy --with-perl=yes --with-perl-lib=$RPM_BUILD_ROOT  --with-modules --disable-ssl --with-glib2

%build
export CC=%{gcc_name}
%configure %{default_buildparams}
make

cd xirssi
%configure --with-irssi=%{_builddir}/%{irssisource}
%ifarch sparc
rm -rf depcomp INSTALL install-sh missing mkinstalldirs
ln -s /usr/share/automake-%{automakever}/depcomp depcomp
ln -s /usr/share/automake-%{automakever}/INSTALL INSTALL
ln -s /usr/share/automake-%{automakever}/install-sh install-sh
ln -s /usr/share/automake-%{automakever}/missing missing
ln -s /usr/share/automake-%{automakever}/mkinstalldirs mkinstalldirs
%endif
make
cd ..

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall PREFIX=$RPM_BUILD_ROOT%{_prefix}

for i in $(ls $RPM_BUILD_ROOT%{_libdir}/irssi/modules/lib*.so*); do strip $i; done
if [ ! -d $RPM_BUILD_ROOT%{_docdir} ]; then mkdir $RPM_BUILD_ROOT%{_docdir}; fi
mkdir $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
# nuke "bad" docs
rm -Rf $RPM_BUILD_ROOT%{_docdir}/%{name}
# perl cleanup
mkdir $RPM_BUILD_ROOT%{_libdir}/perl5/
mkdir $RPM_BUILD_ROOT%{_libdir}/perl5/site_perl/
mkdir $RPM_BUILD_ROOT%{_libdir}/perl5/site_perl/%(eval "`perl -V:version`"; echo $version)/
for i in  $(find $RPM_BUILD_ROOT -name perllocal.pod); do rm $i; done
for i in $(find $RPM_BUILD_ROOT -name %{_arch}-linux\*); do mv $i $RPM_BUILD_ROOT%{_libdir}/perl5/site_perl/%(eval "`perl -V:version`"; echo $version)/; done
cp -r themes/*.theme $RPM_BUILD_ROOT%{_datadir}/irssi/themes
cd %{_builddir}/%{irssisource}/xirssi
%makeinstall PREFIX=$RPM_BUILD_ROOT%{_prefix}
mkdir $RPM_BUILD_ROOT/%{_datadir}/pixmaps
mkdir $RPM_BUILD_ROOT/%{_datadir}/pixmaps/xirssi
cp pixmaps/*.png $RPM_BUILD_ROOT%{_datadir}/pixmaps/xirssi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog NEWS README TODO
%doc docs/*.txt docs/*.html 
%{_bindir}/
%config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/irssi*
%dir %{_libdir}/irssi
%{_libdir}/irssi/*
%{_libdir}/perl5/site_perl/*
%{_mandir}/man1/irssi.1*
%dir %{_datadir}/irssi
%dir %{_datadir}/irssi/themes
%{_datadir}/irssi/*
%{_datadir}/irssi/themes/*

%files -n xirssi
%defattr(-,root,root)
%{_bindir}/xirssi
%config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/irssi*
%dir %{_datadir}/pixmaps/xirssi
%{_datadir}/pixmaps/xirssi/*

%changelog
* Thu Feb 20 2003 Jeremy Portzer <jeremyp@pobox.com> 0.8.6-0.cvs20030220.fedora.1
- version bump
- version,description and other minor adjustments for Fedora
- tried to make %setup stuff for additional sources saner
- remove glib1 support and command-line switch

* Tue Feb 04 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030204.1
- version bump

* Mon Feb 03 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030203.2
- switch to new glib1 command line switch
- re-arrange static & non-static build params
- use gcc3 & glib1 on ia64

* Mon Feb 03 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030203.1
- version bump

* Thu Jan 30 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030130.1
- version bump

* Wed Jan 29 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030129.1
- depends fix
- version bump
- docfile fixes

* Tue Jan 28 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030128.1
- version bump
- correct perl build errors to be non-i386 specific
- sparc fixes here and there

* Fri Jan 24 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030124.3
- adjust spec so that the --with and --without vars get parsed *AFTER* the ifarch statement (allowing glib2 builds on sparc with the --with)
- change build id number and release date to macros

* Fri Jan 24 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030124.2
- make glib2=0 the default on sparc

* Fri Jan 24 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030124.1
- verison bump
- disable ssl to allow builds on pheobe

* Fri Jan 24 2003 Tom "spot" Callaway <tcallawa@redhat.com>
- conditional for sparc

* Fri Jan 10 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030110.1
- version bump
- do not *build* or *setup* xirssi on glib1 systems

* Thu Jan 09 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030108.1
- version bump
- add themes to main rpm :)
- params added to build on glib1 systems
- do not package xirssi on glib1 systems
- fix possible build error in %setup

* Mon Jan 06 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030105.1
- version bump
- more depends fixes

* Mon Jan 06 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030102.5
- depends fixes

* Fri Jan 03 2003 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20030102.4
- include pixmaps in xirssi builds
- put pixmaps someplace sane

* Thu Dec 19 2002 Kevin Sonney <ksonney@redhat.com> 0.8.6.CVS-20021219.6
- updates to latest version
- better cleanup for perl files
- should compile multiple RH revs without issue

* Thu Dec 19 2002 Kevin Sonney <ksonney@redhat.com> 0.8.6-4
- made perllib modular
- Remove incorrect perllocal.pod file
- need to add a %post script to regen perllocal.pod properly
- fixes (I hope) for perl library locations
- update to use glib2 instead of glib1 (probably should make this depend on distro versions)
- need to get proxy compiled in statically and not as a module

* Thu Dec 19 2002 Kevin Sonney <ksonney@redhat.com> 0.8.6-3
- More doc fixes

* Thu Dec 19 2002 Kevin Sonney <ksonney@redhat.com> 0.8.6-2
- Fixes for orphened files
- fixes for non-root builds
- docdir fixes from Tanner Lovelace's trilug RPMS

