#define svnrev   1449
#define alphatag 20090430svn%{svnrev}

Name:           google-gadgets
Summary:        Google Gadgets platform for Linux
Version:        0.11.2
Release:        3%{?_dist_release}

Group:          User Interface/Desktops
License:        ASL 2.0
URL:            http://code.google.com/p/google-gadgets-for-linux/

Vendor:		Project Vine
Distribution:	Vine Linux
Packager:	inagaki,yasumichi

Source0:        http://google-gadgets-for-linux.googlecode.com/files/google-gadgets-for-linux-%{version}.tar.bz2
#Source0:        %{name}-%{version}-r%{svnrev}.tar.bz2
Patch0:		NM-0.9.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-root

BuildRequires:  curl-devel libxml2-devel zlib-devel libtool-ltdl-devel
# still needed even if we're not buliding gtkmoz element, for JavaScript
#%%if %{?_dist_release} == "vl5"
#BuildRequires:  xulrunner-devel-unstable
#%%else
#BuildRequires:  xulrunner-devel
#%%endif
BuildRequires:  WebKit-gtk-devel 
BuildRequires:  dbus-devel gstreamer-devel gstreamer-plugins-base-devel
BuildRequires:  cairo-devel gtk2-devel librsvg2-devel
BuildRequires:  qt4-devel zip
# Desktop integration
BuildRequires:  NetworkManager-devel startup-notification-devel
# libxml2-devel needed for desktop file generation
BuildRequires:  libxml2-devel desktop-file-utils
BuildRequires:  pkgconfig
Requires:       %{name}-frontend = %{version}-%{release}
Requires:       hicolor-icon-theme

%description
Google Gadgets for Linux provides a platform for running desktop
gadgets under Linux, catering to the unique needs of Linux users. It
can run, without modification, many Google Desktop gadgets as well as
the Universal Gadgets on iGoogle.


%package        gtk
Summary:        GTK+ front-end for %{name}
Summary(ja):    Google Gadgets の GTK+ 版フロントエンド
Group:          User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
Provides:       %{name}-frontend = %{version}-%{release}

%description    gtk
The %{name}-gtk package contains the GTK+ front-end for %{name}.


%package        qt
Summary:        Qt front-end for %{name}
Summary(ja):    Google Gadgets の Qt 版フロントエンド
Group:          User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
Provides:       %{name}-frontend = %{version}-%{release}

%description    qt
The %{name}-qt package contains the Qt front-end for %{name}.


%package        devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発用ファイル
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig dbus-devel gtk2-devel qt4-devel
Requires:       %{name}-gtk
Requires:       %{name}-qt

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%prep
%setup -q -n %{name}-for-linux-%{version}
%patch0 -p1
# Permission fixes
chmod -x ggadget/qt/utilities.h
# Fix invalid desktop file MIME type
# http://code.google.com/p/google-gadgets-for-linux/issues/detail?id=360
for f in hosts/*/ggl-*.desktop.in; do
    sed -i 's|;app/gg;|;|' $f
done


%build
#autotools/bootstrap.sh
#ln -s %{_datadir}/automake-*/mkinstalldirs libltdl/

%configure --disable-static \
           --with-browser-plugins-dir=%{_libdir}/mozilla/plugins \
           --disable-gtkmoz-browser-element --disable-smjs-script-runtime

# Rpath fix by Mamoru Tasaka
# we don't want to obliterate all RPATHs, since it is used during build
# Add library search path
sed -i.libdir_syssearch -e \
 '/sys_lib_dlsearch_path_spec/s|/usr/lib |/usr/lib /usr/lib64 /lib /lib64 |' \
 configure
