%define mono_dir %{_prefix}/lib/mono
%define moonlight_dir %{_libdir}/moonlight
%define pkgconfigdir %{_datadir}/pkgconfig
%define included_mono 2.6
Summary:  An open source implementation of Silverlight
Summary(ja): Silverlight のオープンソースによる実装
Name: moonlight
Version: 2.0
Release: 1%{?_dist_release}
Group: Applications/Multimedia
License: LGPL v2.0 only ; MIT License (or similar) ; Ms-Pl
Url: http://go-mono.com/moonlight/
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Source0: ftp://ftp.novell.com/pub/mono/sources/moon/2.0/moonlight-%{version}.tar.bz2
Source1: mono-%{included_mono}.tar.bz2
Source2: mono-basic-%{included_mono}.tar.bz2
#Patch0: missing-files.patch
BuildRequires: mono-devel >= 2.6
BuildRequires: monodoc
BuildRequires: gtk-sharp2 rsvg2-sharp
BuildRequires: gtk2-devel gcc-c++
BuildRequires: alsa-lib-devel
BuildRequires: xulrunner-devel
ExclusiveArch: %ix86 x86_64
%description
Moonlight is an open source implementation of Microsoft Silverlight for
Unix systems.

%package libs
License: LGPL v2.0 only
Summary: Moonlight libmoon
Group: Development/Libraries
%description libs

%package devel
License: LGPL v2.0 only
Summary: Moonlight libmoon C/C++ development files
Group: Development/Libraries
Requires: %{name}-libs == %{version}
%description devel
Development files for libmoon

%package tools
Summary: Moonlight tools
Group: Development/Libraries
Requires: %{name}-libs == %{version}
%description tools
Moonlight tools (mopen, xamlg, xaml2html, mxap, respack, svg2xaml)

%package plugin
Summary: Moonlight browser plugin
Group: Applications/Internet
Requires: %{name}-libs == %{version}
%description plugin
Browser plugin for Novell Moonlight

%package web-devel
License: MIT License (or similar) ; Ms-Pl
Summary: Development files for Moonlight Web
Group: Development/Languages/Other
Requires: %{name}-plugin == %{version}
%description web-devel
Development files for creating Moonlight web applications.

%package desktop
License: MIT License (or similar) ; Ms-Pl
Summary: Mono bindings for Moonlight Desktop
Group: Productivity/Multimedia/Other
Requires: %{name}-libs == %{version}
%description desktop
Mono bindings for Novell Moonlight.

%package desktop-devel
License: MIT License (or similar) ; Ms-Pl
Summary: Development files for Moonlight Desktop
Group: Development/Languages/Other
Requires: %{name}-libs == %{version}
Requires: glib2-devel
Requires: gtk-sharp2
Requires: %{name}-desktop == %{version}
Requires: %{name}-tools == %{version}
%description desktop-devel
Development files for Moonlight Desktop.

%package sharp
Summary: Moonlight sharp
Group: Development/Libraries
Requires: %{name}-libs == %{version}
%description sharp
Provides a gtk-sharp object that can be used to embed a moonlight surface in a desktop application.


%prep
%setup -q
%setup -q -T -D -b 1 -n %{name}-%{version}
%setup -q -T -D -b 2 -n %{name}-%{version}


%build
# The plugin requires a complete build of it's own mono
pushd ../mono-%{included_mono}
./configure --prefix=%{_builddir}/install --with-mcs-docs=no --with-ikvm-native=no
%{__make}
%{__make} install
find %{_builddir}/install -name \*.la -delete
popd

%configure \
	--without-testing \
	--without-performance \
	--without-examples \
	--disable-debug \
	--disable-sanity \
	--with-mcspath=%{_builddir}/mono-%{included_mono}/mcs \
	--with-mono-basic-path=%{_builddir}/mono-basic-%{included_mono} \
	--with-ffmpeg=no \
	--with-cairo=system \
	--with-ff3=yes \
	
%{__make} %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=${RPM_BUILD_ROOT} pkgconfigdir=%{pkgconfigdir}

mkdir -p $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins
ln -s %{moonlight_dir}/plugin/libmoonloader.so \
	$RPM_BUILD_ROOT%{_libdir}/mozilla/plugins/libmoonloader.so

# remove unuse files
rm -f $RPM_BUILD_ROOT%{_libdir}/libshocker.so
find %{buildroot} -name \*.la -delete


%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%clean
rm -rf $RPM_BUILD_ROOT

%files libs
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog README TODO NEWS
%{_libdir}/libmoon.so.*

%files devel
%defattr(-, root, root)
%{_libdir}/libmoon.so

%files tools
%defattr(-, root, root)
%{_bindir}/mopen
%{_bindir}/munxap
%{_bindir}/mxap
%{_bindir}/respack
%{_bindir}/sockpol
%{_bindir}/unrespack
%{_bindir}/xaml2html
%{_bindir}/xamlg
%dir %{moonlight_dir}
%{moonlight_dir}/mopen.exe*
%{moonlight_dir}/munxap.exe
%{moonlight_dir}/mxap.exe
%{moonlight_dir}/respack.exe
%{moonlight_dir}/xaml2html.exe
%{moonlight_dir}/xamlg.exe
%{moonlight_dir}/sockpol.exe
%{_mandir}/man1/mopen.1.gz
%{_mandir}/man1/mxap.1.gz
%{_mandir}/man1/respack.1.gz
%{_mandir}/man1/svg2xaml.1.gz
%{_mandir}/man1/xamlg.1.gz
%{_mandir}/man1/sockpol.1.gz

