%{!?python_sitearch:%global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%global pyqt4_version 4.7

%define ver 1.78

%global qtdir	%(pkg-config --variable=prefix Qt)
%global qtdata	%(pkg-config --variable=datadir Qt)
%global qtinc	%{qtdir}/include
%global qtlib	%{qtdir}/lib

Summary:	A Scintilla port to Qt
Name:		qscintilla
Version:	2.4.2
Release:	1%{?_dist_release}
# matches up (pretty much) with qt4
License:	GPLv3 or GPLv2 with exceptions
Group:		Development/Tools
URL:		http://www.riverbankcomputing.co.uk/qscintilla
Source:		QScintilla-gpl-%{version}.tar.gz
# TODO: upstream this
Patch1:         QScintilla-2-gpl-Qt4-incpath.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	qt4-devel
BuildRequires:  PyQt4-devel >= %{pyqt4_version} 

%description
QScintilla is a port of Scintilla to the Qt GUI toolkit.

This version of QScintilla is based on Scintilla v%{ver}.

%package designer
Summary:  QScintilla designer plugin 
Group:    Development/Tools
Requires: %{name} = %{version}-%{release}
Requires: qt4-designer

%description designer
%{summary}.

%package devel
Summary: QScintilla Development Files
Group: Development/Libraries
Requires: %{name} = %{version}
Requires: qt4-devel

%description  devel
This packages contains the libraries, include and other files
you can use to develop applications with QScintilla.

%package python
Summary:  QScintilla PyQt4 bindings
Group:    Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: PyQt4 >= %{pyqt4_version}

%description python
%{summary}.

%package python-devel
Summary:  Development files for QScintilla PyQt4 bindings 
Group:    Development/Libraries
Requires: %{name}-python = %{version}-%{release}
Requires: PyQt4-devel

%description python-devel
%{summary}.

%prep 
%setup -q -n QScintilla-gpl-%{version}
%patch1 -p1 -b .designer-incpath-qt4

# fix permissions on doc files
find doc example-Qt4  -type f -exec chmod 0644 {} ';'
find src include -type f -exec chmod 0644 {} ';'

# fix line endings in license file(s)
sed -i 's/\r//' LICENSE.GPL2 GPL_EXCEPTION_ADDENDUM.TXT

%build
export QTDIR=`pkg-config --variable=prefix Qt`
%ifarch x86_64
export QMAKESPEC=$QTDIR/mkspecs/linux-g++-64/
%else
export QMAKESPEC=$QTDIR/mkspecs/linux-g++/
%endif

pushd Qt4
$QTDIR/bin/qmake -o Makefile qscintilla.pro
make %{?_smp_mflags}
popd

pushd designer-Qt4
$QTDIR/bin/qmake -o Makefile designer.pro
make %{?_smp_mflags}
popd

pushd Python
%{__python} configure.py \
            -c -j 3 \
            -n ../Qt4 \
            -o ../Qt4
make %{?_smp_mflags}
popd

%install
rm -rf $RPM_BUILD_ROOT

make install INSTALL_ROOT=$RPM_BUILD_ROOT -C Qt4
make install INSTALL_ROOT=$RPM_BUILD_ROOT -C designer-Qt4
make install DESTDIR=$RPM_BUILD_ROOT -C Python


%clean
rm -rf $RPM_BUILD_ROOT

%post  -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files 
%defattr(-, root, root, 755)
%doc ChangeLog NEWS README
%doc LICENSE.GPL3
%doc LICENSE.GPL2 GPL_EXCEPTION.TXT GPL_EXCEPTION_ADDENDUM.TXT
%{qtlib}/lib*.so.*
%{qtdir}/qsci/*
## %{qtdir}/translations/*
%{_datadir}/qt4/translations/*

%files designer
%defattr(-,root,root,-)
%{qtdir}/plugins/designer/libqscintillaplugin.so

%files devel
%defattr(-, root, root, 755)
%{qtinc}/*
%{qtlib}/lib*.so

%files python
%defattr(-,root,root,-)
%{python_sitearch}/PyQt4/Qsci.so

%files python-devel
%defattr(-,root,root,-)
%{_datadir}/sip/PyQt4/Qsci

%changelog
* Sat Feb 06 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.4.2-1
- new upstream release

* Fri Feb 05 2010 Shu KONNO <owa@bg.wakwak.com> 2.4-3
- rebuilt with qt4-4.6.1, python-2.6
- installed translation to %%{_datadir}/qt4/translations now

* Thu Oct 22 2009 Shu KONNO <owa@bg.wakwak.com> 2.4-2
- updated macro pyqt4_version to 4.6
- fixed changelog year below (2008 -> 2009)

* Sat Aug 29 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.4-1
- new upstream release
- added designer, python and python-devel sub-packages

* Sun Aug 17 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.7.1-1
- appiled new versioning policy

* Fri Nov 30 2007 Shu KONNO <owa@bg.wakwak.com> 1.7.1-0vl2
- updated macro QMAKESPEC to linux-g++-64 (if x86_64)

* Thu Sep 13 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.7.1-0vl1
- new upstream release (1.71)

* Mon Jun  4 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6-0vl1
- new upstream release (1.65)
- changed Group to System Environment/Libraries

* Sat Jan 15 2005 Satoshi MACHINO <machino@vinelinux.org> 1.4-0vl1
- initial built for VineLinux

