Index: /packaging/qt.spec
===================================================================
--- /packaging/qt.spec	(revision 1061)
+++ /packaging/qt.spec	(revision 1062)
@@ -3,6 +3,4 @@
 #
 
-%define test_mode   1
-
 %define ver_major   4
 %define ver_minore  7
@@ -11,5 +9,5 @@
 %define rpm_release 1
 
-%define svn_revision    816
+%define svn_revision    0
 
 %define descr_brief Qt is a software toolkit for developing applications.
@@ -24,11 +22,12 @@
 
 %define qt_prefix           %{_libdir}/%{qtM}
-%define qt_datadir          %{_datadir}/%{qtM}
 %define qt_libdir           %{_libdir}
-%define qt_headerdir        %{_includedir}/%{qtM}
+%define qt_headerdir        %{_includedir}/qt4
 %define qt_bindir           %{qt_prefix}/bin
 %define qt_plugindir        %{qt_prefix}/plugins
+%define qt_importdir        %{qt_prefix}/imports
 %define qt_demosdir         %{qt_prefix}/demos
 %define qt_examplesdir      %{qt_prefix}/examples
+%define qt_datadir          %{_datadir}/%{qtM}
 %define qt_docdir           %{qt_datadir}/doc
 %define qt_translationdir   %{qt_datadir}/translations
@@ -48,7 +47,4 @@
 Provides:   %{qtM} = %{version}-%{release}
 
-# @todo?
-#Requires:   libc >= 0.6.3
-
 License:    LGPLv2 with exceptions or GPLv3 with exceptions
 Url:        http://www.qtsoftware.com/
@@ -56,5 +52,5 @@
 Source:     qt.zip
 
-%description 
+%description
 %{descr_brief}
 
@@ -123,9 +119,4 @@
 %post
 
-%wps_object_create_begin
-%{pkg_wps_folder_create}
-#%{pkg_wps_base}_CHANGELOG:WPProgram|ChangeLog|%{pkg_wps_folder_id}|%{pkg_wps_view_txt %{pkg_docdir}/ChangeLog}
-%wps_object_create_end
-
 %postun
 
@@ -166,6 +157,7 @@
 %{descr_brief}
 
-This package contains the demo Qt applications along with their source code.
-These applications demonstrate the possibilities of the Qt toolkit.
+This package contains the demo and example Qt applications and their
+source code. These applications demonstrate the possibilities of the
+Qt toolkit.
 
 %files demos
@@ -179,31 +171,13 @@
 
 %post demos
+
 %wps_object_create_begin -n %{name}-demos
-%{wps_qt4_folder}
-QT4_DEMO:WPProgram|Examples and Demos|<QT4_FOLDER>|EXENAME=((%{qt_bindir}/qtdemo.exe))
+%pkg_wps_folder_create%
+%{pkg_wps_base}_DEMO:WPProgram|Examples and Demos|<QT4_FOLDER>|EXENAME=((%{qt_bindir}/qtdemo.exe))
+#%{pkg_wps_base}_CHANGELOG:WPProgram|ChangeLog|%{pkg_wps_folder_id}|%{pkg_wps_view_txt %{pkg_docdir}/ChangeLog}
 %wps_object_create_end
 
 %postun demos
 %wps_object_delete_all -n %{name}-demos
-
-#------------------------------------------------------------------------------
-%package examples
-#------------------------------------------------------------------------------
-Summary:    Programming examples for Qt
-Group:      Documentation
-
-Requires:   %{qt_}-pm = %{version}-%{release}
-
-Provides:   %{qtM}-examples = %{version}-%{release}
-
-%description examples
-%{descr_brief}
-
-This package contains the sample Qt applications along with their source code.
-These applications are used to learn how to program with the Qt toolkit.
-
-%files examples
-%defattr(-,root,root,-)
-%{qt_examplesdir}/
 
 #------------------------------------------------------------------------------
@@ -306,8 +280,8 @@
 #------------------------------------------------------------------------------
 
-%if 0%{?test_mode}
-%setup -TD
+%if "%{?QT_SOURCE_TREE}" != ""
+%setup -n "%{qt_}-%{version}-%{release}" -Tc
 %else
-%setup -q
+%setup -n "%{qt_}-%{version}-%{release}" -q
 %endif
 
@@ -316,17 +290,55 @@
 #------------------------------------------------------------------------------
 
