source: trunk/qmake/main.cpp@ 350

Last change on this file since 350 was 29, checked in by Dmitry A. Kuminov, 16 years ago

qmake: More OS/2-specific fixes. Enabled GNUMakefileGenerator (turned on by MAKEFILE_GENERATOR=GNUMAKE).

File size: 7.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the qmake application of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "project.h"
43#include "property.h"
44#include "option.h"
45#include "cachekeys.h"
46#include "metamakefile.h"
47#include <qnamespace.h>
48#include <qdebug.h>
49#include <qregexp.h>
50#include <qdir.h>
51#include <stdio.h>
52#include <stdlib.h>
53#include <ctype.h>
54#include <fcntl.h>
55#include <sys/types.h>
56#include <sys/stat.h>
57
58QT_BEGIN_NAMESPACE
59
60// for Borland, main is defined to qMain which breaks qmake
61#undef main
62#ifdef Q_OS_MAC
63#endif
64
65/* This is to work around lame implementation on Darwin. It has been noted that the getpwd(3) function
66 is much too slow, and called much too often inside of Qt (every fileFixify). With this we use a locally
67 cached copy because I can control all the times it is set (because Qt never sets the pwd under me).
68*/
69static QString pwd;
70QString qmake_getpwd()
71{
72 if(pwd.isNull())
73 pwd = QDir::currentPath();
74 return pwd;
75}
76bool qmake_setpwd(const QString &p)
77{
78 if(QDir::setCurrent(p)) {
79 pwd = QDir::currentPath();
80 return true;
81 }
82 return false;
83}
84
85int runQMake(int argc, char **argv)
86{
87 // parse command line
88 int ret = Option::init(argc, argv);
89 if(ret != Option::QMAKE_CMDLINE_SUCCESS) {
90 if ((ret & Option::QMAKE_CMDLINE_ERROR) != 0)
91 return 1;
92 return 0;
93 }
94
95 // report Qt usage for commercial customers with a "metered license" (currently experimental)
96#if QT_EDITION != QT_EDITION_OPENSOURCE
97 QString reporterPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator()
98 + "qtusagereporter";
99#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
100 reporterPath += ".exe";
101#endif
102 if (QFile::exists(reporterPath))
103 system(qPrintable(reporterPath + " qmake"));
104#endif
105
106 QString oldpwd = qmake_getpwd();
107#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
108 if(!(oldpwd.length() == 3 && oldpwd[0].isLetter() && oldpwd.endsWith(":/")))
109#endif
110 {
111 if(oldpwd.right(1) != QString(QChar(QDir::separator())))
112 oldpwd += QDir::separator();
113 }
114 Option::output_dir = oldpwd; //for now this is the output dir
115
116 if(Option::output.fileName() != "-") {
117 QFileInfo fi(Option::output);
118 QString dir;
119 if(fi.isDir()) {
120 dir = fi.filePath();
121 } else {
122 QString tmp_dir = fi.path();
123 if(!tmp_dir.isEmpty() && QFile::exists(tmp_dir))
124 dir = tmp_dir;
125 }
126 if(!dir.isNull() && dir != ".")
127 Option::output_dir = dir;
128 if(QDir::isRelativePath(Option::output_dir))
129 Option::output_dir.prepend(oldpwd);
130 Option::output_dir = QDir::cleanPath(Option::output_dir);
131 }
132
133 QMakeProperty prop;
134 if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY)