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,75 +1,72 @@ | |||
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 | } |
@@ -586,106 +583,106 @@ MetrowerksMakefileGenerator::init() | |||
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 += "/"; |
@@ -712,67 +709,67 @@ MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool ) | |||
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") { |