1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the qmake application of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
47 #include <qstringlist.h>
49 #include <qlibraryinfo.h>
53 #define QMAKE_VERSION_MAJOR 2
54 #define QMAKE_VERSION_MINOR 1
55 #define QMAKE_VERSION_PATCH 0
56 const char *qmake_version();
58 QString qmake_getpwd();
59 bool qmake_setpwd(const QString &p);
61 #define debug_msg if(Option::debug_level) debug_msg_internal
62 void debug_msg_internal(int level, const char *fmt, ...); //don't call directly, use debug_msg
67 WarnDeprecated = 0x04,
70 void warn_msg(QMakeWarn t, const char *fmt, ...);
74 //simply global convenience
75 static QString js_ext;
76 static QString libtool_ext;
77 static QString pkgcfg_ext;
78 static QString prf_ext;
79 static QString prl_ext;
80 static QString ui_ext;
81 static QStringList h_ext;
82 static QStringList cpp_ext;
83 static QStringList c_ext;
84 static QString h_moc_ext;
85 static QString cpp_moc_ext;
86 static QString obj_ext;
87 static QString lex_ext;
88 static QString yacc_ext;
89 static QString h_moc_mod;
90 static QString cpp_moc_mod;
91 static QString lex_mod;
92 static QString yacc_mod;
93 static QString dir_sep;
94 static QString dirlist_sep;
95 static QString sysenv_mod;
96 static QString pro_ext;
97 static QString mmp_ext;
98 static QString res_ext;
99 static char field_sep;
100 static const char *application_argv0;
103 QMAKE_CMDLINE_SUCCESS = 0x00,
104 QMAKE_CMDLINE_SHOW_USAGE = 0x01,
105 QMAKE_CMDLINE_BAIL = 0x02,
106 QMAKE_CMDLINE_ERROR = 0x04
109 //both of these must be called..
110 static int init(int argc=0, char **argv=0); //parse cmdline
111 static void applyHostMode();
112 static QStringList mkspecPaths();
113 static bool prepareProject(const QString &pfile);
114 static bool postProcessProject(QMakeProject *);
116 enum StringFixFlags {
119 FixPathCanonicalize = 0x02,
120 FixPathToLocalSeparators = 0x04,
121 FixPathToTargetSeparators = 0x08,
122 FixPathToNormalSeparators = 0x10
124 static QString fixString(QString string, uchar flags);
126 //and convenience functions
127 inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
129 uchar flags = FixPathToLocalSeparators;
133 flags |= FixPathCanonicalize;
134 return fixString(in, flags);
136 inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
138 uchar flags = FixPathToTargetSeparators;
142 flags |= FixPathCanonicalize;
143 return fixString(in, flags);
145 inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
147 uchar flags = FixPathToNormalSeparators;
151 flags |= FixPathCanonicalize;
152 return fixString(in, flags);
155 inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
157 foreach (const QString &ext, extensions)
158 if (str.endsWith(ext))
163 //global qmake mode, can only be in one mode per invocation!
164 enum QMAKE_MODE { QMAKE_GENERATE_NOTHING,
165 QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL,
166 QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY };
167 static QMAKE_MODE qmake_mode;
170 static QString qmake_abslocation;
172 static QString output_dir;
173 static int debug_level;
174 static int warn_level;
175 enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
176 static QMAKE_RECURSIVE recursive;
177 static QStringList before_user_vars, after_user_vars;
178 enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
179 static HOST_MODE host_mode;
180 enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE,
181 TARG_INTEGRITY_MODE };
182 static TARG_MODE target_mode;
183 static bool target_mode_overridden;
184 static QString user_template, user_template_prefix;
185 static QStringList shellPath;
187 //QMAKE_*_PROPERTY options
189 static QStringList properties;
192 //QMAKE_GENERATE_PROJECT options
195 static QStringList project_dirs;
198 //QMAKE_GENERATE_MAKEFILE options
200 static QString qmakespec;
201 static bool do_cache;
204 static bool do_dep_heuristics;
205 static bool do_preprocess;
206 static bool do_stub_makefile;
207 static QString project_root;
208 static QString project_build_root;
209 static QString cachefile;
210 static int cachefile_depth;
211 static QStringList project_files;
212 static QString qmakespec_commandline;
216 static int parseCommandLine(int, char **, int=0);
217 static bool resolveSpec(QString *spec);
220 inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
221 inline QStringList splitPathList(const QString &paths) { return paths.split(Option::dirlist_sep); }