Index: /trunk/README.OS2
===================================================================
--- /trunk/README.OS2	(revision 575)
+++ /trunk/README.OS2	(revision 576)
@@ -46,4 +46,14 @@
 
       http://unix.os2site.com/pub/binary/make/make-3_81beta1-bin-static.zip
+
+  - eCUPS 1.3.11 or later to support printing in Qt. The eCUPS WPI is available
+    at:
+
+      ftp://ftp.netlabs.org/incoming/eCUPS003.wpi   or
+      ftp://ftp.netlabs.org/pub/ecups/eCUPS003.wpi
+
+    Linking against eCUPS also requires pthread.lib:
+
+      http://web.os2power.com/download/lib/pthread-20100217-os2.zip
 
   - LxLite 1.3.3 or above (not tested) if you want Qt DLLs and application
@@ -90,4 +100,18 @@
       set PATH=D:\Coding\Qt4\bin;%PATH%
       set BEGINLIBPATH=D:\Coding\Qt4\bin;%BEGINLIBPATH%
+
+  - Install the eCUPS WPI archive to enable printing support. If this WPI is
+    installed, the Qt build system will pick up all necessary libraries
+    automatically. Otherwise, you will need to use the following environment
+    variables to tell it where to look for CUPS:
+
+      set CUPS_INCLUDEPATH=X:\Path\to\CUPS\include
+      set CUPS_LIBS=X:\Path\to\CUPS\lib\libcups.a
+
+    Note that if the eCUPS WPI is not installed and these variables are not set,
+    printing support will be completely disabled in the resulting Qt build.
+
+    You will also need to make sure that pthread.lib is placed somewhere in your
+    system library path so that the compiler can find it.
 
 Note that the QTDIR environment variable used by previous Qt versions is not
@@ -317,4 +341,22 @@
 
 
+PRINTING SUPPORT
+
+Starting with version 4.6.1, Qt for OS/2 supports printing through the CUPS
+framework (provided that this support is enabled when building Qt, see the
+respective sections in the beginning of this document). The OS/2 implementation
+of the CUPS framework is provided by the eCUPS package available at
+http://svn.netlabs.org/ecups/.
+
+The Qt Runtime detects the presence of eCUPS in the system on the fly and talks
+to the CUPS daemon directly, bypassing the standard OS/2 printing subsystem.
+This means that in order to print from Qt applications, you don't need to create
+and configure printer objects using the standard OS/2 system printer setup
+procedure -- you only need to install eCUPS and configure your printers in
+there. Please refer to the eCUPS user manual to obtain the detailed instructions
+on how to configure CUPS printers.
+
+
+
 CURRENT LIMITATIONS
 
@@ -368,6 +410,6 @@
      relevant parts of code so they should still build.
 
-  9. No QAssistant, no printer support (QT_NO_PRINTER and QT_NO_PRINTDIALOG are
-     defined). No IPV6 support in the network module (QT_NO_IPV6 is defined).
+  9. No QAssistant. No IPV6 support in the network module (QT_NO_IPV6 is
+     defined).
 
   See the project roadmap for more information on the current progress and
Index: /trunk/configure.cmd
===================================================================
--- /trunk/configure.cmd	(revision 575)
+++ /trunk/configure.cmd	(revision 576)
@@ -45,6 +45,5 @@
     "QT_NO_TABLET",
     "QT_NO_SYSTEMSEMAPHORE QT_NO_SHAREDMEMORY",
-    "QT_NO_IM QT_NO_ACCESSIBILITY QT_NO_IPV6",
-    "QT_NO_PRINTER QT_NO_PRINTDIALOG"
+    "QT_NO_IM QT_NO_ACCESSIBILITY QT_NO_IPV6"
 
 G.QT_DEFAULT_BUILD_PARTS = "libs tools qmake" /* examples demos docs translations */
@@ -271,7 +270,7 @@
     G.CFG_DECORATION_PLUGIN_AVAILABLE = ""
     G.CFG_DECORATION_PLUGIN = ""
+    G.CFG_CUPS = "auto"
+    G.CFG_NIS = "auto"
 /* @todo do we really need this?
-    G.CFG_NIS = "auto"
-    G.CFG_CUPS = "auto"
     G.CFG_ICONV = "auto"
     G.CFG_GLIB = "auto"
@@ -593,4 +592,33 @@
     call SetEnv "QMAKE_EXEPACK_POST_FLAGS", G.QMAKE_EXEPACK_POST_FLAGS
 
+    /* detect the CUPS support */
+
+    call GetPkgVersionAndPath 'Peter Brown\CUPS\CUPS', 'G.CUPS'
+    if (G.CUPS.version \== '') then
+        call SayVerbose 'eCUPS version 'G.CUPS.version' detected in "'G.CUPS.path'"'
+    else
+        call SayVerbose 'eCUPS is not found.'
+
+    if (G.CUPS.version >= "1.3.11") then do
+        G.CUPS.path = FixDirNoSlash(G.CUPS.path)'\cups';
+        G.CFG_CUPS = "yes"
+        G.CUPS_INCLUDEPATH = G.CUPS.path'\include'
+        G.CUPS_LIBS = '-L'G.CUPS.path'\lib libcups.a pthread.lib'
+    end
+    else do
+        G.CFG_CUPS = "no"
+        G.CUPS_INCLUDEPATH = ''
+        G.CUPS_LIBS = ''
+        /* so far, CUPS is the only printing system we support so disable
+         * the printer classses at all when CUPS is not available */
+        call SaySay 'WARNING: Printing support is completely disabled due to',
+                    'missing or outdated eCUPS framework.'
+        G.D_FLAGS = Join(G.D_FLAGS, "QT_NO_PRINTER")
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_PRINTER")
+    end
+
+    /* NIS support is always off for now */
+    G.CFG_NIS = "no"
+
     /*--------------------------------------------------------------------------
      post process QT_INSTALL_* variables
@@ -1061,9 +1089,10 @@
         G.QT_CONFIG = Join(G.QT_CONFIG, "system-zlib")
 
-/* @todo do we really need this?
+    if (G.CFG_CUPS == "yes") then
+        G.QT_CONFIG = Join(G.QT_CONFIG, "cups")
     if (G.CFG_NIS == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "nis")
-    if (G.CFG_CUPS == "yes") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "cups")
+
+/* @todo do we really need this?
     if (G.CFG_ICONV == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "iconv")
@@ -1241,4 +1270,5 @@
      * to be included in the build key */
     DEFS = ""
