%define qt4_ver 4.8.6
# Qt4 version auto-detection
%define _qt4_version %(pkg-config --modversion --silence-errors Qt 2>/dev/null || echo %{qt4_ver})
%define _qt4_prefix %(pkg-config --variable prefix --silence-errors Qt 2>/dev/null || echo %{_libdir}/qt4)
%define _qt4_bindir %(pkg-config --variable bindir --silence-errors Qt 2>/dev/null || echo %{_qt4_prefix}/bin)
%define _qt4_headerdir %(pkg-config --variable headerdir --silence-errors Qt 2>/dev/null || echo %{_includedir})
%define _qt4_plugindir %(pkg-config --variable plugindir --silence-errors Qt 2>/dev/null || echo %{_qt4_prefix}/plugins)
%define _qt4_qmake %(pkg-config --variable qmake --silence-errors Qt 2>/dev/null || echo %{_qt4_bindir}/qmake)

Name:		qtscriptgenerator
Summary: 	A tool to generate Qt bindings for Qt Script	
Summary(ja): 	Qt Script の Qt バインディングを生成するツール	
Version:	0.2.0
Release:	1%{?_dist_release}

Group:		Development/Tools
License: 	GPLv2	
URL:		http://code.google.com/p/qtscriptgenerator/	

Source0:	http://qtscriptgenerator.googlecode.com/files/qtscriptgenerator-src-%{version}.tar.gz	

Patch1: qtscriptgenerator-0.1.0-gcc44.patch
Patch2: qtscriptgenerator-src-0.1.0-no_phonon.patch

## upstreamable patches
Patch50: qtscriptgenerator-src-0.1.0-qmake_target.path.patch
# needs work
Patch51: qtscriptgenerator-kde_phonon443.patch
## debian patches
Patch60: memory_alignment_fix.diff

## upstream patches

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
# explictly BR libxslt, for xsltproc
BuildRequires: libxslt
#BuildRequires: phonon-devel >= 4.4.2-2%{?_dist_release}
BuildRequires: qt4-devel >= 4.5.0-7
#BuildRequires: qt4-webkit-devel

# not strictly required, but the expectation would be for the 
# bindings to be present
Requires: qtscriptbindings = %{version}-%{release}

%description
Qt Script Generator is a tool to generate Qt bindings for Qt Script.

%package -n qtscriptbindings 
Summary: Qt bindings for Qt Script
Summary(ja): Qt Script の Qt バインディング
Group: System Environment/Libraries
Requires: qt4 >= %{_qt4_version}
Provides: qtscript-qt = %{version}-%{release}

%description -n qtscriptbindings
Bindings providing access to substantial portions of the Qt API
from within Qt Script.


%prep
%setup -q -n %{name}-src-%{version}

%patch1 -p0 -b .gcc44
%patch2 -p1 -b .no_phonon

%patch50 -p1 -b .qmake_target.path
%patch51 -p1 -b .kde_phonon

%patch60 -p1 -b .memory_alignment


%build

# workaround buildsys bogosity, see also:
# http://code.google.com/p/qtscriptgenerator/issues/detail?id=38
export INCLUDE=%{_qt4_headerdir}

pushd generator 
%{_qt4_qmake}
make %{?_smp_mflags}
./generator
popd

pushd qtbindings
%{_qt4_qmake}
make %{?_smp_mflags}
popd

pushd tools/qsexec/src
%{_qt4_qmake}
make  %{?_smp_mflags}
popd


%install
rm -rf %{buildroot} 

mkdir -p %{buildroot}%{_qt4_plugindir}/script/
# install doesn't do symlinks
cp -a plugins/script/libqtscript* \
  %{buildroot}%{_qt4_plugindir}/script/

cp -a tools/qsexec/README.TXT README.qsexec
install -D -p -m755 tools/qsexec/qsexec %{buildroot}%{_bindir}/qsexec

install -D -p -m755 generator/generator %{buildroot}%{_qt4_bindir}/generator


%clean
rm -rf %{buildroot} 


%files
%defattr(-,root,root,-)
%{_qt4_bindir}/generator

%files -n qtscriptbindings
%defattr(-,root,root,-)
%doc LICENSE.LGPL LGPL_EXCEPTION.txt
%doc README README.qsexec 
%doc doc/
%doc examples/
%{_bindir}/qsexec
%{_qt4_plugindir}/script/libqtscript*


%changelog
* Tue Jan 20 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> - 0.2.0-1
- updated to 0.2.0
- removed BR: phonon-devel
- dropt Patch3

* Mon Jan  9 2012 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.1.0-15
- rebuilt with qt-4.8.0
- added Patch3

* Sun Mar 13 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.1.0-14
- rebuilt with qt-4.7.2
- added Patch1

* Sun Oct 17 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.1.0-13
- initial build for Vine Linux

* Sat May 08 2010 Rex Dieter <rdieter@fedoraproject.org> - 0.1.0-12
- BR: qt4-webkit-devel

* Mon Mar 01 2010 Rex Dieter <rdieter@fedoraproject.org> - 0.1.0-11
- borrow memory_alignment_fix.diff from debian (should help arm/sparc)

* Wed Nov 18 2009 Rex Dieter <rdieter@fedoraproject.org> - 0.1.0-10 
- rebuild (qt-4.6.0-rc1, fc13+)

* Mon Oct 19 2009 Rex Dieter <rdieter@fedoraproject.org> - 0.1.0-9
- fix build (for qt-4.6.0/phonon-isms)

* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Jun 09 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-7
- upstream sun_issue27 patch

* Fri Apr 10 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-6
- qtscriptbindings: Provides: qtscript-qt ...

* Tue Mar 24 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-5
- qtscriptgenerator/qtscriptbindings pkgs 
- qtscriptbindings: include docs, examples

* Mon Mar 23 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-4
- include qsexec

* Mon Mar 23 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-3
- BR: phonon-devel

* Fri Mar 20 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-2
- qt-4.5.0-7 fixed wrt phonon, drop no_phonon patch

* Fri Mar 06 2009 Rex Dieter <rdieter@fedoraproject.org> 0.1.0-1
- first try

