Index: trunk/configure.cmd
===================================================================
--- trunk/configure.cmd	(revision 356)
+++ trunk/configure.cmd	(revision 357)
@@ -299,5 +299,5 @@
     G.CFG_GRAPHICS_SYSTEM = "default"
 
-    /* initalize variables used for installation */
+    /* variables used for locating installed Qt components */
     G.QT_INSTALL_PREFIX = ""
     G.QT_INSTALL_DOCS = ""
@@ -545,35 +545,35 @@
     /* prefix */
     if (G.QT_INSTALL_PREFIX == "") then
-        G.QT_INSTALL_PREFIX = G.OutPath
+        G.QT_INSTALL_PREFIX = "."
     /* docs */
     if (G.QT_INSTALL_DOCS == "") then
-        G.QT_INSTALL_DOCS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\docs"
+        G.QT_INSTALL_DOCS = "doc"
     /* headers */
     if (G.QT_INSTALL_HEADERS == "") then
-        G.QT_INSTALL_HEADERS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\include"
+        G.QT_INSTALL_HEADERS = "include"
     /* libs */
     if (G.QT_INSTALL_LIBS == "") then
-        G.QT_INSTALL_LIBS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\lib"
+        G.QT_INSTALL_LIBS = "lib"
     /* bins */
     if (G.QT_INSTALL_BINS == "") then
-        G.QT_INSTALL_BINS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\bin"
+        G.QT_INSTALL_BINS = "bin"
     /* plugins */
     if (G.QT_INSTALL_PLUGINS == "") then
-        G.QT_INSTALL_PLUGINS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\plugins"
+        G.QT_INSTALL_PLUGINS = "plugins"
     /* data */
     if (G.QT_INSTALL_DATA == "") then
-        G.QT_INSTALL_DATA = FixDirNoSlash(G.QT_INSTALL_PREFIX)
+        G.QT_INSTALL_DATA = "."
     /* translations */
     if (G.QT_INSTALL_TRANSLATIONS == "") then
-        G.QT_INSTALL_TRANSLATIONS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\translations"
+        G.QT_INSTALL_TRANSLATIONS = "translations"
     /* settings */
     if (G.QT_INSTALL_SETTINGS == "") then
-        G.QT_INSTALL_SETTINGS = SysBootDrive()"\OS2\xdg"
+        G.QT_INSTALL_SETTINGS = "$(ETC)\qt"
     /* examples */
     if (G.QT_INSTALL_EXAMPLES == "") then
-        G.QT_INSTALL_EXAMPLES = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\examples"
+        G.QT_INSTALL_EXAMPLES = "examples"
     /* demos */
     if (G.QT_INSTALL_DEMOS == "") then
-        G.QT_INSTALL_DEMOS = FixDirNoSlash(G.QT_INSTALL_PREFIX)"\demos"
+        G.QT_INSTALL_DEMOS = "demos"
 
     /*--------------------------------------------------------------------------
@@ -634,6 +634,5 @@
     --------------------------------------------------------------------------*/
 
-    if (\DirExists(G.OutPath"\src\corelib\global")) then
-        call MakeDir G.OutPath"\src\corelib\global"
+    call MakeDir G.OutPath"\src\corelib\global"
 
     qconfig_cpp = G.OutPath"\src\corelib\global\qconfig.cpp"
@@ -641,32 +640,30 @@
     config_cpp_str =,
 '/* License Info */'G.EOL||,
