%define debug 0

%define build_for_ftp 0

%define strip_bin 0
%define final 0
%define rpm_clean 1

%define desktop_file 1
%define desktop_file_utils_version 0.2.93

%define qt_version 3.1.1

%define libtool 0

Version: 3.1
Release: 3
Name: kdetoys
Prefix: /usr
Summary: K Desktop Environment - Toys and Amusements
Epoch: 7
Group: Amusements/Graphics
License: GPL
BuildRoot: %{_tmppath}/%{name}-buildroot

Source: ftp://ftp.kde.org/pub/kde/stable/%{version}/src/%{name}-%{version}.tar.bz2
Patch: kde-libtool.patch

%if %{build_for_ftp}
ExclusiveArch: %{ix86}
%endif

Requires: kdelibs >= 6:%{version}-7
Requires: kdebase >= 6:%{version}-7

BuildRequires: kdelibs >= 6:%{version}-7
BuildRequires: kdelibs-devel >= 6:%{version}-7
BuildRequires: kdebase >= 6:%{version}-7
BuildRequires: kdebase-devel >= 6:%{version}-7
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: glibc-devel
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: libstdc++-devel
BuildRequires: qt-devel >= %{qt_version}

%if %{desktop_file}
BuildRequires:desktop-file-utils >= %{desktop_file_utils_version}
%endif

Prereq: /sbin/ldconfig

%description
Toys for the K Desktop Environment.

Includes: kmoon (displays various phases of the moon); kworldwatch
(displays where in the world it is light and dark depending on time), and
kodo (a mouse odometer which shows how far your mouse has traveled).

%prep
%setup -q
%patch -p1 -b .libtool

%build
unset QTDIR || : ; . /etc/profile.d/qt.sh
FLAGS="-D_GNU_SOURCE $RPM_OPT_FLAGS -DNDEBUG -DNO_DEBUG"
export KDEDIR=%{prefix}
export CFLAGS="$FLAGS"
export CXXFLAGS="$FLAGS"

# Workaround for legacy auto* tools
%if %{libtool}
[ -x /usr/bin/autoconf-2.5? ] && ln -s /usr/bin/autoconf-2.5? autoconf
[ -x /usr/bin/autoheader-2.5? ] && ln -s /usr/bin/autoheader-2.5? autoheader
[ -x /usr/bin/aclocal-1.5 ] && ln -s /usr/bin/aclocal-1.5 aclocal
[ -x /usr/bin/automake-1.5 ] && ln -s /usr/bin/automake-1.5 automake
export PATH=`pwd`:$PATH
make -f Makefile.cvs
%endif

%configure \
   --with-qt-libraries=$QTDIR/lib \
   --includedir=%{_includedir}/kde \
   --enable-final

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

# Make symlinks relative
pushd $RPM_BUILD_ROOT%{_docdir}/HTML/en
for i in *; do
   [ -d $i -a -L $i/common ] && ln -nfs ../common $i/common
done
popd

pushd $RPM_BUILD_ROOT%{_datadir}/apps/amor
ln -nfs tips-en tips
popd

# start desktop-file-install
%if %{desktop_file}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications

desktop-file-install \
   --vendor kde \
   --dir $RPM_BUILD_ROOT%{_datadir}/applications \
   --add-category "Application;Toys;X-Red-Hat-Extra" \
   --delete-original \
   $RPM_BUILD_ROOT%{_datadir}/applnk/Toys/kodo.desktop \
   $RPM_BUILD_ROOT%{_datadir}/applnk/Toys/kworldclock.desktop

