1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the qmake application of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
47 #include <qstringlist.h>
52 #define QMAKE_VERSION_MAJOR 2
53 #define QMAKE_VERSION_MINOR 1
54 #define QMAKE_VERSION_PATCH 0
55 const char *qmake_version();
57 QString qmake_getpwd();
58 bool qmake_setpwd(const QString &p);
60 #define debug_msg if(Option::debug_level) debug_msg_internal
61 void debug_msg_internal(int level, const char *fmt, ...); //don't call directly, use debug_msg
66 WarnDeprecated = 0x04,
69 void warn_msg(QMakeWarn t, const char *fmt, ...);
73 //simply global convenience
74 static QString js_ext;
75 static QString libtool_ext;
76 static QString pkgcfg_ext;
77 static QString prf_ext;
78 static QString prl_ext;
79 static QString ui_ext;
80 static QStringList h_ext;
81 static QStringList cpp_ext;
82 static QStringList c_ext;
83 static QString h_moc_ext;
84 static QString cpp_moc_ext;
85 static QString obj_ext;
86 static QString lex_ext;
87 static QString yacc_ext;
88 static QString h_moc_mod;
89 static QString cpp_moc_mod;
90 static QString lex_mod;
91 static QString yacc_mod;
92 static QString dir_sep;
93 static QString dirlist_sep;
94 static QString sysenv_mod;
95 static QString pro_ext;
96 static QString mmp_ext;
97 static QString res_ext;
98 static char field_sep;
99 static const char *application_argv0;
102 QMAKE_CMDLINE_SUCCESS = 0x00,
103 QMAKE_CMDLINE_SHOW_USAGE = 0x01,
104 QMAKE_CMDLINE_BAIL = 0x02,
105 QMAKE_CMDLINE_ERROR = 0x04
108 //both of these must be called..
109 static int init(int argc=0, char **argv=0); //parse cmdline
110 static void applyHostMode();
111 static bool postProcessProject(QMakeProject *);
113 enum StringFixFlags {
116 FixPathCanonicalize = 0x02,
117 FixPathToLocalSeparators = 0x04,
118 FixPathToTargetSeparators = 0x08,
119 FixPathToNormalSeparators = 0x10
121 static QString fixString(QString string, uchar flags);
123 //and convenience functions
124 inline static QString fixPathToLocalOS(const QString &in, bool fix_env=true, bool canonical=true)
126 uchar flags = FixPathToLocalSeparators;
130 flags |= FixPathCanonicalize;
131 return fixString(in, flags);
133 inline static QString fixPathToTargetOS(const QString &in, bool fix_env=true, bool canonical=true)
135 uchar flags = FixPathToTargetSeparators;
139 flags |= FixPathCanonicalize;
140 return fixString(in, flags);
142 inline static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
144 uchar flags = FixPathToNormalSeparators;
148 flags |= FixPathCanonicalize;
149 return fixString(in, flags);
152 inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
154 foreach (const QString &ext, extensions)
155 if (str.endsWith(ext))
160 //global qmake mode, can only be in one mode per invocation!
161 enum QMAKE_MODE { QMAKE_GENERATE_NOTHING,
162 QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL,
163 QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY };
164 static QMAKE_MODE qmake_mode;
167 static QString qmake_abslocation;
169 static QString output_dir;
170 static int debug_level;
171 static int warn_level;
172 enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
173 static QMAKE_RECURSIVE recursive;
174 static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs;
175 enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
176 static HOST_MODE host_mode;
177 enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE,
178 TARG_INTEGRITY_MODE };
179 static TARG_MODE target_mode;
180 static bool target_mode_overridden;
181 static QString user_template, user_template_prefix;
182 static QStringList shellPath;
184 //QMAKE_*_PROPERTY options
186 static QStringList properties;
189 //QMAKE_GENERATE_PROJECT options
192 static QStringList project_dirs;
195 //QMAKE_GENERATE_MAKEFILE options
197 static QString qmakespec;
198 static bool do_cache;
201 static bool do_dep_heuristics;
202 static bool do_preprocess;
203 static bool do_stub_makefile;
204 static QString cachefile;
205 static int cachefile_depth;
206 static QStringList project_files;
207 static QString qmakespec_commandline;
211 static int parseCommandLine(int, char **, int=0);
214 inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
215 inline QStringList splitPathList(const QString &paths) { return paths.split(Option::dirlist_sep); }
217 // this is a stripped down version of the one found in QtCore
236 static QString location(LibraryLocation);