summaryrefslogtreecommitdiff
path: root/qmake/option.cpp
authorllornkcor <llornkcor>2003-07-10 02:40:10 (UTC)
committer llornkcor <llornkcor>2003-07-10 02:40:10 (UTC)
commit155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff)
treee6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/option.cpp
parent86703e8a5527ef114facd02c005b6b3a7e62e263 (diff)
downloadopie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip
opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz
opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2
update qmake to 1.05a
Diffstat (limited to 'qmake/option.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/option.cpp153
1 files changed, 104 insertions, 49 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 34b3ee2..8b7e5e8 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -61,270 +61,325 @@ Option::QMAKE_MODE Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING;
61 61
62//all modes 62//all modes
63int Option::warn_level = WarnLogic; 63int Option::warn_level = WarnLogic;
64int Option::debug_level = 0; 64int Option::debug_level = 0;
65QFile Option::output; 65QFile Option::output;
66QString Option::output_dir; 66QString Option::output_dir;
67QStringList Option::before_user_vars; 67QStringList Option::before_user_vars;
68QStringList Option::after_user_vars; 68QStringList Option::after_user_vars;
69QString Option::user_template; 69QString Option::user_template;
70QString Option::user_template_prefix; 70QString Option::user_template_prefix;
71#if defined(Q_OS_WIN32) 71#if defined(Q_OS_WIN32)
72Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE; 72Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
73#elif defined(Q_OS_MAC9) 73#elif defined(Q_OS_MAC9)
74Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE; 74Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE;
75#elif defined(Q_OS_MACX) 75#elif defined(Q_OS_MACX)
76Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE; 76Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE;
77#elif defined(Q_OS_QNX6) 77#elif defined(Q_OS_QNX6)
78Option::TARG_MODE Option::target_mode = Option::TARG_QNX6_MODE; 78Option::TARG_MODE Option::target_mode = Option::TARG_QNX6_MODE;
79#else 79#else
80Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE; 80Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE;
81#endif 81#endif
82 82
83//QMAKE_GENERATE_PROJECT stuff 83//QMAKE_GENERATE_PROJECT stuff
84bool Option::projfile::do_pwd = TRUE; 84bool Option::projfile::do_pwd = TRUE;
85bool Option::projfile::do_recursive = FALSE; 85bool Option::projfile::do_recursive = TRUE;
86QStringList Option::projfile::project_dirs; 86QStringList Option::projfile::project_dirs;
87 87
88//QMAKE_GENERATE_MAKEFILE stuff 88//QMAKE_GENERATE_MAKEFILE stuff
89QString Option::mkfile::qmakespec; 89QString Option::mkfile::qmakespec;
90int Option::mkfile::cachefile_depth = -1; 90int Option::mkfile::cachefile_depth = -1;
91bool Option::mkfile::do_deps = TRUE; 91bool Option::mkfile::do_deps = TRUE;
92bool Option::mkfile::do_mocs = TRUE; 92bool Option::mkfile::do_mocs = TRUE;
93bool Option::mkfile::do_dep_heuristics = TRUE; 93bool Option::mkfile::do_dep_heuristics = TRUE;
94bool Option::mkfile::do_preprocess = FALSE; 94bool Option::mkfile::do_preprocess = FALSE;
95bool Option::mkfile::do_cache = TRUE; 95bool Option::mkfile::do_cache = TRUE;
96QString Option::mkfile::cachefile; 96QString Option::mkfile::cachefile;
97QStringList Option::mkfile::project_files; 97QStringList Option::mkfile::project_files;
98QString Option::mkfile::qmakespec_commandline; 98QString Option::mkfile::qmakespec_commandline;
99 99
100static Option::QMAKE_MODE default_mode(QString progname)
101{
102 int s = progname.findRev(Option::dir_sep);
103 if(s != -1)
104 progname = progname.right(progname.length() - (s + 1));
105 if(progname == "qmakegen")
106 return Option::QMAKE_GENERATE_PROJECT;
107 return Option::QMAKE_GENERATE_MAKEFILE;
108}
109
110QString project_builtin_regx();
100bool usage(const char *a0) 111bool usage(const char *a0)
101{ 112{
102 fprintf(stdout, "Usage: %s [mode] [options] [files]\n" 113 fprintf(stdout, "Usage: %s [mode] [options] [files]\n"
103 "\n" 114 "\n"
104 " QMake has two modes, one mode for generating project files based on\n" 115 " QMake has two modes, one mode for generating project files based on\n"
105 "some heuristics, and the other for generating makefiles. Normally you\n" 116 "some heuristics, and the other for generating makefiles. Normally you\n"
106 "shouldn't need to specify a mode, as makefile generation is the default\n" 117 "shouldn't need to specify a mode, as makefile generation is the default\n"
107 "mode for qmake, but you may use this to test qmake on an existing project\n" 118 "mode for qmake, but you may use this to test qmake on an existing project\n"
108 "\n" 119 "\n"
109 "Mode:\n" 120 "Mode:\n"
110 "\t-project Put qmake into project file generation mode\n" 121 "\t-project Put qmake into project file generation mode%s\n"
111 "\t In this mode qmake interprets files as files to\n" 122 "\t In this mode qmake interprets files as files to\n"
112 "\t be built,\n" 123 "\t be built,\n"
113 "\t defaults to *.cpp; *.l; *.y; *.ui\n" 124 "\t defaults to %s\n"
114 "\t-makefile Put qmake into makefile generation mode (default)\n" 125 "\t-makefile Put qmake into makefile generation mode%s\n"
115 "\t In this mode qmake interprets files as project files to\n" 126 "\t In this mode qmake interprets files as project files to\n"
116 "\t be processed, if skipped qmake will try to find a project\n" 127 "\t be processed, if skipped qmake will try to find a project\n"
117 "\t file in your current working directory\n" 128 "\t file in your current working directory\n"
118 "\n" 129 "\n"
119 "Warnings Options:\n" 130 "Warnings Options:\n"
120 "\t-Wnone Turn off all warnings\n" 131 "\t-Wnone Turn off all warnings\n"
121 "\t-Wall Turn on all warnings\n" 132 "\t-Wall Turn on all warnings\n"
122 "\t-Wparser Turn on parser warnings\n" 133 "\t-Wparser Turn on parser warnings\n"
123 "\t-Wlogic Turn on logic warnings\n" 134 "\t-Wlogic Turn on logic warnings\n"
124 "\n" 135 "\n"
125 "Options:\n" 136 "Options:\n"
126 "\t * You can place any variable assignment in options and it will be *\n" 137 "\t * You can place any variable assignment in options and it will be *\n"
127 "\t * processed as if it was in [files]. These assignments will be parsed *\n" 138 "\t * processed as if it was in [files]. These assignments will be parsed *\n"
128 "\t * before [files]. *\n" 139 "\t * before [files]. *\n"
129 "\t-o file Write output to file\n" 140 "\t-o file Write output to file\n"
130 "\t-unix Run in unix mode\n" 141 "\t-unix Run in unix mode\n"
131 "\t-win32 Run in win32 mode\n" 142 "\t-win32 Run in win32 mode\n"
132 "\t-macx Run in Mac OS X mode\n" 143 "\t-macx Run in Mac OS X mode\n"
133 "\t-d Increase debug level\n" 144 "\t-d Increase debug level\n"
134 "\t-t templ Overrides TEMPLATE as templ\n" 145 "\t-t templ Overrides TEMPLATE as templ\n"
135 "\t-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n" 146 "\t-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n"
136 "\t-help This help\n" 147 "\t-help This help\n"
137 "\t-v Version information\n" 148 "\t-v Version information\n"
138 "\t-after All variable assignments after this will be\n" 149 "\t-after All variable assignments after this will be\n"
139 "\t parsed after [files] [makefile mode only]\n" 150 "\t parsed after [files]\n"
140 "\t-cache file Use file as cache [makefile mode only]\n" 151 "\t-cache file Use file as cache [makefile mode only]\n"
141 "\t-spec spec Use spec as QMAKESPEC [makefile mode only]\n" 152 "\t-spec spec Use spec as QMAKESPEC [makefile mode only]\n"
142 "\t-nocache Don't use a cache file [makefile mode only]\n" 153 "\t-nocache Don't use a cache file [makefile mode only]\n"
143 "\t-nodepend Don't generate dependencies [makefile mode only]\n" 154 "\t-nodepend Don't generate dependencies [makefile mode only]\n"
144 "\t-nomoc Don't generate moc targets [makefile mode only]\n" 155 "\t-nomoc Don't generate moc targets [makefile mode only]\n"
145 "\t-nopwd Don't look for files in pwd [ project mode only]\n" 156 "\t-nopwd Don't look for files in pwd [ project mode only]\n"
146 "\t-r Recursive search [ project mode only]\n" 157 "\t-norecursive Don't do a recursive search [ project mode only]\n"
147 ,a0); 158 ,a0,
159 default_mode(a0) == Option::QMAKE_GENERATE_PROJECT ? " (default)" : "", project_builtin_regx().latin1(),
160 default_mode(a0) == Option::QMAKE_GENERATE_MAKEFILE ? " (default)" : "");
148 return FALSE; 161 return FALSE;
149} 162}
150static Option::QMAKE_MODE default_mode(QString progname)
151{
152 int s = progname.findRev(Option::dir_sep);
153 if(s != -1)
154 progname = progname.right(progname.length() - (s + 1));
155 if(progname == "qmakegen")
156 return Option::QMAKE_GENERATE_PROJECT;
157 return Option::QMAKE_GENERATE_MAKEFILE;
158}
159
160 163
161bool 164bool
162Option::parseCommandLine(int argc, char **argv) 165Option::internalParseCommandLine(int argc, char **argv, int skip)
163{ 166{
164 bool before = TRUE; 167 bool before = TRUE;
165 for(int x = 1; x < argc; x++) { 168 for(int x = skip; x < argc; x++) {
166 if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ 169 if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */
167 QString opt = argv[x] + 1; 170 QString opt = argv[x] + 1;
168 171
169 //first param is a mode, or we default 172 //first param is a mode, or we default
170 if(x == 1) { 173 if(x == 1) {
171 bool specified = TRUE; 174 bool specified = TRUE;
172 if(opt == "project") { 175 if(opt == "project") {
173 Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT; 176 Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT;
174 } else if(opt == "prl") { 177 } else if(opt == "prl") {
175 Option::mkfile::do_deps = FALSE; 178 Option::mkfile::do_deps = FALSE;
176 Option::mkfile::do_mocs = FALSE; 179 Option::mkfile::do_mocs = FALSE;
177 Option::qmake_mode = Option::QMAKE_GENERATE_PRL; 180 Option::qmake_mode = Option::QMAKE_GENERATE_PRL;
178 } else if(opt == "makefile") { 181 } else if(opt == "makefile") {
179 Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; 182 Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE;
180 } else { 183 } else {
181 specified = FALSE; 184 specified = FALSE;
182 Option::qmake_mode = default_mode(argv[0]);
183 } 185 }
184 if(specified) 186 if(specified)
185 continue; 187 continue;
186 } 188 }
187 //all modes 189 //all modes
188 if(opt == "o" || opt == "output") { 190 if(opt == "o" || opt == "output") {
189 Option::output.setName(argv[++x]); 191 Option::output.setName(argv[++x]);
190 } else if(opt == "after") { 192 } else if(opt == "after") {
191 before = FALSE; 193 before = FALSE;
192 } else if(opt == "t" || opt == "template") { 194 } else if(opt == "t" || opt == "template") {
193 Option::user_template = argv[++x]; 195 Option::user_template = argv[++x];
194 } else if(opt == "tp" || opt == "template_prefix") { 196 } else if(opt == "tp" || opt == "template_prefix") {
195 Option::user_template_prefix = argv[++x]; 197 Option::user_template_prefix = argv[++x];
196 } else if(opt == "mac9") { 198 } else if(opt == "mac9") {
197 Option::target_mode = TARG_MAC9_MODE; 199 Option::target_mode = TARG_MAC9_MODE;
198 } else if(opt == "macx") { 200 } else if(opt == "macx") {
199 Option::target_mode = TARG_MACX_MODE; 201 Option::target_mode = TARG_MACX_MODE;
200 } else if(opt == "unix") { 202 } else if(opt == "unix") {
201 Option::target_mode = TARG_UNIX_MODE; 203 Option::target_mode = TARG_UNIX_MODE;
202 } else if(opt == "win32") { 204 } else if(opt == "win32") {
203 Option::target_mode = TARG_WIN_MODE; 205 Option::target_mode = TARG_WIN_MODE;
204 } else if(opt == "d") { 206 } else if(opt == "d") {
205 Option::debug_level++; 207 Option::debug_level++;
206 } else if(opt == "version" || opt == "v" || opt == "-version") { 208 } else if(opt == "version" || opt == "v" || opt == "-version") {
207 fprintf(stderr, "Qmake version: %s\n", qmake_version()); 209 fprintf(stderr, "Qmake version: %s (Qt %s)\n", qmake_version(), QT_VERSION_STR);
208 fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); 210 fprintf(stderr, "Qmake is free software from Trolltech AS.\n");
209 return FALSE; 211 return FALSE;
210 } else if(opt == "h" || opt == "help") { 212 } else if(opt == "h" || opt == "help") {
211 return usage(argv[0]); 213 return FALSE;
212 } else if(opt == "Wall") { 214 } else if(opt == "Wall") {
213 Option::warn_level |= WarnAll; 215 Option::warn_level |= WarnAll;
214 } else if(opt == "Wparser") { 216 } else if(opt == "Wparser") {
215 Option::warn_level |= WarnParser; 217 Option::warn_level |= WarnParser;
216 } else if(opt == "Wlogic") { 218 } else if(opt == "Wlogic") {
217 Option::warn_level |= WarnLogic; 219 Option::warn_level |= WarnLogic;
218 } else if(opt == "Wnone") { 220 } else if(opt == "Wnone") {
219 Option::warn_level = WarnNone; 221 Option::warn_level = WarnNone;
220 } else { 222 } else {
221 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 223 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
222 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 224 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
223 if(opt == "nodepend") { 225 if(opt == "nodepend") {
224 Option::mkfile::do_deps = FALSE; 226 Option::mkfile::do_deps = FALSE;
225 } else if(opt == "nomoc") { 227 } else if(opt == "nomoc") {
226 Option::mkfile::do_mocs = FALSE; 228 Option::mkfile::do_mocs = FALSE;
227 } else if(opt == "nocache") { 229 } else if(opt == "nocache") {
228 Option::mkfile::do_cache = FALSE; 230 Option::mkfile::do_cache = FALSE;
229 } else if(opt == "nodependheuristics") { 231 } else if(opt == "nodependheuristics") {
230 Option::mkfile::do_dep_heuristics = FALSE; 232 Option::mkfile::do_dep_heuristics = FALSE;
231 } else if(opt == "E") { 233 } else if(opt == "E") {
232 Option::mkfile::do_preprocess = TRUE; 234 Option::mkfile::do_preprocess = TRUE;
233 } else if(opt == "cache") { 235 } else if(opt == "cache") {
234 Option::mkfile::cachefile = argv[++x]; 236 Option::mkfile::cachefile = argv[++x];
235 } else if(opt == "platform" || opt == "spec") { 237 } else if(opt == "platform" || opt == "spec") {
236 Option::mkfile::qmakespec = argv[++x]; 238 Option::mkfile::qmakespec = argv[++x];
237 Option::mkfile::qmakespec_commandline = argv[x]; 239 Option::mkfile::qmakespec_commandline = argv[x];
238 } else { 240 } else {
239 fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); 241 fprintf(stderr, "***Unknown option -%s\n", opt.latin1());
240 return usage(argv[0]); 242 return usage(argv[0]);
241 } 243 }
242 } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { 244 } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
243 if(opt == "nopwd") { 245 if(opt == "nopwd") {
244 Option::projfile::do_pwd = FALSE; 246 Option::projfile::do_pwd = FALSE;
245 } else if(opt == "r") { 247 } else if(opt == "r") {
246 Option::projfile::do_recursive = TRUE; 248 Option::projfile::do_recursive = TRUE;
249 } else if(opt == "norecursive") {
250 Option::projfile::do_recursive = FALSE;
247 } else { 251 } else {
248 fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); 252 fprintf(stderr, "***Unknown option -%s\n", opt.latin1());
249 return usage(argv[0]); 253 return FALSE;
250 } 254 }
251 } 255 }
252 } 256 }
253 } else { 257 } else {
254 if(x == 1)
255 Option::qmake_mode = default_mode(argv[0]);
256
257 QString arg = argv[x]; 258 QString arg = argv[x];
258 if(arg.find('=') != -1) { 259 if(arg.find('=') != -1) {
259 if(before) 260 if(before)
260 Option::before_user_vars.append(arg); 261 Option::before_user_vars.append(arg);
261 else 262 else
262 Option::after_user_vars.append(arg); 263 Option::after_user_vars.append(arg);
263 } else { 264 } else {
264 QFileInfo fi(arg); 265 QFileInfo fi(arg);
265 if(!fi.convertToAbs()) //strange 266 if(!fi.convertToAbs()) //strange
266 arg = fi.filePath(); 267 arg = fi.filePath();
267 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 268 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
268 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) 269 Option::qmake_mode == Option::QMAKE_GENERATE_PRL)
269 Option::mkfile::project_files.append(arg); 270 Option::mkfile::project_files.append(arg);
270 else 271 else
271 Option::projfile::project_dirs.append(arg); 272 Option::projfile::project_dirs.append(arg);
272 } 273 }
273 } 274 }
274 } 275 }
276 return TRUE;
277}
278
279
280bool
281Option::parseCommandLine(int argc, char **argv)
282{
283 Option::moc_mod = "moc_";
284 Option::lex_mod = "_lex";
285 Option::yacc_mod = "_yacc";
286 Option::prl_ext = ".prl";
287 Option::prf_ext = ".prf";
288 Option::ui_ext = ".ui";
289 Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx";
290 Option::moc_ext = ".moc";
291 Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C";
292 Option::lex_ext = ".l";
293 Option::yacc_ext = ".y";
294
275 if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) 295 if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING)
276 Option::qmake_mode = default_mode(argv[0]); 296 Option::qmake_mode = default_mode(argv[0]);
297 if(const char *envflags = getenv("QMAKEFLAGS")) {
298 int env_argc = 0, env_size = 0, currlen=0;
299 char quote = 0, **env_argv = NULL;
300 for(int i = 0; envflags[i]; i++) {
301 if(!quote && (envflags[i] == '\'' || envflags[i] == '"')) {
302 quote = envflags[i];
303 } else if(envflags[i] == quote) {
304 quote = 0;
305 } else if(!quote && envflags[i] == ' ') {
306 if(currlen && env_argv && env_argv[env_argc]) {
307 env_argv[env_argc][currlen] = '\0';
308 currlen = 0;
309 env_argc++;
310 }
311 } else {
312 if(!env_argv || env_argc > env_size) {
313 env_argv = (char **)realloc(env_argv, sizeof(char *)*(env_size+=10));
314 for(int i2 = env_argc; i2 < env_size; i2++)
315 env_argv[i2] = NULL;
316 }
317 if(!env_argv[env_argc]) {
318 currlen = 0;
319 env_argv[env_argc] = (char*)malloc(255);
320 }
321 if(currlen < 255)
322 env_argv[env_argc][currlen++] = envflags[i];
323 }
324 }
325 if(env_argv[env_argc]) {
326 env_argv[env_argc][currlen] = '\0';
327 currlen = 0;
328 env_argc++;
329 }
330 internalParseCommandLine(env_argc, env_argv);
331 for(int i2 = 0; i2 < env_size; i2++) {
332 if(env_argv[i2])
333 free(env_argv[i2]);
334 }
335 free(env_argv);
336 }
337 if(!internalParseCommandLine(argc, argv, 1))
338 return usage(argv[0]);
277 339
278 //last chance for defaults 340 //last chance for defaults
279 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 341 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
280 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 342 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
281 if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty()) 343 if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty())
282 Option::mkfile::qmakespec = getenv("QMAKESPEC"); 344 Option::mkfile::qmakespec = getenv("QMAKESPEC");
283 345
284 //try REALLY hard to do it for them, lazy.. 346 //try REALLY hard to do it for them, lazy..
285 if(Option::mkfile::project_files.isEmpty()) { 347 if(Option::mkfile::project_files.isEmpty()) {
286 QString proj = QDir::currentDirPath(); 348 QString pwd = QDir::currentDirPath(),
287 proj = proj.right(proj.length() - (proj.findRev('/') + 1)) + ".pro"; 349 proj = pwd + "/" + pwd.right(pwd.length() - (pwd.findRev('/') + 1)) + ".pro";
288 if(QFile::exists(proj)) 350 if(QFile::exists(proj)) {
289 Option::mkfile::project_files.append(proj); 351 Option::mkfile::project_files.append(proj);
290 else 352 } else { //last try..
291 return usage(argv[0]); 353 QDir d(pwd, "*.pro");
354 if(d.count() != 1)
355 return usage(argv[0]);
356 Option::mkfile::project_files.append(pwd + "/" + d[0]);
357 }
292 } 358 }
293 } 359 }
294 360
295 //defaults for globals 361 //defaults for globals
296 Option::moc_mod = "moc_";
297 Option::lex_mod = "_lex";
298 Option::yacc_mod = "_yacc";
299 Option::prl_ext = ".prl";
300 Option::prf_ext = ".prf";
301 Option::ui_ext = ".ui";
302 Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx";
303 Option::moc_ext = ".moc";
304 Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C";
305 Option::lex_ext = ".l";
306 Option::yacc_ext = ".y";
307 if(Option::target_mode == Option::TARG_WIN_MODE) { 362 if(Option::target_mode == Option::TARG_WIN_MODE) {
308 Option::dir_sep = "\\"; 363 Option::dir_sep = "\\";
309 Option::obj_ext = ".obj"; 364 Option::obj_ext = ".obj";
310 } else { 365 } else {
311 if(Option::target_mode == Option::TARG_MAC9_MODE) 366 if(Option::target_mode == Option::TARG_MAC9_MODE)
312 Option::dir_sep = ":"; 367 Option::dir_sep = ":";
313 else 368 else
314 Option::dir_sep = "/"; 369 Option::dir_sep = "/";
315 Option::obj_ext = ".o"; 370 Option::obj_ext = ".o";
316 } 371 }
317 return TRUE; 372 return TRUE;
318} 373}
319 374
320bool Option::postProcessProject(QMakeProject *project) 375bool Option::postProcessProject(QMakeProject *project)
321{ 376{
322 Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; 377 Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"];
323 if(cpp_ext.isEmpty()) 378 if(cpp_ext.isEmpty())
324 cpp_ext << ".cpp"; //something must be there 379 cpp_ext << ".cpp"; //something must be there
325 Option::h_ext = project->variables()["QMAKE_EXT_H"]; 380 Option::h_ext = project->variables()["QMAKE_EXT_H"];
326 if(h_ext.isEmpty()) 381 if(h_ext.isEmpty())
327 h_ext << ".h"; 382 h_ext << ".h";
328 383
329 if(!project->isEmpty("QMAKE_EXT_PRL")) 384 if(!project->isEmpty("QMAKE_EXT_PRL"))
330 Option::prl_ext = project->first("QMAKE_EXT_PRL"); 385 Option::prl_ext = project->first("QMAKE_EXT_PRL");
@@ -365,55 +420,55 @@ static QString fixPath(QString x)
365 QFileInfo fi(x); 420 QFileInfo fi(x);
366 if(fi.isDir()) { 421 if(fi.isDir()) {
367 QDir dir(x); 422 QDir dir(x);
368 x = dir.canonicalPath(); 423 x = dir.canonicalPath();
369 } else { 424 } else {
370 QString dir = fi.dir().canonicalPath(); 425 QString dir = fi.dir().canonicalPath();
371 if(!dir.isEmpty() && dir.right(1) != Option::dir_sep) 426 if(!dir.isEmpty() && dir.right(1) != Option::dir_sep)
372 dir += Option::dir_sep; 427 dir += Option::dir_sep;
373 x = dir + fi.fileName(); 428 x = dir + fi.fileName();
374 } 429 }
375#endif 430#endif
376 return QDir::cleanDirPath(x); 431 return QDir::cleanDirPath(x);
377} 432}
378 433
379 434
380QString 435QString
381Option::fixPathToTargetOS(const QString& in, bool fix_env, bool canonical) 436Option::fixPathToTargetOS(const QString& in, bool fix_env, bool canonical)
382{ 437{
383 QString tmp(in); 438 QString tmp(in);
384 if(fix_env) 439 if(fix_env)
385 fixEnvVariables(tmp); 440 fixEnvVariables(tmp);
386 if(canonical) 441 if(canonical)
387 tmp = fixPath(tmp); 442 tmp = fixPath(tmp);
388 QString rep; 443 QString rep;
389 if(Option::target_mode == TARG_MAC9_MODE) 444 if(Option::target_mode == TARG_MAC9_MODE)
390 rep = "[/\\\\]"; 445 tmp = tmp.replace('/', Option::dir_sep).replace('\\', Option::dir_sep);
391 else if(Option::target_mode == TARG_WIN_MODE) 446 else if(Option::target_mode == TARG_WIN_MODE)
392 rep = "[/]"; 447 tmp = tmp.replace('/', Option::dir_sep);
393 else 448 else
394 rep = "[\\\\]"; 449 tmp = tmp.replace('\\', Option::dir_sep);
395 return tmp.replace(QRegExp(rep), Option::dir_sep); 450 return tmp;
396} 451}
397 452
398QString 453QString
399Option::fixPathToLocalOS(const QString& in, bool fix_env, bool canonical) 454Option::fixPathToLocalOS(const QString& in, bool fix_env, bool canonical)
400{ 455{
401 QString tmp(in); 456 QString tmp(in);
402 if(fix_env) 457 if(fix_env)
403 fixEnvVariables(tmp); 458 fixEnvVariables(tmp);
404 if(canonical) 459 if(canonical)
405 tmp = fixPath(tmp); 460 tmp = fixPath(tmp);
406#if defined(Q_OS_WIN32) 461#if defined(Q_OS_WIN32)
407 return tmp.replace('/', '\\'); 462 return tmp.replace('/', '\\');
408#else 463#else
409 return tmp.replace('\\', '/'); 464 return tmp.replace('\\', '/');
410#endif 465#endif
411} 466}
412 467
413const char *qmake_version() 468const char *qmake_version()
414{ 469{
415 static char *ret = NULL; 470 static char *ret = NULL;
416 if(ret) 471 if(ret)
417 return ret; 472 return ret;
418 ret = (char *)malloc(15); 473 ret = (char *)malloc(15);
419 sprintf(ret, "%d.%02d%c", QMAKE_VERSION_MAJOR, QMAKE_VERSION_MINOR, 'a' + QMAKE_VERSION_PATCH); 474 sprintf(ret, "%d.%02d%c", QMAKE_VERSION_MAJOR, QMAKE_VERSION_MINOR, 'a' + QMAKE_VERSION_PATCH);