-'static const char qt_configure_licensee_str          [260 + 12] = "qt_lcnsuser='CPPPath(MaxLen(G.Licensee,259))'";'G.EOL||,
-'static const char qt_configure_licensed_products_str [260 + 12] = "qt_lcnsprod='CPPPath(MaxLen(G.Edition,259))'";'G.EOL||,
-'/* Installation Info */'G.EOL||,
-'static const char qt_configure_prefix_path_str       [260 + 12] = "qt_prfxpath='CPPPath(MaxLen(G.QT_INSTALL_PREFIX,259))'";'G.EOL||,
-'static const char qt_configure_documentation_path_str[260 + 12] = "qt_docspath='CPPPath(MaxLen(G.QT_INSTALL_DOCS,259))'";'G.EOL||,
-'static const char qt_configure_headers_path_str      [260 + 12] = "qt_hdrspath='CPPPath(MaxLen(G.QT_INSTALL_HEADERS,259))'";'G.EOL||,
-'static const char qt_configure_libraries_path_str    [260 + 12] = "qt_libspath='CPPPath(MaxLen(G.QT_INSTALL_LIBS,259))'";'G.EOL||,
-'static const char qt_configure_binaries_path_str     [260 + 12] = "qt_binspath='CPPPath(MaxLen(G.QT_INSTALL_BINS,259))'";'G.EOL||,
-'static const char qt_configure_plugins_path_str      [260 + 12] = "qt_plugpath='CPPPath(MaxLen(G.QT_INSTALL_PLUGINS,259))'";'G.EOL||,
-'static const char qt_configure_data_path_str         [260 + 12] = "qt_datapath='CPPPath(MaxLen(G.QT_INSTALL_DATA,259))'";'G.EOL||,
-'static const char qt_configure_translations_path_str [260 + 12] = "qt_trnspath='CPPPath(MaxLen(G.QT_INSTALL_TRANSLATIONS,259))'";'G.EOL||,
-'static const char qt_configure_settings_path_str     [260 + 12] = "qt_stngpath='CPPPath(MaxLen(G.QT_INSTALL_SETTINGS,259))'";'G.EOL||,
-'static const char qt_configure_examples_path_str     [260 + 12] = "qt_xmplpath='CPPPath(MaxLen(G.QT_INSTALL_EXAMPLES,259))'";'G.EOL||,
-'static const char qt_configure_demos_path_str        [260 + 12] = "qt_demopath='CPPPath(MaxLen(G.QT_INSTALL_DEMOS,259))'";'G.EOL||,
-'/* strlen( "qt_lcnsxxxx" ) == 12 */'G.EOL||,
-'#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;'G.EOL||,
-'#define QT_CONFIGURE_DEMOS_PATH qt_configure_demos_path_str + 12;'G.EOL||,
+'#define QT_CONFIGURE_LICENSEE "'CPPPath(MaxLen(G.Licensee,259))'"'G.EOL||,
+'#define QT_CONFIGURE_LICENSED_PRODUCTS "'CPPPath(MaxLen(G.Edition,259))'"'G.EOL||,
+'/* Installation Info */'G.EOL
+
+    if (G.QT_INSTALL_PREFIX == ".") then
+        /* make the prefix path be the directory where the module containing
+         * core Qt classes (in particular, QLibraryInfo) resides. Normally, it
+         * will be the path to QtCore4.DLL which is useful for separate Qt runtime
+         * distros that will have all components along in the same directory */
+        config_cpp_str = config_cpp_str||,
+'#define QT_CONFIGURE_PREFIX_PATH qt_module_path()'G.EOL
+    else
+        config_cpp_str = config_cpp_str||,
+'#define QT_CONFIGURE_PREFIX_PATH "'CPPPath(G.QT_INSTALL_PREFIX)'"'G.EOL
+
+    config_cpp_str = config_cpp_str||,
+'#define QT_CONFIGURE_DOCUMENTATION_PATH "'CPPPath(G.QT_INSTALL_DOCS)'"'G.EOL||,
+'#define QT_CONFIGURE_HEADERS_PATH "'CPPPath(G.QT_INSTALL_HEADERS)'"'G.EOL||,
+'#define QT_CONFIGURE_LIBRARIES_PATH "'CPPPath(G.QT_INSTALL_LIBS)'"'G.EOL||,
+'#define QT_CONFIGURE_BINARIES_PATH "'CPPPath(G.QT_INSTALL_BINS)'"'G.EOL||,
+'#define QT_CONFIGURE_PLUGINS_PATH "'CPPPath(G.QT_INSTALL_PLUGINS)'"'G.EOL||,
+'#define QT_CONFIGURE_DATA_PATH "'CPPPath(G.QT_INSTALL_DATA)'"'G.EOL||,
+'#define QT_CONFIGURE_TRANSLATIONS_PATH "'CPPPath(G.QT_INSTALL_TRANSLATIONS)'"'G.EOL||,
+'#define QT_CONFIGURE_SETTINGS_PATH "'CPPPath(G.QT_INSTALL_SETTINGS)'"'G.EOL||,
+'#define QT_CONFIGURE_EXAMPLES_PATH "'CPPPath(G.QT_INSTALL_EXAMPLES)'"'G.EOL||,
+'#define QT_CONFIGURE_DEMOS_PATH "'CPPPath(G.QT_INSTALL_DEMOS)'"'G.EOL||,
 G.EOL
 