desktop-file-install \
   --vendor kde \
   --delete-original \
   --dir $RPM_BUILD_ROOT%{_datadir}/applications \
   --add-category "Application;Toys;X-Red-Hat-Base" \
   --add-only-show-in KDE \
   $RPM_BUILD_ROOT%{_datadir}/applnk/Toys/*.desktop

# move screensave desktops
mv $RPM_BUILD_ROOT%{_datadir}/applnk/System/ScreenSavers \
   $RPM_BUILD_ROOT%{_datadir}/apps/kscreensaver/

rm -rfv $RPM_BUILD_ROOT%{_datadir}/applnk
%endif

# don't include it
rm -rf $RPM_BUILD_ROOT%{prefix}/include \
       $RPM_BUILD_ROOT%{prefix}/%{_lib}/kde3/*.la

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc %{_docdir}/HTML/en/*
%{_bindir}/*
%{_libdir}/kde3/*.so*
%{_datadir}/apps/*
%{_datadir}/icons/*/*/*/*
%{_datadir}/services/*
%if %{desktop_file}
%{_datadir}/applications/*
%else
%{_datadir}/applnk/*
%endif

%changelog
* Mon Feb 24 2003 Elliot Lee <sopwith@redhat.com>
- debuginfo rebuild

* Fri Feb 21 2003 Than Ngo <than@redhat.com> 3.1-2
- get rid of gcc path from dependency_libs

* Tue Jan 28 2003 Than Ngo <than@redhat.com> 3.1-1
- 3.1 release

* Thu Jan 23 2003 Tim Powers <timp@redhat.com> 7:3.1-0.4
- rebuild

* Tue Jan 14 2003 Thomas Woerner <twoerner@redhat.com> 3.1-0.3
- rc6

* Sat Nov 30 2002 Than Ngo <than@redhat.com> 3.1-0.2
- desktop file issues

* Thu Nov 28 2002 Than Ngo <than@redhat.com> 3.1-0.1
- update 3.1 rc 4

* Sat Nov  9 2002 Than Ngo <than@redhat.com> 3.0.5-1
- 3.0.5

* Tue Oct 15 2002 Than Ngo <than@redhat.com> 3.0.4-1
- 3.0.4

* Fri Sep 06 2002 Karsten Hopp <karsten@redhat.de>
- add --libdir

* Mon Aug 12 2002 Than Ngo <than@redhat.com> 3.0.3-1
- 3.0.3
- build using gcc-3.2-0.3
- desktop file issue

* Tue Jul 23 2002 Tim Powers <timp@redhat.com> 3.0.2-2
- build using gcc-3.2-0.1

* Tue Jul 09 2002 Than Ngo <than@redhat.com> 3.0.2-1
- 3.0.2
- use desktop-file-install

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

* Wed Jun 19 2002 Than Ngo <than@redhat.com> 3.0.1-3
- Don't forcibly strip binaries

* Thu May 23 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue May 14 2002 Bernhard Rosenkraenzer <bero@redhat.com> 3.0.1-1
- 3.0.1

* Tue Apr 16 2002 Bernhard Rosenkraenzer <bero@redhat.com> 3.0.0-3
- Rebuild

* Thu Apr 11 2002 Bernhard Rosenkraenzer <bero@redhat.com> 3.0.0-2
- Fix build in current environment

* Wed Mar 27 2002 Bernhard Rosenkraenzer <bero@redhat.com> 3.0.0-1
- 3.0.0 final

* Wed Mar  6 2002 Bernhard Rosenkraenzer <bero@redhat.com> 3.0.0-0.cvs20020306.1
- Remove kaphorism, it's of no use and German only
- move AmorIface.h to /usr/include/kde

* Wed Jan 09 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue Jan  7 2002 Than Ngo <than@redhat.com> 3.0-0.cvs20020108.1
- update to CVS

* Mon Aug  6 2001 Than Ngo <than@redhat.com> 2.2-1
- update to 2.2 release

* Mon Jul 23 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.2-0.cvs20010723.1
- Update

* Wed Feb 21 2001 Than Ngo <than@redhat.com>
- 2.1-respin

* Tue Feb 20 2001 Than Ngo <than@redhat.com>
- update to 2.1

* Mon Feb 05 2001 Than Ngo <than@redhat.com>
- updated
- fixed absolute-pathname symlinks (bug #24795)

* Mon Jan 22 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Update

* Wed Dec 20 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- update to CVS
- Don't exclude ia64

* Mon Oct 23 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.0 final


* Wed Oct  4 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.0

* Thu Aug 24 2000 Than Ngo <than@redhat.com>
- update to kdetoys-1.93

* Mon Aug  7 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- new version

* Thu Jul 13 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- SMPify
- don't hardcode QTDIR

* Tue Jul 11 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- use gcc 2.96
- new snapshot

* Wed Jun 21 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- new snapshot
- ExcludeArch ia64 for now

* Mon Apr 10 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.0 snapshot

* Sat Jan  8 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- KDE_1_1_BRANCH
- rebuild for 6.2

* Fri Sep 24 1999 Preston Brown <pbrown@redhat.com>
- marked docs files as such.

* Tue Sep 14 1999 Preston Brown <pbrown@redhat.com>
- got 1.1.2 release.

* Thu Sep 09 1999 Preston Brown <pbrown@redhat.com>
- built for 6.1

* Fri Jun 11 1999 Preston Brown <pbrown@redhat.com>
- snapshot, includes kde 1.1.1 + fixes