summaryrefslogtreecommitdiff
path: root/qmake/generators/mac/metrowerks_xml.cpp
Unidiff
Diffstat (limited to 'qmake/generators/mac/metrowerks_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/mac/metrowerks_xml.cpp23
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,22 +1,20 @@
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
@@ -33,31 +31,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
52MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) 49MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE)
53{ 50{
54 51
55} 52}
56 53
57bool 54bool
58MetrowerksMakefileGenerator::writeMakefile(QTextStream &t) 55MetrowerksMakefileGenerator::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());
@@ -598,39 +595,39 @@ MetrowerksMakefileGenerator::init()
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
609QString 606QString
610MetrowerksMakefileGenerator::findTemplate(QString file) 607MetrowerksMakefileGenerator::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
621bool 618bool
622MetrowerksMakefileGenerator::createFork(const QString &f) 619MetrowerksMakefileGenerator::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 }
@@ -655,25 +652,25 @@ MetrowerksMakefileGenerator::createFork(const QString &f)
655} 652}
656 653
657bool 654bool
658MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool ) 655MetrowerksMakefileGenerator::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 }
@@ -724,43 +721,43 @@ MetrowerksMakefileGenerator::processPrlFiles()
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 }