Index: /packaging/CreateRPMs.sh
===================================================================
--- /packaging/CreateRPMs.sh	(revision 1074)
+++ /packaging/CreateRPMs.sh	(revision 1075)
@@ -12,5 +12,5 @@
 #
 
-qt_spec=qt.spec
+spec_file=qt.spec
 
 #
@@ -31,9 +31,7 @@
     local src_base="$1"
 
-    [ -d "$src_base" ] || die "'$src_base' is not a directory."
-
     run $env_cmd rpmbuild \
         -D "QT_SOURCE_TREE $src_base" \
-        -ba $qt_spec
+        -ba $spec_file
 }
 
@@ -42,20 +40,26 @@
     local src_base="$1"
 
-    [ -d "$src_base" ] || die "'$src_base' is not a directory."
+    run $env_cmd rpmbuild \
+        -D "QT_SOURCE_TREE $src_base" \
+        -D "skip_prep_export 1" -D "skip_prep_clean 1" \
+        --short-circuit -bc $spec_file
+}
+
+cmd_install()
+{
+    local src_base="$1"
 
     run $env_cmd rpmbuild \
-        -D "QT_SOURCE_TREE $src_base" -D "skip_prep_export 1" \
-        -bc $qt_spec
+        -D "QT_SOURCE_TREE $src_base" \
+        -D "skip_prep_export 1" -D "skip_prep_clean 1" \
+        --short-circuit -bi $spec_file
 }
 
 cmd_rpm()
 {
-    local inst_base="$1"
-
-    [ -d "$inst_base" ] || die "'$inst_base' is not a directory."
-
     run $env_cmd rpmbuild \
-        -D "QT_BUILD_TREE $inst_base" \
-        --short-circuit -bi $qt_spec
+        -D "skip_prep_export 1" -D "skip_prep_clean 1" \
+        -D "skip_build 1" -D "skip_install 1" \
+        --short-circuit -bb $spec_file
 }
 
@@ -83,27 +87,22 @@
 Usage:
   $script_name all <srcdir>     Do everything (RPM, SRPM, ZIP)
-  $script_name build <srcdir>   Build product (shadow build)
-  $script_name rpm [<instdir>]  Build RPMs only
+  $script_name build <srcdir>   Build product (in BUILD/<product>)
+  $script_name install <srcdir> Install product (to BUILDROOT/<product>)
+  $script_name rpm              Build RPMs only
 
 Options:
   <srcdir>      Qt SVN source tree location
-  <instdir>     Qt installation tree location
-                (default: $HOME/rpmbuild/BUILDROOT/qt-X.Y.Z)
 "
 }
 
 case "$1" in
-    all|build)
+    all|build|install)
         if [ -n "$2" ]; then
+            [ -d "$2" ] || die "'$2' is not a directory."
             cmd_$1 $(echo "$2" | tr '\\' '/')
         else
             cmd_help
         fi;;
-    rpm)
-        if [ -n "$2" ]; then
-            cmd_rpm $(echo "$2" | tr '\\' '/')
-        else
-            cmd_rpm
-        fi;;
+    rpm) cmd_rpm;;
     -h|-?|--help|*) cmd_help;;
 esac
Index: /packaging/env.tpl.cmd
===================================================================
--- /packaging/env.tpl.cmd	(revision 1074)
+++ /packaging/env.tpl.cmd	(revision 1075)
@@ -22,10 +22,10 @@
 'set MYSQL_ROOT=D:\Coding\mysql\mysql51'
 'set MYSQL_INCLUDEPATH=%MYSQL_ROOT%\include'
-'set MYSQL_LIBS=-L%MYSQL_ROOT%\lib -lmysqlclient_r -llibssl -llibcrypto -lpthread'
+'set MYSQL_LIBS=-L%MYSQL_ROOT%\lib -lmysqlclient_r -L%UNIXROOT%\usr\lib -llibssl -llibcrypto -lpthread'
 
 /* PostgresSQL libraries */
 'set PSQL_ROOT=D:\Coding\pgsql\pgsql901'
 'set PSQL_INCLUDEPATH=%PSQL_ROOT%\include'
-'set PSQL_LIBS=-L%PSQL_ROOT%\lib -llibpq -llibssl -llibcrypto -lpthread'
+'set PSQL_LIBS=-L%PSQL_ROOT%\lib -llibpq -L%UNIXROOT%\usr\lib -llibssl -llibcrypto -lpthread'
 
 /* Number of make jobs, normally # of CPUs + 1 */