# Remove the redundant RPATH for %%{_libdir}, already searched by Fedora libtool
sed -i.extra_R -e \
 's|-R\$(libdir)||' \
 hosts/*/Makefile.in

# default compile flags are impossibly strict
make %{?_smp_mflags} DEFAULT_COMPILE_FLAGS=

# Remove quotes from .pc files
find . -name '*.pc' -exec sed -i 's|\"||g' '{}' \;


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT \
     INSTALL="install -p" CPPROG="cp -p"
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'

# reinstall desktop files
for i in gtk qt; do
  desktop-file-install \
    --dir=$RPM_BUILD_ROOT%{_datadir}/applications \
    --delete-original \
    $RPM_BUILD_ROOT%{_datadir}/applications/ggl-$i.desktop
done

# wipe prematurely-generated MIME info
rm -rf $RPM_BUILD_ROOT%{_datadir}/mime
rm -f $RPM_BUILD_ROOT%{_datadir}/applications/mimeinfo.cache

%clean
rm -rf $RPM_BUILD_ROOT


%post
/sbin/ldconfig
touch --no-create %{_datadir}/icons/hicolor || :

%postun
/sbin/ldconfig
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%post gtk
/sbin/ldconfig
update-desktop-database &> /dev/null || :

%postun gtk
/sbin/ldconfig
update-desktop-database &> /dev/null || :

%post qt
/sbin/ldconfig
update-desktop-database &> /dev/null || :

%postun qt
/sbin/ldconfig
update-desktop-database &> /dev/null || :


%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING README
%{_libdir}/google-gadgets
#%%exclude %{_libdir}/google-gadgets/gtkmoz-browser-child
%exclude %{_libdir}/google-gadgets/modules/gtk*.so
%exclude %{_libdir}/google-gadgets/modules/qt*.so
%exclude %{_libdir}/google-gadgets/include
%{_libdir}/lib*.so.*
%exclude %{_libdir}/lib*gtk*
%exclude %{_libdir}/lib*qt*
%{_datadir}/google-gadgets
%{_datadir}/pixmaps/google-gadgets.png
%{_datadir}/icons/hicolor/*/*/*.png

%files gtk
%defattr(-,root,root,-)
%{_bindir}/ggl-gtk
%{_libdir}/libggadget-gtk*.so.*
#%%{_libdir}/google-gadgets/gtkmoz-browser-child
%{_libdir}/google-gadgets/modules/gtk*.so
%{_datadir}/applications/*gtk.desktop
%{_datadir}/applications/*designer.desktop

%files qt
%defattr(-,root,root,-)
%{_bindir}/ggl-qt
%{_libdir}/libggadget-qt*.so.*
%{_libdir}/google-gadgets/modules/qt*.so
%{_datadir}/applications/*qt.desktop

%files devel
%defattr(-,root,root,-)
%{_includedir}/google-gadgets
%{_libdir}/lib*.so
%{_libdir}/google-gadgets/include
%{_libdir}/pkgconfig/*.pc


%changelog
* Sat Aug 27 2011 Yasumichi Akahoshi <yasumichi@vinelinux.org> 0.11.2-3
- add patch for building with NetworkManager-0.9.0
- add Vendor, Distribution and Packager tag

* Thu Aug 18 2011 Yasumichi Akahoshi <yasumichi@vinelinux.org> 0.11.2-2
- not work with xulrunner 2.0, remove from BR.
- add --disable-gtkmoz-browser-element , --disable-smjs-script-runtime

* Thu Sep 30 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.11.2-1
- new upstream release
- built with rpm-4.8.1 for pkg-config
- dropt Patch0
- added BR: WebKit-gtk-devel
- removed invalid MIME entry from .desktop files

* Sat Oct 24 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.11.1-1
- new upstream release

* Sat Aug 29 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.11.0-2
- Initial build for Vine Linux

* Wed Jul  1 2009 Michel Salim <michel@erdos.localdomain> - 0.11.0-1
- Update to 0.11.0

* Sat May  2 2009 Michel Salim <salimma@fedoraproject.org> - 0.10.6-0.1.20090430svn1449%{?dist}
- Update to SVN checkout, for xulrunner 1.9.1 compatibility

* Mon Apr 27 2009 Christopher Aillon <caillon@redhat.com> - 0.10.5-6
- Rebuild against newer gecko

* Fri Mar 27 2009 Christopher Aillon <caillon@redhat.com> - 0.10.5-4
- Rebuild against newer gecko

* Fri Mar 06 2009 Jan Horak <jhorak@redhat.com> - 0.10.5-3
- Rebuild against newer gecko

* Wed Feb 04 2009 Christopher Aillon <caillon@redhat.com> - 0.10.5-2
- Rebuild against newer gecko

* Wed Jan 14 2009 Rex Dieter <rdieter@fedoraproject.org> - 0.10.5-1
- 0.10.5, req'd by kde

* Tue Dec 30 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.4-2
- BR: Network-Manager-devel, startup-notification-devel
- Pass the browser plugin directory to ./configure
- Move designer desktop entry to -gtk subpackage

* Sat Dec 20 2008 Rex Dieter <rdieter@fedoraproject.org> - 0.10.4-1
- Update to 0.10.4 (#477251)
- -devel: Requires: %%name-gtk %%name-qt (devel symlinks)
- BR: pkgconfig (automatic pkgconfig deps)

* Sun Nov 23 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.3-1
- Update to 0.10.3

* Sat Nov  8 2008 Rex Dieter <rdieter@fedoraproject.org> - 0.10.1-5
- s/qt-devel/qt4-devel/
- -qt: fix summary

* Tue Sep  2 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.1-4
- Unquote version strings in .pc files

* Thu Aug 28 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.1-3
- RPATH and timestamp fixes from Mamoru Tasaka

* Tue Aug 26 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.1-2
- Fix desktop file creation

* Mon Aug 25 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.1-1
- Update to 0.10.1

* Mon Jul 14 2008 Michel Salim <salimma@fedoraproject.org> - 0.10.0-1
- Update to 0.10.0
- Add missing dependencies for -devel subpackage

* Sun Jul  6 2008 Michel Salim <salimma@fedoraproject.org> - 0.9.3-1
- Update to 0.9.3

* Fri Jun  6 2008 Michel Salim <salimma@fedoraproject.org> - 0.9.1-1
- Initial package
