Index: trunk/qmake/option.cpp
===================================================================
--- trunk/qmake/option.cpp	(revision 769)
+++ trunk/qmake/option.cpp	(revision 846)
@@ -1,5 +1,5 @@
 /****************************************************************************
 **
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
@@ -85,9 +85,9 @@
 //all modes
 QString Option::qmake_abslocation;
-int Option::warn_level = WarnLogic;
+int Option::warn_level = WarnLogic | WarnDeprecated;
 int Option::debug_level = 0;
 QFile Option::output;
 QString Option::output_dir;
-bool Option::recursive = false;
+Option::QMAKE_RECURSIVE Option::recursive = Option::QMAKE_RECURSIVE_DEFAULT;
 QStringList Option::before_user_vars;
 QStringList Option::after_user_vars;
@@ -97,13 +97,7 @@
 QString Option::user_template_prefix;
 QStringList Option::shellPath;
-#if defined(Q_OS_WIN32)
-Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
-#elif defined(Q_OS_OS2)
-Option::TARG_MODE Option::target_mode = Option::TARG_OS2_MODE;
-#elif defined(Q_OS_MAC)
-Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE;
-#else
-Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE;
-#endif
+Option::HOST_MODE Option::host_mode = Option::HOST_UNKNOWN_MODE;
+Option::TARG_MODE Option::target_mode = Option::TARG_UNKNOWN_MODE;
+bool Option::target_mode_overridden = false;
 
 //QMAKE_*_PROPERTY stuff
@@ -129,5 +123,5 @@
 static Option::QMAKE_MODE default_mode(QString progname)
 {
-    int s = progname.lastIndexOf(Option::dir_sep);
+    int s = progname.lastIndexOf(QDir::separator());
     if(s != -1)
         progname = progname.right(progname.length() - (s + 1));
@@ -137,4 +131,18 @@
         return Option::QMAKE_QUERY_PROPERTY;
     return Option::QMAKE_GENERATE_MAKEFILE;
+}
+
+static QString detectProjectFile(const QString &path)
+{
+    QString ret;
+    QDir dir(path);
+    if(dir.exists(dir.dirName() + Option::pro_ext)) {
+        ret = dir.filePath(dir.dirName()) + Option::pro_ext;
+    } else { //last try..
+        QStringList profiles = dir.entryList(QStringList("*" + Option::pro_ext));
+        if(profiles.count() == 1)
+            ret = dir.filePath(profiles.at(0));
+    }
+    return ret;
 }
 
@@ -163,8 +171,10 @@
             "\n"
             "Warnings Options:\n"
-            "  -Wnone         Turn off all warnings\n"
+            "  -Wnone         Turn off all warnings; specific ones may be re-enabled by\n"
+            "                 later -W options\n"
             "  -Wall          Turn on all warnings\n"
             "  -Wparser       Turn on parser warnings\n"
-            "  -Wlogic        Turn on logic warnings\n"
+            "  -Wlogic        Turn on logic warnings (on by default)\n"
+            "  -Wdeprecated   Turn on deprecation warnings (on by default)\n"
             "\n"
             "Options:\n"
@@ -173,8 +183,4 @@
             "   * before [files].                                                     *\n"
             "  -o file        Write output to file\n"
-            "  -unix          Run in unix mode\n"
-            "  -win32         Run in win32 mode\n"
-            "  -os2           Run in OS/2 mode\n"
-            "  -macx          Run in Mac OS X mode\n"
             "  -d             Increase debug level\n"
             "  -t templ       Overrides TEMPLATE as templ\n"
@@ -213,5 +219,5 @@
                 bool specified = true;
                 if(opt == "project") {
-                    Option::recursive = true;
+                    Option::recursive = Option::QMAKE_RECURSIVE_YES;
                     Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT;
                 } else if(opt == "prl") {
@@ -240,14 +246,24 @@
             } else if(opt == "tp" || opt == "template_prefix") {
                 Option::user_template_prefix = argv[++x];
-            } else if(opt == "mac9") {
-                Option::target_mode = TARG_MAC9_MODE;
             } else if(opt == "macx") {
+                fprintf(stderr, "-macx is deprecated.\n");
+                Option::host_mode = HOST_MACX_MODE;
                 Option::target_mode = TARG_MACX_MODE;
+                Option::target_mode_overridden = true;
             } else if(opt == "unix") {
+                fprintf(stderr, "-unix is deprecated.\n");
+                Option::host_mode = HOST_UNIX_MODE;
                 Option::target_mode = TARG_UNIX_MODE;
+                Option::target_mode_overridden = true;
             } else if(opt == "win32") {
+                fprintf(stderr, "-win32 is deprecated.\n");
+                Option::host_mode = HOST_WIN_MODE;
                 Option::target_mode = TARG_WIN_MODE;
+                Option::target_mode_overridden = true;
             } else if(opt == "os2") {
+                fprintf(stderr, "-os2 is deprecated.\n");
+                Option::host_mode = TARG_OS2_MODE;
                 Option::target_mode = TARG_OS2_MODE;
+                Option::target_mode_overridden = true;
             } else if(opt == "d") {
                 Option::debug_level++;
@@ -270,10 +286,12 @@
             } else if(opt == "Wlogic") {
                 Option::warn_level |= WarnLogic;
+            } else if(opt == "Wdeprecated") {
+                Option::warn_level |= WarnDeprecated;
             } else if(opt == "Wnone") {
                 Option::warn_level = WarnNone;
             } else if(opt == "r" || opt == "recursive") {
-                Option::recursive = true;
-            } else if(opt == "norecursive") {
-                Option::recursive = false;
+                Option::recursive = Option::QMAKE_RECURSIVE_YES;
+            } else if(opt == "nr" || opt == "norecursive") {
+                Option::recursive = Option::QMAKE_RECURSIVE_NO;
             } else if(opt == "config") {
                 Option::user_configs += argv[++x];
@@ -292,4 +310,5 @@
                         Option::mkfile::do_dep_heuristics = false;
                     } else if(opt == "E") {
+                        fprintf(stderr, "-E is deprecated. Use -d instead.\n");
                         Option::mkfile::do_preprocess = true;
                     } else if(opt == "cache") {
@@ -328,10 +347,16 @@
                         arg = fi.filePath();
                     if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
-                       Option::qmake_mode == Option::QMAKE_GENERATE_PRL)
+                       Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
+                        if(fi.isDir()) {
+                            QString proj = detectProjectFile(arg);
+                            if (!proj.isNull())
+                                arg = proj;
+                        }
                         Option::mkfile::project_files.append(arg);
-                    else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)
+                    } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
                         Option::projfile::project_dirs.append(arg);
-                    else
+                    } else {
                         handled = false;
+                    }
                 }
                 if(!handled) {
@@ -401,6 +426,8 @@
     Option::dirlist_sep = ";";
     Option::shellPath = detectShellPath();
+    Option::res_ext = ".res";
 #else
     Option::dirlist_sep = ":";
+    Option::shellPath = QStringList("sh");
 #endif
     Option::sysenv_mod = "QMAKE_ENV_";
@@ -508,13 +535,7 @@
         //try REALLY hard to do it for them, lazy..
         if(Option::mkfile::project_files.isEmpty()) {
-            QString pwd = qmake_getpwd(),
-                   proj = pwd + "/" + pwd.right(pwd.length() - (pwd.lastIndexOf('/') + 1)) + Option::pro_ext;
-            if(QFile::exists(proj)) {
+            QString proj = detectProjectFile(qmake_getpwd());
+            if(!proj.isNull())
                 Option::mkfile::project_files.append(proj);
-            } else { //last try..
-                QStringList profiles = QDir(pwd).entryList(QStringList("*" + Option::pro_ext));
-                if(profiles.count() == 1)
-                    Option::mkfile::project_files.append(pwd + "/" + profiles[0]);
-            }
 #ifndef QT_BUILD_QMAKE_LIBRARY
             if(Option::mkfile::project_files.isEmpty()) {
@@ -524,21 +545,36 @@
 #endif
         }
+    } else if (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
+#if defined(Q_OS_MAC)
+        Option::host_mode = Option::HOST_MACX_MODE;
+        Option::target_mode = Option::TARG_MACX_MODE;
+#elif defined(Q_OS_UNIX)
+        Option::host_mode = Option::HOST_UNIX_MODE;
+        Option::target_mode = Option::TARG_UNIX_MODE;
+#elif defined(Q_OS_OS2)
+        Option::host_mode = Option::HOST_OS2_MODE;
+        Option::target_mode = Option::TARG_OS2_MODE;
+#else
+        Option::host_mode = Option::HOST_WIN_MODE;
+        Option::target_mode = Option::TARG_WIN_MODE;
+#endif
     }
 
     //defaults for globals
-    if(Option::target_mode == Option::TARG_WIN_MODE ||
-       Option::target_mode == Option::TARG_OS2_MODE) {
-        Option::dir_sep = "\\";
-        Option::obj_ext = ".obj";
-        Option::res_ext = ".res";
-    } else {
-        if(Option::target_mode == Option::TARG_MAC9_MODE)
-            Option::dir_sep = ":";
-        else
-            Option::dir_sep = "/";
-        Option::obj_ext = ".o";
-    }
-    Option::qmake_abslocation = Option::fixPathToTargetOS(Option::qmake_abslocation);
+    if (Option::host_mode != Option::HOST_UNKNOWN_MODE)
+        applyHostMode();
     return QMAKE_CMDLINE_SUCCESS;
+}
+
+void Option::applyHostMode()
+{
+   if (Option::host_mode == Option::HOST_WIN_MODE ||
+       Option::host_mode == Option::HOST_OS2_MODE) {
+       Option::dir_sep = "\\";
+       Option::obj_ext = ".obj";
+   } else {
+       Option::dir_sep = "/";
+       Option::obj_ext = ".o";
+   }
 }
 
@@ -599,5 +635,5 @@
 Option::fixString(QString string, uchar flags)
 {
-    const QString orig_string = string;
+    //const QString orig_string = string;
     static QHash<FixStringCacheKey, QString> *cache = 0;
     if(!cache) {
