summaryrefslogtreecommitdiff
path: root/qmake/generators/unix/unixmake.cpp
Unidiff
Diffstat (limited to 'qmake/generators/unix/unixmake.cpp') (more/less context) (show whitespace changes)
-rw-r--r--qmake/generators/unix/unixmake.cpp154
1 files changed, 119 insertions, 35 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 7df95b2..e274481 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -5,7 +5,7 @@
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
@@ -72,11 +72,10 @@ UnixMakefileGenerator::init()
72 } 72 }
73 73
74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { 74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) {
75 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 75 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
76 if ( os == "cygwin" ) {
77 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
78 } else {
79 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); 76 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" );
77 } else {
78 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
80 } 79 }
81 } 80 }
82 if( project->isEmpty("QMAKE_COPY_FILE") ) 81 if( project->isEmpty("QMAKE_COPY_FILE") )
@@ -176,18 +175,6 @@ UnixMakefileGenerator::init()
176 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 175 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
177 } 176 }
178 } 177 }
179 if ( project->isActiveConfig("thread") ) {
180 if(project->isActiveConfig("qt"))
181 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
182 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
183 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
184 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
185 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
186 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
187 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
188 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
189 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
190 }
191 if ( project->isActiveConfig("opengl") ) { 178 if ( project->isActiveConfig("opengl") ) {
192 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; 179 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
193 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) 180 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL"))
@@ -199,10 +186,6 @@ UnixMakefileGenerator::init()
199 } 186 }
200 if(project->isActiveConfig("global_init_link_order")) 187 if(project->isActiveConfig("global_init_link_order"))
201 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 188 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
202 if ( project->isActiveConfig("x11sm") )
203 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
204 if ( project->isActiveConfig("dylib") )
205 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
206 if ( project->isActiveConfig("x11inc") ) 189 if ( project->isActiveConfig("x11inc") )
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; 190 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"];
208 if ( project->isActiveConfig("x11lib") ) { 191 if ( project->isActiveConfig("x11lib") ) {
@@ -210,6 +193,22 @@ UnixMakefileGenerator::init()
210 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); 193 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", "");
211 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; 194 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"];
212 } 195 }
196 if ( project->isActiveConfig("x11sm") )
197 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
198 if ( project->isActiveConfig("dylib") )
199 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
200 if ( project->isActiveConfig("thread") ) {
201 if(project->isActiveConfig("qt"))
202 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
203 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
204 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
205 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
206 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
208 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
209 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
210 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
211 }
213 if ( project->isActiveConfig("moc") ) 212 if ( project->isActiveConfig("moc") )
214 setMocAware(TRUE); 213 setMocAware(TRUE);
215 if ( project->isEmpty("QMAKE_RUN_CC") ) 214 if ( project->isEmpty("QMAKE_RUN_CC") )
@@ -357,6 +356,90 @@ UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList
357 MakefileGenerator::processPrlVariable(var, l); 356 MakefileGenerator::processPrlVariable(var, l);
358} 357}
359 358
359bool
360UnixMakefileGenerator::findLibraries()
361{
362 QPtrList<MakefileDependDir> libdirs;
363 libdirs.setAutoDelete(TRUE);
364 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
365 for(int i = 0; !lflags[i].isNull(); i++) {
366 QStringList &l = project->variables()[lflags[i]];
367 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
368 QString stub, dir, extn, opt = (*it).stripWhiteSpace();
369 if(opt.startsWith("-")) {
370 if(opt.startsWith("-L")) {
371 QString r = opt.right(opt.length() - 2), l = r;
372 fixEnvVariables(l);
373 libdirs.append(new MakefileDependDir(r.replace("\"",""),
374 l.replace("\"","")));
375 } else if(opt.startsWith("-l")) {
376 stub = opt.mid(2);
377 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
378 if(opt.length() > 11) {
379 opt = opt.mid(11);
380 } else {
381 ++it;
382 opt = (*it);
383 }
384 extn = "";
385 dir = "/System/Library/Frameworks/" + opt + ".framework/";
386 stub = opt;
387 }
388 } else {
389 extn = dir = "";
390 stub = opt;
391 int slsh = opt.findRev(Option::dir_sep);
392 if(slsh != -1) {
393 dir = opt.left(slsh);
394 stub = opt.mid(slsh+1);
395 }
396 QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
397 if(stub_reg.exactMatch(stub)) {
398 stub = stub_reg.cap(1);
399 extn = stub_reg.cap(2);
400 }
401 }
402 if(!stub.isEmpty()) {
403 const QString modifs[] = { "-mt", QString::null };
404 for(int modif = 0; !modifs[modif].isNull(); modif++) {
405 bool found = FALSE;
406 QStringList extens;
407 if(!extn.isNull())
408 extens << extn;
409 else
410 extens << project->variables()["QMAKE_EXTENSION_SHLIB"].first() << "a";
411 for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
412 if(dir.isNull()) {
413 QString lib_stub;
414 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
415 if(QFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub +
416 modifs[modif] + "." + (*extit))) {
417 lib_stub = stub + modifs[modif];
418 break;
419 }
420 }
421 if(!lib_stub.isNull()) {
422 (*it) = "-l" + lib_stub;
423 found = TRUE;
424 break;
425 }
426 } else {
427 if(QFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) {
428 (*it) = "lib" + stub + modifs[modif] + "." + (*extit);
429 found = TRUE;
430 break;
431 }
432 }
433 }
434 if(found)
435 break;
436 }
437 }
438 }
439 }
440 return FALSE;
441}
442
360void 443void
361UnixMakefileGenerator::processPrlFiles() 444UnixMakefileGenerator::processPrlFiles()
362{ 445{
@@ -434,12 +517,13 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
434 return QString(); 517 return QString();
435 518
436 bool resource = FALSE; 519 bool resource = FALSE;
520 const QString root = "$(INSTALL_ROOT)";
437 QStringList &uninst = project->variables()[t + ".uninstall"]; 521 QStringList &uninst = project->variables()[t + ".uninstall"];
438 QString ret, destdir=fileFixify(project->first("DESTDIR")); 522 QString ret, destdir=project->first("DESTDIR");
439 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE); 523 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE);
440 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) 524 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
441 destdir += Option::dir_sep; 525 destdir += Option::dir_sep;
442 targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE); 526 targetdir = fileFixify(targetdir);
443 if(targetdir.right(1) != Option::dir_sep) 527 if(targetdir.right(1) != Option::dir_sep)
444 targetdir += Option::dir_sep; 528 targetdir += Option::dir_sep;
445 529
@@ -458,19 +542,18 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
458 int slsh = dst_prl.findRev('/'); 542 int slsh = dst_prl.findRev('/');
459 if(slsh != -1) 543 if(slsh != -1)
460 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); 544 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
461 dst_prl = targetdir + dst_prl; 545 dst_prl = root + targetdir + dst_prl;
462 ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl; 546 ret += "-$(COPY) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
463 if(!uninst.isEmpty()) 547 if(!uninst.isEmpty())
464 uninst.append("\n\t"); 548 uninst.append("\n\t");
465 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); 549 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
466 } 550 }
467 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 551 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
468 if ( os != "cygwin" ) {
469 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { 552 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
470 if ( os == "hpux" ) { 553 if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) {
471 links << "$(TARGET0)";
472 } else {
473 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; 554 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
555 } else {
556 links << "$(TARGET0)";
474 } 557 }
475 } 558 }
476 } 559 }
@@ -478,15 +561,17 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
478 QString src_targ = target; 561 QString src_targ = target;
479 if(!destdir.isEmpty()) 562 if(!destdir.isEmpty())
480 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); 563 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
481 QString dst_targ = fileFixify(targetdir + target); 564 QString dst_targ = root + fileFixify(targetdir + target);
482 if(!ret.isEmpty()) 565 if(!ret.isEmpty())
483 ret += "\n\t"; 566 ret += "\n\t";
484 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + 567 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" +
485 src_targ + "\" \"" + dst_targ + "\""; 568 src_targ + "\" \"" + dst_targ + "\"";
486 if(!project->isEmpty("QMAKE_STRIP")) { 569 if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP")) {
487 ret += "\n\t-" + var("QMAKE_STRIP"); 570 ret += "\n\t-" + var("QMAKE_STRIP");
571 if(!project->isEmpty("QMAKE_STRIPFLAGS_LIB") && project->first("TEMPLATE") == "lib")
572 ret += " " + var("QMAKE_STRIPFLAGS_LIB");
488 if(resource) 573 if(resource)
489 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)"; 574 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
490 else 575 else
491 ret += " \"" + dst_targ + "\""; 576 ret += " \"" + dst_targ + "\"";
492 } 577 }
@@ -506,7 +591,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
506 int lslash = link.findRev(Option::dir_sep); 591 int lslash = link.findRev(Option::dir_sep);
507 if(lslash != -1) 592 if(lslash != -1)
508 link = link.right(link.length() - (lslash + 1)); 593 link = link.right(link.length() - (lslash + 1));
509 QString dst_link = fileFixify(targetdir + link); 594 QString dst_link = root + fileFixify(targetdir + link);
510 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; 595 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
511 if(!uninst.isEmpty()) 596 if(!uninst.isEmpty())
512 uninst.append("\n\t"); 597 uninst.append("\n\t");
@@ -517,4 +602,3 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
517 return ret; 602 return ret;
518} 603}
519 604
520