-#configure.cmd \
-#    --official-build-quiet %{svn_revision} \
-#    -prefix "%{qt_prefix}" \
-#    -datadir "%{qt_datadir}" \
-#    -libdir "%{qt_libdir}" \
-#    -headerdir "%{qt_headerdir}" \
-#    -bindir "%{qt_bindir}" \
-#    -plugindir "%{qt_plugindir}" \
-#    -demosdir "%{qt_demosdir}" \
-#    -examplesdir "%{qt_examplesdir}" \
-#    -docdir "%{qt_docdir}" \
-#    -translationdir "%{qt_translationdir}" \
-#    -sysconfdir "%{qt_sysconfdir}" \
+# @todo add to BuildRequires:
+#   libc-devel
+#   gcc
+#   cups-devel
+#   openssl-devel
+#   mysql-devel
+#   psql-devel
+#   pthread-devel
+
+die() { echo "ERROR: $@"; exit 1; }
+check_var() { eval "[ -n \"\$$1\" ] || die \"$1 variable is not set.\""; }
+
+# Define Qt source tree
+if [ -z "%{QT_SOURCE_TREE}" ]; then QT_SOURCE_TREE=.
+else QT_SOURCE_TREE="%{QT_SOURCE_TREE}"
+fi
+
+QT_SOURCE_TREE_D=$(echo "%{QT_SOURCE_TREE}" | tr '/' '\\')
+
+# Sanity checks (laking these would turn off features that must be ON)
+check_var "CUPS_INCLUDEPATHH"
+check_var "OPENSSL_INCLUDEPATH"
+check_var "MYSQL_INCLUDEPATH"
+check_var "MYSQL_LIBS"
+check_var "PSQL_INCLUDEPATH"
+check_var "PSQL_LIBS"
+
+# CMD.EXE is required by the build process for now
+export MAKESHELL=%{os2_boot_drive}\\OS2\\CMD.EXE
+
+# Qt doesn't understand /@unixroot in library paths, replace it with $(UNIXROOT)
+library_paths=$(echo \
+    --official-build-quiet %{svn_revision} \
+    -prefix "%{qt_prefix}" \
+    -datadir "%{qt_datadir}" \
+    -libdir "%{qt_libdir}" \
+    -headerdir "%{qt_headerdir}" \
+    -bindir "%{qt_bindir}" \
+    -plugindir "%{qt_plugindir}" \
+    -importdir "%{qt_importdir}" \
+    -demosdir "%{qt_demosdir}" \
+    -examplesdir "%{qt_examplesdir}" \
+    -docdir "%{qt_docdir}" \
+    -translationdir "%{qt_translationdir}" \
+    -sysconfdir "%{qt_sysconfdir}" \
+| sed -re 's,/@unixroot,$(UNIXROOT),g')
+
+cmd /c $QT_SOURCE_TREE_D\\configure.cmd $library_paths
+
+make -j%MAKE_JOBS%
+make docs -j%MAKE_JOBS%
 
 #------------------------------------------------------------------------------
@@ -336,20 +348,21 @@
 rm -rf %{buildroot}
 
-#make install INSTALL_ROOT=%{buildroot}
-
-mkdir -p %{buildroot}/%{qt_libdir}
-cp QtCore4.dll %{buildroot}/%{qt_libdir}/
-cp QtGui4.dll %{buildroot}/%{qt_libdir}/
-mkdir -p %{buildroot}/%{qt_bindir}
-cp qtdemo.exe %{buildroot}/%{qt_bindir}/
-cp designer.exe %{buildroot}/%{qt_bindir}/
-cp linguist.exe %{buildroot}/%{qt_bindir}/
-cp assistant.exe %{buildroot}/%{qt_bindir}/
-mkdir -p %{buildroot}/%{qt_demosdir}
-cp -R demos/* %{buildroot}/%{qt_demosdir}/
-mkdir -p %{buildroot}/%{qt_examplesdir}
-cp -R examples/* %{buildroot}/%{qt_examplesdir}/
-mkdir -p %{buildroot}/%{qt_docdir}
-cp -R doc/* %{buildroot}/%{qt_docdir}/
+make install INSTALL_ROOT=%{buildroot}
+
+# @todo remove
+#mkdir -p %{buildroot}/%{qt_libdir}
+#cp QtCore4.dll %{buildroot}/%{qt_libdir}/
+#cp QtGui4.dll %{buildroot}/%{qt_libdir}/
+#mkdir -p %{buildroot}/%{qt_bindir}
+#cp qtdemo.exe %{buildroot}/%{qt_bindir}/
+#cp designer.exe %{buildroot}/%{qt_bindir}/
+#cp linguist.exe %{buildroot}/%{qt_bindir}/
+#cp assistant.exe %{buildroot}/%{qt_bindir}/
+#mkdir -p %{buildroot}/%{qt_demosdir}
+#cp -R demos/* %{buildroot}/%{qt_demosdir}/
+#mkdir -p %{buildroot}/%{qt_examplesdir}
+#cp -R examples/* %{buildroot}/%{qt_examplesdir}/
+#mkdir -p %{buildroot}/%{qt_docdir}
+#cp -R doc/* %{buildroot}/%{qt_docdir}/
 
 #------------------------------------------------------------------------------
@@ -364,3 +377,2 @@
 * Sun Oct 31 2010 Dmitry A. Kuminov <coding/dmik.org> - 4.6.3-1
 - test version
-