%files plugin
%defattr(-, root, root)
%dir %{moonlight_dir}/plugin
%{moonlight_dir}/plugin/Microsoft.VisualBasic.dll
%{moonlight_dir}/plugin/System.Core.dll*
%{moonlight_dir}/plugin/System.Net.dll*
%{moonlight_dir}/plugin/System.Runtime.Serialization.dll*
%{moonlight_dir}/plugin/System.ServiceModel.Web.dll*
%{moonlight_dir}/plugin/System.ServiceModel.dll*
%{moonlight_dir}/plugin/System.Windows.Browser.dll*
%{moonlight_dir}/plugin/System.Windows.dll*
%{moonlight_dir}/plugin/System.Xml.dll*
%{moonlight_dir}/plugin/System.dll*
%{moonlight_dir}/plugin/libmoonloader.so
%{moonlight_dir}/plugin/libmoonplugin-ff3bridge.so
%{moonlight_dir}/plugin/libmoonplugin.so
%{moonlight_dir}/plugin/mscorlib.dll*
%{_libdir}/mozilla/plugins/libmoonloader.so

%files web-devel
%defattr(-, root, root)
%{_bindir}/smcs
%dir %{_prefix}/lib/moonlight/2.0-redist
%{_prefix}/lib/moonlight/2.0-redist/System.Windows.Controls.Data.dll*
%{_prefix}/lib/moonlight/2.0-redist/System.Windows.Controls.dll*
%{_prefix}/lib/moonlight/2.0-redist/System.Xml.Linq.dll*
%dir %{_prefix}/lib/moonlight/2.0
%{_prefix}/lib/moonlight/2.0/Microsoft.VisualBasic.dll*
%{_prefix}/lib/moonlight/2.0/Mono.CompilerServices.SymbolWriter.dll*
%{_prefix}/lib/moonlight/2.0/System.Core.dll*
%{_prefix}/lib/moonlight/2.0/System.Net.dll*
%{_prefix}/lib/moonlight/2.0/System.Runtime.Serialization.dll*
%{_prefix}/lib/moonlight/2.0/System.ServiceModel.Web.dll*
%{_prefix}/lib/moonlight/2.0/System.ServiceModel.dll*
%{_prefix}/lib/moonlight/2.0/System.Windows.Browser.dll*
%{_prefix}/lib/moonlight/2.0/System.Windows.dll*
%{_prefix}/lib/moonlight/2.0/System.Xml.dll*
%{_prefix}/lib/moonlight/2.0/System.dll*
%{_prefix}/lib/moonlight/2.0/mscorlib.dll*
%{_prefix}/lib/moonlight/2.0/respack.exe*
%{_prefix}/lib/moonlight/2.0/smcs.exe*
%{_prefix}/lib/moonlight/2.0/buildversion
%{_datadir}/pkgconfig/moonlight-web-2.0.pc

%files desktop
%defattr(-, root, root)
%{_prefix}/lib/mono/gac/Moon.Windows.Desktop
%{_prefix}/lib/mono/gac/Moonlight.Gtk
%{_prefix}/lib/mono/gac/System.Windows
%{_prefix}/lib/mono/gac/System.Windows.Browser
%{_prefix}/lib/mono/gac/System.Windows.Controls
%{_prefix}/lib/mono/gac/System.Windows.Controls.Data

%files desktop-devel
%defattr(-, root, root)
%dir %{_prefix}/lib/mono/moonlight
%{_prefix}/lib/mono/moonlight/Moon.Windows.Desktop.dll*
%{_prefix}/lib/mono/moonlight/System.Windows.Browser.dll*
%{_prefix}/lib/mono/moonlight/System.Windows.Controls.Data.dll*
%{_prefix}/lib/mono/moonlight/System.Windows.Controls.dll*
%{_prefix}/lib/mono/moonlight/System.Windows.dll*
%{_datadir}/pkgconfig/moonlight-desktop-2.0.pc
# It may make sense in the future to have a moonlight-gtk package
%{_prefix}/lib/mono/moonlight/Moonlight.Gtk.dll*
%{_prefix}/lib/monodoc/sources/moonlight-gtk.source
%{_prefix}/lib/monodoc/sources/moonlight-gtk.tree
%{_prefix}/lib/monodoc/sources/moonlight-gtk.zip
%{_datadir}/pkgconfig/moonlight-gtk-2.0.pc


%changelog
* Thu Dec 31 2009 Shu KONNO <owa@bg.wakwak.com> 2.0-1
- updated moonlight to 2.0

* Thu Jul 09 2009 Shu KONNO <owa@bg.wakwak.com> 1.0.1-1
- updated moon to 1.0.1
- dropt missing-files.patch (included in source)
- built with latest rpm to update mono-dependencies

* Sun Apr 19 2009 Shu KONNO <owa@bg.wakwak.com> 0.8.1-2
- changed plugin Group to Applications/Internet
- changed other sub packages Group to Development/Libraries
- added %%pkgconfigdir macro

* Sat Sep 27 2008 Shu KONNO <owa@bg.wakwak.com> 0.8.1-1
- new upstream release
- added missing-files.patch from suse
- added --with-managed=desktop

* Wed Sep 17 2008 Shu KONNO <owa@bg.wakwak.com> 0.8-1
- initial build for VineSeed
    - moonlight 0.8
    - vine versioning policy
    - spec in utf-8