@@ -679,4 +676,14 @@
         call charout qconfig_cpp
     end
+
+    /* create qt.conf in the bin\ subdirectory with the correct paths to the
+     * Qt components we will build. This is necessary because the default paths
+     * in qconfig.cpp generated above will be relative to QtCore4.DLL while in
+     * the development environment they need to be relative to the output tree
+     * of the Qt library */
+    call MakeDir G.OutPath"\bin"
+    qt_conf = G.OutPath"\bin\qt.conf"
+    call charout qt_conf, '[Paths]'G.EOL'Prefix = ..'G.EOL
+    call charout qt_conf
 
     /*--------------------------------------------------------------------------
@@ -1829,11 +1836,36 @@
 
 MakeDir: procedure expose (Globals)
-    /* @todo teach it to create all non-existing intermediate dirs */
     parse arg aDir
-    rc = SysMkDir(aDir)
-    if (rc \= 0) then do
-        call SayErr 'FATAL: Could not create directory '''aDir'''!'
-        call SayErr 'SysMkDir returned 'rc
-        call Done 1
+    aDir = translate(aDir, '\', '/')
+    curdir = directory()
+    base = aDir
+    todo.0 = 0
+    do while 1
+        d = directory(base)
+        if (d \== '') then
+            leave
+        i = todo.0 + 1
+        todo.i = filespec('N', base)
+        todo.0 = i
+        drv = filespec('D', base)
+        path = filespec('P', base)
+        if (path == '\' | path == '') then do
+            base = drv||path
+            leave
+        end
+        base = drv||strip(path, 'T', '\')
+    end
+    call directory curdir
+    do i = todo.0 to 1 by -1
+        if (i < todo.0 | (base \== '' & right(base,1) \== '\' &,
+                                        right(base,1) \== ':')) then
+            base = base'\'
+        base = base||todo.i
+        rc = SysMkDir(base)
+        if (rc \= 0) then do
+            call SayErr 'FATAL: Could not create directory '''base'''!'
+            call SayErr 'SysMkDir returned 'rc
+            call Done 1
+        end
     end
     return
@@ -2238,5 +2270,5 @@
 
 /**
- *  Returns the name of the temporary directory.
+ *  Returns the absolute path to the temporary directory.
  *  The returned value doesn't end with a slash.
  */
Index: trunk/doc/src/qt-conf.qdoc
===================================================================
--- trunk/doc/src/qt-conf.qdoc	(revision 356)
+++ trunk/doc/src/qt-conf.qdoc	(revision 357)
@@ -58,4 +58,10 @@
     libraries look elsewhere.
 
+	Note that on OS/2, the libraries do not use the hard-coded paths
+	by default. Instead, they look for plugins and other components in a
+	directory that contains the QtCore DLL library (or the application
+	executable if Qt is built as a static library). This behavior may
+	also be overridden using the \c qt.conf file.
+    
     QLibraryInfo will load \c qt.conf from one of the following locations:
 
@@ -72,4 +78,16 @@
     \endlist
 
+    On OS/2, if neither of the above locations contains \c qt.conf,
+    QLibraryInfo will additionally try the following two locations:
+
+    \list 1
+
+    \o \c qt.conf in the directory containing the QtCore DLL library
+    (or the application executable if Qt is built as a static library)
+
+    \o \c %ETC%\qt\qtsys.conf
+    
+    \endlist
+    
     The \c qt.conf file is an INI text file, as described in the \l
     {QSettings::Format}{QSettings} documentation. The file should have
@@ -106,6 +124,7 @@
     need to be placed in specific sub-directories under the
     \c{plugins} directory (see \l{How to Create Qt Plugins} for
-    details).
-
+    details). On OS/2, the \c Prefix is always relative to the directory
+    where \c qt.conf or \c qtsys.conf is loaded from.
+    
     For example, a \c qt.conf file could contain the following:
 
Index: trunk/src/corelib/global/qlibraryinfo.cpp
===================================================================
--- trunk/src/corelib/global/qlibraryinfo.cpp	(revision 356)
+++ trunk/src/corelib/global/qlibraryinfo.cpp	(revision 357)
@@ -41,5 +41,5 @@
 
 #include "qdir.h"
-#include "qfile.h"    
+#include "qfile.h"
 #include "qconfig.h"
 #include "qsettings.h"
@@ -58,4 +58,26 @@
 #  include "private/qcore_mac_p.h"
 #endif
+
+#ifdef Q_OS_OS2
+
+#include "qt_os2.h"
+
+static const char *qt_module_path()
+{
+    static char path[CCHMAXPATH] = {'\0'};
+    if (!path[0]) {
+        HMODULE hmod;
+        ULONG objNum, offset;
+        DosQueryModFromEIP(&hmod, &objNum, sizeof(path), path, &offset,
+                           (ULONG)qt_module_path);
+        DosQueryModuleName(hmod, sizeof(path), path);
+        char *slash = strrchr(path, '\\');
+        if (slash)
+            *slash = '\0';
+    }
+    return path;
+}
+
+#endif // Q_OS_OS2
 
 #include "qconfig.cpp"
@@ -137,4 +159,24 @@
                 qtconfig = pwd.filePath(QLatin1String("qt.conf"));
 	    }
+#ifdef Q_OS_OS2
+    if (!QFile::exists(qtconfig)) {
+        // search in the directory that contains the DLL or EXE where this
+        // code is located (e.g. QtCore.dll or app.exe if Qt is a static lib)
+        qtconfig = QString::fromLocal8Bit(qt_module_path());
+        qtconfig = QDir::fromNativeSeparators(qtconfig) +
+                   QLatin1String("/qt.conf");
+        qtconfig = QDir::cleanPath(qtconfig);
+
+        if (!QFile::exists(qtconfig)) {
+            // search in the system-wide location
+            qtconfig = QString::fromLocal8Bit(qgetenv("ETC"));
+            if (qtconfig.isEmpty())
+                qtconfig = QDir::rootPath();
+            qtconfig = QDir::fromNativeSeparators(qtconfig) +
+                       QLatin1String("/qt/qtsys.conf");
+            qtconfig = QDir::cleanPath(qtconfig);
+        }
+    }
+#endif
     }
 #endif
@@ -296,6 +338,18 @@
         }
 
-        if (path)
+        if (path) {
             ret = QString::fromLocal8Bit(path);
+#ifdef Q_OS_OS2
+            // expand environment variables in the form $(ENVVAR)
+            int rep;
+            QRegExp reg_var(QLatin1String("\\$\\(.*\\)"));
+            reg_var.setMinimal(true);
+            while((rep = reg_var.indexIn(ret)) != -1) {
+                ret.replace(rep, reg_var.matchedLength(),
+                            QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2,
+                                reg_var.matchedLength() - 3).toLatin1().constData()).constData()));
+            }
+#endif
+        }
     } else {
         QString key;
@@ -431,6 +485,17 @@
             // we make the prefix path absolute to the executable's directory
 #ifdef QT_BUILD_QMAKE
-            return QFileInfo(qmake_libraryInfoFile()).absolutePath();
+            QFileInfo fi(qmake_libraryInfoFile());
+            return QDir::cleanPath(QDir(fi.absolutePath()).absoluteFilePath(ret));
 #else
+#ifdef Q_OS_OS2
+            QSettings *config = QLibraryInfoPrivate::configuration();
+            if (config) {
+                // if we read paths from qt[sys].conf, the Prefix is relative to
+                // the directory we load qt[sys].conf from
+                QFileInfo fi(config->fileName());
+                return QDir::cleanPath(QDir(fi.absolutePath()).absoluteFilePath(ret));
+            }
+            else
+#endif
             if (QCoreApplication::instance()) {
 #ifdef Q_OS_MAC
@@ -444,5 +509,5 @@
 		}
 #endif
-                return QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(ret);
+                return QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(ret));
             } else {
                 return QDir::current().absoluteFilePath(ret);
@@ -451,8 +516,8 @@
         } else {
             // we make any other path absolute to the prefix directory
-            return QDir(location(PrefixPath)).absoluteFilePath(ret);
+            return QDir::cleanPath(QDir(location(PrefixPath)).absoluteFilePath(ret));
         }
     }
-    return ret;
+    return QDir::cleanPath(ret);
 }
 