Index: /packaging/qt.spec
===================================================================
--- /packaging/qt.spec	(revision 1074)
+++ /packaging/qt.spec	(revision 1075)
@@ -59,10 +59,4 @@
 %if "%{?QT_SOURCE_TREE}" == ""
 %define QT_SOURCE_TREE .
-%endif
-
-%if "%{?QT_BUILD_TREE}" != ""
-%define skip_prep 1
-%define skip_build 1
-%define skip_install 1
 %endif
 
@@ -86,4 +80,7 @@
 %define qtM                 %{name}%{ver_major}
 
+# disable lxlite compression (Qt EXEs and DLLs are already compressed)
+%define __os_install_post	%{nil}
+
 #------------------------------------------------------------------------------
 # main package
@@ -337,5 +334,5 @@
 %else
 # use passed source tree as is (shadow build)
-%setup -n "%{name}-%{version}" -TDc
+%setup -n "%{name}-%{version}" -Tc%{?skip_prep_clean:D}
 %endif
 %else
@@ -364,4 +361,6 @@
 check_var "PSQL_INCLUDEPATH"
 check_var "PSQL_LIBS"
+
+[ -z "$MAKE_JOBS" ] && MAKE_JOBS=1
 
 # Qt links to some OS/2 DLLs directly (w/o import libs)
@@ -391,10 +390,21 @@
 
 # make sure the right DLLs are used by the build (and in particular by qdoc
-# in make install) in case if there is another Qt version installed
+# in make docs) in case if there is another Qt version installed
 export PATH="$BUILDDIR_D\\bin\;$PATH"
 export BEGINLIBPATH="$BUILDDIR_D\\bin\;$BEGINLIBPATH"
 
+# temporarily reset UNIXROOT so that install targets will get only Qt prefixes
+# w/o the UNIXROOT directory chain (if it's not at root)
+UNIXROOT_OLD="$UNIXROOT"
+export UNIXROOT=
+
 cmd /c $QT_SOURCE_TREE_D\\configure.cmd $library_paths
 
+make -j$MAKE_JOBS
+
+# resture UNIXROOT
+export UNIXROOT="$UNIXROOT_OLD"
+
+%if !0%{?skip_build_docs}
 # qdoc needs the qsqlite plugin but nothing is installed to target locations
 # yet, so generate qt.conf to override paths
@@ -406,9 +416,6 @@
 Demos = demos" \
 > "%{_builddir}/%{buildsubdir}/bin/qt.conf"
-
-make -j$MAKE_JOBS
-
-%if !0%{?skip_build_docs}
 make docs -j$MAKE_JOBS
+rm -f "%{_builddir}/%{buildsubdir}/bin/qt.conf"
 %endif
 
@@ -423,14 +430,24 @@
 rm -rf %{buildroot}
 
-make install INSTALL_ROOT=%{buildroot}
+# Qt links to some OS/2 DLLs directly (w/o import libs)
+export LIBRARY_PATH=%{os2_boot_drive}/OS2/DLL\;%{os2_boot_drive}/MPTN/DLL\;$LIBRARY_PATH
+
+# CMD.EXE is required by the build process for now
+export MAKESHELL=%{os2_boot_drive}\\OS2\\CMD.EXE
+
+# exclude install_htmldocs from install targets
+make install_subtargets install_qchdocs install_qmake install_mkspecs \
+    INSTALL_ROOT=$(echo "%{buildroot}/@unixroot" | sed -re 's,/,\\,g')
 
 # copy READMEs (make install doesn't do that)
-cp %{QT_SOURCE_TREE}/LICENSE.* \
-   %{QT_SOURCE_TREE}/LGPL_EXCEPTION.txt \
-   %{QT_SOURCE_TREE}/README \
-   %{QT_SOURCE_TREE}/changes-%{ver_major}.%{ver_minor}.%{ver_} \
-   %{QT_SOURCE_TREE}/README.OS2 \
-   %{QT_SOURCE_TREE}/CHANGES.OS2 \
-   %{pkg_docdir}/
+mkdir -p %{buildroot}/%{pkg_docdir}/
+cp -dp \
+    %{QT_SOURCE_TREE}/LICENSE.* \
+    %{QT_SOURCE_TREE}/LGPL_EXCEPTION.txt \
+    %{QT_SOURCE_TREE}/README \
+    %{QT_SOURCE_TREE}/changes-%{ver_major}.%{ver_minor}.%{ver_patch} \
+    %{QT_SOURCE_TREE}/README.OS2 \
+    %{QT_SOURCE_TREE}/CHANGES.OS2 \
+    %{buildroot}/%{pkg_docdir}/
 
 %endif # if !0%{?skip_install}
