-# TODO:
-# - add gtk BRs
-# - configure: WARNING: Library SpiderMonkey is not available, smjs-script-runtime extension won't be built.
-# - update desc
-# - split to main,devel,static,gadgets
-%define realname google-gadgets
#
-Summary: google-gadgets-for-linux
-Name: google-gadgets-for-linux
-Version: 0.10.1
-Release: 0.1
+# Conditional build:
+%bcond_without gtk # without gtk support
+%bcond_without qt # without qt support
+%bcond_without gadgets # without gadgets
+
+%define rev r1084
+
+# use this to get latest rev:
+# svn export http://google-gadgets-for-linux.googlecode.com/svn/trunk/ google-gadgets-for-linux
+Summary: Google Gadgets for Linux
+Name: google-gadgets
+Version: 0.11.2
+Release: 8
License: Apache License v2.0
Group: X11/Applications
-Source0: http://google-gadgets-for-linux.googlecode.com/files/%{name}-%{version}.tar.gz
-# Source0-md5: 95b43aca687036753ad4d14a9f13126f
-Source1: %{name}-gtk.desktop
-Source1: %{name}-qt.desktop
+#Source0: %{name}-for-linux-%{version}-%{rev}.tar.bz2
+Source0: http://google-gadgets-for-linux.googlecode.com/files/%{name}-for-linux-%{version}.tar.bz2
+# Source0-md5: 279305553bcbf74f3e3615f6abc36a5e
+Source1: %{name}-for-linux-gtk.desktop
+Source2: %{name}-for-linux-qt.desktop
+Patch0: %{name}-for-linux-cmake.patch
+Patch1: %{name}-for-linux-link_with_qtnetwork.patch
+Patch2: %{name}-for-linux-js.patch
+Patch3: gcc-4.7.patch
+Patch4: glib-2.32.patch
+Patch5: nm09.patch
+Patch6: nm-mobile-devtypes.patch
URL: http://code.google.com/p/google-gadgets-for-linux/
-BuildRequires: QtCore-devel >= 4.3
-BuildRequires: QtScript-devel >= 4.3
-BuildRequires: QtWebKit-devel >= 4.3
-BuildRequires: autoconf >= 2.59
-BuildRequires: automake >= 1.9.6
+BuildRequires: NetworkManager-devel >= 0.6.5
+%if %{with qt}
+BuildRequires: QtCore-devel >= 4.4.3
+BuildRequires: QtNetwork-devel >= 4.4.3
+BuildRequires: QtScript-devel >= 4.4.3
+BuildRequires: QtWebKit-devel >= 4.4.3
+%endif
+BuildRequires: autoconf
+BuildRequires: automake
+%if %{with gtk}
+BuildRequires: cairo-devel >= 1.2.0
+BuildRequires: gtk+2-devel >= 2:2.10.0
+BuildRequires: startup-notification-devel
+%endif
BuildRequires: curl-devel >= 7.18.2
BuildRequires: dbus-devel >= 1.0.2
BuildRequires: flex
BuildRequires: gstreamer-plugins-base-devel >= 0.10.0
+BuildRequires: gtk-webkit-devel
BuildRequires: libltdl-devel
-BuildRequires: libtool >= 1.5.22
-BuildRequires: libxml2-devel >= 2.4.0
-BuildRequires: sed >= 4.0
-BuildRequires: xulrunner-devel >= 1.8
+BuildRequires: librsvg-devel
+BuildRequires: libtool >= 2:1.5.22
+BuildRequires: libxml2-devel >= 1:2.4.0
+BuildRequires: pkgconfig
+BuildRequires: qt4-build
+BuildRequires: zip
+BuildRequires: zlib-devel >= 1.2.0
+Requires: libggadget = %{version}-%{release}
+Provides: google-gadgets-for-linux-gadgets = %{version}
+Obsoletes: google-gadgets-for-linux-gadgets
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
-google-gadgets-for-linux.
+Google Gadgets for Linux provides a platform for running desktop
+gadgets under Linux, catering to the unique needs of Linux users. It's
+compatible with the gadgets written for Google Desktop for Windows as
+well as the Universal Gadgets on iGoogle.
+
+%package -n libggadget
+Summary: Google Gadgets main libraries
+Group: Libraries
+Requires: dbus >= 1.0.21G
+Requires: libltdl
+Obsoletes: google-gadgets-for-linux
+
+%description -n libggadget
+This package contains the main Google Gadgets libraries, it is
+required by both the GTK+ and QT versions of Google Gadgets.
+
+%package -n libggadget-devel
+Summary: Google Gadgets main development files
+Group: Development/Libraries
+Requires: dbus-devel >= 1.0.2
+Requires: libggadget = %{version}-%{release}
+
+%description -n libggadget-devel
+This package contains the development files assoicated with
+libggadget, it is needed to write programs that utilise libggadget.
+
+%description -n libggadget-devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki google-gadgets.
+
+%package -n libggadget-gtk
+Summary: Google Gadgets GTK+ library
+Group: Libraries
+Requires: cairo >= 1.2.0
+Requires: gtk+2 >= 2:2.10.0
+Requires: libggadget = %{version}-%{release}
+Requires: librsvg >= 1:2.18.0
+
+%description -n libggadget-gtk
+This package contains the GTK+ Google Gadgets library, it is required
+to run the GTK+ version of Google Gadgets.
+
+%package -n libggadget-gtk-devel
+Summary: Google Gadgets GTK+ development files
+Group: Development/Libraries
+Requires: cairo-devel >= 1.2.0
+Requires: gtk+2-devel >= 2:2.10.0
+Requires: libggadget-devel = %{version}-%{release}
+Requires: libggadget-gtk = %{version}-%{release}
+Requires: librsvg-devel >= 1:2.18.0
+
+%description -n libggadget-gtk-devel
+This package contains the development files assoicated with
+libggadget-gtk, it is needed to write GTK+ programs that utilise
+libggadget.
+
+%package -n libggadget-qt
+Summary: Google Gadgets QT library
+Group: Libraries
+Requires: QtWebKit >= 4.4.0
+Requires: libggadget = %{version}-%{release}
+
+%description -n libggadget-qt
+This package contains the QT Google Gadgets library, it is required to
+run the QT version of Google Gadgets.
+
+%package -n libggadget-qt-devel
+Summary: Google Gadgets QT development files
+Group: Development/Libraries
+Requires: QtWebKit-devel >= 4.4.0
+Requires: libggadget-devel = %{version}-%{release}
+Requires: libggadget-qt = %{version}-%{release}
+
+%description -n libggadget-qt-devel
+This package contains the development files assoicated with
+libggadget-qt, it is needed to write QT programs that utilise
+libggadget.
+
+%package gtk
+Summary: GTK+ Version of Google Gadgets
+Group: X11/Applications
+Requires: google-gadgets = %{version}-%{release}
+Requires: google-gadgets-gst = %{version}-%{release}
+Requires: libggadget-gtk = %{version}-%{release}
+Obsoletes: google-gadgets-for-linux-gtk
+
+%description gtk
+Google Gadgets for Linux provides a platform for running desktop
+gadgets under Linux, catering to the unique needs of Linux users. It's
+compatible with the gadgets written for Google Desktop for Windows as
+well as the Universal Gadgets on iGoogle.
+
+This package includes the GTK+ version.
+
+%package qt
+Summary: QT Version of Google Gadgets
+Group: X11/Applications
+Requires: google-gadgets = %{version}-%{release}
+Requires: google-gadgets-gst = %{version}
+Requires: libggadget-qt = %{version}-%{release}
+Obsoletes: google-gadgets-for-linux-qt
+
+%description qt
+Google Gadgets for Linux provides a platform for running desktop
+gadgets under Linux, catering to the unique needs of Linux users. It's
+compatible with the gadgets written for Google Desktop for Windows as
+well as the Universal Gadgets on iGoogle.
+
+This package includes the QT version.
+
+%package gst
+Summary: GStreamer modules for Google Gadgets
+Group: X11/Applications
+Requires: gstreamer-plugins-base >= 0.10.6
+Requires: libggadget = %{version}-%{release}
+
+%description gst
+Google Gadgets for Linux provides a platform for running desktop
+gadgets under Linux, catering to the unique needs of Linux users. It's
+compatible with the gadgets written for Google Desktop for Windows as
+well as the Universal Gadgets on iGoogle.
+
+This package includes the GStreamer modules.
%prep
-%setup -q
-# little hack for xulrunner
-%{__sed} -i "s/PREDEFINED_MACROS)/PREDEFINED_MACROS) -I\%{_includedir}\/xulrunner\/gtkembedmoz -I\%{_includedir}\/xulrunner\/js -I\%{_includedir}\/xulrunner\/xpcom /" extensions/gtkmoz_browser_element/Makefile.am
-mkdir -p build
+%setup -q -n %{name}-for-linux-%{version}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
%build
-# with our configure macro there are lots of unused variable errors (-Wall -Werror -D_something=2)
-export CC='%{__cc}'
-export CXX='%{__cxx}'
-export CXXFLAGS='%{rpmcxxflags}'
+install -d libltdl
%{__libtoolize}
%{__aclocal} -I autotools
%{__autoconf}
%{__autoheader}
%{__automake}
-cd build
-../configure --prefix=%{_prefix}
-%{__make} -j2
+%configure \
+ --disable-ltdl-install \
+ --disable-static \
+ --disable-werror \
+ --with-oem-brand=pld-linux \
+ --with-browser-plugins-dir=%{_libdir}/browser-plugins \
+ --disable-gtkmoz-browser-element \
+ --disable-smjs-script-runtime
+
+%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-
install -d $RPM_BUILD_ROOT{%{_desktopdir},%{_pixmapsdir}}
-cd build
-%{__make} install \
+%{__make} -j1 install \
DESTDIR=$RPM_BUILD_ROOT
+# desync with cmake/ac makefiles
+mv $RPM_BUILD_ROOT%{_datadir}/mime/packages/{00-,}google-gadgets.xml
# desktop files
install %{SOURCE1} $RPM_BUILD_ROOT%{_desktopdir}/ggl-gtk.desktop
install %{SOURCE2} $RPM_BUILD_ROOT%{_desktopdir}/ggl-qt.desktop
+rm -f $RPM_BUILD_ROOT%{_libdir}/google-gadgets/modules/*.la
+
%clean
rm -rf $RPM_BUILD_ROOT
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
+%post -n libggadget -p /sbin/ldconfig
+%postun -n libggadget -p /sbin/ldconfig
+
+%post -n libggadget-gtk -p /sbin/ldconfig
+%postun -n libggadget-gtk -p /sbin/ldconfig
+
+%post -n libggadget-qt -p /sbin/ldconfig
+%postun -n libggadget-qt -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/*
-%{_datadir}/mime/application/x-google-gadgets.xml
-%{_datadir}/mime/packages/00-google-gadgets.xml
-%dir %{_datadir}/%{realname}
-%{_datadir}/%{realname}/*.gg
-%{_desktopdir}/*.desktop
-%{_pixmapsdir}/%{realname}.png
-
-%attr(755,root,root) %{_libdir}/*.so.*.*.*
-%attr(755,root,root) %ghost %attr(755,root,root) %{_libdir}/*.so.0
-%attr(755,root,root) %{_libdir}/%{realname}/gtkmoz-browser-child
-%dir %{_libdir}/%{realname}
-%dir %{_libdir}/%{realname}/modules
-%attr(755,root,root) %{_libdir}/%{realname}/modules/*.so
-
-%dir %{_libdir}/%{realname}/include
-%dir %{_libdir}/%{realname}/include/ggadget
-%{_libdir}/%{realname}/include/ggadget/*.h
-%dir %{_includedir}/%{realname}
-%dir %{_includedir}/%{realname}/ggadget
-%{_includedir}/%{realname}/ggadget/*.h
-%dir %{_includedir}/%{realname}/ggadget/dbus
-%{_includedir}/%{realname}/ggadget/dbus/*.h
-%dir %{_includedir}/%{realname}/ggadget/gtk
-%{_includedir}/%{realname}/ggadget/gtk/*.h
-%dir %{_includedir}/%{realname}/ggadget/qt
-%{_includedir}/%{realname}/ggadget/qt/*.h
-%dir %{_includedir}/%{realname}/ggadget/js
-%{_includedir}/%{realname}/ggadget/js/*.h
-%{_pkgconfigdir}/*.pc
-%{_libdir}/*.so
+%doc AUTHORS README NEWS
+%dir %{_libdir}/google-gadgets
+%dir %{_libdir}/google-gadgets/modules
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/analytics-usage-collector.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/curl-xml-http-request.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/dbus-script-class.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/default-framework.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/default-options.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/google-gadget-manager.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/libxml2-xml-parser.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/linux-system-framework.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/html-flash-element.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/soup-xml-http-request.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/webkit-script-runtime.so
+%dir %{_datadir}/google-gadgets
+%{_datadir}/google-gadgets/*.gg
+%{_datadir}/mime/packages/google-gadgets.xml
+%{_iconsdir}/*/*/*/*.png
+%{_pixmapsdir}/google-gadgets.png
+
+%files -n libggadget
+%defattr(644,root,root,755)
+%attr(755,root,root) %ghost %{_libdir}/libggadget-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-1.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libggadget-dbus-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-dbus-1.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libggadget-js-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-js-1.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libggadget-npapi-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-npapi-1.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libggadget-xdg-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-xdg-1.0.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libggadget-webkitjs-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-webkitjs-1.0.so.*.*.*
+
+%files -n libggadget-devel
+%defattr(644,root,root,755)
+%dir %{_includedir}/google-gadgets
+%dir %{_includedir}/google-gadgets/ggadget
+%dir %{_includedir}/google-gadgets/ggadget/dbus
+%dir %{_includedir}/google-gadgets/ggadget/js
+%dir %{_includedir}/google-gadgets/ggadget/xdg
+%dir %{_includedir}/google-gadgets/ggadget/npapi
+%{_includedir}/google-gadgets/ggadget/*.h
+%{_includedir}/google-gadgets/ggadget/dbus/*.h
+%{_includedir}/google-gadgets/ggadget/js/*.h
+%{_includedir}/google-gadgets/ggadget/xdg/*.h
+%{_includedir}/google-gadgets/ggadget/npapi/*.h
+%dir %{_libdir}/google-gadgets/include
+%dir %{_libdir}/google-gadgets/include/ggadget
+%{_libdir}/google-gadgets/include/ggadget/sysdeps.h
+%{_libdir}/libggadget-1.0*.so
+%{_libdir}/libggadget-dbus-1.0*.so
+%{_libdir}/libggadget-js-1.0*.so
+%{_libdir}/libggadget-xdg-1.0*.so
+%{_libdir}/libggadget-npapi-1.0*.so
+%{_libdir}/libggadget-webkitjs-1.0*.so
+%if 0
+%{_libdir}/libggadget-1.0*.la
+%{_libdir}/libggadget-dbus-1.0*.la
+%{_libdir}/libggadget-js-1.0*.la
+%{_libdir}/libggadget-xdg-1.0*.la
+%{_libdir}/libggadget-npapi-1.0*.la
+%endif
+%{_pkgconfigdir}/libggadget-1.0.pc
+%{_pkgconfigdir}/libggadget-dbus-1.0.pc
+%{_pkgconfigdir}/libggadget-js-1.0.pc
+%{_pkgconfigdir}/libggadget-xdg-1.0.pc
+%{_pkgconfigdir}/libggadget-npapi-1.0.pc
+
+%files -n libggadget-gtk
+%defattr(644,root,root,755)
+%attr(755,root,root) %ghost %{_libdir}/libggadget-gtk-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-gtk-1.0.so.*.*.*
+
+%files -n libggadget-gtk-devel
+%defattr(644,root,root,755)
+%dir %{_includedir}/google-gadgets/ggadget/gtk
+%{_includedir}/google-gadgets/ggadget/gtk/*.h
+%{_libdir}/libggadget-gtk-1.0*.so
+#%{_libdir}/libggadget-gtk-1.0*.la
+%{_pkgconfigdir}/libggadget-gtk-1.0.pc
+
+%files -n libggadget-qt
+%defattr(644,root,root,755)
+%attr(755,root,root) %ghost %{_libdir}/libggadget-qt-1.0.so.0
+%attr(755,root,root) %{_libdir}/libggadget-qt-1.0.so.*.*.*
+
+%files -n libggadget-qt-devel
+%defattr(644,root,root,755)
+%dir %{_includedir}/google-gadgets/ggadget/qt
+%{_includedir}/google-gadgets/ggadget/qt/*.h
+%{_libdir}/libggadget-qt-1.0*.so
+#%{_libdir}/libggadget-qt-1.0*.la
+%{_pkgconfigdir}/libggadget-qt-1.0.pc
+
+%files gtk
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/ggl-gtk
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gtk-edit-element.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gtk-flash-element.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gtk-system-framework.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gtkwebkit-browser-element.so
+%{_desktopdir}/ggl-gtk.desktop
+%{_desktopdir}/ggl-designer.desktop
+
+%files qt
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/ggl-qt
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/qt-edit-element.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/qt-script-runtime.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/qt-system-framework.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/qt-xml-http-request.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/qtwebkit-browser-element.so
+%{_desktopdir}/ggl-qt.desktop
+
+%files gst
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gst-audio-framework.so
+%attr(755,root,root) %{_libdir}/google-gadgets/modules/gst-video-element.so