author | zecke <zecke> | 2004-07-15 17:36:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-15 17:36:57 (UTC) |
commit | 323e9a7472a110b4befba7320540263147505bae (patch) (unidiff) | |
tree | 14c810bdb9c0603a30356b17b4bdf9ccb72741c6 /qmake/generators/mac/metrowerks_xml.cpp | |
parent | aa292b322f1ecb43dd8f4e3cd295855730dd9f59 (diff) | |
download | opie-323e9a7472a110b4befba7320540263147505bae.zip opie-323e9a7472a110b4befba7320540263147505bae.tar.gz opie-323e9a7472a110b4befba7320540263147505bae.tar.bz2 |
Manually updatet to qmake1.06a which includes support for precompiled
headers.
Opies 'PRO' keyword was already reintroduced
Diffstat (limited to 'qmake/generators/mac/metrowerks_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/mac/metrowerks_xml.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/qmake/generators/mac/metrowerks_xml.cpp b/qmake/generators/mac/metrowerks_xml.cpp index 125749d..baaeeec 100644 --- a/qmake/generators/mac/metrowerks_xml.cpp +++ b/qmake/generators/mac/metrowerks_xml.cpp | |||
@@ -1,147 +1,144 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** |
3 | ** | 3 | ** |
4 | ** Definition of ________ class. | 4 | ** Implementation of MetrowerksMakefileGenerator class. |
5 | ** | 5 | ** |
6 | ** Created : 970521 | 6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | 8 | ** This file is part of qmake. |
9 | ** | ||
10 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
11 | ** | 9 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 10 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 11 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 13 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 14 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 15 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 16 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 17 | ** packaging of this file. |
20 | ** | 18 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 19 | ** Licensees holding valid Qt Enterprise Edition licenses may use this |
22 | ** file in accordance with the Qt Commercial License Agreement provided | 20 | ** file in accordance with the Qt Commercial License Agreement provided |
23 | ** with the Software. | 21 | ** with the Software. |
24 | ** | 22 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 25 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 27 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 30 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 31 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 32 | ** not clear to you. |
35 | ** | 33 | ** |
36 | **********************************************************************/ | 34 | **********************************************************************/ |
37 | 35 | ||
38 | #include "metrowerks_xml.h" | 36 | #include "metrowerks_xml.h" |
39 | #include "option.h" | 37 | #include "option.h" |
40 | #include <qdir.h> | 38 | #include <qdir.h> |
41 | #include <qdict.h> | 39 | #include <qdict.h> |
42 | #include <qregexp.h> | 40 | #include <qregexp.h> |
43 | #include <stdlib.h> | 41 | #include <stdlib.h> |
44 | #include <time.h> | 42 | #include <time.h> |
45 | #ifdef Q_OS_MAC | 43 | #if !defined(QWS) && defined(Q_OS_MAC) |
46 | #include <Carbon/Carbon.h> | 44 | #include <Carbon/Carbon.h> |
47 | #include <sys/types.h> | 45 | #include <sys/types.h> |
48 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
49 | #endif | 47 | #endif |
50 | 48 | ||
51 | |||
52 | MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) | 49 | MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) |
53 | { | 50 | { |
54 | 51 | ||
55 | } | 52 | } |
56 | 53 | ||
57 | bool | 54 | bool |
58 | MetrowerksMakefileGenerator::writeMakefile(QTextStream &t) | 55 | MetrowerksMakefileGenerator::writeMakefile(QTextStream &t) |
59 | { | 56 | { |
60 | if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { | 57 | if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { |
61 | /* for now just dump, I need to generated an empty xml or something.. */ | 58 | /* for now just dump, I need to generated an empty xml or something.. */ |
62 | fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", | 59 | fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", |
63 | var("QMAKE_FAILED_REQUIREMENTS").latin1()); | 60 | var("QMAKE_FAILED_REQUIREMENTS").latin1()); |
64 | return TRUE; | 61 | return TRUE; |
65 | } | 62 | } |
66 | 63 | ||
67 | if(project->first("TEMPLATE") == "app" || | 64 | if(project->first("TEMPLATE") == "app" || |
68 | project->first("TEMPLATE") == "lib") { | 65 | project->first("TEMPLATE") == "lib") { |
69 | return writeMakeParts(t); | 66 | return writeMakeParts(t); |
70 | } | 67 | } |
71 | else if(project->first("TEMPLATE") == "subdirs") { | 68 | else if(project->first("TEMPLATE") == "subdirs") { |
72 | writeHeader(t); | 69 | writeHeader(t); |
73 | qDebug("Not supported!"); | 70 | qDebug("Not supported!"); |
74 | return TRUE; | 71 | return TRUE; |
75 | } | 72 | } |
76 | return FALSE; | 73 | return FALSE; |
77 | } | 74 | } |
78 | 75 | ||
79 | bool | 76 | bool |
80 | MetrowerksMakefileGenerator::writeMakeParts(QTextStream &t) | 77 | MetrowerksMakefileGenerator::writeMakeParts(QTextStream &t) |
81 | { | 78 | { |
82 | //..grrr.. libs! | 79 | //..grrr.. libs! |
83 | QStringList extra_objs; | 80 | QStringList extra_objs; |
84 | bool do_libs = TRUE; | 81 | bool do_libs = TRUE; |
85 | if(project->first("TEMPLATE") == "app") | 82 | if(project->first("TEMPLATE") == "app") |
86 | extra_objs += project->variables()["QMAKE_CRT_OBJECTS"]; | 83 | extra_objs += project->variables()["QMAKE_CRT_OBJECTS"]; |
87 | else if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) | 84 | else if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) |
88 | do_libs = FALSE; | 85 | do_libs = FALSE; |
89 | if(do_libs) | 86 | if(do_libs) |
90 | extra_objs += project->variables()["QMAKE_LIBS"]; | 87 | extra_objs += project->variables()["QMAKE_LIBS"]; |
91 | for(QStringList::Iterator val_it = extra_objs.begin(); | 88 | for(QStringList::Iterator val_it = extra_objs.begin(); |
92 | val_it != extra_objs.end(); ++val_it) { | 89 | val_it != extra_objs.end(); ++val_it) { |
93 | if((*val_it).startsWith("-L")) { | 90 | if((*val_it).startsWith("-L")) { |
94 | QString dir((*val_it).right((*val_it).length() - 2)); | 91 | QString dir((*val_it).right((*val_it).length() - 2)); |
95 | fixEnvVariables(dir); | 92 | fixEnvVariables(dir); |
96 | if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && | 93 | if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && |
97 | project->variables()["INCLUDEPATH"].findIndex(dir) == -1) | 94 | project->variables()["INCLUDEPATH"].findIndex(dir) == -1) |
98 | project->variables()["INCLUDEPATH"].append(dir); | 95 | project->variables()["INCLUDEPATH"].append(dir); |
99 | } else if((*val_it).startsWith("-l")) { | 96 | } else if((*val_it).startsWith("-l")) { |
100 | QString lib("lib" + (*val_it).right((*val_it).length() - 2) + "." + | 97 | QString lib("lib" + (*val_it).right((*val_it).length() - 2) + "." + |
101 | project->first("QMAKE_EXTENSION_SHLIB")); | 98 | project->first("QMAKE_EXTENSION_SHLIB")); |
102 | if(project->variables()["LIBRARIES"].findIndex(lib) == -1) | 99 | if(project->variables()["LIBRARIES"].findIndex(lib) == -1) |
103 | project->variables()["LIBRARIES"].append(lib); | 100 | project->variables()["LIBRARIES"].append(lib); |
104 | } else | 101 | } else |
105 | if((*val_it) == "-framework") { | 102 | if((*val_it) == "-framework") { |
106 | ++val_it; | 103 | ++val_it; |
107 | if(val_it == extra_objs.end()) | 104 | if(val_it == extra_objs.end()) |
108 | break; | 105 | break; |
109 | QString frmwrk = (*val_it) + ".framework"; | 106 | QString frmwrk = (*val_it) + ".framework"; |
110 | if(project->variables()["FRAMEWORKS"].findIndex(frmwrk) == -1) | 107 | if(project->variables()["FRAMEWORKS"].findIndex(frmwrk) == -1) |
111 | project->variables()["FRAMEWORKS"].append(frmwrk); | 108 | project->variables()["FRAMEWORKS"].append(frmwrk); |
112 | } else if((*val_it).left(1) != "-") { | 109 | } else if((*val_it).left(1) != "-") { |
113 | QString lib=(*val_it); | 110 | QString lib=(*val_it); |
114 | int s = lib.findRev('/'); | 111 | int s = lib.findRev('/'); |
115 | if(s != -1) { | 112 | if(s != -1) { |
116 | QString dir = lib.left(s); | 113 | QString dir = lib.left(s); |
117 | lib = lib.right(lib.length() - s - 1); | 114 | lib = lib.right(lib.length() - s - 1); |
118 | fixEnvVariables(dir); | 115 | fixEnvVariables(dir); |
119 | if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && | 116 | if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && |
120 | project->variables()["INCLUDEPATH"].findIndex(dir) == -1) | 117 | project->variables()["INCLUDEPATH"].findIndex(dir) == -1) |
121 | project->variables()["INCLUDEPATH"].append(dir); | 118 | project->variables()["INCLUDEPATH"].append(dir); |
122 | } | 119 | } |
123 | project->variables()["LIBRARIES"].append(lib); | 120 | project->variables()["LIBRARIES"].append(lib); |
124 | } | 121 | } |
125 | } | 122 | } |
126 | //let metrowerks find the files & set the files to the type I expect | 123 | //let metrowerks find the files & set the files to the type I expect |
127 | QDict<void> seen(293); | 124 | QDict<void> seen(293); |
128 | QString paths[] = { QString("SRCMOC"), QString("FORMS"), QString("UICDECLS"), | 125 | QString paths[] = { QString("SRCMOC"), QString("FORMS"), QString("UICDECLS"), |
129 | QString("UICIMPLS"), QString("SOURCES"),QString("HEADERS"), | 126 | QString("UICIMPLS"), QString("SOURCES"),QString("HEADERS"), |
130 | QString::null }; | 127 | QString::null }; |
131 | for(int y = 0; paths[y] != QString::null; y++) { | 128 | for(int y = 0; paths[y] != QString::null; y++) { |
132 | QStringList &l = project->variables()[paths[y]]; | 129 | QStringList &l = project->variables()[paths[y]]; |
133 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 130 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
134 | //establish file types | 131 | //establish file types |
135 | seen.insert((*val_it), (void *)1); | 132 | seen.insert((*val_it), (void *)1); |
136 | createFork((*val_it)); //the file itself | 133 | createFork((*val_it)); //the file itself |
137 | QStringList &d = findDependencies((*val_it)); //depends | 134 | QStringList &d = findDependencies((*val_it)); //depends |
138 | for(QStringList::Iterator dep_it = d.begin(); dep_it != d.end(); ++dep_it) { | 135 | for(QStringList::Iterator dep_it = d.begin(); dep_it != d.end(); ++dep_it) { |
139 | if(!seen.find((*dep_it))) { | 136 | if(!seen.find((*dep_it))) { |
140 | seen.insert((*dep_it), (void *)1); | 137 | seen.insert((*dep_it), (void *)1); |
141 | createFork((*dep_it)); | 138 | createFork((*dep_it)); |
142 | } | 139 | } |
143 | } | 140 | } |
144 | //now chop it | 141 | //now chop it |
145 | int s = (*val_it).findRev('/'); | 142 | int s = (*val_it).findRev('/'); |
146 | if(s != -1) { | 143 | if(s != -1) { |
147 | QString dir = (*val_it).left(s); | 144 | QString dir = (*val_it).left(s); |
@@ -514,309 +511,309 @@ MetrowerksMakefileGenerator::writeMakeParts(QTextStream &t) | |||
514 | } | 511 | } |
515 | 512 | ||
516 | 513 | ||
517 | 514 | ||
518 | void | 515 | void |
519 | MetrowerksMakefileGenerator::init() | 516 | MetrowerksMakefileGenerator::init() |
520 | { | 517 | { |
521 | if(init_flag) | 518 | if(init_flag) |
522 | return; | 519 | return; |
523 | init_flag = TRUE; | 520 | init_flag = TRUE; |
524 | 521 | ||
525 | if ( project->isEmpty("QMAKE_XML_TEMPLATE") ) | 522 | if ( project->isEmpty("QMAKE_XML_TEMPLATE") ) |
526 | project->variables()["QMAKE_XML_TEMPLATE"].append("mwerkstmpl.xml"); | 523 | project->variables()["QMAKE_XML_TEMPLATE"].append("mwerkstmpl.xml"); |
527 | 524 | ||
528 | QStringList &configs = project->variables()["CONFIG"]; | 525 | QStringList &configs = project->variables()["CONFIG"]; |
529 | if(project->isActiveConfig("qt")) { | 526 | if(project->isActiveConfig("qt")) { |
530 | if(configs.findIndex("moc")) configs.append("moc"); | 527 | if(configs.findIndex("moc")) configs.append("moc"); |
531 | if ( !( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || | 528 | if ( !( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || |
532 | (project->first("TARGET") == "qt-mt") ) ) | 529 | (project->first("TARGET") == "qt-mt") ) ) |
533 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | 530 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; |
534 | if(configs.findIndex("moc")) | 531 | if(configs.findIndex("moc")) |
535 | configs.append("moc"); | 532 | configs.append("moc"); |
536 | if ( !project->isActiveConfig("debug") ) | 533 | if ( !project->isActiveConfig("debug") ) |
537 | project->variables()["DEFINES"].append("QT_NO_DEBUG"); | 534 | project->variables()["DEFINES"].append("QT_NO_DEBUG"); |
538 | } | 535 | } |
539 | 536 | ||
540 | //version handling | 537 | //version handling |
541 | if(project->variables()["VERSION"].isEmpty()) | 538 | if(project->variables()["VERSION"].isEmpty()) |
542 | project->variables()["VERSION"].append("1.0." + | 539 | project->variables()["VERSION"].append("1.0." + |
543 | (project->isEmpty("VER_PAT") ? QString("0") : | 540 | (project->isEmpty("VER_PAT") ? QString("0") : |
544 | project->first("VER_PAT")) ); | 541 | project->first("VER_PAT")) ); |
545 | QStringList ver = QStringList::split('.', project->first("VERSION")); | 542 | QStringList ver = QStringList::split('.', project->first("VERSION")); |
546 | ver << "0" << "0"; //make sure there are three | 543 | ver << "0" << "0"; //make sure there are three |
547 | project->variables()["VER_MAJ"].append(ver[0]); | 544 | project->variables()["VER_MAJ"].append(ver[0]); |
548 | project->variables()["VER_MIN"].append(ver[1]); | 545 | project->variables()["VER_MIN"].append(ver[1]); |
549 | project->variables()["VER_PAT"].append(ver[2]); | 546 | project->variables()["VER_PAT"].append(ver[2]); |
550 | 547 | ||
551 | if( !project->isEmpty("LIBS") ) | 548 | if( !project->isEmpty("LIBS") ) |
552 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | 549 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; |
553 | if( project->variables()["QMAKE_EXTENSION_SHLIB"].isEmpty() ) | 550 | if( project->variables()["QMAKE_EXTENSION_SHLIB"].isEmpty() ) |
554 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dylib" ); | 551 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dylib" ); |
555 | 552 | ||
556 | if ( project->isActiveConfig("moc") ) { | 553 | if ( project->isActiveConfig("moc") ) { |
557 | QString mocfile = project->first("TARGET"); | 554 | QString mocfile = project->first("TARGET"); |
558 | if(project->first("TEMPLATE") == "lib") | 555 | if(project->first("TEMPLATE") == "lib") |
559 | mocfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; | 556 | mocfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; |
560 | project->variables()["MOCS"].append(mocfile + ".mocs"); | 557 | project->variables()["MOCS"].append(mocfile + ".mocs"); |
561 | setMocAware(TRUE); | 558 | setMocAware(TRUE); |
562 | } | 559 | } |
563 | if(!project->isEmpty("FORMS")) { | 560 | if(!project->isEmpty("FORMS")) { |
564 | QString uicfile = project->first("TARGET"); | 561 | QString uicfile = project->first("TARGET"); |
565 | if(project->first("TEMPLATE") == "lib") | 562 | if(project->first("TEMPLATE") == "lib") |
566 | uicfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; | 563 | uicfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; |
567 | project->variables()["UICS"].append(uicfile + ".uics"); | 564 | project->variables()["UICS"].append(uicfile + ".uics"); |
568 | } | 565 | } |
569 | if(project->isEmpty("DESTDIR")) | 566 | if(project->isEmpty("DESTDIR")) |
570 | project->variables()["DESTDIR"].append(QDir::currentDirPath()); | 567 | project->variables()["DESTDIR"].append(QDir::currentDirPath()); |
571 | MakefileGenerator::init(); | 568 | MakefileGenerator::init(); |
572 | 569 | ||
573 | if ( project->isActiveConfig("opengl") ) { | 570 | if ( project->isActiveConfig("opengl") ) { |
574 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; | 571 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; |
575 | if ( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || | 572 | if ( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || |
576 | (project->first("TARGET") == "qt-mt") ) | 573 | (project->first("TARGET") == "qt-mt") ) |
577 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; | 574 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; |
578 | else | 575 | else |
579 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; | 576 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; |
580 | } | 577 | } |
581 | 578 | ||
582 | if(project->isActiveConfig("qt")) | 579 | if(project->isActiveConfig("qt")) |
583 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; | 580 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; |
584 | if(project->isEmpty("FRAMEWORKPATH")) | 581 | if(project->isEmpty("FRAMEWORKPATH")) |
585 | project->variables()["FRAMEWORKPATH"].append("/System/Library/Frameworks/"); | 582 | project->variables()["FRAMEWORKPATH"].append("/System/Library/Frameworks/"); |
586 | 583 | ||
587 | //set the target up | 584 | //set the target up |
588 | project->variables()["TARGET_STEM"] = project->variables()["TARGET"]; | 585 | project->variables()["TARGET_STEM"] = project->variables()["TARGET"]; |
589 | if(project->first("TEMPLATE") == "lib") { | 586 | if(project->first("TEMPLATE") == "lib") { |
590 | if(project->isActiveConfig("staticlib")) | 587 | if(project->isActiveConfig("staticlib")) |
591 | project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + ".lib"; | 588 | project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + ".lib"; |
592 | else | 589 | else |
593 | project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + "." + | 590 | project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + "." + |
594 | project->first("QMAKE_EXTENSION_SHLIB"); | 591 | project->first("QMAKE_EXTENSION_SHLIB"); |
595 | 592 | ||
596 | project->variables()["CODEWARRIOR_VERSION"].append(project->first("VER_MAJ") + | 593 | project->variables()["CODEWARRIOR_VERSION"].append(project->first("VER_MAJ") + |
597 | project->first("VER_MIN") + | 594 | project->first("VER_MIN") + |
598 | project->first("VER_PAT")); | 595 | project->first("VER_PAT")); |
599 | } else { | 596 | } else { |
600 | project->variables()["CODEWARRIOR_VERSION"].append("0"); | 597 | project->variables()["CODEWARRIOR_VERSION"].append("0"); |
601 | if(project->isEmpty("QMAKE_ENTRYPOINT")) | 598 | if(project->isEmpty("QMAKE_ENTRYPOINT")) |
602 | project->variables()["QMAKE_ENTRYPOINT"].append("start"); | 599 | project->variables()["QMAKE_ENTRYPOINT"].append("start"); |
603 | project->variables()["CODEWARRIOR_ENTRYPOINT"].append( | 600 | project->variables()["CODEWARRIOR_ENTRYPOINT"].append( |
604 | project->first("QMAKE_ENTRYPOINT")); | 601 | project->first("QMAKE_ENTRYPOINT")); |
605 | } | 602 | } |
606 | } | 603 | } |
607 | 604 | ||
608 | 605 | ||
609 | QString | 606 | QString |
610 | MetrowerksMakefileGenerator::findTemplate(QString file) | 607 | MetrowerksMakefileGenerator::findTemplate(const QString &file) |
611 | { | 608 | { |
612 | QString ret; | 609 | QString ret; |
613 | if(!QFile::exists(ret = file) && | 610 | if(!QFile::exists(ret = file) && |
614 | !QFile::exists((ret = Option::mkfile::qmakespec + QDir::separator() + file)) && | 611 | !QFile::exists((ret = Option::mkfile::qmakespec + QDir::separator() + file)) && |
615 | !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/mac-mwerks/" + file)) && | 612 | !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/mac-mwerks/" + file)) && |
616 | !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) | 613 | !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) |
617 | return ""; | 614 | return ""; |
618 | return ret; | 615 | return ret; |
619 | } | 616 | } |
620 | 617 | ||
621 | bool | 618 | bool |
622 | MetrowerksMakefileGenerator::createFork(const QString &f) | 619 | MetrowerksMakefileGenerator::createFork(const QString &f) |
623 | { | 620 | { |
624 | #if defined(Q_OS_MACX) | 621 | #if !defined(QWS) && defined(Q_OS_MACX) |
625 | FSRef fref; | 622 | FSRef fref; |
626 | FSSpec fileSpec; | 623 | FSSpec fileSpec; |
627 | if(QFile::exists(f)) { | 624 | if(QFile::exists(f)) { |
628 | mode_t perms = 0; | 625 | mode_t perms = 0; |
629 | { | 626 | { |
630 | struct stat s; | 627 | struct stat s; |
631 | stat(f.latin1(), &s); | 628 | stat(f.latin1(), &s); |
632 | if(!(s.st_mode & S_IWUSR)) { | 629 | if(!(s.st_mode & S_IWUSR)) { |
633 | perms = s.st_mode; | 630 | perms = s.st_mode; |
634 | chmod(f.latin1(), perms | S_IWUSR); | 631 | chmod(f.latin1(), perms | S_IWUSR); |
635 | } | 632 | } |
636 | } | 633 | } |
637 | FILE *o = fopen(f.latin1(), "a"); | 634 | FILE *o = fopen(f.latin1(), "a"); |
638 | if(!o) | 635 | if(!o) |
639 | return FALSE; | 636 | return FALSE; |
640 | if(FSPathMakeRef((const UInt8 *)f.latin1(), &fref, NULL) == noErr) { | 637 | if(FSPathMakeRef((const UInt8 *)f.latin1(), &fref, NULL) == noErr) { |
641 | if(FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL) == noErr) | 638 | if(FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL) == noErr) |
642 | FSpCreateResFile(&fileSpec, 'CUTE', 'TEXT', smSystemScript); | 639 | FSpCreateResFile(&fileSpec, 'CUTE', 'TEXT', smSystemScript); |
643 | else | 640 | else |
644 | qDebug("bogus %d", __LINE__); | 641 | qDebug("bogus %d", __LINE__); |
645 | } else | 642 | } else |
646 | qDebug("bogus %d", __LINE__); | 643 | qDebug("bogus %d", __LINE__); |
647 | fclose(o); | 644 | fclose(o); |
648 | if(perms) | 645 | if(perms) |
649 | chmod(f.latin1(), perms); | 646 | chmod(f.latin1(), perms); |
650 | } | 647 | } |
651 | #else | 648 | #else |
652 | Q_UNUSED(f) | 649 | Q_UNUSED(f) |
653 | #endif | 650 | #endif |
654 | return TRUE; | 651 | return TRUE; |
655 | } | 652 | } |
656 | 653 | ||
657 | bool | 654 | bool |
658 | MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool ) | 655 | MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool ) |
659 | { | 656 | { |
660 | v = "Absolute"; | 657 | v = "Absolute"; |
661 | if(p.find(':') != -1) //guess its macish already | 658 | if(p.find(':') != -1) //guess its macish already |
662 | return TRUE; | 659 | return TRUE; |
663 | 660 | ||
664 | static QString st_volume; | 661 | static QString st_volume; |
665 | if(st_volume.isEmpty()) { | 662 | if(st_volume.isEmpty()) { |
666 | st_volume = var("QMAKE_VOLUMENAME"); | 663 | st_volume = var("QMAKE_VOLUMENAME"); |
667 | #ifdef Q_OS_MAC | 664 | #if !defined(QWS) && defined(Q_OS_MACX) |
668 | if(st_volume.isEmpty()) { | 665 | if(st_volume.isEmpty()) { |
669 | uchar foo[512]; | 666 | uchar foo[512]; |
670 | HVolumeParam pb; | 667 | HVolumeParam pb; |
671 | memset(&pb, '\0', sizeof(pb)); | 668 | memset(&pb, '\0', sizeof(pb)); |
672 | pb.ioVRefNum = 0; | 669 | pb.ioVRefNum = 0; |
673 | pb.ioNamePtr = foo; | 670 | pb.ioNamePtr = foo; |
674 | if(PBHGetVInfoSync((HParmBlkPtr)&pb) == noErr) { | 671 | if(PBHGetVInfoSync((HParmBlkPtr)&pb) == noErr) { |
675 | int len = foo[0]; | 672 | int len = foo[0]; |
676 | memcpy(foo,foo+1, len); | 673 | memcpy(foo,foo+1, len); |
677 | foo[len] = '\0'; | 674 | foo[len] = '\0'; |
678 | st_volume = (char *)foo; | 675 | st_volume = (char *)foo; |
679 | } | 676 | } |
680 | } | 677 | } |
681 | #endif | 678 | #endif |
682 | } | 679 | } |
683 | QString volume = st_volume; | 680 | QString volume = st_volume; |
684 | 681 | ||
685 | fixEnvVariables(p); | 682 | fixEnvVariables(p); |
686 | if(p.startsWith("\"") && p.endsWith("\"")) | 683 | if(p.startsWith("\"") && p.endsWith("\"")) |
687 | p = p.mid(1, p.length() - 2); | 684 | p = p.mid(1, p.length() - 2); |
688 | if(p.isEmpty()) | 685 | if(p.isEmpty()) |
689 | return FALSE; | 686 | return FALSE; |
690 | if(!p.endsWith("/")) | 687 | if(!p.endsWith("/")) |
691 | p += "/"; | 688 | p += "/"; |
692 | if(QDir::isRelativePath(p)) { | 689 | if(QDir::isRelativePath(p)) { |
693 | if(p.startsWith("{")) { | 690 | if(p.startsWith("{")) { |
694 | int eoc = p.find('}'); | 691 | int eoc = p.find('}'); |
695 | if(eoc == -1) | 692 | if(eoc == -1) |
696 | return FALSE; | 693 | return FALSE; |
697 | volume = p.mid(1, eoc - 1); | 694 | volume = p.mid(1, eoc - 1); |
698 | p = p.right(p.length() - eoc - 1); | 695 | p = p.right(p.length() - eoc - 1); |
699 | } else { | 696 | } else { |
700 | QFileInfo fi(p); | 697 | QFileInfo fi(p); |
701 | if(fi.convertToAbs()) //strange | 698 | if(fi.convertToAbs()) //strange |
702 | return FALSE; | 699 | return FALSE; |
703 | p = fi.filePath(); | 700 | p = fi.filePath(); |
704 | } | 701 | } |
705 | } | 702 | } |
706 | p = QDir::cleanDirPath(p); | 703 | p = QDir::cleanDirPath(p); |
707 | if(!volume.isEmpty()) | 704 | if(!volume.isEmpty()) |
708 | v = volume; | 705 | v = volume; |
709 | p.replace("/", ":"); | 706 | p.replace("/", ":"); |
710 | if(p.right(1) != ":") | 707 | if(p.right(1) != ":") |
711 | p += ':'; | 708 | p += ':'; |
712 | return TRUE; | 709 | return TRUE; |
713 | } | 710 | } |
714 | 711 | ||
715 | void | 712 | void |
716 | MetrowerksMakefileGenerator::processPrlFiles() | 713 | MetrowerksMakefileGenerator::processPrlFiles() |
717 | { | 714 | { |
718 | QPtrList<MakefileDependDir> libdirs; | 715 | QPtrList<MakefileDependDir> libdirs; |
719 | libdirs.setAutoDelete(TRUE); | 716 | libdirs.setAutoDelete(TRUE); |
720 | const QString lflags[] = { "QMAKE_LIBS", QString::null }; | 717 | const QString lflags[] = { "QMAKE_LIBS", QString::null }; |
721 | for(int i = 0; !lflags[i].isNull(); i++) { | 718 | for(int i = 0; !lflags[i].isNull(); i++) { |
722 | for(bool ret = FALSE; TRUE; ret = FALSE) { | 719 | for(bool ret = FALSE; TRUE; ret = FALSE) { |
723 | QStringList l_out; | 720 | QStringList l_out; |
724 | QStringList &l = project->variables()[lflags[i]]; | 721 | QStringList &l = project->variables()[lflags[i]]; |
725 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 722 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
726 | QString opt = (*it); | 723 | QString opt = (*it); |
727 | if(opt.startsWith("-")) { | 724 | if(opt.startsWith("-")) { |
728 | if(opt.startsWith("-L")) { | 725 | if(opt.startsWith("-L")) { |
729 | QString r = opt.right(opt.length() - 2), l = r; | 726 | QString r = opt.right(opt.length() - 2), l = r; |
730 | fixEnvVariables(l); | 727 | fixEnvVariables(l); |
731 | libdirs.append(new MakefileDependDir(r.replace( "\"", ""), | 728 | libdirs.append(new MakefileDependDir(r.replace( "\"", ""), |
732 | l.replace( "\"", ""))); | 729 | l.replace( "\"", ""))); |
733 | } else if(opt.left(2) == "-l") { | 730 | } else if(opt.left(2) == "-l") { |
734 | QString lib = opt.right(opt.length() - 2), prl; | 731 | QString lib = opt.right(opt.length() - 2), prl; |
735 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { | 732 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { |
736 | prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; | 733 | prl = mdd->local_dir + Option::dir_sep + "lib" + lib; |
737 | if(processPrlFile(prl)) { | 734 | if(processPrlFile(prl)) { |
738 | if(prl.startsWith(mdd->local_dir)) | 735 | if(prl.startsWith(mdd->local_dir)) |
739 | prl.replace(0, mdd->local_dir.length(), mdd->real_dir); | 736 | prl.replace(0, mdd->local_dir.length(), mdd->real_dir); |
740 | QRegExp reg("^.*lib(" + lib + "[^.]*)\\." + | 737 | QRegExp reg("^.*lib(" + lib + "[^.]*)\\." + |
741 | project->first("QMAKE_EXTENSION_SHLIB") + "$"); | 738 | project->first("QMAKE_EXTENSION_SHLIB") + "$"); |
742 | if(reg.exactMatch(prl)) | 739 | if(reg.exactMatch(prl)) |
743 | prl = "-l" + reg.cap(1); | 740 | prl = "-l" + reg.cap(1); |
744 | opt = prl; | 741 | opt = prl; |
745 | ret = TRUE; | 742 | ret = TRUE; |
746 | break; | 743 | break; |
747 | } | 744 | } |
748 | } | 745 | } |
749 | } else if(opt == "-framework") { | 746 | } else if(opt == "-framework") { |
750 | l_out.append(opt); | 747 | l_out.append(opt); |
751 | ++it; | 748 | ++it; |
752 | opt = (*it); | 749 | opt = (*it); |
753 | QString prl = "/System/Library/Frameworks/" + opt + | 750 | QString prl = "/System/Library/Frameworks/" + opt + |
754 | ".framework/" + opt + Option::prl_ext; | 751 | ".framework/" + opt; |
755 | if(processPrlFile(prl)) | 752 | if(processPrlFile(prl)) |
756 | ret = TRUE; | 753 | ret = TRUE; |
757 | } | 754 | } |
758 | if(!opt.isEmpty()) | 755 | if(!opt.isEmpty()) |
759 | l_out.append(opt); | 756 | l_out.append(opt); |
760 | } else { | 757 | } else { |
761 | if(processPrlFile(opt)) | 758 | if(processPrlFile(opt)) |
762 | ret = TRUE; | 759 | ret = TRUE; |
763 | if(!opt.isEmpty()) | 760 | if(!opt.isEmpty()) |
764 | l_out.append(opt); | 761 | l_out.append(opt); |
765 | } | 762 | } |
766 | } | 763 | } |
767 | if(ret) | 764 | if(ret) |
768 | l = l_out; | 765 | l = l_out; |
769 | else | 766 | else |
770 | break; | 767 | break; |
771 | } | 768 | } |
772 | } | 769 | } |
773 | } | 770 | } |
774 | 771 | ||
775 | void | 772 | void |
776 | MetrowerksMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) | 773 | MetrowerksMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) |
777 | { | 774 | { |
778 | if(var == "QMAKE_PRL_LIBS") { | 775 | if(var == "QMAKE_PRL_LIBS") { |
779 | QStringList &out = project->variables()["QMAKE_LIBS"]; | 776 | QStringList &out = project->variables()["QMAKE_LIBS"]; |
780 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { | 777 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { |
781 | bool append = TRUE; | 778 | bool append = TRUE; |
782 | if((*it).startsWith("-")) { | 779 | if((*it).startsWith("-")) { |
783 | if((*it).startsWith("-l") || (*it).startsWith("-L")) { | 780 | if((*it).startsWith("-l") || (*it).startsWith("-L")) { |
784 | append = out.findIndex((*it)) == -1; | 781 | append = out.findIndex((*it)) == -1; |
785 | } else if((*it).startsWith("-framework")) { | 782 | } else if((*it).startsWith("-framework")) { |
786 | ++it; | 783 | ++it; |
787 | for(QStringList::ConstIterator outit = out.begin(); | 784 | for(QStringList::ConstIterator outit = out.begin(); |
788 | outit != out.end(); ++it) { | 785 | outit != out.end(); ++it) { |
789 | if((*outit) == "-framework") { | 786 | if((*outit) == "-framework") { |
790 | ++outit; | 787 | ++outit; |
791 | if((*outit) == (*it)) { | 788 | if((*outit) == (*it)) { |
792 | append = FALSE; | 789 | append = FALSE; |
793 | break; | 790 | break; |
794 | } | 791 | } |
795 | } | 792 | } |
796 | } | 793 | } |
797 | } | 794 | } |
798 | } else if(QFile::exists((*it))) { | 795 | } else if(QFile::exists((*it))) { |
799 | append = out.findIndex((*it)); | 796 | append = out.findIndex((*it)); |
800 | } | 797 | } |
801 | if(append) | 798 | if(append) |
802 | out.append((*it)); | 799 | out.append((*it)); |
803 | } | 800 | } |
804 | } else { | 801 | } else { |
805 | MakefileGenerator::processPrlVariable(var, l); | 802 | MakefileGenerator::processPrlVariable(var, l); |
806 | } | 803 | } |
807 | } | 804 | } |
808 | 805 | ||
809 | 806 | ||
810 | bool | 807 | bool |
811 | MetrowerksMakefileGenerator::openOutput(QFile &file) const | 808 | MetrowerksMakefileGenerator::openOutput(QFile &file) const |
812 | { | 809 | { |
813 | QString outdir; | 810 | QString outdir; |
814 | if(!file.name().isEmpty()) { | 811 | if(!file.name().isEmpty()) { |
815 | QFileInfo fi(file); | 812 | QFileInfo fi(file); |
816 | if(fi.isDir()) | 813 | if(fi.isDir()) |
817 | outdir = file.name() + QDir::separator(); | 814 | outdir = file.name() + QDir::separator(); |
818 | } | 815 | } |
819 | if(!outdir.isEmpty() || file.name().isEmpty()) | 816 | if(!outdir.isEmpty() || file.name().isEmpty()) |
820 | file.setName(outdir + project->first("TARGET") + ".xml"); | 817 | file.setName(outdir + project->first("TARGET") + ".xml"); |
821 | return MakefileGenerator::openOutput(file); | 818 | return MakefileGenerator::openOutput(file); |
822 | } | 819 | } |