+    ALL_D_FLAGS = G.D_FLAGS G.QCONFIG_FLAGS
     do i = 1 to words(G.D_FLAGS)
         opt = strip(word(G.D_FLAGS, i))
@@ -1390,8 +1420,11 @@
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_GRAPHICSSYSTEM_OPENGL")
 
+    if (G.CFG_CUPS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_CUPS")
+    if (G.CFG_NIS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NIS")
+
     /* X11/Unix/Mac only configs */
 /* @todo detect what's actually relevant
-    if (G.CFG_CUPS == "no") then
-        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_CUPS")
     if (G.CFG_ICONV == "no") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_ICONV")
@@ -1414,6 +1447,4 @@
     if (G.CFG_NAS == "no") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NAS")
-    if (G.CFG_NIS == "no") then
-        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NIS")
     if (G.CFG_OPENSSL == "linked") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_LINKED_OPENSSL")
@@ -1620,5 +1651,14 @@
         call lineout qmake_cache_new, 'OPENSSL_LIBS = -lssl -lcrypto'
 
+    /* dump CUPS_INCLUDEPATH and friends */
+    if (G.CFG_CUPS == "yes") then do
+        if (G.CUPS_INCLUDEPATH \== "") then
+            call lineout qmake_cache_new, 'CUPS_INCLUDEPATH = 'G.CUPS_INCLUDEPATH
+        if (G.CUPS_LIBS \== "") then
+            call lineout qmake_cache_new, 'CUPS_LIBS = 'G.CUPS_LIBS
+    end
+
     /* dump the qmake spec */
+    call lineout qmake_cache_new, ""
     if (DirExists(G.OutPath"\mkspecs\"G.XPLATFORM)) then
        call lineout qmake_cache_new, 'QMAKESPEC = $$QT_BUILD_TREE\mkspecs\'G.XPLATFORM
@@ -1709,10 +1749,10 @@
     call SaySay "Graphics System ..... "G.CFG_GRAPHICS_SYSTEM
     call SaySay "Accessibility ....... "G.CFG_ACCESSIBILITY
+    call SaySay "CUPS support ........ "G.CFG_CUPS
+    call SaySay "NIS support ......... "G.CFG_NIS
 /* @todo do we really need this?
     call SaySay "IPv6 support ........ "G.CFG_IPV6
     call SaySay "IPv6 ifname support . "G.CFG_IPV6IFNAME
     call SaySay "getifaddrs support .. "G.CFG_GETIFADDRS
-    call SaySay "NIS support ......... "G.CFG_NIS
-    call SaySay "CUPS support ........ "G.CFG_CUPS
     call SaySay "Iconv support ....... "G.CFG_ICONV
     call SaySay "Glib support ........ "G.CFG_GLIB
@@ -1926,4 +1966,33 @@
  utility functions
 ------------------------------------------------------------------------------*/
+
+GetPkgVersionAndPath: procedure expose (Globals)
+    parse arg aPkgId, aStem
+    ver = ''
+    pth = ''
+    WarpInDir = strip(SysIni('USER', 'WarpIN', 'Path'), 'T', '0'x)
+    if (WarpInDir \== '') then do
+        rc = SysFileTree(WarpInDir'\DATBAS_?.INI', 'inis', 'FO')
+        if (rc == 0) then do
+            do i = 1 to inis.0
+                rc = SysIni(inis.i, 'ALL:', 'apps')
+                if (rc == '') then do
+                    do j = 1 to apps.0
+                        apps.j = strip(apps.j, 'T', '0'x)
+                        if (left(apps.j, length(aPkgId)) == aPkgId) then do
+                            /* found the app */
+                            ver = right(apps.j, length(apps.j) - length(aPkgId) - 1)
+                            ver = translate(ver, '.', '\')
+                            pth = strip(SysIni(inis.i, apps.j, 'TargetPath'), 'T', '0'x)
+                            leave
+                        end
+                    end
+                end
+            end
+        end
+    end
+    call value aStem'.version', ver
+    call value aStem'.path', pth
+    return
 
 MaxLen: procedure expose (Globals)
