%define 	add_to_doc_files()	\
	mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}; \
	cp -p %1  %{buildroot}%{_docdir}/%{name}-%{version}/$(echo '%1' | sed -e 's!/!.!g') \
	echo %%{_docdir}/%{name}-%{version}/$(echo '%1' | sed -e 's!/!.!g') >> docfiles.list

#define		svn_revision	43436

# --with coverage: Enables compile-time checking of code coverage. (default: no)
%bcond_with	coverage
# --with jit: Enable JIT ("just-in-time") JavaScript compiling support.
#%bcond_with	jit
# --with pango : use pango for font rendering instead of freetype2 (default: use freetype2)
%bcond_with	pango
# --with wml: Build support for WML
%bcond_with	wml

Name:		WebKit3
Version:	1.6.1
Release:        1%{?_dist_release}
Summary:	Web content engine library
Summary(ja):	ウェブコンテンツエンジンライブラリ

Group:		Development/Libraries
License:	LGPLv2+ and BSD
URL:		http://webkitgtk.org/

Vendor: Project Vine
Distribution: Vine Linux
Packager: Takemikaduchi

Source0:	http://www.webkitgtk.org/webkit-%{version}.tar.gz

# upstream patch
Patch100:	WebKit-icu44-36381.patch

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

BuildRequires:	bison
BuildRequires:	flex
BuildRequires:	gperf
BuildRequires:	gtk3-devel
BuildRequires:	libicu-devel
BuildRequires:	libjpeg-turbo-devel
BuildRequires:	libtool
BuildRequires:	libxslt-devel
BuildRequires:	libXt-devel
BuildRequires:	pcre-devel
BuildRequires:	sqlite3-devel
BuildRequires:  geoclue-devel
BuildRequires:  gnome-keyring-devel
BuildRequires:  gstreamer-devel
BuildRequires:  gstreamer-plugins-base-devel
BuildRequires:  enchant-devel
BuildRequires:  gobject-introspection-devel

%if %{with pango}
BuildRequires:  pango-devel
%else
BuildRequires:  cairo-devel
BuildRequires:  fontconfig-devel
BuildRequires:  freetype2-devel
%endif

BuildRequires:  libsoup-devel >= 2.28.2


%description
WebKit is an open source web browser engine.

%package	gtk
Summary:	GTK+ port of WebKit
Summary(ja):	WebKit の GTK+ ポート
Group:		Development/Libraries

%description	gtk
%{name} is an open-source Web content engine library. This package contains
the shared libraries for the WebKit GTK+ port as well as the sample
GtkLauncher tool.


%package	gtk-devel
Summary:	Development package for %{name}
Summary(ja):	%{name} の開発パッケージ
Group:		Development/Libraries
Requires:	%{name}-gtk = %{version}-%{release}
Requires:	pkgconfig
Requires:	gtk3-devel
Requires:	libsoup-devel >= 2.28.2

%description	gtk-devel
The %{name}-gtk-devel package contains libraries, build data, and header
files for developing applications that use %{name}-gtk.
Please note that the WebKit/GTK+ API is not yet stable. This should
only be used as a "preview" rather than a stable platform library.


%package	doc
Summary:	Documentation for %{name}
Summary(ja):	%{name} のドキュメント
Group:		Documentation

%description	doc
%{name} is an open-source Web content engine library. This package contains
the documentation for %{name}, including various LICENSE, README, and
AUTHORS files.


%prep
%setup -q -n webkit-%{version}

# upstream
## %patch100 -p0

%build
%configure \
--with-gtk=3.0 \
--enable-icon-database \
--enable-geolocation \
--enable-introspection=yes \
%{?with_coverage:       --enable-coverage               }       \
%{?with_pango:          --with-font-backend=pango       }       \
%{?with_wml:            --enable-wml                    }
make %{?_smp_mflags}

# workaround for bug 488112
# Compile libJavaScriptCore.a with -fno-strict-aliasing
##touch JavaScriptCore/AllInOneFile.cpp
##make %{?_smp_mflags} CXXFLAGS="%{optflags} -fno-strict-aliasing"


%install
rm -rf %{buildroot}

make install DESTDIR=%{buildroot}
install -d -m 755 %{buildroot}%{_libexecdir}/%{name}
install -m 755 Programs/GtkLauncher %{buildroot}%{_libexecdir}/%{name}

# Finally, copy over and rename the various files for %%doc inclusion.
%add_to_doc_files Source/WebKit/LICENSE
%add_to_doc_files Source/WebKit/gtk/po/README
%add_to_doc_files Source/WebKit/gtk/NEWS
%add_to_doc_files Source/WebCore/icu/LICENSE
%add_to_doc_files Source/WebCore/LICENSE-APPLE
%add_to_doc_files Source/WebCore/LICENSE-LGPL-2
%add_to_doc_files Source/WebCore/LICENSE-LGPL-2.1
%add_to_doc_files Source/JavaScriptCore/COPYING.LIB
%add_to_doc_files Source/JavaScriptCore/THANKS
%add_to_doc_files Source/JavaScriptCore/AUTHORS
%add_to_doc_files Source/JavaScriptCore/icu/README
%add_to_doc_files Source/JavaScriptCore/icu/LICENSE

%find_lang webkit-3.0

%clean
rm -rf %{buildroot}


%post	gtk -p /sbin/ldconfig

%posttrans gtk
glib-compile-schemas %{_datadir}/glib-2.0/schemas ||:

%postun	gtk 
/sbin/ldconfig
if [ $1 -eq 0 ] ; then
    glib-compile-schemas %{_datadir}/glib-2.0/schemas ||:
fi


# %files -f webkit.lang gtk
%files gtk -f webkit-3.0.lang
%defattr(-,root,root,-)
%doc
%{_libdir}/*.so.*
%{_libexecdir}/WebKit3/
%{_bindir}/jsc-3
%{_libdir}/girepository-1.0/*.typelib
%{_datadir}/glib-2.0/schemas/org.webkitgtk-3.0.gschema.xml
%{_datadir}/webkitgtk-3.0/*

%files	gtk-devel
%defattr(-,root,root,-)
%exclude %{_libdir}/*.la
%{_includedir}/webkit-3.0
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_datadir}/gir-1.0/*.gir

%files	doc -f docfiles.list
%defattr(-,root,root,-)
%{_docdir}/%{name}-%{version}/


%changelog
* Wed Sep 28 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.6.1-1
- new upstream release

* Fri Sep 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.5.90-1
- new upstream release

* Sat Aug 27 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.5.2-1
- new upstream release

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.5.1-1
- initial build for Vine Linux

